/usr/share/systemtap/tapset/linux/loadavg.stp is in systemtap-common 3.1-3ubuntu0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | // Copyright (C) 2013 Red Hat Inc., Aaron Tomlin <atomlin@redhat.com>
//
// This file is part of systemtap, and is free software. You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.
// <tapsetdescription>
// Functions in the loadavg tapset allow a probe handler to capture
// the load average.
// </tapsetdescription>
%{
#include <linux/sched.h>
#define LOAD_INT(x) ((x) >> FSHIFT)
#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
%}
/**
* sfunction get_loadavg_index - Get the load average for a specified interval
* @indx: The load average interval to capture.
*
* Description: This function returns the load average at a specified interval.
* The three load average values 1, 5 and 15 minute average corresponds to
* indexes 0, 1 and 2 of the avenrun array - see linux/sched.h.
* Please note that the truncated-integer portion of the load average is returned.
* If the specified index is out-of-bounds, then an error message and exception is
* thrown.
*/
function get_loadavg_index:long (indx:long) %{ /* pure */
int value;
if (STAP_ARG_indx < 0 || STAP_ARG_indx > 2)
STAP_ERROR("Invalid loadavg index %lld specified.",
STAP_ARG_indx);
value = avenrun[STAP_ARG_indx] + (FIXED_1/200);
STAP_RETVALUE = LOAD_INT(value);
%}
/**
* sfunction sprint_loadavg - Report a pretty-printed load average
*
* Description: Returns the a string with three decimal numbers
* in the usual format for 1-, 5- and 15-minute load averages.
*/
function sprint_loadavg:string () %{ /* pure */ /* stable */
int a, b, c;
a = avenrun[0] + (FIXED_1/200);
b = avenrun[1] + (FIXED_1/200);
c = avenrun[2] + (FIXED_1/200);
snprintf(STAP_RETVALUE, MAXSTRINGLEN,
"%d.%02d %d.%02d %d.%02d\n",
LOAD_INT(a), LOAD_FRAC(a),
LOAD_INT(b), LOAD_FRAC(b),
LOAD_INT(c), LOAD_FRAC(c));
%}
|