I had a script to know the https status
#!/bin/bash
urls=(“https://vers.com/broadcast","https://vers.com/salesDashboard ”,
“https://vers.com/vcms ”)
for url in “${urls[@]}”; do
response=$(curl -s -L -I -k -o /dev/null -w “%{http_code}” “$url”)
if [ “$response” = “200” ]; then
status=“Success”
else
status=“Connection-failed”
fi
echo “$url” “$status”
done
and the plugin i used in telegraf is
[[inputs.exec]]
name_suffix = “curl_status”
commands = [“sh /root/http_response.sh”]
data_format = “influx”
i’m not able to get the output in telegraf debug command
jpowers
September 15, 2023, 12:31pm
2
raviteja.chandika:
data_format = “influx”
The format of your data from the script is not in line protocol. If you wish to use line protocol, please see InfluxDB line protocol tutorial | InfluxDB OSS v1 Documentation
Or consider switching to the value
format and returning only the status.
Additionally, consider using the HTTP repsonse plugin: https://github.com/influxdata/telegraf/tree/master/plugins/inputs/http_response
If I try to run the script the output will show like below
https://vers.com/broadcast " Success
“https://vers.com/salesDashboard ” Success
“https://vers.com/vcms ” connection failed
how i want to display the script output as output through telegraf .
And while debugging the telegraf the .exec plugin is showing there .
srebhan
September 18, 2023, 1:14pm
4
So why don’t you just use the http_response
input plugin as @jpowers mentioned?
As per the requirement they told that they want the output of that script only based on that they are working on different things .
Maybe the PATH
variable is not set in telegraf’s environment. Have you tried changing the invocation of executables (sh
, curl
) to absolute paths?