This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Controlling a systemtap script from userspace
- From: "James Dickens" <jamesd dot wi at gmail dot com>
- To: "David A Sperry" <David_A_Sperry at raytheon dot com>
- Cc: systemtap at sources dot redhat dot com
- Date: Tue, 9 Jan 2007 16:19:19 -0600
- Subject: Re: Controlling a systemtap script from userspace
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=a4tKoyLf/B9pIHh/fvxig+FwG9cBmbnjPGhzWjrrn4qgB7PcdXycy+OCPZUbzzV9byJsK9ee4mxxJ1ZLtwbbwtuIOVutrtAZaZcFVCv5bTwu5MFFjl5lHheBGQbEHVfawTcCh+S6XJfUKhtD4etjySaDKuHrpzDasolAatSGDc0=
- References: <20070101201031.7334.qmail@sourceware.org> <OFCB4EEF78.39E6604C-ON8525725E.00773691-8525725E.007A0846@mck.us.ray.com>
On 1/9/07, David A Sperry <David_A_Sperry@raytheon.com> wrote:
Hi,
I am interested in logging kernel stuff only during small
portions of a long test. About 10 milliseconds of logging every
10 minutes. I have a C++ program than knows when to do the
logging, the question is how to get that user space C++ program to set a
global in a systemTap script? Is there an obscure syscall
or something else I can use as a probe to set a global?
one easy way is to have the userland app execute a signal, and your
systemtap script can watch for the signal and verify that it was
called by your application via its commandname you could use standard
signals such as
SIGUSR1 30,10,16 Term User-defined signal 1
SIGUSR2 31,12,17 Term User-defined signal 2
or you could fire a non normal one such as signal 255 or something if
you are worried your signal being thought of as a normal signal.
James Dickens
uadmin.blogspot.com
For example:
#!/usr/bin/env stap
#
# This script sporatically lists the top 20 systemcalls on the system
#
global syscalls isLogging
# turn on logging
probe ### something from user space ### {isLogging = 1}
# turn off logging
probe ### something else from user space #### {isLogging = 0}
# probe gated with isLogging
probe kernel.function("sys_*") {
if (isLogging == 1) {
syscalls[probefunc()]++
}
}
# print top syscalls every 5 seconds
probe timer.ms(5000) {
print_top ()
}
function print_top () {
cnt=0
printf ("SYSCALL\t\t\t\tCOUNT\n")
foreach ([name] in syscalls-) {
printf("%-20s\t\t%5d\n",name, syscalls[name])
if (cnt++ == 20)
break
}
printf("--------------------------------------\n")
delete syscalls
}