"segmentation fault" with check_by_ssh
Posted: Wed Dec 19, 2012 3:01 am
I'm trying to configure a bash script to be run with nagios plugin - check_by_ssh. The is to check if a process (I've used syslogd here) is running or not after ssh'ing into the server with "check_by_ssh" plugin. If running/sleeping the script will return 0. Else if the process has T or Z state, the script will return 1, else the script exits with exit 2. The final aim is to display the status of process as as ok,warn or critical on the nagios web interface.
But when I run this code as:
I get the below error:
When i run the bash script locally on the destination server, I get returned the exact status code of the process being checked. But it fails when I run as mentioned above. If I uncomment the 'echo' lines in the script, I get returned "Running fine" as the result of above command. Is my approach correct here in this case?
Code: Select all
#!/bin/bash
pid=`/sbin/pidof syslogd`
if /sbin/pidof syslogd &> /dev/null; then
while read name first rest; do
if [[ $name = "State:" ]] ; then state="$first"; break;
fi;
done </proc/$pid/status;
case "$state" in
S|R|D) #echo "Running fine"
exit 0
;;
T|Z) #echo "Some problem"
exit 1
;;
esac
else
#echo "Process does not exist"
exit 2;
fiCode: Select all
/usr/lib/nagios/plugins/check_by_ssh -l www-data -H x.x.x.x -C 'bash /usr/local/scripts/check'Code: Select all
Segmentation fault