From 48d137cd7f0017f8fd9f00233f3ba96975e52d50 Mon Sep 17 00:00:00 2001 From: slerena Date: Wed, 4 Aug 2010 14:57:56 +0000 Subject: [PATCH] 2010-08-04 Sancho Lerena * 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 --- pandora_agents/win32/ChangeLog | 5 +++ pandora_agents/win32/bin/util/df_percent.vbs | 38 ++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 pandora_agents/win32/bin/util/df_percent.vbs diff --git a/pandora_agents/win32/ChangeLog b/pandora_agents/win32/ChangeLog index 0bf278a4eb..bbb4b674eb 100644 --- a/pandora_agents/win32/ChangeLog +++ b/pandora_agents/win32/ChangeLog @@ -1,3 +1,8 @@ +2010-08-04 Sancho Lerena + + * win32/bin/util/df_percent.vbs: New VBS plugin to detect all + hardrives and return free disk on %. + 2010-08-04 Ramon Novoa * modules/pandora_module.cc: Changed sscanf format strings. They did diff --git a/pandora_agents/win32/bin/util/df_percent.vbs b/pandora_agents/win32/bin/util/df_percent.vbs new file mode 100644 index 0000000000..b904324836 --- /dev/null +++ b/pandora_agents/win32/bin/util/df_percent.vbs @@ -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 "" + Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine "" + Wscript.StdOut.flush + End If + End If +Next