|
Home > Archive > Unix Programming > July 2004 > Measure host load every 10 seconds during an execution
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Measure host load every 10 seconds during an execution
|
|
|
| Hi,
I want to measure host loads (using getloadavg()) 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
before the application ends.
I want to modify (instrument) the source code and call the getloadavg
every 10 seconds during an execution. I don't want to create a child
process to run an application while the parent process measures the
load. is there a way to instrument the application source code so that
I can call getloadavg() every 10 seconds until the execution ends?
thanks a lot for any input on this.
pj
| |
| Eric Sosman 2004-07-28, 6:19 pm |
| pj wrote:
> Hi,
>
> I want to measure host loads (using getloadavg()) 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
> before the application ends.
>
> I want to modify (instrument) the source code and call the getloadavg
> every 10 seconds during an execution. I don't want to create a child
> process to run an application while the parent process measures the
> load. is there a way to instrument the application source code so that
> I can call getloadavg() every 10 seconds until the execution ends?
You could launch a separate thread to gather the data.
In this context, though, there's really not much difference
between running a separate thread and running a separate
process, except that running a separate process might be
a little easier.
--
Eric.Sosman@sun.com
| |
| Pascal Bourguignon 2004-07-28, 8:47 pm |
| nsf470@yahoo.com (pj) writes:
> Hi,
>
> I want to measure host loads (using getloadavg()) 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
> before the application ends.
>
> I want to modify (instrument) the source code and call the getloadavg
> every 10 seconds during an execution. I don't want to create a child
> process to run an application while the parent process measures the
> load. is there a way to instrument the application source code so that
> I can call getloadavg() every 10 seconds until the execution ends?
>
> thanks a lot for any input on this.
> pj
Yes, that's very useful to try to get the load average every 10
seconds when the system updates the fastest load average only every
minute!
The getloadavg() function returns the number of processes in the system
run queue averaged over various periods of time. Up to nelem samples are
retrieved and assigned to successive elements of loadavg[]. The system
imposes a maximum of 3 samples, representing averages over the last 1, 5,
and 15 minutes, respectively.
--
__Pascal Bourguignon__ http://www.informatimago.com/
There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
| |
| Alex Fraser 2004-07-29, 2:52 am |
| "Pascal Bourguignon" <spam@thalassa.informatimago.com> wrote in message
news:87llh37db2.fsf@thalassa.informatimago.com...
[snip]
> Yes, that's very useful to try to get the load average every 10
> seconds when the system updates the fastest load average only every
> minute!
Hint: rolling/moving average.
Alex
| |
| Ian Fitchet 2004-07-29, 7:52 am |
| Eric Sosman <Eric.Sosman@sun.com> writes:
> In this context, though, there's really not much difference
> between running a separate thread and running a separate
> process, except that running a separate process might be
> a little easier.
I wrote a little job distribution app a few years back and to keep
the load down the server processes ran "iostat -c 10" in a child
process and read the values back in through a pipe. Quite remarkably
(or a very subtle artifact of Solaris 2.5.1 through 8) after months
of continuous operation the child iostat processes never showed any
accumulated CPU time.
Not that that helps you if you're quite determined to call
getloadavg() but interesting to note that some processes cause very
little CPU load.
Cheers,
Ian
| |
| Pascal Bourguignon 2004-07-29, 8:08 am |
| "Alex Fraser" <me@privacy.net> writes:
> "Pascal Bourguignon" <spam@thalassa.informatimago.com> wrote in message
> news:87llh37db2.fsf@thalassa.informatimago.com...
> [snip]
>
> Hint: rolling/moving average.
Oops, you're right. Sorry.
--
__Pascal Bourguignon__ http://www.informatimago.com/
There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
|
|
|
|
|