Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Accessing SNMP trap information using WMI

Accessing SNMP trap information using WMI

Scheduled Pinned Locked Moved Visual Basic
databasesysadminhelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vikramlinux
    wrote on last edited by
    #1

    Hi All, I am trying to retrieve the SNMP TRAP information using WMI calls like Try Dim connection As New ConnectionOptions() ' connection.Username = "xxx" 'connection.Password = "yyyy" 'connection.Authority = "ntlmdomain:DOMAIN" Dim scope As New ManagementScope("\\localhost\root\snmp\localhost", connection) scope.Connect() Dim query As New WqlEventQuery("SELECT * FROM SnmpNotification") Dim watcher As New ManagementEventWatcher(scope, query) Console.WriteLine("Waiting for an event on FullComputerName ...") Dim eventObj As ManagementBaseObject = watcher.WaitForNextEvent() watcher.Start() Console.WriteLine("{0} event occurred.", eventObj("__CLASS")) console.WriteLine("{0} Community name---> .", eventObj("Community")) 'Display information from the event Console.WriteLine("Process {0} has created, path is: ", eventObj("__PATH")) Console.WriteLine("Property count {0}", eventObj("__PROPERTY_COUNT")) Console.WriteLine("Relative path {0} ", eventObj("__RELPATH")) Console.WriteLine("Server {0} ", eventObj("__SERVER")) Console.WriteLine("SUPERCLASS {0} ", eventObj("__SUPERCLASS")) Console.WriteLine("AgentAddress {0} ", eventObj("AgentAddress")) Console.WriteLine("AgentTransportAddress {0} ", eventObj("AgentTransportAddress")) Console.WriteLine("AgentTransportProtocol {0} ", eventObj("AgentTransportProtocol")) Console.WriteLine("Identification {0} ", eventObj("Identification")) Console.WriteLine("TimeStamp {0} ", eventObj("TimeStamp")) Console.WriteLine("VarBindList {0} ", eventObj("VarBindList")) 'Console.WriteLine("Enterprise {0} ", eventObj("Enterprise")) ' Cancel the event subscription watcher.Stop() Close() Catch err As ManagementException MessageBox.Show("An error occurred while trying to receive an event: " & err.Message) Catch unauthorizedErr As System.UnauthorizedAccessException MessageBox.Show("Connection error (user name or password might be incorrect): " & unauthorizedErr.Message) End Try Output is like SnmpV1Notification event occurred. public Community name---> . Process has created, path is: Property count 9 Relative path Server SUPERCLASS SnmpNotification AgentAddress 127.0.0.1 AgentTransportAddress 127.0.0.1 AgentTransportProtocol IP Identification 1.3.6.1.4.1.393.200.50.66.0.2 TimeStamp 9 Here I am unable get to the text message inside the trap. Does anybody know how to retrieve it?

    V 1 Reply Last reply
    0
    • V vikramlinux

      Hi All, I am trying to retrieve the SNMP TRAP information using WMI calls like Try Dim connection As New ConnectionOptions() ' connection.Username = "xxx" 'connection.Password = "yyyy" 'connection.Authority = "ntlmdomain:DOMAIN" Dim scope As New ManagementScope("\\localhost\root\snmp\localhost", connection) scope.Connect() Dim query As New WqlEventQuery("SELECT * FROM SnmpNotification") Dim watcher As New ManagementEventWatcher(scope, query) Console.WriteLine("Waiting for an event on FullComputerName ...") Dim eventObj As ManagementBaseObject = watcher.WaitForNextEvent() watcher.Start() Console.WriteLine("{0} event occurred.", eventObj("__CLASS")) console.WriteLine("{0} Community name---> .", eventObj("Community")) 'Display information from the event Console.WriteLine("Process {0} has created, path is: ", eventObj("__PATH")) Console.WriteLine("Property count {0}", eventObj("__PROPERTY_COUNT")) Console.WriteLine("Relative path {0} ", eventObj("__RELPATH")) Console.WriteLine("Server {0} ", eventObj("__SERVER")) Console.WriteLine("SUPERCLASS {0} ", eventObj("__SUPERCLASS")) Console.WriteLine("AgentAddress {0} ", eventObj("AgentAddress")) Console.WriteLine("AgentTransportAddress {0} ", eventObj("AgentTransportAddress")) Console.WriteLine("AgentTransportProtocol {0} ", eventObj("AgentTransportProtocol")) Console.WriteLine("Identification {0} ", eventObj("Identification")) Console.WriteLine("TimeStamp {0} ", eventObj("TimeStamp")) Console.WriteLine("VarBindList {0} ", eventObj("VarBindList")) 'Console.WriteLine("Enterprise {0} ", eventObj("Enterprise")) ' Cancel the event subscription watcher.Stop() Close() Catch err As ManagementException MessageBox.Show("An error occurred while trying to receive an event: " & err.Message) Catch unauthorizedErr As System.UnauthorizedAccessException MessageBox.Show("Connection error (user name or password might be incorrect): " & unauthorizedErr.Message) End Try Output is like SnmpV1Notification event occurred. public Community name---> . Process has created, path is: Property count 9 Relative path Server SUPERCLASS SnmpNotification AgentAddress 127.0.0.1 AgentTransportAddress 127.0.0.1 AgentTransportProtocol IP Identification 1.3.6.1.4.1.393.200.50.66.0.2 TimeStamp 9 Here I am unable get to the text message inside the trap. Does anybody know how to retrieve it?

      V Offline
      V Offline
      v 2rahna
      wrote on last edited by
      #2

      Hey even I am facing this issue. I am unable to retrieve the VarBindList. Please help Regards,, Rahul :((

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups