Munin

From Tuxunix

Jump to: navigation, search

Plugins personnalisé Windows

  • Fichier bat : Windows_Memory.cmd
@echo off
call %windir%\system32\cscript.exe //NoLogo "C:\ECRITEL\MUNIN\plugins\Windows_Memory.vbs" %1
  • Fichier VBS : Windows_Memory.vbs
set args = WScript.Arguments
num = args.Count
if num = 0 then
    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("select * from Win32_PerfRawData_PerfOS_Memory")
    For Each objItem in colItems
         mem_free=int(objItem.AvailableBytes)
    Next

end if
if num = 0 then
    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("select * from CIM_PhysicalMemory")     
    For Each objItem in colItems
         mem_install=mem_install + int(objItem.Capacity)
    Next
         Wscript.StdOut.Write "mem2.value " & mem_install & Vblf
         mem_used=mem_install - mem_free
         Wscript.StdOut.Write "mem3.value " & mem_used & Vblf
         Wscript.StdOut.Write 	"." & Vblf
end if
if num = 1 then
    if args.Item(0) = "config" then
         WScript.StdOut.Write "graph_title Memory usage" & Vblf
         WScript.StdOut.Write "graph_category System" & Vblf
    WScript.StdOut.Write "graph_vlabel Bytes" & Vblf
    WScript.StdOut.Write "graph_args --base 1024 -l 0" & Vblf
    WScript.StdOut.Write "mem2.label Memoire disponible" & Vblf
    WScript.StdOut.Write "mem2.type GAUGE" & Vblf
    WScript.StdOut.Write "mem2.draw LINE2" & Vblf
    WScript.StdOut.Write "mem3.label Memoire utilisee" & Vblf
    WScript.StdOut.Write "mem3.type GAUGE" & Vblf
    WScript.StdOut.Write "mem3.draw AREA" & Vblf &"." & Vblf

    elseif args.Item(0) = "name" then
         WScript.StdOut.Write("memory")
    end if
end if
  • Puis dans le fichier ini : "munin-node.ini"
Check0x01=C:\ECRITEL\MUNIN\plugins\Windows_Memory.cmd
Personal tools