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: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Marc
Powell
Sent: Tuesday, January 03, 2006 4:06 PM
To: [email protected]
Subject: RE: Return Codes? (was RE: [Nagios-users] Remotely Checking
Windows: Mapped Network Drives)



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:nagios-users- 
> [EMAIL PROTECTED] On Behalf Of Robert Reeves
> Sent: Tuesday, January 03, 2006 3:58 PM
> To: [email protected]
> 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
[email protected]
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
[email protected]
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

Reply via email to