+ Post New Thread
Results 1 to 2 of 2
*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. Code: ...
  1. #1
    Jenko22's Avatar
    Join Date
    May 2007
    Location
    Truro
    Posts
    26
    Thank Post
    1
    Thanked 4 Times in 4 Posts
    Rep Power
    15

    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.

    Code:
    #!/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.

  2. #2

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    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 )

SHARE:
+ Post New Thread

Similar Threads

  1. [SIMS] Edit Excel Output
    By blackwill in forum MIS Systems
    Replies: 37
    Last Post: 1st June 2012, 02:16 PM
  2. Replies: 17
    Last Post: 18th June 2010, 12:48 PM
  3. output script to log file
    By RabbieBurns in forum Scripts
    Replies: 1
    Last Post: 17th June 2009, 11:55 AM
  4. BGInfo - how to format the output?
    By Number6 in forum How do you do....it?
    Replies: 2
    Last Post: 22nd May 2009, 10:10 AM
  5. HD Output from PC
    By Hightower in forum How do you do....it?
    Replies: 17
    Last Post: 23rd June 2008, 04:04 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •