Re: measureing host loads every 10 sec until an application is
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Re: measureing host loads every 10 sec until an application is




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Re: measureing host loads every 10 sec until an application is  
Joe Chung


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-17-04 12:49 PM

nsf470@yahoo.com (pj) writes:

> Hi,
>
> I want to measure host loads (using system(uptime)) every 10 seconds
> while I am running an application which is written in C, and write the
> host
> load average during the application execution to a file right after
> the application terminates.
>
> i.e.,
> --- Application is started
>       --- measure load average (using `uptime`) every 10 seconds
>           during the execution
> --- Application is finished.
>       --- calculate the load average and print it out
>
> My question is how I can run system(uptime) every 10 seconds during
> the application execution using one processor machine? I was thinking
> of having two threads, but the thread blocks the other until it is
> terminated which is not what I want. I need to run two jobs (uptime
> every 10 seconds and an application executable) simultaneously and
> measureing uptime should be finished when the application is finished.
> any suggestions? thanks for any help in advance

How about something like this.

#!/bin/sh
myprog &
childpid=$!
while [ $? -eq 0 ]; do
sleep 10
/bin/uptime
kill -0 $childpid 2>/dev/null
done

where myprog is your program.

The output of this script can be redirected to some file while
can be post-processed with awk, perl, or pick your poison.

-jc
--
(apply 'concat (reverse (list "com"
(char-to-string 46) "yahoo"
(char-to-string 64) "joechung")))





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:04 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register