Advertisement
qiwichupa

Script for zabbix low level service discovery rule

Jul 24th, 2012
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Used in this article: http://obrivki.blogspot.com/2012/07/zabbix-2-low-level-discovery-windows.html
  2. '
  3. Sub ServicesList()
  4.     Dim objWMIService, colItems, oServices, objNTInfo
  5.     Set objNTInfo = CreateObject("WinNTSystemInfo")
  6.     ComputerName = lcase(objNTInfo.ComputerName)
  7.  
  8.     wscript.echo  "{"
  9.     wscript.echo  "    " & Chr(34) & "data" & Chr(34) & ":[" & vbCrLf
  10.     wscript.echo  ""
  11.  
  12.  
  13.     Set objWMIService = GetObject("winmgmts:\root\cimv2")
  14.     Set colItems = objWMIService.ExecQuery("Select * from Win32_Service",,48)
  15.     For Each objItem in colItems
  16. '       if (objItem.StartMode="Auto") then
  17. '              if (objItem.Started=False) then
  18.  
  19.             wscript.echo  "{ "&Chr(34)&"{#SCNAME}"&Chr(34)&":"&Chr(34)& objItem.Name &Chr(34)&",    "    &Chr(34)&"{#SCCAPTION}"&Chr(34)&":"&Chr(34)&objItem.Caption&Chr(34)&",    "    &Chr(34)&"{#SCSTARTMODE}"&Chr(34)&":"&Chr(34)&objItem.StartMode&Chr(34)&",    "    &Chr(34)&"{#SCDISCOVERYFILTER}"&Chr(34)&":"&Chr(34)&objItem.StartMode&"-"&ComputerName&"-"&objItem.Name&Chr(34)&"   },"
  20.  
  21. '         end if
  22. '            end if
  23.     Next
  24.     wscript.echo  "{ "&Chr(34)&"{#SCNAME}"&Chr(34)&":"&Chr(34)& "NULL" &Chr(34)&",    "    &Chr(34)&"{#SCCAPTION}"&Chr(34)&":"&Chr(34)&"NULL"&Chr(34)&",    "    &Chr(34)&"{#SCSTARTMODE}"&Chr(34)&":"&Chr(34)&"NULL"&Chr(34)&",    "    &Chr(34)&"{#SCDISCOVERYFILTER}"&Chr(34)&":"&Chr(34)&"NULL"&Chr(34)&"   }"
  25.  
  26.     wscript.echo  ""
  27.     wscript.echo  "    ]"
  28.     wscript.echo  "}"
  29.    
  30.  
  31. End Sub
  32.  
  33. ServicesList()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement