cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2657
Views
5
Helpful
13
Replies

EEM to parse cli output from multiple lines

silver.markus
Level 1
Level 1

Hi all,

I wandered over here from the IPT forum because my initial query has changed somewhat.

I need to run an EEM script which will collect the output of show call active voice brief with the appropriate pipes such as PID: and dur 00:30: where I am looking for the call leg id and the duration of the call and when found, string them together.

The flow would look like this:

show call active voice brief | PID:100|dur 00:30:

result:

1A31 : 4294 186160660ms.1 +20 pid:100 Answer 073333333 connected

dur 00:30:57 tx:1725/275682 rx:1984/300436

1A38 : 4301 186176310ms.1 +17410 pid:200 Originate 033333333 active

dur 00:30:01 tx:1228/196480 rx:2093/334880

Then somehow, which I am still trying to do, parse the output into a variable and string the two lines each containing PID and dur into one, then a regexp to extract the call leg id into a variable and clear the call. This would work on a loop until the variable was empty.

Impossible?

Edit: I just thought of something... I will also get calls that are of a shorter duration than 00:30 because of the PID being 100? That is what lack of sleep does to you. Any better ideas of doing it.

2 Accepted Solutions

Accepted Solutions

The script is self-contained. It's a proof of concept. If you run it, it should provide you with correct results given the static input. The point is, if you plug in the algorithm into another script (which sets the output variable to the actual content to parse) it will do the right thing.

View solution in original post

Much easier. This EEM policy should do what you want. It is untested as I do not have a voice setup.

View solution in original post

13 Replies 13

Joe Clarke
Cisco Employee
Cisco Employee

What you want sounds very doable, but I'm still a bit confused about exactly what values you want to extract from the above output. I'm guessing you want the 073333333 value?

Hi,

I want to extract the call leg ID and the call duration so right at the end of the EEM script I can run a clear call voice active id xxxxxx for calls that are above 00:30 in the timer.

A bit of background... I tried using TCL to set a timer but unfortunately, when the call gets handed off to the outbound dial-peer, it goes to the default application and so is not in control of the call leg anymore. So my request above is about actioning a syslog message that triggers an application to clear a call.

My golden solution would be to use a tcl script outbound, that does a timer but I guess this is not possible on its own according to the documentation so I would need an inbound script that does a handoff to the outbound script if it matches an area code.

The inbound script doesnt need to do anything, except an if statement to match the area code, if true, it will hand it off to the outbound application, it no, then close the call. The outbound will have a timer that will clear the call leg once it has expired.

I wouldn't need EEM then for this.

As I am stuck with EEM, I decided to look at the TCL side but again, I have hit a snag but I have attached the scripts here as they are quite short.

One inbound and outbound with inbound "handoff" to outbound.

The debug output is below:

Jun 26 2009 14:28:11.868 BST: //4990//SSIN:/doProxyBeforeTXFR: VOIP dialpeer #200: Preference(0)

Jun 26 2009 14:28:11.868 BST: //4990//SSIN:/doProxyBeforeTXFR: Handoff: voip preference(0) pots dp preference(-1)

Jun 26 2009 14:28:11.868 BST: //4990//SSIN:/AFW_SS_PrepareHandOffLocalTRT: This TXFR will be a handoff.

Jun 26 2009 14:28:11.868 BST: //4990//SSIN:/AFW_SS_PrepareHandOffLocalTRT: xorCallID=4993, xtoCallID=-1

Jun 26 2009 14:28:11.868 BST: //4990//SSIN:/AFW_SS_PrepareHandOffLocalTRT: Handoff to instance of leg LEG[4993 ][LEG_INCCONNECTED(5)][Cause(0)]Didn't find Destination listener

Jun 26 2009 14:28:11.868 BST: //4993/078E25B788A7/SSIN:/AFW_SS_HandOffLocalTRT_FindSession: Didn't find Destination listener

Jun 26 2009 14:28:11.868 BST: //4990//SSIN:/AFW_SS_PrepareHandOffLocalTRT: Didn't find a Session listener of XOR leg

Jun 26 2009 14:28:11.868 BST: //4990//SSIN:/AFW_SS_PrepareHandOffLocalTRT: module handle leg instance - TclModule_48585584_0_225347680

Jun 26 2009 14:28:11.868 BST: //4990//Dest:/DestReturnReroute: reroute type 2

Jun 26 2009 14:28:11.868 BST: //-1//AFW_:/AFW_Event_New: Event ID: ev_reroute_ind

Jun 26 2009 14:28:11.868 BST: //4990//AFW_:/AFW_Module_ReturnArgEv:

Jun 26 2009 14:28:11.868 BST: //-1//Dest:/DestAddToHoldEvQ:

Jun 26 2009 14:28:11.868 BST: //4990//Dest:/AFW_M_Destination_Initiate: attempting call to destination 07736007651

Jun 26 2009 14:28:11.868 BST: //4990//Call:/CS_Placecall: Call placed to 0776576351 index 0

Jun 26 2009 14:28:11.868 BST: //4990//AFW_:/AFW_FSM_Drive: ACTION END: -------------(S_PLACECALL[2])---------------

Jun 26 2009 14:28:11.868 BST: //4990//Call:/CS_Complete: Can't complete

Jun 26 2009 14:28:11.872 BST: //4990//AFW_:/AFW_ExecEnv_SetModuleScope: CallSetup_4A7EABAC_0_225347740 ---> NULL

Bah humbug! Can't get anything working... I will be happy for any solution to this dilemma of mine... EEM or TCL... so your help would be *****GREATLY***** appreciated.

I don't do anything with IVR scripts, but here is a Tcl code snippet which could be used in an EEM policy or tclsh script. It may also work for an IVR script. If you want a full EEM policy, let me know.

Hi mate...

You are brill. I am a step closer to what I want to achieve thanks to you.

A full EEM policy sounds great... if you have time, it would put a smile on this "Grumpy Old Man" as my wife has been calling me for the last 4 days.

I am not sure I understand the top part of your tcl script... will that be used at all?

The script is self-contained. It's a proof of concept. If you run it, it should provide you with correct results given the static input. The point is, if you plug in the algorithm into another script (which sets the output variable to the actual content to parse) it will do the right thing.

Can the script me made instead to look for the output of the telephone number generated by the syslog and run the command to clear the voice call based on called number as I believe that makes it a cleaner solution?

What is the one syslog message that would provide all of the necessary information?

The message is:

%IVR-2-APP_CRIT: Maximum call time reached for calling number 0204455456

Thanks once again...

Much easier. This EEM policy should do what you want. It is untested as I do not have a voice setup.

This is working... AWESOME.. seriously mate... I spent 4 days on this and you solved it in about 10 minutes... wow... all i can say is that I am indebted to you and that my first born's soul is yours.. LOL!

Thank you again... :)

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco