11-27-2017 03:36 AM - edited 03-05-2019 09:32 AM
Hello
Certain counters cannot be polled using SNMP, so for troubleshooting I would like to log, say, number of PIM Registers to a file with a time stamp.
I would like to log a timestamp, a recognizable delimiter "&" and the output of "show ip route | include Register" to a file so that the file eventually would look like this:
12:09:00.081 MET Mon Nov 27 2017 & Registers: 13339381/0 (0 non-rp, 0 non-sm-group), Register Stops: 0/12608419, Hellos: 229496591/229501127
12:10:00.079 MET Mon Nov 27 2017 & Registers: 13339438/0 (0 non-rp, 0 non-sm-group), Register Stops: 0/12608476, Hellos: 229497410/229501946
12:11:00.047 MET Mon Nov 27 2017 & Registers: 13339482/0 (0 non-rp, 0 non-sm-group), Register Stops: 0/12608516, Hellos: 229498227/229502763
12:12:00.056 MET Mon Nov 27 2017 & Registers: 13339539/0 (0 non-rp, 0 non-sm-group), Register Stops: 0/12608573, Hellos: 229499046/229503582
12:13:00.041 MET Mon Nov 27 2017 & Registers: 13339579/0 (0 non-rp, 0 non-sm-group), Register Stops: 0/12608613, Hellos: 229499867/229504402
12:14:00.058 MET Mon Nov 27 2017 & Registers: 13339595/0 (0 non-rp, 0 non-sm-group), Register Stops: 0/12608629, Hellos: 229500686/229505222
12:15:00.037 MET Mon Nov 27 2017 & Registers: 13339671/0 (0 non-rp, 0 non-sm-group), Register Stops: 0/12608705, Hellos: 229501505/229506041
This is an easy format for further counter analysis in Excel or other tool.
My event manager applet looks like this:
event manager applet LOG_PERIODICS
event timer cron cron-entry "*/1 * * * *" maxrun 45
action 0010.0 info type routername
action 0100.0 file open STATUSFILE bootflash:log_register_counter_$_info_routername.txt a+
action 0110.0 cli command "term length 0"
action 0120.0 cli command "show clock"
action 0130.0 file puts STATUSFILE nonewline "$_cli_result &"
action 0140.0 cli command "sho ip traffic | i Register"
action 0150.0 file puts STATUSFILE "$_cli_result"
action 0160.0 file close STATUSFILE
But the output file does not look as expected - what is actually puts to file seems to include the prompt that follows the cli commands - this is the result:
12:07:00.040 MET Mon Nov 27 2017
router# & Registers: 13339283/0 (0 non-rp, 0 non-sm-group), Register Stops: 0/12608321, Hellos: 229494949/229499482
router#
12:08:00.108 MET Mon Nov 27 2017
router# & Registers: 13339340/0 (0 non-rp, 0 non-sm-group), Register Stops: 0/12608378, Hellos: 229495769/229500304
router#
12:09:00.081 MET Mon Nov 27 2017
router# & Registers: 13339381/0 (0 non-rp, 0 non-sm-group), Register Stops: 0/12608419, Hellos: 229496591/229501127
router#
12:10:00.079 MET Mon Nov 27 2017
router# & Registers: 13339438/0 (0 non-rp, 0 non-sm-group), Register Stops: 0/12608476, Hellos: 229497410/229501946
router#
All in all correct, except from the prompt "<CRLF>router#"being inserted for every cli command.
Any suggestions for a better way to do this, please ?
Thanks
Christian
11-27-2017 05:23 AM
Hello,
without having tested this, try:
no logging origin-id
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide