Telegraf: inputs.exec exit code

When we configure inputs.exec , your program/bash script must have exit code 0. If it’s not 0 , telegraf will not send the metrics. This is an example , i have a bash file which will run 10 small scripts

myscripts.sh

/scripts/file1.sh
/scripts/file2.sh
/scripts/file3.sh
/scripts/file9.sh
/scripts/file10.sh

Telegraf will run my scripts.sh , the last script file10.sh is very important, if this script does not exit 0 , the entire stack will not send any metrics. There is a trick , we can add exit 0 at the end of the myscripts.sh

/scripts/file1.sh
/scripts/file2.sh
/scripts/file3.sh
/scripts/file9.sh
/scripts/file10.sh

exit 0

Leave a Reply

Your email address will not be published. Required fields are marked *