Announcement

Collapse
No announcement yet.

SNMP

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SNMP

    I was looking for tools/scripts to manage SNMP on remote computers, when I came across this thread... http://www.systemtools.com/HyenaBoar...ML/000074.html .

    Has this been implemented anywhere? If not, can any suggestions/ideas be made on this?

  • #2
    Re: SNMP

    I've put together this script to kinda get people going on gathering SNMP data. It's in a VERY RAW FORMAT and will produce information that is useless, I'm sure. But it's a start. As I hone the SNMP provider, I'll post updates.

    (Disclaimer: follow these directions on the PC/Server you wish to run these function on: http://msdn.microsoft.com/library/defaul...mp_provider.asp

    Installing the SNMP Provider is CRITICAL)

    -------------------------------------------

    strTargetSnmpDevice = "192.168.254.253"
    strTargetSnmpCommunity = "public"

    Set objWmiLocator = CreateObject("WbemScripting.SWbemLocator")
    Set objWmiServices = objWmiLocator.ConnectServer("","root\snmp\localhos t")

    Set objWmiNamedValueSet = CreateObject("WbemScripting.SWbemNamedValueSet")
    objWmiNamedValueSet.Add "AgentAddress", strTargetSnmpDevice
    objWmiNamedValueSet.Add "AgentReadCommunityName", strTargetSnmpCommunity

    Set colSystem = objWmiServices.InstancesOf("SNMP_RFC1213_MIB_syste m", , objWmiNamedValueSet)

    For Each objSystem In colSystem
    WScript.Echo "sysContact: " & objSystem.sysContact & vbCrLf & _
    "sysDescr: " & objSystem.sysDescr & vbCrLf & _
    "sysLocation: " & objSystem.sysLocation & vbCrLf & _
    "sysName: " & objSystem.sysName & vbCrLf & _
    "sysObjectID: " & objSystem.sysObjectID & vbCrLf & _
    "sysServices: " & objSystem.sysServices & vbCrLf & _
    "sysUpTime: " & objSystem.sysUpTime
    Next

    Set colIfTable = objWmiServices.InstancesOf("SNMP_RFC1213_MIB_ifTab le", , objWmiNamedValueSet)

    For Each objInterface In colIfTable
    WScript.Echo "ifIndex [Key]: " & objInterface.ifIndex & vbCrLf & _
    " ifAdminStatus: " & objInterface.ifAdminStatus & vbCrLf & _
    " ifDescr: " & objInterface.ifDescr & vbCrLf & _
    " ifInDiscards: " & objInterface.ifInDiscards & vbCrLf & _
    " ifInErrors: " & objInterface.ifInErrors & vbCrLf & _
    " ifInNUcastPkts: " & objInterface.ifInNUcastPkts & vbCrLf & _
    " ifInOctets: " & objInterface.ifInOctets & vbCrLf & _
    " ifInUcastPkts: " & objInterface.ifInUcastPkts & vbCrLf & _
    " ifInUnknownProtos: " & objInterface.ifInUnknownProtos & vbCrLf & _
    " ifLastChange: " & objInterface.ifLastChange & vbCrLf & _
    " ifMtu: " & objInterface.ifMtu & vbCrLf & _
    " ifOperStatus: " & objInterface.ifOperStatus & vbCrLf & _
    " ifOutDiscards: " & objInterface.ifOutDiscards & vbCrLf & _
    " ifOutErrors: " & objInterface.ifOutErrors & vbCrLf & _
    " ifOutNUcastPkts: " & objInterface.ifOutNUcastPkts & vbCrLf & _
    " ifOutOctets: " & objInterface.ifOutOctets & vbCrLf & _
    " ifOutQLen: " & objInterface.ifOutQLen & vbCrLf & _
    " ifOutUcastPkts: " & objInterface.ifOutUcastPkts & vbCrLf & _
    " ifPhysAddress: " & objInterface.ifPhysAddress & vbCrLf & _
    " ifSpecific: " & objInterface.ifSpecific & vbCrLf & _
    " ifSpeed: " & objInterface.ifSpeed & vbCrLf & _
    " ifType: " & objInterface.ifType & vbCrLf
    Next

    Set colTcpConnTable = objWmiServices.InstancesOf("SNMP_RFC1213_MIB_tcpCo nnTable", , objWmiNamedValueSet)

    Set colUdpTable = objWmiServices.InstancesOf("SNMP_RFC1213_MIB_udpTa ble", , objWmiNamedValueSet)

    Set colIpTable = objWmiServices.InstancesOf("SNMP_RFC1213_MIB_IpAdd rTable", , objWmiNamedValueSet)

    WScript.Echo "TCP Connections and Listening Ports" & vbCrLf & _
    "-----------------------------------"
    For Each objTcpConn In colTcpConnTable
    WScript.Echo objTcpConn.tcpConnLocalAddress & ":" & _
    objTcpConn.tcpConnLocalPort & " => " & _
    objTcpConn.tcpConnRemAddress & ":" & _
    objTcpConn.tcpConnRemPort & " " & _
    "[State: " & objTcpConn.tcpConnState & "]"
    Next


    WScript.Echo vbCrLf & "IP Ports" & vbCrLf & "---------"
    For Each objIp In colIpTable
    WScript.Echo "ipAdEntAddr :" & objIp.ipAdEntAddr
    WScript.Echo "ipAdEntBcastAddr :" & objIp.ipAdEntBcastAddr
    WScript.Echo "ipAdEntIfIndex :" & objIp.ipAdEntIfIndex
    WScript.Echo "ipAdEntNetMask :" & objIp.ipAdEntNetMask
    WScript.Echo "ipAdEntReasmMaxSize :" & objIp.ipAdEntReasmMaxSize
    WScript.Echo "-----------------------------------"
    Next


    WScript.Echo vbCrLf & "UDP Ports" & vbCrLf & "---------"
    For Each objUdp In colUdpTable
    WScript.Echo objUdp.udpLocalAddress & ":" & objUdp.UdpLocalPort
    Next

    ----------------------------------------

    Hope this helps!

    Joel

    Comment

    Working...
    X