Hi All,
I have an issue with exec plugin and I don’t know how I can fix it.
My config in telegraf: (1.5)
[[inputs.exec]]
commands = [“/etc/telegraf/plugins/alertasnagios.sh”]
timeout = “5s”
data_format = “influx”
My script to get data:
#!/bin/bash
log=/var/log/nagios/nagios.log
mongo=cat $log | grep "SERVICE NOTIFICATION" | grep mongo | wc -l
echo Alertas,alertado=nagios Mongo=$mongo
then I tested:
[root@cvs1pan01 plugins]# telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d --test --input-filter=exec
- Plugin: inputs.exec, Collection 1
Alertas,alerts=nagios,hostgroup=compute,host_type=nagiosserver,host=machine Mongo=21961 1523605711000000000
So everything seem okay, but If I check on Chronograf:
My mongo value inserts 0.
I don’t know what is happening, my real value is 21691 not 0.
Could be something about format or any exit??
I only try to insert the number of alerts I have in Nagios log to Mongo.
I would appreciate your help.
Thanks in advance.