' VB script to send specific eventlog entries to zabbix server
' edit Zabbix Server IP, Hostname and Keyname in commandstring to your needs
'
' create item in zabbix:
' Type: ZABBIX trapper
' Key: new_event
' Type of information: Text
'
' Default Logfiles: Application, Security, System, Internet Explorer
' EventTypes: 1 = Error, 2 = Warning, 3 = Information, 4 = Succes audit, 5 = Failure audit
' WMI info source: WMITools.exe
'
strComputer = "."
Set objWMIService = GetObject("winmgmts:{(Security)}\\" & _
strComputer & "\root\cimv2")
Set colEvents = objWMIService.ExecNotificationQuery _
("Select * from __instancecreationevent where " _
& "TargetInstance isa 'Win32_NTLogEvent' " _
& "and TargetInstance.Logfile = 'System' " _
& "and TargetInstance.EventType = '1' ")
Do
Set objEvent = colEvents.NextEvent
SendString = Chr(34) & objEvent.TargetInstance.Logfile & "," & objEvent.TargetInstance.EventType & _
"," & objEvent.TargetInstance.User & "," & objEvent.TargetInstance.ComputerName & _
"," & objEvent.TargetInstance.Message & Chr(34)
set WshShell = CreateObject("wscript.Shell")
commandstring="c:\zabbix\zabbix_sender.exe -z 192.168.2.199 -s SERVER001 -k new_event -o " & SendString
WshShell.Run commandstring,0
Loop
' edit Zabbix Server IP, Hostname and Keyname in commandstring to your needs
'
' create item in zabbix:
' Type: ZABBIX trapper
' Key: new_event
' Type of information: Text
'
' Default Logfiles: Application, Security, System, Internet Explorer
' EventTypes: 1 = Error, 2 = Warning, 3 = Information, 4 = Succes audit, 5 = Failure audit
' WMI info source: WMITools.exe
'
strComputer = "."
Set objWMIService = GetObject("winmgmts:{(Security)}\\" & _
strComputer & "\root\cimv2")
Set colEvents = objWMIService.ExecNotificationQuery _
("Select * from __instancecreationevent where " _
& "TargetInstance isa 'Win32_NTLogEvent' " _
& "and TargetInstance.Logfile = 'System' " _
& "and TargetInstance.EventType = '1' ")
Do
Set objEvent = colEvents.NextEvent
SendString = Chr(34) & objEvent.TargetInstance.Logfile & "," & objEvent.TargetInstance.EventType & _
"," & objEvent.TargetInstance.User & "," & objEvent.TargetInstance.ComputerName & _
"," & objEvent.TargetInstance.Message & Chr(34)
set WshShell = CreateObject("wscript.Shell")
commandstring="c:\zabbix\zabbix_sender.exe -z 192.168.2.199 -s SERVER001 -k new_event -o " & SendString
WshShell.Run commandstring,0
Loop
Comment