cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2285
Views
0
Helpful
3
Replies

ASR9K NP controllers drop counter monitoring

jaemlee
Cisco Employee
Cisco Employee

                   Hi, Team

Customer asked to check np drop counter from their own ASR9k. If there are any controller its drop counter is over 0, wanna get syslog.

Sample result of command as following.

RP/1/RSP0/CPU0:ASR_02# show controllers np counters np4 | in DROP

                                                                                              FrameValue     Rate

Wed Jan 30 12:54:36.213 UTC

626 RESOLVE_INV_REMOTE_RACK_UIDB_DROP_CNT               786886           5

694 MODIFY_PUNT_REASON_MISS_DROP                               1           0

626 RESOLVE_INV_REMOTE_RACK_UIDB_DROP_CNT                 823788           5

694 MODIFY_PUNT_REASON_MISS_DROP                               2        0

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Actually I don't know how I can split each line for checking final rate number whether over 0 or not.

Could you share how I can do it easier?

3 Replies 3

Dan Frey
Cisco Employee
Cisco Employee

If you put this into an EEM TCL policy it will set, split, iterate over each line of the show output and produce a syslog when the rate is over 0.

set show "show controllers np counters np4 | in DROP"

set lines [split $show "\n"]

foreach line $lines {

if [regexp {\d+\s+([A-Z_]+)\s+\d+\s+(\d+)} $line match desc rate] {

if {$rate > 0 } {

action_syslog msg "DROP_PKT $desc Rate = $rate"

}}}

Dan

Thanks, Dafrey!

I've tested your regular expression with sample text file.

After that I've built following script and applied.

But IOS-XR said..

!! SEMANTIC ERRORS: This configuration was rejected by
!! the system due to semantic errors. The individual
!! errors with each failed configuration command can be
!! found below.


event manager policy check_drop_test.tcl username cisco persist-time 3600 type user
!!% Embedded Event Manager configuration: failed to retrieve intermediate registration result for policy check_drop_test.tcl
end

I think..there might be some semantic error but couldn't find it!

Could you comment about it?

*************************************************************************************************************

::cisco::eem::event_register_timer cron name check_drop_test.tcl cron_entry "* * * * *"

namespace import ::cisco::eem::*
namespace import ::cisco::lib::*

# Open the CLI
if [catch {cli_open} result] {
   error $result $errorInfo
} else {
   array set cli1 $result
}
set counter 0
while { $counter < 8 }
{ incr $counter
        set cmd "show controllers np counters np$counter"
if [catch {cli_exec $cli1(fd) $cmd } summary ] {
  error $summary $errorInfo
}
action_syslog msg "[Test:Jaemi] NP$counter Drop Counter Viewed"
set lines [split $summary "\n"]
foreach line $lines {
if [regexp {\d+\s+([A-Z_]+)\s+\d+\s+(\d+)} $line match desc rate] {
if {$rate > 0 } {
action_syslog msg "[Test:Jaemi] DROP_PKT $desc Rate = $rate"
}}}
action_syslog msg "[Test:Jaemi] NP$counter Drop Counter Check Finished"
}

**********************************************************************************************************

Give this one a try.

::cisco::eem::event_register_timer cron name check_drop_test.tcl cron_entry "* * * * *"

namespace import ::cisco::eem::*

namespace import ::cisco::lib::*

# Open the CLI

if [catch {cli_open} result] {

   error $result $errorInfo

} else {

    array set cli1 $result

}

# Go into enable mode

if [catch {cli_exec $cli1(fd) "en"} result] {

    error $result $errorInfo

}

set counter 0

while { $counter < 8 }  {

incr counter

set cmd "show controllers np counters np$counter"

if [catch {cli_exec $cli1(fd) "$cmd" } summary ] {

error $summary $errorInfo

}

action_syslog msg "Test:Jaemi NP$counter Drop Counter Viewed"

set lines [split $summary "\n"]

foreach line $lines {

if [regexp {\d+\s+([A-Z_]+)\s+\d+\s+(\d+)} $line match desc rate] {

if {$rate > 0 } {

action_syslog msg "Test:Jaemi DROP_PKT $desc Rate = $rate"

}}}

action_syslog msg "Test:Jaemi NP$counter Drop Counter Check Finished"

}

Message was edited by: Daniel Frey