influxdata / influxdata/telegraf

inputs.monit error parsing input with color escape codes

Open
#10,939 4 comments 0 reactions 1 assignee Claimed by @srebhan View on GitHub
area/xml bug
Dominant language
Go
Stars
17.8k
Forks
5.8k
Avg merge
1d 20h
Merged PRs (30d)
161

Description

### Relevant telegraf.conf

```toml
# /etc/telegraf/telegraf.d/monit.conf
[[inputs.monit]]
address = "https://local-fqdn:2812"
username = "admin123"
password = "pass123"
```

### Logs from Telegraf

```text
2022-04-05T07:37:15Z E! [inputs.monit] Error in plugin: error parsing input: XML syntax error on line 1: illegal character code U+001B
```

### System info

latest Telegraf 1.22.0-1, RedHat flavours

### Docker

_No response_

### Steps to reproduce

```bash
# check script
cat <<- EOT > /tmp/test
#!/bin/sh
# msg with color codes (green)
echo -e "this should \e[0;32m work \e[0m"
EOT
chmod +x /tmp/test

# monit check
cat <<- EOT > /etc/monit.d/test
check program MsgWithColors with path "/tmp/test"
if status != 0 then alert
EOT

# monit status
monit reload
monit status MsgWithColors
Monit 5.32.0 uptime: 29m

Program 'MsgWithColors'
status OK
monitoring status Monitored
monitoring mode active
on reboot start
last exit value 0
last output this should work # <--- 'work' in green
data collected Tue, 05 Apr 2022 11:17:20
```

### Expected behavior

Telegraf `inputs.monit` should handle output by stripping color escape codes.

### Actual behavior

Error in Logfile:

```
2022-04-05T07:37:15Z E! [inputs.monit] Error in plugin: error parsing input: XML syntax error on line 1: illegal character code U+001B
```

### Additional info

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.