Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Looking for a Script to read text and put it into show commands

     I am familiar with applets on IOS however I am getting to the point where I want to do more advance actions.

     I have a router with multiple call legs on it. I want to run a show command to see how many calls have been up for longer than a day. (show call active voice br | count dur 1d). If the router does not have anything that meets the one day time frame, it kicks out "Number of lines which match regexp = 0". I want to make this a conditional action after this output, so if it equals or is greater than 1, then it continues on.

     The next step would be for the router to search through the full output and pull the call identifiers of each call that has "dur 1d" on it. The call identifier is the first string for each call and the duration is in the second line.

     Example:

124A : 1117 09:48:43.111 CDT Mon Aug 13 2012.1 +160 pid:501 Originate REDACTED active

dur 1d2h tx:2327/369824 rx:2214/354240

IP REDACTED:28914 SRTP: off rtt:0ms pl:140/50ms lost:0/1/0 delay:70/70/90ms g711ulaw TextRelay: off

media inactive detected:n media contrl rcvd:n/a timestamp:n/a

long duration call detected:n long duration call duration:n/a timestamp:n/a

     Each router can have anywhere from one or two calls on it to a hundred. I want to take that string and paste it into a show command for tracking purposes. (show call active voice br | section 124A) I would like to have the information either pushed out into a syslog or into a file on the flash.

     I had the following applet started however I am not seeing how I can do the read and paste command for the call identified.

event manager applet Show_Calls

event timer watchdog time 28800

action 1.0 cli command "sh call active voice br | count dur 1d"

??????????????????????

action 3.0 cli command "sh call active voice br"

action 3.1 syslog msg "$_cli_result"

action 3.2 cli command "yes"

action 3.3 syslog msg "$_cli_result"

Please help!

Thank You,

Roger

Everyone's tags (3)
1 REPLY
Cisco Employee

Looking for a Script to read text and put it into show commands

The first thing to do is:

regexp "match regexp = ([0-9]+)" $_cli_result match count

if $count eq 0

exit 0

end

The second is a bit more challenging.  I think this will work:

cli command "show call active voice br"

foreach line $_cli_result "\n"

regexp "^([0-9a-zA-Z]+) : " $line match callid

if $_regexp_result eq 1

  continue

end

regexp "^dur 1d" $line

if $_regexp_result eq 1

  cli command "show call active voice br | section $callid"

  syslog msg "$_cli_result"

end

end

508
Views
0
Helpful
1
Replies
CreatePlease login to create content