Jenko22 Posted January 11, 2010 Posted January 11, 2010 Hi I'm hoping someone can help me solve a problem I'm having with a script I'm running in nagios. #!/bin/bash ## 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 else exit 2 fi 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. 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.
powdarrmonkey Posted January 11, 2010 Posted January 11, 2010 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 )
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now