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]

Sorting systemtap output with Perl


Here's a slightly different version of topsys, I use Perl to sort the output form systemtap (Tom, thanks for the idea).
topsys.pl invokes topsys_1.stp, after a while the tap script will log the data then exit, topsys.pl will capture the data and print them in sort order.


Hien.

Attachment: topsys.pl
Description: Perl program

#! stap -g
#
# This script lists the top 20 system calls in the interval of 2000 jiffies.
#

global syscalls_count

function syscall_name:string () %{
	char *str, buff[80];
	char *tok;
	str = buff;
	strlcpy(str, CONTEXT->probe_point, sizeof(buff));
	tok = strsep(&str, "\"");
	tok = strsep(&str, "@");
	strlcpy(THIS->__retvalue, tok, MAXSTRINGLEN);
%}

function accumulate () {
	syscall=syscall_name()
	syscalls_count[syscall]++
}

function print_systop () {
	foreach ([syscall] in syscalls_count) {
		sys_cnt = syscalls_count[syscall]
		log (syscall . "\t" . string(sys_cnt))
	}
}

probe kernel.function("sys_*") {
	accumulate ()
}

probe timer.jiffies(2000) {
	exit ()
}

probe end {
	print_systop ()
}

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