Tuesday, March 8, 2011

Nagios Check - check_temp_weathergoose

I wrote a check for Nagios to check (and convert to Fahrenheit) the temperature for a Weathergoose environmental monitor.

   This is a simple check that checks the temperature (and converts it to Fahrenheit) for Weathergoose environmental monitors. I would guess this would work fine with other IT Watchdogs environmental monitors, i.e. Supergoose, Microgoose, Minigoose.

Usage: check_temp_weathergoose.sh -H [-f] -w -c
-H - The IP address of the Weathergoose
-C - SNMP Community
-f - Convert output to Fahrenheit
-w - Warning Range
-c - Critical Range


  1. Your script is good but you should really change the snmpwalk to a snmpget. In the version of snmp that I'm using it appends a last line that says "End of MIB" which breaks your script.

  2. Trying to set up your plugin. I've got the script in the Nagios libexec folder and the following commands to call the script:
    define command{
    command name check_server_room_temp
    command_line $USER1$/check_temp.sh -H [-f] -w 80 -c 95
    define command{
    command name check_telco_room_temp
    command_line $USER1$/check_temp.sh -H [-f] -w 80 -c 95

    Getting the following error: Return code of 127 is out of bounds - plugin may be missing.

    Any pointers?

    1. Have you tried running the script directly? One possibility is that it is not executable (i.e. sudo chmod +x check_temp_weathergoose.sh. Also, you may want to change the snmpwalks to snmpgets, as Matt suggested. I don't have a Weathergoose any more to test with.

  3. I concur with the suggestion that snmpget is preferable to snmpwalk, and I've changed it and it works.

    Another more serious problem is that the script returns 2 (critical) for both critical and warning states. To correct this, the "exit 2" code at lines 64 and 72 should be "exit 1"

    One thing that threw me on my initial effort was (on ubuntu at least) it really wants syntax with colons (or ranges I suppose) for the warning and critical temperatures - i.e. -w:80 -c:90 rather than -w 80 -c 90.

    finally, if you're running this on linux, remember to use dos2unix first, or you'll get
    "/bin/bash^M: bad interpreter: No such file or directory"
    - the ^M from the dos formatting is being interpreted as the interpreter name.

    Thanks for a very useful script for those of us still running the weather goose Version 1 (V2 has an OID for temp in F). Even with my corrections and feedback, it was just what I needed and definitely way better than writing it myself.