On Fri, Jul 24, 2009 at 1:55 PM, Sudev Barar <sba...@gmail.com> wrote:

> I have made a script that starts netcat repeatedly in listen mode. Once
> incoming data is started the script fires off another NC instance and
> previous NC process then dies when data string ends. I want to count how
> many netcat processes were launched during a particular testing period.
>
> One option is to build a counter before firing up each instance of netcat.
> Any other method? I would not like to touch the netcat launch script right
> now.
>
> -
>
ps -aef and then use grep/awk etc., to get your fix? This will work if you
want to count number of netcat processes active at any given time.
For duration, fire ps -aef twice, once at beginning and once at the end of
duration. GET the PIDs, and then count PIDs for second ps which were not
there in first ps.
For example Time  T
It gives you 4445,4446,4447
Time T+D
It gives you 4447,4449,4450
So 4447 was there beforehand, so you ignore that, and your result is 2
_______________________________________________
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/

Reply via email to