Capturing load average from within systemtap script...

Frank Ch. Eigler fche@redhat.com
Thu Feb 7 17:32:00 GMT 2008


Hi -

On Thu, Feb 07, 2008 at 05:16:39PM +0000, Rick Beldin wrote:
> [...]
> %}
> function get_avenrun:long (idx:long) %{ /* pure */
>     if (idx < 0 || idx > 2) return 0;
>         else return avenrun[idx];
> %}

Very sorry, I sent you untested code.  The API for embedded-C
functions is different than normal functions, since parameters and
return values are passed in an explicit stack-like data structure.
This should work better:

-------------------
function get_avenrun:long (idx:long) %{ /* pure */
    if (THIS->idx < 0 || THIS->idx > 2) THIS->__retvalue = 0;
    else THIS->__retvalue = avenrun[THIS->idx];
%}
-------------------

By the way, you will find scanning "stap -p3" useful in decoding error
messages like those from "stap -p4 -v".


- FChE



More information about the Systemtap mailing list