2010-08-04 16:57:56 +02:00
|
|
|
' df_all.vbs
|
|
|
|
' Returns free space (%) for all drives
|
2014-05-30 17:55:42 +02:00
|
|
|
' Pandora FMS Plugin, (c) 2014 Sancho Lerena
|
2010-08-04 16:57:56 +02:00
|
|
|
' ------------------------------------------
|
|
|
|
|
|
|
|
Option Explicit
|
|
|
|
On Error Resume Next
|
|
|
|
|
|
|
|
' Variables
|
|
|
|
Dim objWMIService, objItem, colItems, argc, argv, i, Percent
|
|
|
|
|
|
|
|
|
|
|
|
' Parse command line parameters
|
|
|
|
argc = Wscript.Arguments.Count
|
|
|
|
Set argv = CreateObject("Scripting.Dictionary")
|
|
|
|
For i = 0 To argc - 1
|
|
|
|
argv.Add Wscript.Arguments(i), i
|
|
|
|
Next
|
|
|
|
|
|
|
|
' Get drive information
|
|
|
|
Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2")
|
|
|
|
Set colItems = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
|
|
|
|
|
|
|
|
For Each objItem in colItems
|
|
|
|
If argc = 0 Or argv.Exists(objItem.Name) Then
|
|
|
|
' Include only harddrivers (type 3)
|
|
|
|
If (objItem.FreeSpace <> "") AND (objItem.DriveType =3) Then
|
2017-02-03 12:41:47 +01:00
|
|
|
Percent = round ((objItem.FreeSpace / objItem.Size) * 100, 2)
|
2010-08-04 16:57:56 +02:00
|
|
|
Wscript.StdOut.WriteLine "<module>"
|
|
|
|
Wscript.StdOut.WriteLine " <name><![CDATA[DiskFree%_" & objItem.Name & "]]></name>"
|
2017-02-03 12:41:47 +01:00
|
|
|
Wscript.StdOut.WriteLine " <description><![CDATA[Drive " & objItem.Name & " free space: " & Int(objItem.FreeSpace /1048576) & " MB]]></description>"
|
|
|
|
If (Percent > 99.99) then
|
2013-12-09 16:38:09 +01:00
|
|
|
Wscript.StdOut.WriteLine " <data><![CDATA[" & 100 & "]]></data>"
|
2017-02-03 12:41:47 +01:00
|
|
|
Elseif (Percent < 0.01) then
|
2013-12-09 16:38:09 +01:00
|
|
|
Wscript.StdOut.WriteLine " <data><![CDATA[" & 0 & "]]></data>"
|
2017-02-03 12:41:47 +01:00
|
|
|
Else
|
2013-12-09 16:38:09 +01:00
|
|
|
Wscript.StdOut.WriteLine " <data><![CDATA[" & Percent & "]]></data>"
|
2017-02-03 12:41:47 +01:00
|
|
|
End If
|
|
|
|
Wscript.StdOut.WriteLine " <unit>%</unit>"
|
|
|
|
Wscript.StdOut.WriteLine " <min_warning>5</min_warning>"
|
|
|
|
Wscript.StdOut.WriteLine " <max_warning>10</max_warning>"
|
|
|
|
Wscript.StdOut.WriteLine " <min_critical>0</min_critical>"
|
|
|
|
Wscript.StdOut.WriteLine " <max_critical>5</max_critical>"
|
|
|
|
Wscript.StdOut.WriteLine "</module>"
|
|
|
|
Wscript.StdOut.flush
|
2010-08-04 16:57:56 +02:00
|
|
|
End If
|
|
|
|
End If
|
|
|
|
Next
|