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.
Ok, I have been seaching the forums and smashing my face off of this simple script for quite a while and I wonder if I am just missing something that someone else has come across. Here is the script with important stuff stripped, of course:
#!/bin/sh
# Gracefully fail if stack number not specified on command line
if [ -z "$1" ]
then
echo "Usage: sbapp_callattempts.sh <stack_number>"
exit 3
else
STACK=$1
fi
DB_NAME=`/usr/local/nagios/scripts/set_db_name.sh $STACK`
CALLATTEMPTS=`sqlplus -S nagios_adm/xxxxxx@$DB_NAME << EOF
set head off
set pagesize 0
<some sql stuff here>
/
EOF`
CALLATTEMPTS=`echo $CALLATTEMPTS |awk '{print $1}' | sed -e 's/^[ \t] *//'`
case $CALLATTEMPTS in
'no')
echo "OK: CALLATTEMPTS 0 | call_attempts=0"
exit 0
;;
''|*[!0-9]*)
echo "UNKNOWN: Could not get valid number for call attempts"
exit 3
;;
*)
echo "OK: CALLATTEMPTS $CALLATTEMPTS | call_attempts=$CALLATTEMPTS"
exit 0
;;
esac
When I run this as a check in 4.0.1, I consistently get the matches for our UNKNOWN case but I can run it at the same time as nagios and get correct results, while at the same time my old nagios instance is also returning correctly. This should not matter but it should be mentioned, we are moving from centos 5.4 32bit running 3.4 to centos 6.4 64bit running 4.0.1.
#!/bin/sh
# Gracefully fail if stack number not specified on command line
if [ -z "$1" ]
then
echo "Usage: sbapp_callattempts.sh <stack_number>"
exit 3
else
STACK=$1
fi
DB_NAME=`/usr/local/nagios/scripts/set_db_name.sh $STACK`
CALLATTEMPTS=`sqlplus -S nagios_adm/xxxxxx@$DB_NAME << EOF
set head off
set pagesize 0
<some sql stuff here>
/
EOF`
echo $CALLATTEMPTS > /tmp/call_attempts_test.txt
CALLATTEMPTS=`echo $CALLATTEMPTS |awk '{print $1}' | sed -e 's/^[ \t] *//'`
echo $CALLATTEMPTS >> /tmp/call_attempts_test.txt
case $CALLATTEMPTS in
'no')
echo "OK: CALLATTEMPTS 0 | call_attempts=0"
exit 0
;;
''|*[!0-9]*)
echo "UNKNOWN: Could not get valid number for call attempts"
exit 3
;;
*)
echo "OK: CALLATTEMPTS $CALLATTEMPTS | call_attempts=$CALLATTEMPTS"
exit 0
;;
esac
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.
root@monitorbos02|/root>cat /tmp/call_attempts_test.txt
root@monitorbos02|/root>
This is what I have after one manual run:
nagios@monitorbos02|/home/nagios>cat /tmp/call_attempts_test.txt
37389
nagios@monitorbos02|/home/nagios>
Edited out my extra copy and paste from the output of catting the file
Last edited by heebs on Thu Dec 05, 2013 2:36 pm, edited 1 time in total.
CALLATTEMPTS=`sqlplus -S nagios_adm/xxxxxx@$DB_NAME << EOF
set head off
set pagesize 0
<some sql stuff here>
/
EOF`
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.