Help needed with "awk" or "sed" to separate output
Posted: 2010/05/31 14:43:36
Hi Guys,
Here is an output of a command run on CentOS 5.4 with Asterisk installed:
[code]
root@pbx:~ $ asterisk -rx "sip show channels"
Peer User/ANR Call ID Seq (Tx/Rx) Format Hold Last Message
192.168.0.100 (None) f2bee81d79e 00101/01638 0x0 (nothing) No Rx: REGISTER
211.211.11.11 4164005000 769124927da 00101/00102 0x4 (ulaw) No Rx: ACK
192.168.0.100 502 a6e594f37ef 00101/21193 0x4 (ulaw) No Rx: ACK
3 active SIP channels
[/code]
From above I want to simply segregate the IP address and the format which is ulaw. Those two means a call is in progress. So, I want to basically count how many calls are in progress at this time.
Here is what I have been fiddling with to get it working but it doesn't seem so:
[code]
[root@ip-10-251-123-3 ~]# gawk -F: '{ print $1 $5 }' | asterisk -rx "sip show channels"
Peer User/ANR Call ID Format Hold Last Message
111.111.111.111 (None) 326fd0be2333b62 0x0 (nothing) No Rx: REGISTER
1 active SIP dialogs
[/code]
So, the above doesn't actually spit out "111.111.111.111" and "nothing" which it should. I am sure I am not using awk in the right away. Any help is appreciated.
Thanks,
Bruce
[Moderator edited to insert [i]code[/i] tags to improve readability.]
Here is an output of a command run on CentOS 5.4 with Asterisk installed:
[code]
root@pbx:~ $ asterisk -rx "sip show channels"
Peer User/ANR Call ID Seq (Tx/Rx) Format Hold Last Message
192.168.0.100 (None) f2bee81d79e 00101/01638 0x0 (nothing) No Rx: REGISTER
211.211.11.11 4164005000 769124927da 00101/00102 0x4 (ulaw) No Rx: ACK
192.168.0.100 502 a6e594f37ef 00101/21193 0x4 (ulaw) No Rx: ACK
3 active SIP channels
[/code]
From above I want to simply segregate the IP address and the format which is ulaw. Those two means a call is in progress. So, I want to basically count how many calls are in progress at this time.
Here is what I have been fiddling with to get it working but it doesn't seem so:
[code]
[root@ip-10-251-123-3 ~]# gawk -F: '{ print $1 $5 }' | asterisk -rx "sip show channels"
Peer User/ANR Call ID Format Hold Last Message
111.111.111.111 (None) 326fd0be2333b62 0x0 (nothing) No Rx: REGISTER
1 active SIP dialogs
[/code]
So, the above doesn't actually spit out "111.111.111.111" and "nothing" which it should. I am sure I am not using awk in the right away. Any help is appreciated.
Thanks,
Bruce
[Moderator edited to insert [i]code[/i] tags to improve readability.]