Return Codes? (was RE: Remotely Checking Windows: Mapped Network Drives)
Robert Reeves
robert.reeves at newisys.com
Tue Jan 3 23:12:11 CET 2006
Yeah, thanks...this whole exercise with VBScript has made me feel very
dirty and caused me to not think straight. Here's the final working
product...
'On Error Resume Next
DeviceName = WScript.Arguments.Item(0)
'Wscript.Echo "DeviceName=" & DeviceName
WarningPercentage = WScript.Arguments.Item(1)
'Wscript.Echo "WarningPercentage=" & WarningPercentage
CriticalPercentage = WScript.Arguments.Item(2)
'Wscript.Echo "CriticalPercentage=" & CriticalPercentage
Const intOK = 0
Const intWarning = 1
Const intCritical = 2
Const intUnknown = 3
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_MappedLogicalDisk WHERE DeviceID=""" & DeviceName & """")
For Each objItem in colItems
PercentageFree = objItem.FreeSpace / objItem.Size
PercentageFree = Int(PercentageFree * 100)
If (PercentageFree <= Int(CriticalPercentage)) Then
ReturnString = "CRITICAL"
ReturnCode = intCritical
ElseIf (PercentageFree <= Int(WarningPercentage)) Then
ReturnString = "WARNING"
ReturnCode = intWarning
Else
ReturnString = "OK"
ReturnCode = intOK
End If
Wscript.Echo ReturnString & " " & objItem.DeviceID & " -
Percentage Free = " & PercentageFree & "% (" & objItem.FreeSpace & "/" &
objItem.Size & ")"
Wscript.Quit(ReturnCode)
Next
-----Original Message-----
From: nagios-users-admin at lists.sourceforge.net
[mailto:nagios-users-admin at lists.sourceforge.net] On Behalf Of Marc
Powell
Sent: Tuesday, January 03, 2006 4:06 PM
To: nagios-users at lists.sourceforge.net
Subject: RE: Return Codes? (was RE: [Nagios-users] Remotely Checking
Windows: Mapped Network Drives)
> -----Original Message-----
> From: nagios-users-admin at lists.sourceforge.net [mailto:nagios-users-
> admin at lists.sourceforge.net] On Behalf Of Robert Reeves
> Sent: Tuesday, January 03, 2006 3:58 PM
> To: nagios-users at lists.sourceforge.net
> Subject: Return Codes? (was RE: [Nagios-users] Remotely Checking
Windows:
> Mapped Network Drives)
>
> Now that I have my mapped network drives on remote hosts being
checked,
> I'm getting false negatives.
>
> My script is reporting the following string to NRPE NT and then to
> Nagios:
>
> CRITICAL U: - Percentage Free = 9% (2200961024/23583522816)
>
> However, it's saying that's OK when it clearly has CRITICAL at the
> beginning of the response. The same for warnings:
>
> WARNING V: - Percentage Free = 16% (5904531456/36124491776)
>
> I thought that Nagios looking for OK, WARNING and CRITICAL in the
return
> and classified it accordingly? Do I neet to provide a return code for
> warning or critical states?
Yes, you do. The text response above is for human consumption only.
Nagios relies exclusively on the exit code of the plugin to determine
state.
http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOUTPUT
--
Marc
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files for problems? Stop! Download the new AJAX search engine that
makes searching your log files as easy as surfing the web. DOWNLOAD
SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when
reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list