08
Get Log from Cisco device via SNMP
Posted by jbjorkman on June 8, 2010 underDeprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /var/www/myfoto.se/jbits.se/blog/wp-includes/formatting.php on line 82
Cisco
I made this little script to be able to retrieve log data from any cisco device via snmp.
Unfortunately most devices seem to have a default setting that only keeps the last line in history, this can however be increased by entering: logging history [numlines] in config mode.
Our table is located in Cisco-SysLog-MIB and has the following OID: 1.3.6.1.4.1.9.9.41.1.2.3
The following steps must be taken to allow access to this Mib via WMI:
- Install WMI SNMP Provider ( A Windows component )
- Download the following mibfiles:
CISCO-SYSLOG-MIB.mib
CISCO-SMI.mib
SNMP-FRAMEWORK-MIB.mib
INET-ADDRESS-MIB.mib - Run the SNMP information module compiler smi2smir.exe (located in C:\WINDOWS\system32\wbem\snmp) to compile a mof from your mibfiles
smi2smir.exe /g CISCO-SYSLOG-MIB.mib CISCO-SMI.mib SNMP-FRAMEWORK-MIB.mib INET-ADDRESS-MIB.mib > cisco-syslog-mib.mof - Run mofcomp.exe (located in C:\WINDOWS\system32\wbem) to install your newly created mof into the WMI repository:
mofcomp.exe cisco-syslog-mib.mof
Finally, here's the script to make it all happen:
| Option Explicit
Dim strSNMPCmnt, strSNMPTarget Dim objWmiLocator, objWmiServices, objWmiNamedValueSet strSNMPCmnt="public" Set objWmiLocator = CreateObject("WbemScripting.SWbemLocator") objWmiNamedValueSet.Add "AgentAddress", strSNMPTarget Set colLogTable = objWmiServices.InstancesOf("SNMP_CISCO_SYSLOG_MIB_clogHistoryTable", , objWmiNamedValueSet) For Each objLogEntry In colLogTable Set colLogTable=Nothing |
Add A Comment
You must be logged in to post a comment.