Discussion:
[gentoo-user] Instrumenting emerges
(too old to reply)
Peter Humphrey
2023-07-08 14:30:01 UTC
Permalink
Hello list,

Has anyone here developed a utility to record the one-minute load average once
per minute and log the results? The first bit is easy: just cat /proc/loadavg,
but the logging has me stumped for the moment.

I see there's a QT-Charts module, but my impression is that it's a
programmer's tool.

Ideas?
--
Regards,
Peter.
Alexe Stefan
2023-07-08 14:50:01 UTC
Permalink
Read from /proc/loadavg every minute and write in a file?
Post by Peter Humphrey
Hello list,
Has anyone here developed a utility to record the one-minute load average once
per minute and log the results? The first bit is easy: just cat /proc/loadavg,
but the logging has me stumped for the moment.
I see there's a QT-Charts module, but my impression is that it's a
programmer's tool.
Ideas?
--
Regards,
Peter.
Neil Bothwick
2023-07-08 15:30:01 UTC
Permalink
Post by Peter Humphrey
Has anyone here developed a utility to record the one-minute load
just cat /proc/loadavg, but the logging has me stumped for the moment.
You could use dev-db/influxdb to record the information and
www-apps/grafana-bin to make pretty pictures with it. I've used this
combination in the past, although long enough ago[1] for the details t
have become fuzzy.

