This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Capturing load average from within systemtap script...


Hi... 

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);

in timer.c from within a systemtap script.   I figured I could access
this variable since it is global to the module and exported as a
symbol. 

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

The intent is to have a script that will fire a timer when the system 
load average exceeds a certain threshold.  The idea came from this
program by Chris Snook of Red Hat: 

http://people.redhat.com/csnook/hangwatch/

The idea was to have the timer running outside of process context
to avoid some of the scheduling overhead. 

In this script, I've purposely limited the number of iterations of
the timer to 5 (for safety)" 

global timer_count
%{
#include <linux/sysrq.h>
%}
function rab_show_mem:long (arg:long) 
%{
        handle_sysrq('m', NULL, NULL);
        handle_sysrq('t', NULL, NULL);
%}
probe timer.ms(3000) {
    if (timer_count < 5) {
        printf("timer %d %d\n", rab_show_mem(0),timer_count++)
        ave = kernel_long(avenrun)
        printf("avenrun %d\n",ave)
        count++
    }
    else
            exit()
}


I'm doing this on RHEL5.1 ( 2.6.18-53.1.6.el5  ).  Systemtap is 
systemtap-0.5.14-1.el5. 

Thoughts? 

Rick 
-- 
+----------------------------------------------------------------------+
| Rick Beldin                    |  Hewlett-Packard Company            |
| email: Rick.Beldin@hp.com      |  Global Solutions Engineering       |
| WTEC Linux, RHCE               |  5555 Windward Parkway West         |
|                                |  Alpharetta, GA 30004               |
+----------------------------------------------------------------------+



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]