Changeset 7443b58 in nscp for scripts/lib
- Timestamp:
- 03/24/11 21:38:31 (2 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 2d69ab6
- Parents:
- 569a179
- File:
-
- 1 edited
-
scripts/lib/NagiosPlugins.vbs (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
scripts/lib/NagiosPlugins.vbs
r9661f81 r7443b58 114 114 Public Function get_threshold (threshold) 115 115 ' Simple function to return the warning and critical threshold 116 If threshold = LCase("warning")Then116 If LCase(threshold) = "warning" Then 117 117 get_threshold = threshold_warning 118 118 End IF 119 119 120 If threshold = LCase("critical")Then120 If LCase(threshold) = "critical" Then 121 121 get_threshold = threshold_critical 122 122 End If … … 136 136 End Function 137 137 138 138 139 140 Public Function get_threshold_perfdat(string) 141 142 Dim cintw0 143 Dim cintw 144 Dim x 145 Dim colon 146 147 cintw0=get_threshold(string) 148 x=Replace(cintw0,"~","") 149 cintw0=Replace(x,"@","") 150 151 colon=Instr(cintw0,":") 152 153 If (colon > 1) Then 154 cintw=Left(cintw0,colon-1) 155 Else 156 If (colon=1) Then 157 cintw=Mid(cintw0,2) 158 Else 159 cintw=cintw0 160 End If 161 End If 162 163 get_threshold_perfdat=cintw 164 165 End Function 166 167 139 168 Public Function check_threshold (value) 140 169 ' Verify the thresholds for warning and critical … … 152 181 check_threshold = 0 153 182 183 value = CDbl(value) 184 154 185 Set re = New RegExp 155 186 re.IgnoreCase = True … … 232 263 Set threshold = re.Execute(threshold) 233 264 234 If threshold(0) < 0 Or threshold(0) > value Then 265 If value < 0 Or value > CDbl(threshold(0)) Then 266 parse_range = 1 267 Else 235 268 parse_range = 0 236 Else237 parse_range = 1238 269 End If 239 270 … … 242 273 re.Pattern = "^([0-9]+):$" 243 274 Set threshold = re.Execute(threshold) 244 If value > threshold(0) Then 245 parse_range = 0 246 Else 247 parse_range = 1 248 End If 249 250 Case 3 251 ' outside the range infinity <- value 252 re.Pattern = "^~:([0-9]+)$" 253 Set threshold = re.Execute(threshold) 254 If value < threshold(0) Then 255 parse_range = 0 256 Else 257 parse_range = 1 258 End If 259 260 Case 4 261 ' outside the range of value:value 262 re.Pattern = "^([0-9]+):([0-9]+)$" 263 Set threshold = re.Execute(threshold) 275 264 276 265 277 For Each thres In threshold 266 If value < thres.SubMatches(0) Or value > thres.SubMatches(1) Then 278 'Wscript.Echo "SubMatches(0): " & thres.SubMatches(0) & " val: " & value 279 If value < CDbl(thres.SubMatches(0)) Then 267 280 parse_range = 1 268 281 Else … … 271 284 Next 272 285 286 287 288 Case 3 289 ' outside the range infinity <- value 290 re.Pattern = "^~:([0-9]+)$" 291 Set threshold = re.Execute(threshold) 292 293 For Each thres In threshold 294 If value > CDbl(thres.SubMatches(0)) Then 295 parse_range = 1 296 Else 297 parse_range = 0 298 End If 299 Next 300 301 302 Case 4 303 ' outside the range of value:value 304 re.Pattern = "^([0-9]+):([0-9]+)$" 305 Set threshold = re.Execute(threshold) 306 307 For Each thres In threshold 308 If value < CDbl(thres.SubMatches(0)) Or value > CDbl(thres.SubMatches(1)) Then 309 parse_range = 1 310 Else 311 parse_range = 0 312 End If 313 Next 314 273 315 Case 5 274 316 re.Pattern = "^@([0-9]+):([0-9]+)$" … … 276 318 277 319 For Each thres In threshold 278 If value > thres.SubMatches(0) And value < thres.SubMatches(1) Then279 Wscript.Echo "Bigger than " & thres.SubMatches(0) & " and smaller than " & thres.SubMatches(1)320 If value >= CDbl(thres.SubMatches(0)) And value <= CDbl(thres.SubMatches(1)) Then 321 'Wscript.Echo "Bigger than " & thres.SubMatches(0) & " and smaller than " & thres.SubMatches(1) 280 322 parse_range = 1 281 323 Else
Note: See TracChangeset
for help on using the changeset viewer.








