Nagios smartmon stops working after python upgrade

This just in:

$ /usr/local/bin/sudo /usr/local/libexec/nagios/check_smartmon -d /dev/da0
Traceback (most recent call last):
  File "/usr/local/libexec/nagios/check_smartmon", line 307, in <module>
    (healthStatus, temperature) = parseOutput(healthStatusOutput, temperatureOutput, devtype)
  File "/usr/local/libexec/nagios/check_smartmon", line 216, in parseOutput
    vprint(3, "Health status: %s" % healthStatus)
UnboundLocalError: local variable 'healthStatus' referenced before assignment

But I can’t fix that now. I’m off to the Oscars party.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

2 thoughts on “Nagios smartmon stops working after python upgrade”

  1. Here is an ata device:

    $ sudo /usr/local/sbin/smartctl -H /dev/ad0 
    smartctl 6.2 2013-07-26 r3841 [FreeBSD 9.2-RELEASE-p3 amd64] (local build)
    Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
    
    === START OF READ SMART DATA SECTION ===
    SMART overall-health self-assessment test result: PASSED
    
    

    Here is the same type of device, presented as a scsi device:

    $ sudo /usr/local/sbin/smartctl -H /dev/da0
    smartctl 6.2 2013-07-26 r3841 [FreeBSD 9.2-RELEASE-p3 amd64] (local build)
    Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
    
    === START OF READ SMART DATA SECTION ===
    SMART STATUS RETURN: incomplete response, ATA output registers missing
    SMART overall-health self-assessment test result: PASSED
    Warning: This result is based on an Attribute check.
    
    

    Here is the patch which ignores that incomplete response line:

    $ diff -ub /usr/local/libexec/nagios/check_smartmon ~/tmp/check_smartmon
    --- /usr/local/libexec/nagios/check_smartmon	2014-03-03 16:50:31.633784726 +0000
    +++ /usr/home/dan/tmp/check_smartmon	2014-03-03 16:59:06.385990486 +0000
    @@ -59,7 +59,7 @@
                             metavar="LEVEL", help="set verbosity level to LEVEL; defaults to 0 (quiet), \
                                             possible values go up to 3")
             parser.add_option("-t", "--type", action="store", dest="devtype", default="ata", metavar="DEVTYPE",
    -                        help="type of device (ATA|SCSI)")
    +                        help="type of device (ata|scsi)")
             parser.add_option("-w", "--warning-threshold", metavar="TEMP", action="store",
                             type="int", dest="warningThreshold", default=55,
                             help="set temperature warning threshold to given temperature (defaults to 55)")
    @@ -162,6 +162,7 @@
                     getNext = 0
                     for line in lines:
                             if getNext:
    +                                if line <> "SMART STATUS RETURN: incomplete response, ATA output registers missing":
                                     statusLine = line
                                     break
                             elif line == "=== START OF READ SMART DATA SECTION ===":
    @@ -290,11 +291,12 @@
             # check device type, ATA is default
             vprint(2, "Get device type")
             devtype = options.devtype
    +        vprint(2, "command line supplied device type is: %s" % devtype)
             if not devtype:
    -                devtype = "ATA"
    -
             if device_re.search( device ):
                     devtype = "scsi"
    +                else:
    +                        devtype4= "ata"
     
             vprint(1, "Device type: %s" % devtype)
     
    @@ -304,6 +306,7 @@
             if value != 0:
                     exitWithMessage(value, message)
             vprint(2, "Parse smartctl output")
    +        
             (healthStatus, temperature) = parseOutput(healthStatusOutput, temperatureOutput, devtype)
             vprint(2, "Generate return information")
             (value, message) = createReturnInfo(healthStatus, temperature,
    

Leave a Comment

Scroll to Top