From 97c6a722d1ac8017376c7e8ec931dd2c13bf1f0a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 20 Oct 2016 15:19:55 +0200 Subject: [PATCH] Added du_percent.vbs plugin (c) Antonio Sanchez --- pandora_agents/win32/bin/util/du_percent.vbs | 50 ++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pandora_agents/win32/bin/util/du_percent.vbs diff --git a/pandora_agents/win32/bin/util/du_percent.vbs b/pandora_agents/win32/bin/util/du_percent.vbs new file mode 100644 index 0000000000..29265acf39 --- /dev/null +++ b/pandora_agents/win32/bin/util/du_percent.vbs @@ -0,0 +1,50 @@ +' df_all.vbs +' Returns free space (%) for all drives +' Pandora FMS Plugin, (c) 2014 Sancho Lerena +' ------------------------------------------ + +Option Explicit +On Error Resume Next + +' Variables +Dim objWMIService, objItem, colItems, argc, argv, i, Percent, Percentused + + +' 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) + Percentused = 100 - (Percent) + + Wscript.StdOut.WriteLine "" + Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine " " + if (Percentused > 99.99) then + Wscript.StdOut.WriteLine " " + elseif (Percentused < 0.01) then + Wscript.StdOut.WriteLine " " + else + Wscript.StdOut.WriteLine " " + End If + Wscript.StdOut.WriteLine " %" + Wscript.StdOut.WriteLine " 5" + Wscript.StdOut.WriteLine " 10" + Wscript.StdOut.WriteLine " 0" + Wscript.StdOut.WriteLine " 5" + Wscript.StdOut.WriteLine "" + Wscript.StdOut.flush + End If + End If +Next