[1] A week seems long enough these days :(
--
Neil Bothwick

Of all the people I've met you're certainly one of them
Peter Humphrey
2023-07-08 16:30:02 UTC
Permalink
Post by Neil Bothwick
Post by Peter Humphrey
Has anyone here developed a utility to record the one-minute load
just cat /proc/loadavg, but the logging has me stumped for the moment.
You could use dev-db/influxdb to record the information and
www-apps/grafana-bin to make pretty pictures with it. I've used this
combination in the past, although long enough ago[1] for the details t
have become fuzzy.
[1] A week seems long enough these days :(
:)
--
Regards,
Peter.
David M. Fellows
2023-07-08 15:50:01 UTC
Permalink
Post by Peter Humphrey
Hello list,
Has anyone here developed a utility to record the one-minute load average once
per minute and log the results? The first bit is easy: just cat /proc/loadavg,
but the logging has me stumped for the moment.
while [ true ] ; do cat /proc/loadavg |logger; sleep 60; done

But you will want to read man logger to see where/how to direct the
logging to somewhere more convenient than default.

DaveF
Post by Peter Humphrey
I see there's a QT-Charts module, but my impression is that it's a
programmer's tool.
Ideas?
--
Regards,
Peter.
Frank Steinmetzger
2023-07-13 23:10:01 UTC
Permalink
Post by David M. Fellows
while [ true ] ; do cat /proc/loadavg |logger; sleep 60; done
A spec more elegant:

while sleep 60; do ... ; done
--
GrÌße | Greetings | Qapla’
Please do not share anything from, with or about me on any social network.

Taglines are like cars - You get a good one, then someone nicks it.
Peter Humphrey
2023-07-14 23:40:01 UTC
Permalink
And if you want more than just the load average, atop keeps a log as well as
being a top-style monitor program.
That's a lot more than I need, thanks.

I'm thinking along the lines Neil suggested.
--
Regards,
Peter.
Peter Humphrey
2023-07-24 07:00:01 UTC
Permalink
Post by Frank Steinmetzger
Post by David M. Fellows
while [ true ] ; do cat /proc/loadavg |logger; sleep 60; done
while sleep 60; do ... ; done
I tried this in a bash script:

merging=true
echo "" > /var/log/local0.log
while [ $merging ] ; do cat /proc/loadavg | logger -p local0.info; sleep 10; done &
/usr/bin/emerge "$@"; merging=false

... But the emerge command is never executed. I thought the '&' would detach
the logging command to run in the background.

Shellcheck only complains about the 'cat' being useless; nothing about the
logic, as I suppose I should have expected.

My programming days are long behind me, as you can see. :(
--
Regards,
Peter.
Jack
2023-07-24 14:50:01 UTC
Permalink
Post by Peter Humphrey
Post by Frank Steinmetzger
Post by David M. Fellows
while [ true ] ; do cat /proc/loadavg |logger; sleep 60; done
while sleep 60; do ... ; done
merging=true
echo "" > /var/log/local0.log
while [ $merging ] ; do cat /proc/loadavg | logger -p local0.info; sleep 10; done &
... But the emerge command is never executed. I thought the '&' would detach
the logging command to run in the background.
Shellcheck only complains about the 'cat' being useless; nothing about the
logic, as I suppose I should have expected.
My programming days are long behind me, as you can see. :(
Pure guess, but the & may be getting attached to something less than the
entire command on that line.  Try enclosing the command (but not the &)
in something.  I leave it as an exercise to determine whether () or {}
or some other closure is the right one.

Jack
Peter Humphrey
2023-07-24 15:40:01 UTC
Permalink
Post by Jack
Pure guess, but the & may be getting attached to something less than the
entire command on that line. Try enclosing the command (but not the &)
in something. I leave it as an exercise to determine whether () or {}
or some other closure is the right one.
Actually, the useless cat seems to have been the problem. This is running now:

# cat /usr/local/bin/emerj
#!/bin/bash
#
# Run emerge while logging the load average every 10 seconds.
#
merging=true
echo "" > /var/log/local0.log
while [ $merging ] ; do ( logger -p local0.info < /proc/loadavg; sleep 10 )
done &
/usr/bin/emerge "$@"; merging=false

I had 'tail -f /var/log/local0.log' running in another Konsole; it showed:

Jul 24 16:28:20 wstn root[13710]: 11.94 18.43 19.70 3/1419 13710
Jul 24 16:28:30 wstn root[13740]: 10.26 17.85 19.50 2/1421 13740
Jul 24 16:28:40 wstn root[13762]: 8.75 17.28 19.29 1/1423 13762
Jul 24 16:28:50 wstn root[17142]: 7.65 16.76 19.10 2/1424 17142
Jul 24 16:29:00 wstn root[20037]: 6.54 16.23 18.90 2/1428 20037
Jul 24 16:29:10 wstn root[25726]: 5.77 15.74 18.71 2/1430 25726
Jul 24 16:29:20 wstn root[2504]: 5.41 15.34 18.55 2/1427 2504
...

The last job is to parse local0.log to extract the values I want and plot
them. LibreOffice Calc might do for that.

Thanks to all for the help.
--
Regards,
Peter.
Peter Humphrey
2023-07-26 12:30:01 UTC
Permalink
Post by Peter Humphrey
Post by Jack
Pure guess, but the & may be getting attached to something less than the
entire command on that line. Try enclosing the command (but not the &)
in something. I leave it as an exercise to determine whether () or {}
or some other closure is the right one.
# cat /usr/local/bin/emerj
#!/bin/bash
#
# Run emerge while logging the load average every 10 seconds.
#
merging=true
echo "" > /var/log/local0.log
while [ $merging ] ; do ( logger -p local0.info < /proc/loadavg; sleep 10 )
done &
Jul 24 16:28:20 wstn root[13710]: 11.94 18.43 19.70 3/1419 13710
Jul 24 16:28:30 wstn root[13740]: 10.26 17.85 19.50 2/1421 13740
Jul 24 16:28:40 wstn root[13762]: 8.75 17.28 19.29 1/1423 13762
Jul 24 16:28:50 wstn root[17142]: 7.65 16.76 19.10 2/1424 17142
Jul 24 16:29:00 wstn root[20037]: 6.54 16.23 18.90 2/1428 20037
Jul 24 16:29:10 wstn root[25726]: 5.77 15.74 18.71 2/1430 25726
Jul 24 16:29:20 wstn root[2504]: 5.41 15.34 18.55 2/1427 2504
...
The last job is to parse local0.log to extract the values I want and plot
them. LibreOffice Calc might do for that.
Just to round off, I think I've found a good compromise between making the most
of the available computing power on the one hand, and jeopardising memory
limits on the other.

Today's update included 76 kde-frameworks packages, and the system load didn't
exceed 29. This should be safe with 64GB RAM.

$ grep '\-j' /etc/portage/make.conf
EMERGE_DEFAULT_OPTS="--jobs=4 --load-average=32 --autounmask=n --keep-going
--nospinner"
MAKEOPTS="-j12"

The small --jobs value slows the emerging of small jobs, but in at least one
case those can only be run a few at a time anyway; that's in the early part of
an emerge -e @world.

So, I now have the instrumentation I needed.
Post by Peter Humphrey
Thanks to all for the help.
--
Regards,
Peter.
Loading...