Question about process loging

Frank Ng frankng at gmail.com
Tue Feb 14 19:52:29 UTC 2006


don't under estimate the command ps, it can actually report a lot of useful
information.

ps -eo pcpu,rss,pid,ruser,args | grep "your_software_process_name"

the above ps command will return in one line the following ...

CPU usage for that one process (by percentage of CPU used), memory used by
the process (in kilobytes), the process id, the user running the software,
and the actual command and it's arguements.

sample output ...

 0.0 1864 13024 root     /usr/sbin/sshd

you can run that command in a endless loop and only log it in a logfile IF
it returns something.  When it doesn't return anything, that means the
command is not running.

Have your script look for a file in every loop to see if it exists,
something like /tmp/STOP, if it exists, end the loop with an exit.  When you
are ready to stop the loop, touch /tmp/STOP to stop the loop.  or simply
issue a kill against the pid when you don't need this script to run anymore.

ps itself doesn't take much resources, unlike top, but I still suggest
putting a sleep 1 in every loop, just so it doesn't take too much resources.

thanks!
-Frank Ng

On 2/13/06, ssevengor at tai.com.tr <ssevengor at tai.com.tr> wrote:
>
> Hi,
>
> I have a software installed on my Red Hat enterprise linux 4, which is
> run by the users that login remotely. The point is that I want to know
> how often this software is used and during its usage how much of the
> resources are used by the software. Is there any tool or something
> like that except the standart unix linux commands like top,ps,...etc.
> or do I have to write a script how??
>
> Thanks to every body
>
> Serdar Sevengör
>
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subjectunsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
>



More information about the redhat-list mailing list