2010-08-04 Sancho Lerena <slerena@artica.es>
* win32/bin/util/df_percent.vbs: New VBS plugin to detect all hardrives and return free disk on %. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3093 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
00882aa537
commit
10e32b6cea
|
@ -1,3 +1,8 @@
|
|||
2010-08-04 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* win32/bin/util/df_percent.vbs: New VBS plugin to detect all
|
||||
hardrives and return free disk on %.
|
||||
|
||||
2010-08-04 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* modules/pandora_module.cc: Changed sscanf format strings. They did
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
' df_all.vbs
|
||||
' Returns free space (%) for all drives
|
||||
' Pandora FMS Plugin, (c) 2010 Sancho Lerena
|
||||
' ------------------------------------------
|
||||
|
||||
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
|
||||
Percent = round ((objItem.FreeSpace / objItem.Size) * 100, 2)
|
||||
|
||||
Wscript.StdOut.WriteLine "<module>"
|
||||
Wscript.StdOut.WriteLine " <name><![CDATA[DiskFree%_" & objItem.Name & "]]></name>"
|
||||
Wscript.StdOut.WriteLine " <description><![CDATA[Drive " & objItem.Name & " % free space ]]></description>"
|
||||
Wscript.StdOut.WriteLine " <data><![CDATA[" & Percent & "]]></data>"
|
||||
Wscript.StdOut.WriteLine "</module>"
|
||||
Wscript.StdOut.flush
|
||||
End If
|
||||
End If
|
||||
Next
|
Loading…
Reference in New Issue