Saturday, October 9, 2010

Sick of Sniffing.......

Well Its been about more than week since my last post , and haven't get a time last weekend to write down something in here.

Last week I had an interesting Idea on implementing a tool for our support engineers for them to troubleshoot voip related stuff.

The Idea was to provide what will happen to a SIP call which will originate / terminate from or to our network.

Before, they tend to come to me and hazzel and saying there's something wrong with this and that service, and All I do to figure out any call routing issue is to do a ngrep at the sip server and see WTF is going on :)

Being after sometime, I thought shouldn't I allow my colleges to see for them selves whats actually happening at our voip network for a call. :D

So I wrote a simple perl/cgi script which ngrep the interface for about 1 minute and showing the call trace in a higher level interface.

ngrep -pqrtW byline string_for_search

I had following challenges when I was working on this.

Problem
1.) There's no option to us to run ngrep for a specified time.

Solution
I used the timeout utility in linux to timeout the ngrep command after running it for about 1 minute.


Problem
2.) ngrep can only be run by root , but the script that I wrote is executed by apache means www-data in debian. So www-data can't open network interface card in promiscuous mode means can't execute ngrep.

Solution
I used `sudo` and allow www-data execute ngrep with root privilege.

"/etc/sudoers"

www-data ALL = NOPASSWD:/usr/bin/ngrep,/usr/bin/timeout

This allowed Apache to execute the commands that i used in my cgi script.


It was quite interesting and support guys get start use the tool before they come to me :)


I got some more stuff to share But feels sleepy now So I'll stop for the moment, I'll have my next post about a server migration that I did this week.. sigh.......................

No comments:

Post a Comment