[c-nsp] Cisco IOS XR event manager run

Mohammad Khalil eng_mssk at hotmail.com
Tue Apr 21 09:25:36 EDT 2015


I tried the below script


array set arr_einfo [event_reqinfo]

if [catch {cli_open} result] {
    error $result $errorInfo
} else {
    array set cli1 $result
}

if [catch {cli_write $cli1(fd) "run attach 0/1/CPU0"} _cli_result] {
    error $_cli_result $errorInfo
}

if [catch {cli_read_pattern $cli1(fd) "#"} _cli_result] {
    error $_cli_result $errorInfo
}

if [catch {cli_write $cli1(fd) "show_nat44_stats"} _cli_result] {
    error $_cli_result $errorInfo
}

if [catch {cli_read_pattern $cli1(fd) "#"} _cli_result] {
    error $_cli_result $errorInfo
}

set output $_cli_result

if [catch {cli_exec $cli1(fd) "exit"} _cli_result] {
    error $_cli_result $errorInfo
}
puts "$_cli_result"}

# Close open cli before exit.
catch {cli_close $cli1(fd) $cli1(tty_id)} result

But nothing appeared on the screen 

> Date: Tue, 7 Apr 2015 20:12:38 +0200
> From: thomas.braun at flashnetworking.de
> To: eng_mssk at hotmail.com; thomas.braun at flashstudy.de; peter at rathlev.dk
> CC: cisco-nsp at puck.nether.net
> Subject: Re: [c-nsp] Cisco IOS XR event manager run
> 
> Hi,
> 
> you need to parse it with something.
> 
> 
> i would send it to syslog and would start a programm to parse it to a
> rrd database or you can write a script to login to your router an parse
> the output there, but than you do not need the event manager.
> 
> 
> 
> regards
> thomas
> 
> > Yes it's already event manager TEST (By mistake) :)
> > Thanks it worked now for me
> > Now , what am looking for is trying to graph these values (supposed I do
> > not have Cacti or something like)
> > 
> > sh interfaces gigabitEthernet 0/0/0/2 | include Output.*multic$
> > 
> > Tue Apr  7 15:47:27.979 EET
> >      Output 1456 broadcast packets, 135 multicast packets
> > 
> > For example , the output below
> > 
> > Thanks again
> > 
> > BR,
> > Mohammad
> > 
> >> Date: Tue, 7 Apr 2015 11:01:03 +0200
> >> From: thomas.braun at flashstudy.de
> >> To: eng_mssk at hotmail.com; peter at rathlev.dk
> >> CC: cisco-nsp at puck.nether.net
> >> Subject: Re: [c-nsp] Cisco IOS XR event manager run
> >>
> >> Hi,
> >>
> >> add following action:
> >> action 3.0 puts $_cli_result
> >>
> >>
> >> and you need to change your command to:
> >> event manager run TEST
> >>
> >>
> >>
> >> Regards
> >> Thomas
> >>
> >>
> >>
> >> Am 07.04.15 um 10:44 schrieb Mohammad Khalil:
> >> > The script ran without any errors but no output appeared
> >> > Even with Cisco IOS , am trying just to display certain output and
> > run the script using the event manage run command
> >> >
> >> > event manager applet TEST
> >> > event none
> >> > action 1.0 cli command "enable"
> >> > action 1.2 cli command "show ip interface brief"
> >> >
> >> > R1#event manager run MSSK
> >> > R1#
> >> >
> >> > No output appears , what should I do in order for the output to be
> > displayed on the screen?
> >> >
> >> > Thanks
> >> >
> >> >
> >> >> Subject: Re: [c-nsp] Cisco IOS XR event manager run
> >> >> From: peter at rathlev.dk
> >> >> To: eng_mssk at hotmail.com
> >> >> CC: cisco-nsp at puck.nether.net
> >> >> Date: Tue, 7 Apr 2015 10:02:14 +0200
> >> >>
> >> >> On Tue, 2015-04-07 at 10:46 +0300, Mohammad Khalil wrote:
> >> >>> #Run cmds
> >> >>> foreach cmd $commands {
> >> >>> action_syslog priority info msg "Executing: $cmd"
> >> >>> set result [ cli_exec $cli(fd) $cmd ]
> >> >>> action_syslog priority info msg $result }
> >> >>>
> >> >>> RP/0/0/CPU0:XR1#event manager run test.tcl
> >> >>> Tue Apr 7 13:43:44.488 EET
> >> >>> RP/0/0/CPU0:Apr 7 13:43:45.768 : tclsh[65816]:
> > %HA-HA_EEM-6-ACTION_SYSLOG_LOG_INFO : test.tcl: test.tcl was triggered
> >> >>> RP/0/0/CPU0:Apr 7 13:43:45.768 : tclsh[65816]:
> > %HA-HA_EEM-5-ACTION_SYSLOG_LOG_NOTICE : test.tcl: Opening CLI...
> >> >>> RP/0/0/CPU0:Apr 7 13:43:47.318 : tclsh[65816]:
> > %HA-HA_EEM-6-ACTION_SYSLOG_LOG_INFO : test.tcl: OK
> >> >>> RP/0/0/CPU0:Apr 7 13:43:47.318 : tclsh[65816]:
> > %HA-HA_EEM-6-ACTION_SYSLOG_LOG_INFO : test.tcl: Executing: sh bgp summary
> >> >>> RP/0/0/CPU0:Apr 7 13:43:48.048 : tclsh[65816]:
> > %HA-HA_EEM-6-ACTION_SYSLOG_LOG_INFO : test.tcl: sh bgp summary
> >> >>>
> >> >>> No output appears
> >> >>
> >> >> Actually, some output appeared. It seems the first line of $result,
> >> >> which is the command itself, is echoed back to you. So it's probably
> >> >> because action_syslog doesn't handle multi-line messages.
> >> >>
> >> >> You could try splitting the result:
> >> >>
> >> >> foreach cmd $commands {
> >> >> action_syslog priority info msg "Executing: $cmd"
> >> >> set result_lines [ split [ cli_exec $cli(fd) $cmd ] "\n" ]
> >> >> foreach line $result_lines {
> >> >> action_syslog priority info msg $line
> >> >> }
> >> >> }
> >> >>
> >> >> --
> >> >> Peter
> >> >>
> >> >>
> >> >>
> >> >
> >> > _______________________________________________
> >> > cisco-nsp mailing list cisco-nsp at puck.nether.net
> >> > https://puck.nether.net/mailman/listinfo/cisco-nsp
> >> > archive at http://puck.nether.net/pipermail/cisco-nsp/
> >> >
> >>
> 
> 
> -- 
> Thomas Braun
> 
> Für Netzwerke, die sorgenfrei funktionieren:
> 
> FlashNetworking GmbH
> Kongressstraße 5
> 52070 Aachen
> 
> 
> Tel.:       0241/53108820
> Fax:        0241/92045421
> Email:      thomas.braun at flashnetworking.de
> 
>   www.flashnetworking.de
> 
> CISCO Systems Select Certified Partner
> 
> Geschäftsführer: Thomas Braun
> Amtsgericht Aachen, HRB 15314
> 
> GPG fingerprint = C6A F110 97C8  5319 7EEB 57C5 FD24 951F
> 
 		 	   		  


More information about the cisco-nsp mailing list