Page 1 of 2
custom bash script
Posted: Mon Aug 19, 2013 8:26 am
by ddk
Hi all!
I wrote custom bash script for Nagios Core, but in web interface it returns:
Code: Select all
Current Status: WARNING
Status Information: (null)
while in console it returns normal results, like:
Exit codes are from manual:
Code: Select all
if [ $RESULT -ge $WARN ] && [ $RESULT -lt $CRIT ]; then
echo "WARNING: $RESULT warn:$WARN; crit:$CRIT $ADDINFO"
exit 1
elif [ $RESULT -ge $CRIT ]
then
echo "CRITICAL: $RESULT warn:$WARN; crit:$CRIT $ADDINFO"
exit 2
else
echo "OK - warn:$WARN; crit:$CRIT"
exit 0
fi
whats wrong?
Re: custom bash script
Posted: Mon Aug 19, 2013 9:53 am
by slansing
Can you share the entire script here via an attachment? That would help greatly!
Re: custom bash script
Posted: Mon Aug 19, 2013 10:06 am
by ddk
here it is
Re: custom bash script
Posted: Mon Aug 19, 2013 1:16 pm
by abrist
ddk wrote:while in console it returns normal results, like:
CRITICAL: 2
Shouldn't it be returning the whole string, not just the $RESULT but also $WARN, $CRIT and $ADDINFO?
Code: Select all
CRITICAL: $RESULT warn:$WARN; crit:$CRIT $ADDINFO
Re: custom bash script
Posted: Mon Aug 19, 2013 2:54 pm
by ddk
abrist wrote:ddk wrote:while in console it returns normal results, like:
CRITICAL: 2
Shouldn't it be returning the whole string, not just the $RESULT but also $WARN, $CRIT and $ADDINFO?
Code: Select all
CRITICAL: $RESULT warn:$WARN; crit:$CRIT $ADDINFO
it's copy-paste fail, sorry.
it is returninng full string as it's writing in script
Re: custom bash script
Posted: Mon Aug 19, 2013 3:01 pm
by abrist
Are you running from the cli as the "nagios" user?
Re: custom bash script
Posted: Mon Aug 19, 2013 3:09 pm
by ddk
Code: Select all
# su nagios
bash-4.1$ /usr/lib64/nagios/plugins//check_mysql_query_custom -H 192.168.0.1 -d DB -w 1 -c 2 -u USER -p PASS -t 1
/bin/bash: /root/.bashrc: Permission denied
CRITICAL: 2 warn:1; crit:2 ID: 5 Desc:192.168.0.2 Date: 2013-08-19 20:07:17
Re: custom bash script
Posted: Mon Aug 19, 2013 3:13 pm
by abrist
Lets just make sure that it works without the bash error:
On teh remote host:
Code: Select all
su nagios
cd /home/nagios/
/usr/lib64/nagios/plugins//check_mysql_query_custom -H 192.168.0.1 -d DB -w 1 -c 2 -u USER -p PASS -t 1
Re: custom bash script
Posted: Mon Aug 19, 2013 3:55 pm
by ddk
abrist wrote:Lets just make sure that it works without the bash error:
On teh remote host:
Code: Select all
su nagios
cd /home/nagios/
/usr/lib64/nagios/plugins//check_mysql_query_custom -H 192.168.0.1 -d DB -w 1 -c 2 -u USER -p PASS -t 1
there is no such directory
'nagios' home dir is - /var/spool/nagios
so:
Code: Select all
# su nagios
bash-4.1$ cd ~/
bash-4.1$ pwd
/var/spool/nagios
bash-4.1$ /usr/lib64/nagios/plugins//check_mysql_query_custom -H 192.168.0.1 -d DB -w 1 -c 2 -u USER -p PASS -t 1
/bin/bash: /root/.bashrc: Permission denied
CRITICAL: 2 warn:1; crit:2 ID: 5 Desc:192.168.0.2 Date: 2013-08-19 20:07:17
Re: custom bash script
Posted: Tue Aug 20, 2013 9:42 am
by abrist
Maybe you are having an environment variable issue. What are your environment variables?