-3

Any help is greatly appreciated. I have a Cisco voice gateway that I connect to with SSH and can send a command to get all the current calls on the gateway. I'm trying to automate this so that I can pull out this information and display it on a big screen TV in an area that needs to see the current active calls at any given moment.

I've got the automated part down already, it will connect to the gateway and pull out the command results in a text file. Sample output is below.

I am trying to find a way, perhaps with powershell, or something else, to parse this text file, and just extract two pieces of information: calling# and called# so I can display it in a web page. The problem is that I need to remove a lot of the headers and stuff and also, the number of callers is not fixed, there can be 0 callers, or 10+ calls at any given time.

Any suggestions on how I may be able to automate this?

Sample output:

Total SIP call legs:4, User Agent Client:2, User Agent Server:2
SIP UAC CALL INFO
No.  CallId    Calling#       Called#        RmtSignalIP                                  RmtMediaIP                                   
     dstCallId SIPState       SIPSubState    
========================================================================================================================================
1    14780     5835           6000           172.30.1.11                                  172.30.1.14                                  
     14779     STATE_ACTIVE   SUBSTATE_NONE  
2    14784     5820           6000           172.30.1.11                                  172.30.1.14                                  
     14783     STATE_ACTIVE   SUBSTATE_NONE  
   Number of SIP User Agent Client(UAC) calls: 2

SIP UAS CALL INFO
No.  CallId    Calling#       Called#        RmtSignalIP                                  RmtMediaIP                                   
     dstCallId SIPState       SIPSubState    
========================================================================================================================================
1    14779     5835           5678           172.30.1.12                                  172.30.1.29                                  
     14780     STATE_ACTIVE   SUBSTATE_NONE  
2    14783     5820           5678           172.30.1.12                                  172.30.1.24                                  
     14784     STATE_ACTIVE   SUBSTATE_NONE  
   Number of SIP User Agent Server(UAS) calls: 2
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
ericb
  • 1
  • Try something yourself first and come back if you have a *specific* question about something you can't get to work in your code. As it stands your question is far too broad. – Ansgar Wiechers Jan 24 '16 at 19:49
  • thanks, I'm not programmer, just a project manager that is in a small bind until this unique situation is resolved. Is there a site where someone can write this script for me for a fee? – ericb Jan 26 '16 at 00:53
  • This site is a programmer-to-programmer site designed to help programmers get problems solved. If you are a project manager without programming skills (and no desire to learn programming) then this isn't the right site to use. – Χpẘ Jan 26 '16 at 04:56
  • thanks! That exactly why I asked if anyone knew of a site like I just described. Sorry to disturb you... – ericb Jan 26 '16 at 13:19

1 Answers1

0

You can use get-content and interate through it, starting with "======" and ended with "Number of SIP User Agents .." All between those lines is your data, where you Need to do some more parsing (trim spaces etc)

Martin
  • 1,853
  • 3
  • 15
  • 22