Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
ddk
Posts: 6 Joined: Mon Aug 19, 2013 7:22 am
Post
by ddk » Mon Aug 19, 2013 8:26 am
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?
slansing
Posts: 7698 Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...
Post
by slansing » Mon Aug 19, 2013 9:53 am
Can you share the entire script here via an attachment? That would help greatly!
ddk
Posts: 6 Joined: Mon Aug 19, 2013 7:22 am
Post
by ddk » Mon Aug 19, 2013 10:06 am
here it is
Attachments
mysqlcheck.sh
(1.74 KiB) Downloaded 330 times
abrist
Red Shirt
Posts: 8334 Joined: Thu Nov 15, 2012 1:20 pm
Post
by abrist » Mon Aug 19, 2013 1:16 pm
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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the
Dark Side .
ddk
Posts: 6 Joined: Mon Aug 19, 2013 7:22 am
Post
by ddk » Mon Aug 19, 2013 2:54 pm
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
abrist
Red Shirt
Posts: 8334 Joined: Thu Nov 15, 2012 1:20 pm
Post
by abrist » Mon Aug 19, 2013 3:01 pm
Are you running from the cli as the "nagios" user?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the
Dark Side .
ddk
Posts: 6 Joined: Mon Aug 19, 2013 7:22 am
Post
by ddk » Mon Aug 19, 2013 3:09 pm
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
abrist
Red Shirt
Posts: 8334 Joined: Thu Nov 15, 2012 1:20 pm
Post
by abrist » Mon Aug 19, 2013 3:13 pm
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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the
Dark Side .
ddk
Posts: 6 Joined: Mon Aug 19, 2013 7:22 am
Post
by ddk » Mon Aug 19, 2013 3:55 pm
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
abrist
Red Shirt
Posts: 8334 Joined: Thu Nov 15, 2012 1:20 pm
Post
by abrist » Tue Aug 20, 2013 9:42 am
Maybe you are having an environment variable issue. What are your environment variables?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the
Dark Side .