*nix Thread, Nagios script output in Technical; Hi I'm hoping someone can help me solve a problem I'm having with a script I'm running in nagios.
11th January 2010, 09:50 PM #1
Nagios script output
Hi I'm hoping someone can help me solve a problem I'm having with a script I'm running in nagios.
That's the bash script I'm calling as a service. It runs a stored procedure given an extension as a variable and returns the time in seconds since the phone last communicated with the server.
## Echo stored procedure name and extension
OUTPUT=$(echo Check_Phone_Last_Activity $1 > my.sql | cat my.sql | isql -b -w -v SWYX_Db user pass | awk 'NR==12' | sed -e 's/<.*>//g')
echo Last Activity: "$OUTPUT"
if [[ "$OUTPUT" < "120" ]]; then exit 0
The part that's causing trouble is the output, running from the command line i get the desired result e.g Last Activity: 12 however when run in nagios the status information just reads Last Activity and doesn't seem to receive the time in seconds.
The if statement is used to determine if the connection has been lost, if the time is less than 120 seconds then it exits with a return code of 0 (ok) or if its longer return code of 2 (critical) this also seems to have no affect in nagios.
I'm sure there is something staring me in the face but i dont have much experience with nagios or bash scripting. So any ideas or suggestions are welcome.
IDG Tech News
12th January 2010, 12:21 AM #2
Why write the sql out to a file and then immediately cat it again? that's a good contender for the useless cat award.
Anyway, I will look at it more closely tomorrow when I have a copy of nagios at my fingertips.
Edit: in fact, isql gets the useless cat award all on its own. I'm astounded that it can't take its own input (filing a bug )
By blackwill in forum MIS Systems
Last Post: 1st June 2012, 03:16 PM
By triggmiester in forum Coding
Last Post: 18th June 2010, 01:48 PM
By RabbieBurns in forum Scripts
Last Post: 17th June 2009, 12:55 PM
By Number6 in forum How do you do....it?
Last Post: 22nd May 2009, 11:10 AM
By Hightower in forum How do you do....it?
Last Post: 23rd June 2008, 05:04 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)