This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Capturing load average from within systemtap script...
- From: fche at redhat dot com (Frank Ch. Eigler)
- To: rick dot beldin at hp dot com
- Cc: "systemtap at sources dot redhat dot com" <systemtap at sources dot redhat dot com>
- Date: Wed, 06 Feb 2008 14:09:14 -0500
- Subject: Re: Capturing load average from within systemtap script...
- References: <1202319114.9217.8.camel@localhost.localdomain>
Rick Beldin <rick.beldin@hp.com> writes:
> [...]
> I've been struggling for a bit on how to (or if possible) to capture the
> value of avenrun (declared as:
>
> unsigned long avenrun[3];
> EXPORT_SYMBOL(avenrun);
> [...]
> I've tried accessing it both as an array or as a single value. I either
> end up with syntax errors or things like this:
>
> sudo stap -g loadavg_trigger.stp
> ERROR: kernel long copy fault at 0x0000000000000000 near identifier
> 'avenrun' at loadavg_trigger.stp:13:27
> timer 0 0
> WARNING: Number of errors: 1, skipped probes: 0
Your script is accessing "avenrun" by that name - and this is treated
as a systemtap numeric variable (with initial value 0). kernel_long
dereferences it, and you get the fault message.
One way to access that is "$avenrun[0]" through "[2]", in the scope of
a kprobe that is set in the same compilation unit. If that doesn't
work for some reason, you can use a smidgen of embedded-C:
%{
#include <some_header_that_declares_avenrun>
%}
function get_avenrun:long (idx:long) %{ /* pure */
if (idx < 0 || idx > 2) return 0;
else return avenrun[idx];
%}
probe foo { /* do something with */ get_avenrun(0) }
- FChE