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: Rick Beldin <rick dot beldin at hp dot com>
- To: Eugene Teo <eugeneteo at kernel dot sg>
- Cc: "systemtap at sources dot redhat dot com" <systemtap at sources dot redhat dot com>
- Date: Thu, 07 Feb 2008 09:29:20 -0500
- Subject: Re: Capturing load average from within systemtap script...
- Organization: WTEC Linux
- References: <1202319114.9217.8.camel@localhost.localdomain> <20080207115439.GA1648@kernel.sg>
- Reply-to: rick dot beldin at hp dot com
Hi Eugene...
Thanks for the feedback.
On Thu, 2008-02-07 at 11:54 +0000, Eugene Teo wrote:
> Hi Rick,
>
> <quote sender="Rick Beldin">
> > 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);
> [...]
>
> > global timer_count
>
> %{
> #include <linux/sysrq.h>
>
> /* defined in fs/proc/proc_misc.c */
> #define LOAD_INT(x) ((x) >> FSHIFT)
> #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
> %}
>
Ok. This will be helpful.
> > function rab_show_mem:long (arg:long)
> > %{
> > handle_sysrq('m', NULL, NULL);
> > handle_sysrq('t', NULL, NULL);
>
> void handle_sysrq(int key, struct tty_struct *tty);
>
> So, it should be handle_sysrq('m', NULL);
>
It looks like it changed in later kernels. Thanks. The
environment I deal with typically limits me to production
kernels from Red Hat and Novell. For example, both
RHEL4's 2.6.9 and RHEL5's 2.6.18 kernels still have handle_sysrq
defined this way:
void handle_sysrq(int, struct pt_regs *, struct tty_struct *);
I guess I'll have to put some ifdef's for other kernels or
keep very close track of this.
> > %}
> > 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)
>
> function get_avenrun:string (idx:long) %{ /* pure */
> if (THIS->idx < 0 || THIS->idx > 2)
> strcat(THIS->__retvalue, "0");
> else {
> int a = avenrun[THIS->idx] + (FIXED_1/200);
> snprintf(THIS->__retvalue, MAXSTRINGLEN, "%d.%02d",
> LOAD_INT(a), LOAD_FRAC(a));
> }
> %}
>
> in hangwatch.c, it reads the first value from /proc/loadavg, so in this case
> we are interested in avenrun[0]:
>
You are right.
Thanks. I'll try to implement these ideas.
Rick
--
+----------------------------------------------------------------------+
| Rick Beldin | Hewlett-Packard Company |
| email: Rick.Beldin@hp.com | Global Solutions Engineering |
| WTEC Linux, RHCE | 5555 Windward Parkway West |
| | Alpharetta, GA 30004 |
+----------------------------------------------------------------------+