mirror of
https://git.freebsd.org/ports.git
synced 2025-05-30 01:46:55 -04:00
net-mgmt/nagios-check_smartmon: Fix ValueError with some drive values
After upgrading to version 20100318_4, users reported ValueError for some disks [1] Also fix Python 3.x compatibility [2] While I'm here: - Pet portlint, NO_* in USE{S} section - Make concurrent-safe, installs executables in libexec PR: 236873 Reported by: Thomas Eckhardt <freebsd eckieck de> [1] Submitted by: Thomas Eckhardt <freebsd eckieck de> [1] Submitted by: Krzysztof <ports bsdserwis com> (maintainer) [2] Approved by: Krzysztof <ports bsdserwis com> (maintainer) MFH: 2019Q2 (bugfixes)
This commit is contained in:
parent
45bee78624
commit
7bc876ee2e
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=502340
2 changed files with 79 additions and 11 deletions
|
@ -7,6 +7,7 @@ PORTREVISION= 4
|
||||||
CATEGORIES= net-mgmt
|
CATEGORIES= net-mgmt
|
||||||
MASTER_SITES= http://ftp.bsdserwis.com/pub/FreeBSD/ports/distfiles/
|
MASTER_SITES= http://ftp.bsdserwis.com/pub/FreeBSD/ports/distfiles/
|
||||||
PKGNAMEPREFIX= nagios-
|
PKGNAMEPREFIX= nagios-
|
||||||
|
PKGNAMESUFFIX= ${PYTHON_PKGNAMESUFFIX}
|
||||||
|
|
||||||
MAINTAINER= ports@bsdserwis.com
|
MAINTAINER= ports@bsdserwis.com
|
||||||
COMMENT= Nagios plug-in to get status from smartmontools
|
COMMENT= Nagios plug-in to get status from smartmontools
|
||||||
|
@ -16,6 +17,8 @@ LICENSE= GPLv2+
|
||||||
RUN_DEPENDS= ${LOCALBASE}/sbin/smartctl:sysutils/smartmontools
|
RUN_DEPENDS= ${LOCALBASE}/sbin/smartctl:sysutils/smartmontools
|
||||||
|
|
||||||
USES= python shebangfix
|
USES= python shebangfix
|
||||||
|
USE_PYTHON= concurrent
|
||||||
|
|
||||||
NO_BUILD= yes
|
NO_BUILD= yes
|
||||||
NO_ARCH= yes
|
NO_ARCH= yes
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,62 @@
|
||||||
--- check_smartmon.orig 2019-03-04 20:08:28 UTC
|
--- check_smartmon.orig 2019-04-16 21:26:22 UTC
|
||||||
+++ check_smartmon
|
+++ check_smartmon
|
||||||
@@ -161,9 +161,12 @@ def parseOutput(healthMessage, temperatureMessage, dev
|
@@ -52,8 +52,8 @@ def parseCmdLine(args):
|
||||||
lines = healthMessage.split("\n")
|
version = "%%prog %s" % (__version__)
|
||||||
|
|
||||||
|
parser = OptionParser(usage=usage, version=version)
|
||||||
|
- parser.add_option("-d", "--device", action="store", dest="device", default="", metavar="DEVICE",
|
||||||
|
- help="device to check")
|
||||||
|
+ parser.add_option("-d", "--device", action="store", dest="device", default="", metavar="DEVICE",
|
||||||
|
+ help="device to check")
|
||||||
|
parser.add_option("-v", "--verbosity", action="store",
|
||||||
|
dest="verbosity", type="int", default=0,
|
||||||
|
metavar="LEVEL", help="set verbosity level to LEVEL; defaults to 0 (quiet), \
|
||||||
|
@@ -123,7 +123,7 @@ def callSmartMonTools(path, device):
|
||||||
|
"")
|
||||||
|
healthStatusOutput = ""
|
||||||
|
for line in child_stdout:
|
||||||
|
- healthStatusOutput = healthStatusOutput + line
|
||||||
|
+ healthStatusOutput = healthStatusOutput + line.decode('utf-8')
|
||||||
|
# done
|
||||||
|
|
||||||
|
# get temperature
|
||||||
|
@@ -138,7 +138,7 @@ def callSmartMonTools(path, device):
|
||||||
|
|
||||||
|
temperatureOutput = ""
|
||||||
|
for line in child_stdout:
|
||||||
|
- temperatureOutput = temperatureOutput + line
|
||||||
|
+ temperatureOutput = temperatureOutput + line.decode('utf-8')
|
||||||
|
# done
|
||||||
|
|
||||||
|
return (0 ,"", healthStatusOutput, temperatureOutput)
|
||||||
|
@@ -153,6 +153,7 @@ def parseOutput(healthMessage, temperatu
|
||||||
|
|
||||||
|
vprint(3, "parseOutput: Device type is %s" % devType)
|
||||||
|
|
||||||
|
+ healthStatus = ""
|
||||||
|
if devType == "ata":
|
||||||
|
# parse health status
|
||||||
|
#
|
||||||
|
@@ -162,13 +163,16 @@ def parseOutput(healthMessage, temperatu
|
||||||
getNext = 0
|
getNext = 0
|
||||||
for line in lines:
|
for line in lines:
|
||||||
+ vprint(3, "parseOutput: line is: '%s'" % line)
|
|
||||||
if getNext:
|
if getNext:
|
||||||
- statusLine = line
|
- statusLine = line
|
||||||
- break
|
- break
|
||||||
+ if line <> "SMART STATUS RETURN: incomplete response, ATA output registers missing" and \
|
+ if line != "SMART STATUS RETURN: incomplete response, ATA output registers missing" and \
|
||||||
+ line <> "SMART Status not supported: Incomplete response, ATA output registers missing" :
|
+ line != "SMART Status not supported: Incomplete response, ATA output registers missing" :
|
||||||
+ statusLine = line
|
+ statusLine = line
|
||||||
+ break
|
+ break
|
||||||
elif line == "=== START OF READ SMART DATA SECTION ===":
|
elif line == "=== START OF READ SMART DATA SECTION ===":
|
||||||
getNext = 1
|
getNext = 1
|
||||||
# fi
|
# fi
|
||||||
@@ -181,7 +184,7 @@ def parseOutput(healthMessage, temperatureMessage, dev
|
# done
|
||||||
|
|
||||||
|
+ vprint(3, "parseOutput: statusLine is: '%s'" % statusLine )
|
||||||
|
if getNext:
|
||||||
|
parts = statusLine.split()
|
||||||
|
healthStatus = parts[-1]
|
||||||
|
@@ -181,7 +185,7 @@ def parseOutput(healthMessage, temperatu
|
||||||
parts = line.split()
|
parts = line.split()
|
||||||
if len(parts):
|
if len(parts):
|
||||||
# 194 is the temperature value id
|
# 194 is the temperature value id
|
||||||
|
@ -24,7 +65,7 @@
|
||||||
temperature = int(parts[9])
|
temperature = int(parts[9])
|
||||||
break
|
break
|
||||||
# fi
|
# fi
|
||||||
@@ -190,9 +193,11 @@ def parseOutput(healthMessage, temperatureMessage, dev
|
@@ -190,9 +194,11 @@ def parseOutput(healthMessage, temperatu
|
||||||
# if devType == ata
|
# if devType == ata
|
||||||
|
|
||||||
if devType == "scsi":
|
if devType == "scsi":
|
||||||
|
@ -37,7 +78,7 @@
|
||||||
if stat_re.search( line ):
|
if stat_re.search( line ):
|
||||||
parts = line.split()
|
parts = line.split()
|
||||||
healthStatus = parts[-1]
|
healthStatus = parts[-1]
|
||||||
@@ -201,14 +206,20 @@ def parseOutput(healthMessage, temperatureMessage, dev
|
@@ -201,19 +207,25 @@ def parseOutput(healthMessage, temperatu
|
||||||
# done
|
# done
|
||||||
|
|
||||||
# get temperature from temperatureMessage
|
# get temperature from temperatureMessage
|
||||||
|
@ -60,7 +101,13 @@
|
||||||
# done
|
# done
|
||||||
|
|
||||||
# if devType == scsi
|
# if devType == scsi
|
||||||
@@ -225,6 +236,7 @@ def createReturnInfo(healthStatus, temperature, warnin
|
|
||||||
|
- vprint(3, "Health status: %s" % healthStatus)
|
||||||
|
+ vprint(3, "Health status: %s" % healthStatus)
|
||||||
|
vprint(3, "Temperature: %d" %temperature)
|
||||||
|
|
||||||
|
return (healthStatus, temperature)
|
||||||
|
@@ -225,6 +237,7 @@ def createReturnInfo(healthStatus, tempe
|
||||||
|
|
||||||
# this is absolutely critical!
|
# this is absolutely critical!
|
||||||
if healthStatus not in [ "PASSED", "OK" ]:
|
if healthStatus not in [ "PASSED", "OK" ]:
|
||||||
|
@ -68,7 +115,25 @@
|
||||||
return (2, "CRITICAL: device does not pass health status")
|
return (2, "CRITICAL: device does not pass health status")
|
||||||
# fi
|
# fi
|
||||||
|
|
||||||
@@ -287,6 +299,7 @@ if __name__ == "__main__":
|
@@ -241,7 +254,7 @@ def createReturnInfo(healthStatus, tempe
|
||||||
|
def exitWithMessage(value, message):
|
||||||
|
"""Exit with given value and status message."""
|
||||||
|
|
||||||
|
- print message
|
||||||
|
+ print( message )
|
||||||
|
sys.exit(value)
|
||||||
|
# end
|
||||||
|
|
||||||
|
@@ -254,7 +267,7 @@ def vprint(level, message):
|
||||||
|
"""
|
||||||
|
|
||||||
|
if level <= verbosity:
|
||||||
|
- print message
|
||||||
|
+ print( message )
|
||||||
|
# fi
|
||||||
|
# end
|
||||||
|
|
||||||
|
@@ -287,6 +300,7 @@ if __name__ == "__main__":
|
||||||
# check device type, ATA is default
|
# check device type, ATA is default
|
||||||
vprint(2, "Get device type")
|
vprint(2, "Get device type")
|
||||||
devtype = options.devtype
|
devtype = options.devtype
|
||||||
|
|
Loading…
Add table
Reference in a new issue