View | Details | Raw Unified | Return to bug 258965 | Differences between
and this patch

Collapse All | Expand All

(-)check_smartmon (-11 / +14 lines)
Lines 59-65 def parseCmdLine(args): Link Here
59
                        metavar="LEVEL", help="set verbosity level to LEVEL; defaults to 0 (quiet), \
59
                        metavar="LEVEL", help="set verbosity level to LEVEL; defaults to 0 (quiet), \
60
                                        possible values go up to 3")
60
                                        possible values go up to 3")
61
        parser.add_option("-t", "--type", action="store", dest="devtype", default="ata", metavar="DEVTYPE",
61
        parser.add_option("-t", "--type", action="store", dest="devtype", default="ata", metavar="DEVTYPE",
62
                        help="type of device (ATA|SCSI)")
62
                        help="type of device (ata|scsi)")
63
        parser.add_option("-w", "--warning-threshold", metavar="TEMP", action="store",
63
        parser.add_option("-w", "--warning-threshold", metavar="TEMP", action="store",
64
                        type="int", dest="warningThreshold", default=55,
64
                        type="int", dest="warningThreshold", default=55,
65
                        help="set temperature warning threshold to given temperature (defaults to 55)")
65
                        help="set temperature warning threshold to given temperature (defaults to 55)")
Lines 231-252 def parseOutput(healthMessage, temperatureMessage, devType): Link Here
231
        return (healthStatus, temperature)
231
        return (healthStatus, temperature)
232
# end
232
# end
233
233
234
def createReturnInfo(healthStatus, temperature, warningThreshold,
234
def createReturnInfo(device, healthStatus, temperature, warningThreshold,
235
                criticalThreshold):
235
                criticalThreshold):
236
        """Create return information according to given thresholds."""
236
        """Create return information according to given thresholds."""
237
237
238
        # this is absolutely critical!
238
        # this is absolutely critical!
239
        if healthStatus not in [ "PASSED", "OK" ]:
239
        if healthStatus not in [ "PASSED", "OK" ]:
240
                vprint(2, "Health status: %s" % healthStatus)
240
                vprint(2, "Health status: %s" % healthStatus)
241
                return (2, "CRITICAL: device does not pass health status")
241
                return (2, "CRITICAL: device (%s) does not pass health status" %device)
242
        # fi
242
        # fi
243
243
244
        if temperature > criticalThreshold:
244
        if temperature > criticalThreshold:
245
                return (2, "CRITICAL: device temperature (%d) exceeds critical temperature threshold (%s)" % (temperature, criticalThreshold))
245
                return (2, "CRITICAL: device (%s) temperature (%d) exceeds critical temperature threshold (%s)|TEMP=%d;%d;%d;" 
246
			% (device, temperature, criticalThreshold, temperature, warningThreshold, criticalThreshold))
246
        elif temperature > warningThreshold:
247
        elif temperature > warningThreshold:
247
                return (1, "WARNING: device temperature (%d) exceeds warning temperature threshold (%s)" % (temperature, warningThreshold))
248
                return (1, "WARNING: device (%s) temperature (%d) exceeds warning temperature threshold (%s)|TEMP=%d;%d;%d;" 
249
			% (device, temperature, warningThreshold, temperature, warningThreshold, criticalThreshold))
248
        else:
250
        else:
249
                return (0, "OK: device is functional and stable (temperature: %d)" % temperature)
251
                return (0, "OK: device (%s) is functional and stable (temperature: %d)|TEMP=%d;%d;%d;" 
252
			% (device, temperature, temperature, warningThreshold, criticalThreshold))
250
        # fi
253
        # fi
251
# end
254
# end
252
255
Lines 302-311 if __name__ == "__main__": Link Here
302
        devtype = options.devtype
305
        devtype = options.devtype
303
        vprint(2, "command line supplied device type is: %s" % devtype)
306
        vprint(2, "command line supplied device type is: %s" % devtype)
304
        if not devtype:
307
        if not devtype:
305
                devtype = "ATA"
308
                if device_re.search( device ):
306
309
                        devtype = "scsi"
307
        if device_re.search( device ):
310
                else:
308
                devtype = "scsi"
311
                        devtype= "ata"
309
312
310
        vprint(1, "Device type: %s" % devtype)
313
        vprint(1, "Device type: %s" % devtype)
311
314
Lines 317-323 if __name__ == "__main__": Link Here
317
        vprint(2, "Parse smartctl output")
320
        vprint(2, "Parse smartctl output")
318
        (healthStatus, temperature) = parseOutput(healthStatusOutput, temperatureOutput, devtype)
321
        (healthStatus, temperature) = parseOutput(healthStatusOutput, temperatureOutput, devtype)
319
        vprint(2, "Generate return information")
322
        vprint(2, "Generate return information")
320
        (value, message) = createReturnInfo(healthStatus, temperature,
323
        (value, message) = createReturnInfo(device, healthStatus, temperature,
321
                        options.warningThreshold, options.criticalThreshold)
324
                        options.warningThreshold, options.criticalThreshold)
322
325
323
        # exit program
326
        # exit program

Return to bug 258965