Mailing List Archive

Instrumenting emerges
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.
Re: Instrumenting emerges [ In reply to ]
Read from /proc/loadavg every minute and write in a file?

sâm., 8 iul. 2023, 17:20 Peter Humphrey <peter@prh.myzen.co.uk> a scris:

> 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.
>
>
>
>
>
Re: Instrumenting emerges [ In reply to ]
On Sat, 08 Jul 2023 15:20:19 +0100, Peter Humphrey wrote:

> 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.

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
Re: Instrumenting emerges [ In reply to ]
>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
>
>I see there's a QT-Charts module, but my impression is that it's a
>programmer's tool.
>
>Ideas?
>
>--
>Regards,
>Peter.
>
>
>
>
Re: Instrumenting emerges [ In reply to ]
On Saturday, 8 July 2023 16:19:49 BST Neil Bothwick wrote:
> On Sat, 08 Jul 2023 15:20:19 +0100, Peter Humphrey wrote:
> > 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.
>
> 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.
Re: Instrumenting emerges [ In reply to ]
Am Sat, Jul 08, 2023 at 12:42:13PM -0300 schrieb 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.
RE: Instrumenting emerges [ In reply to ]
And if you want more than just the load average, atop keeps a log as well as being a top-style monitor program.

LMP

-----Original Message-----
From: Frank Steinmetzger <Warp_7@gmx.de>
Sent: Thursday, July 13, 2023 4:02 PM
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Instrumenting emerges

Am Sat, Jul 08, 2023 at 12:42:13PM -0300 schrieb 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.
Re: Instrumenting emerges [ In reply to ]
On Friday, 14 July 2023 17:33:08 BST Laurence Perkins wrote:

> 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.
Re: Instrumenting emerges [ In reply to ]
On Friday, 14 July 2023 00:02:05 BST Frank Steinmetzger wrote:
> Am Sat, Jul 08, 2023 at 12:42:13PM -0300 schrieb David M. Fellows:
> > while [ true ] ; do cat /proc/loadavg |logger; sleep 60; done
>
> A spec more elegant:
>
> 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.
Re: Instrumenting emerges [ In reply to ]
On 7/24/23 02:54, Peter Humphrey wrote:
> On Friday, 14 July 2023 00:02:05 BST Frank Steinmetzger wrote:
>> Am Sat, Jul 08, 2023 at 12:42:13PM -0300 schrieb David M. Fellows:
>>> while [ true ] ; do cat /proc/loadavg |logger; sleep 60; done
>> A spec more elegant:
>>
>> 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. :(

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
Re: Instrumenting emerges [ In reply to ]
On Monday, 24 July 2023 15:46:07 BST Jack wrote:

> 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.
Re: Instrumenting emerges [ In reply to ]
On Monday, 24 July 2023 16:39:19 BST Peter Humphrey wrote:
> On Monday, 24 July 2023 15:46:07 BST Jack wrote:
> > 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.

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.

> Thanks to all for the help.

--
Regards,
Peter.