This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Capturing load average from within systemtap script...
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