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

Collapse All | Expand All

(-)b/net-mgmt/nagios-check_smartmon/Makefile (-1 / +1 lines)
Lines 2-8 Link Here
2
2
3
PORTNAME=	check_smartmon
3
PORTNAME=	check_smartmon
4
PORTVERSION=	20100318
4
PORTVERSION=	20100318
5
PORTREVISION=	4
5
PORTREVISION=	5
6
CATEGORIES=	net-mgmt
6
CATEGORIES=	net-mgmt
7
MASTER_SITES=	http://ftp.bsdserwis.com/pub/FreeBSD/ports/distfiles/
7
MASTER_SITES=	http://ftp.bsdserwis.com/pub/FreeBSD/ports/distfiles/
8
PKGNAMEPREFIX=	nagios-
8
PKGNAMEPREFIX=	nagios-
(-)b/net-mgmt/nagios-check_smartmon/files/patch-check_smartmon (-14 / +61 lines)
Lines 1-6 Link Here
1
--- check_smartmon.orig	2019-04-16 21:26:22 UTC
1
--- check_smartmon.orig	2021-10-08 16:10:20 UTC
2
+++ check_smartmon
2
+++ check_smartmon
3
@@ -52,8 +52,8 @@ def parseCmdLine(args):
3
@@ -52,14 +52,14 @@ def parseCmdLine(args):
4
         version = "%%prog %s" % (__version__)
4
         version = "%%prog %s" % (__version__)
5
 
5
 
6
         parser = OptionParser(usage=usage, version=version)
6
         parser = OptionParser(usage=usage, version=version)
Lines 11-16 Link Here
11
         parser.add_option("-v", "--verbosity", action="store",
11
         parser.add_option("-v", "--verbosity", action="store",
12
                         dest="verbosity", type="int", default=0,
12
                         dest="verbosity", type="int", default=0,
13
                         metavar="LEVEL", help="set verbosity level to LEVEL; defaults to 0 (quiet), \
13
                         metavar="LEVEL", help="set verbosity level to LEVEL; defaults to 0 (quiet), \
14
                                         possible values go up to 3")
15
         parser.add_option("-t", "--type", action="store", dest="devtype", default="ata", metavar="DEVTYPE",
16
-                        help="type of device (ATA|SCSI)")
17
+                        help="type of device (ata|scsi)")
18
         parser.add_option("-w", "--warning-threshold", metavar="TEMP", action="store",
19
                         type="int", dest="warningThreshold", default=55,
20
                         help="set temperature warning threshold to given temperature (defaults to 55)")
14
@@ -123,7 +123,7 @@ def callSmartMonTools(path, device):
21
@@ -123,7 +123,7 @@ def callSmartMonTools(path, device):
15
                                 "")
22
                                 "")
16
         healthStatusOutput = ""
23
         healthStatusOutput = ""
Lines 29-35 Link Here
29
         # done
36
         # done
30
 
37
 
31
         return (0 ,"", healthStatusOutput, temperatureOutput)
38
         return (0 ,"", healthStatusOutput, temperatureOutput)
