We are developing a script in our Nagiso Server to check a Host by "check_by_ssh" plugin. We have everything correctly configured.
This is the script (modificated for preserve delicate information):
Code: Select all
#!/bin/bash
RESPUESTA=`/usr/lib/nagios/plugins/check_by_ssh -H 10.xx.xx.xx -C /usr/opt/something/command | grep SOMETHING1 | grep SOMETHING-MORE`
# RESPUESTA will be like: "17561 something 123 SOMETHING1 /usr/opt/something/SOMETHING-MORE"
if [[ "$RESPUESTA" == *SOMETHING-MORE* ]]
then
echo "Evryting working OK:" $RESPUESTA
exit 0
elif [[ "$RESPUESTA" != *SOMETHING-MORE* ]]
then
echo "### Error: check_by_ssh failed ###"
exit 2
else
echo "### Script error ###"
exit 3
fi
Code: Select all
root@nagios03:/usr/lib/nagios/plugins# ./script
Evryting working OK: 17561 something 123 SOMETHING1 /usr/opt/something/SOMETHING-MORE
Code: Select all
### Error: check_by_ssh failed ###
Code: Select all
root@nagios03:/usr/lib/nagios/plugins# su nagios -c './script'
Does anyone has a clue about how to solve this issue?
Thanks!