Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Recieving SNMP traps as WMI events.

Reply
Thread Tools Display Modes

Recieving SNMP traps as WMI events.

 
 
Andrew Mishechkin
Guest
Posts: n/a

 
      08-08-2008
Hello All

I want to recieve SNMP traps as WMI events.
I have read the next MSDN articles:
http://msdn.microsoft.com/en-us/library/aa393020.aspx
http://msdn.microsoft.com/en-us/library/aa393019.aspx
http://msdn.microsoft.com/en-us/library/ms907028.aspx

I intend to create the permanent WMI consumer, and I cretated the three
scripts for this: filter, consumer and script for binding.
Filter script:
------------------------------------------------------
Option Explicit
On Error Resume Next

Dim strComputer
Dim strNamespace
Dim objService
Dim objEventFilterClass
Dim objEventFilter

strComputer = "."
strNamespace = "Root\snmp\SMIR"
Set objService = GetObject("WinMgmts:\\" & strComputer & "\" & strNamespace)
Set objEventFilterClass = objService.Get("__EventFilter")
Set objEventFilter = objEventFilterClass.SpawnInstance_()

objEventFilter.Name = "TrapMonitor"
objEventFilter.QueryLanguage = "WQL"
objEventFilter.Query = "SELECT * FROM SnmpColdStartNotification"
objEventFilter.Put_()
-------------------

Consumer script:
-----------------------------------------------------
Option Explicit
On Error Resume Next

Dim strComputer
Dim strNamespace
Dim objService
Dim objConsumerClass
Dim objConsumer

strComputer = "."
strNamespace = "Root\snmp\SMIR"
Set objService = GetObject("WinMgmts:\\" & strComputer & "\" & strNamespace)
Set objConsumerClass = objService.Get("LogFileEventConsumer")
Set objConsumer = objConsumerClass.SpawnInstance_()
objConsumer.Name = "TrapsLog"
objConsumer.Filename = "C:\Temp\TrapsLog.txt"
objConsumer.Text = "ôÒÜÐ ÐÏÌÕÞÅÎ"
objConsumer.Put_()
--------------------------------------------------

Binding script:
----------------------------------------------------
Option Explicit
On Error Resume Next

Dim strComputer
Dim strNamespace
Dim objService
Dim objEventFilter
Dim objConsumer
Dim objBindingClass
Dim objBindingInstance

strComputer = "."
strNamespace = "Root\snmp\SMIR"
Set objService = GetObject("WinMgmts:\\" & strComputer & "\" & strNamespace)
Set objEventFilter = objService.Get("__EventFilter.name=""TrapMonitor"" ")
Set objConsumer = objService.Get("LogFileEventConsumer.name=""TrapsL og""")
Set objBindingClass = objService.Get("__FilterToConsumerBinding")
Set objBindingInstance = objBindingClass.SpawnInstance_()
objBindingInstance.Filter = objEventFilter.Path_
objBindingInstance.Consumer = objConsumer.Path_
objBindingInstance.Put_()
--------------------------------------------
I compile mof-file for LogFileEventConsumer and plase into root\snmp\SMIR
---
mofcomp -N:root\snmp\SMIR C:\Windows\System32\Wbem\wbemcons.mof
---
and run my scripts - everything is OK.
But when SNMP trap is recieving - I have no WMI events. I run temporary
consumer script from MSDN:
---------------------------------------------------------------
Set objLocator = CreateObject("wbemscripting.swbemlocator")
Set objServices = objLocator.ConnectServer(, "root\snmp\SMIR")
set objwbemEventsource = objServices.ExecNotificationQuery("SELECT * FROM
SnmpLinkUpNotification")
set objWbemObject = objwbemEventsource.NextEvent()
wscript.echo "Received " & objWbemObject.path_.class
for each prop in objWbemObject.properties_
wscript.echo prop.name & " -- " & prop.value
next
--------------------------------------------------------------
and this script has no effect too. Traps is recieved - I test with D-Link
D-View.

How make permanent SNMP-events consumer correctly ?

----------------------
Andrew Mishechkin



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Monitoring SNMP traps with VBScript Vedran Matica Scripting 0 09-21-2007 02:21 PM
Monitoring SNMP traps with VBScript Vedran Matica Scripting 0 09-21-2007 02:18 PM
Re: Quick question about missed SNMP traps Edwin vMierlo Windows Server 1 01-05-2007 10:58 AM
SNMP TRAPS Sam Server Networking 0 10-20-2005 09:36 PM
Catching SNMP Traps in Health Monitor Jim Welsh Windows Small Business Server 0 12-14-2004 06:15 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59