32
@@ -153,6 +153,7 @@ def parseOutput(healthMessage, temperatu
39
@@ -153,6 +153,7 @@ def parseOutput(healthMessage, temperatureMessage, dev
33
 
40
 
34
         vprint(3, "parseOutput: Device type is %s" % devType)
41
         vprint(3, "parseOutput: Device type is %s" % devType)
35
 
42
 
Lines 37-43 Link Here
37
         if devType == "ata":
44
         if devType == "ata":
38
                 # parse health status
45
                 # parse health status
39
                 #
46
                 #
40
@@ -162,13 +163,16 @@ def parseOutput(healthMessage, temperatu
47
@@ -162,13 +163,16 @@ def parseOutput(healthMessage, temperatureMessage, dev
41
                 getNext = 0
48
                 getNext = 0
42
                 for line in lines:
49
                 for line in lines:
43
                         if getNext:
50
                         if getNext:
Lines 56-62 Link Here
56
                 if getNext:
63
                 if getNext:
57
                         parts = statusLine.split()
64
                         parts = statusLine.split()
58
                         healthStatus = parts[-1]
65
                         healthStatus = parts[-1]
59
@@ -181,7 +185,7 @@ def parseOutput(healthMessage, temperatu
66
@@ -181,7 +185,7 @@ def parseOutput(healthMessage, temperatureMessage, dev
60
                         parts = line.split()
67
                         parts = line.split()
61
                         if len(parts):
68
                         if len(parts):
62
                                 # 194 is the temperature value id
69
                                 # 194 is the temperature value id
Lines 65-71 Link Here
65
                                         temperature = int(parts[9])
72
                                         temperature = int(parts[9])
66
                                         break
73
                                         break
67
                                 # fi
74
                                 # fi
68
@@ -190,9 +194,11 @@ def parseOutput(healthMessage, temperatu
75
@@ -190,9 +194,11 @@ def parseOutput(healthMessage, temperatureMessage, dev
69
         # if devType == ata
76
         # if devType == ata
70
 
77
 
71
         if devType == "scsi":
78
         if devType == "scsi":
Lines 78-84 Link Here
78
                         if stat_re.search( line ):
85
                         if stat_re.search( line ):
79
                                parts = line.split()
86
                                parts = line.split()
80
                                healthStatus = parts[-1]
87
                                healthStatus = parts[-1]
81
@@ -201,19 +207,25 @@ def parseOutput(healthMessage, temperatu
88
@@ -201,39 +207,49 @@ def parseOutput(healthMessage, temperatureMessage, dev
82
                 # done
89
                 # done
83
 
90
 
84
                 # get temperature from temperatureMessage
91
                 # get temperature from temperatureMessage
Lines 107-121 Link Here
107
         vprint(3, "Temperature: %d" %temperature)
114
         vprint(3, "Temperature: %d" %temperature)
108
 
115
 
109
         return (healthStatus, temperature)
116
         return (healthStatus, temperature)
110
@@ -225,6 +237,7 @@ def createReturnInfo(healthStatus, tempe
117
 # end
118
 
119
-def createReturnInfo(healthStatus, temperature, warningThreshold,
120
+def createReturnInfo(device, healthStatus, temperature, warningThreshold,
121
                 criticalThreshold):
122
         """Create return information according to given thresholds."""
111
 
123
 
112
         # this is absolutely critical!
124
         # this is absolutely critical!
113
         if healthStatus not in [ "PASSED", "OK" ]:
125
         if healthStatus not in [ "PASSED", "OK" ]:
126
-                return (2, "CRITICAL: device does not pass health status")
114
+                vprint(2, "Health status: %s" % healthStatus)
127
+                vprint(2, "Health status: %s" % healthStatus)
115
                 return (2, "CRITICAL: device does not pass health status")
128
+                return (2, "CRITICAL: device (%s) does not pass health status" %device)
129
         # fi
130
 
131
         if temperature > criticalThreshold:
132
-                return (2, "CRITICAL: device temperature (%d) exceeds critical temperature threshold (%s)" % (temperature, criticalThreshold))
133
+                return (2, "CRITICAL: device (%s) temperature (%d) exceeds critical temperature threshold (%s)|TEMP=%d;%d;%d;" 
134
+			% (device, temperature, criticalThreshold, temperature, warningThreshold, criticalThreshold))
135
         elif temperature > warningThreshold:
136
-                return (1, "WARNING: device temperature (%d) exceeds warning temperature threshold (%s)" % (temperature, warningThreshold))
137
+                return (1, "WARNING: device (%s) temperature (%d) exceeds warning temperature threshold (%s)|TEMP=%d;%d;%d;" 
138
+			% (device, temperature, warningThreshold, temperature, warningThreshold, criticalThreshold))
139
         else:
140
-                return (0, "OK: device is functional and stable (temperature: %d)" % temperature)
141
+                return (0, "OK: device (%s) is functional and stable (temperature: %d)|TEMP=%d;%d;%d;" 
142
+			% (device, temperature, temperature, warningThreshold, criticalThreshold))
116
         # fi
143
         # fi
144
 # end
117
 
145
 
118
@@ -241,7 +254,7 @@ def createReturnInfo(healthStatus, tempe
146
@@ -241,7 +257,7 @@ def createReturnInfo(healthStatus, temperature, warnin
119
 def exitWithMessage(value, message):
147
 def exitWithMessage(value, message):
120
         """Exit with given value and status message."""
148
         """Exit with given value and status message."""
121
 
149
 
Lines 124-130 Link Here
124
         sys.exit(value)
152
         sys.exit(value)
125
 # end
153
 # end
126
 
154
 
127
@@ -254,7 +267,7 @@ def vprint(level, message):
155
@@ -254,7 +270,7 @@ def vprint(level, message):
128
         """
156
         """
129
 
157
 
130
         if level <= verbosity:
158
         if level <= verbosity:
Lines 133-143 Link Here
133
         # fi
161
         # fi
134
 # end
162
 # end
135
 
163
 
136
@@ -287,6 +300,7 @@ if __name__ == "__main__":
164
@@ -287,12 +303,13 @@ if __name__ == "__main__":
137
         # check device type, ATA is default
165
         # check device type, ATA is default
138
         vprint(2, "Get device type")
166
         vprint(2, "Get device type")
139
         devtype = options.devtype
167
         devtype = options.devtype
140
+        vprint(2, "command line supplied device type is: %s" % devtype)
168
+        vprint(2, "command line supplied device type is: %s" % devtype)
141
         if not devtype:
169
         if not devtype:
142
                 devtype = "ATA"
170
-                devtype = "ATA"
143
 
171
+                if device_re.search( device ):
172
+                        devtype = "scsi"
173
+                else:
174
+                        devtype= "ata"
175
 
176
-        if device_re.search( device ):
177
-                devtype = "scsi"
178
-
179
         vprint(1, "Device type: %s" % devtype)
180
 
181
         # call smartctl and parse output
182
@@ -303,7 +320,7 @@ if __name__ == "__main__":
183
         vprint(2, "Parse smartctl output")
184
         (healthStatus, temperature) = parseOutput(healthStatusOutput, temperatureOutput, devtype)
185
         vprint(2, "Generate return information")
186
-        (value, message) = createReturnInfo(healthStatus, temperature,
187
+        (value, message) = createReturnInfo(device, healthStatus, temperature,
188
                         options.warningThreshold, options.criticalThreshold)
189
 
190
         # exit program

Return to bug 258965