mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
Added df_percent_used and mem_percent_used plugins
This commit is contained in:
parent
5f0c6a8b81
commit
1bb6dae844
49
pandora_agents/win32/bin/util/df_percent_used.vbs
Normal file
49
pandora_agents/win32/bin/util/df_percent_used.vbs
Normal file
@ -0,0 +1,49 @@
|
||||
' df_all.vbs
|
||||
' Returns used 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
|
||||
|
||||
|
||||
' 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 (100 - (objItem.FreeSpace / objItem.Size) * 100, 2)
|
||||
Wscript.StdOut.WriteLine "<module>"
|
||||
Wscript.StdOut.WriteLine " <name><![CDATA[DiskUsed_" & objItem.Name & "]]></name>"
|
||||
Wscript.StdOut.WriteLine " <description><![CDATA[% used space. Filesystem unit: " & objItem.Name & "]]></description>"
|
||||
If (Percent > 99.99) then
|
||||
Wscript.StdOut.WriteLine " <data><![CDATA[" & 100 & "]]></data>"
|
||||
Elseif (Percent < 0.01) then
|
||||
Wscript.StdOut.WriteLine " <data><![CDATA[" & 0 & "]]></data>"
|
||||
Else
|
||||
Wscript.StdOut.WriteLine " <data><![CDATA[" & Percent & "]]></data>"
|
||||
End If
|
||||
Wscript.StdOut.WriteLine " <unit>%</unit>"
|
||||
Wscript.StdOut.WriteLine " <min_warning>90</min_warning>"
|
||||
Wscript.StdOut.WriteLine " <max_warning>0</max_warning>"
|
||||
Wscript.StdOut.WriteLine " <min_critical>95</min_critical>"
|
||||
Wscript.StdOut.WriteLine " <max_critical>0</max_critical>"
|
||||
Wscript.StdOut.WriteLine " <module_group>System</module_group>"
|
||||
Wscript.StdOut.WriteLine "</module>"
|
||||
Wscript.StdOut.flush
|
||||
End If
|
||||
End If
|
||||
Next
|
57
pandora_agents/win32/bin/util/mem_percent_used.vbs
Normal file
57
pandora_agents/win32/bin/util/mem_percent_used.vbs
Normal file
@ -0,0 +1,57 @@
|
||||
' mem_percent_used.vbs
|
||||
' Returns used RAM (%)
|
||||
' Pandora FMS Plugin, (c) 2017 Fermin Hernandez
|
||||
' ------------------------------------------
|
||||
|
||||
Dim usedMEM, totalMEM, Percent
|
||||
|
||||
strComputer = "."
|
||||
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
|
||||
|
||||
Set colRAMs = objWMIService.ExecQuery("Select capacity from Win32_PhysicalMemory")
|
||||
For Each total in colRAMs
|
||||
totalMEM = total.capacity
|
||||
Next
|
||||
|
||||
Set colUSEDs = objWMIService.ExecQuery("Select freePhysicalMemory from Win32_OperatingSystem")
|
||||
For Each used in colUSEDs
|
||||
usedMEM = used.freePhysicalMemory * 1024
|
||||
Next
|
||||
|
||||
on error resume next
|
||||
flag = colRAMs.Count
|
||||
If (err.number <> 0) Then
|
||||
flag = true
|
||||
Else
|
||||
flag = false
|
||||
End If
|
||||
on error goto 0
|
||||
|
||||
on error resume next
|
||||
flag = colUSEDs.Count
|
||||
If (err.number <> 0) Then
|
||||
flag = true
|
||||
Else
|
||||
flag = false
|
||||
End If
|
||||
on error goto 0
|
||||
|
||||
'Print only when there's results
|
||||
If (NOT flag) Then
|
||||
Percent = round (100 - (usedMEM / totalMEM) * 100, 2)
|
||||
Wscript.StdOut.WriteLine "<module>"
|
||||
Wscript.StdOut.WriteLine " <name><![CDATA[Memory_Used]]></name>"
|
||||
Wscript.StdOut.WriteLine " <description><![CDATA[Used memory %]]></description>"
|
||||
If (Percent > 99.99) then
|
||||
Wscript.StdOut.WriteLine " <data><![CDATA[" & 100 & "]]></data>"
|
||||
Elseif (Percent < 0.01) then
|
||||
Wscript.StdOut.WriteLine " <data><![CDATA[" & 0 & "]]></data>"
|
||||
Else
|
||||
Wscript.StdOut.WriteLine " <data><![CDATA[" & Percent & "]]></data>"
|
||||
End If
|
||||
Wscript.StdOut.WriteLine " <unit>%</unit>"
|
||||
Wscript.StdOut.WriteLine " <min_critical>95</min_critical>"
|
||||
Wscript.StdOut.WriteLine " <max_critical>100</max_critical>"
|
||||
Wscript.StdOut.WriteLine " <module_group>System</module_group>"
|
||||
Wscript.StdOut.WriteLine "</module>"
|
||||
End If
|
Loading…
x
Reference in New Issue
Block a user