What is systemtap?
There are several articles can answer this question:
Official websit: https://sourceware.org/systemtap/
Introduction in chinese: http://www.ibm.com/developerworks/cn/linux/l-cn-systemtap3/
Install systemtap
It is better read this reference before installing, although you can not trust on it completely because of some
content is legacy.
https://wiki.ubuntu.com/Kernel/Systemtap
PRE-INSTALL
Ubuntu 14.04 x86-64
kernel version: 3.13.0-39 root privilege, in order to keep convinient, or you have to create a new user staper etc.
INSTALL
Very important thing is installing corresponding debug symbol image .
There are two resolution:
Build from kernel source
Download kernel source from kernel.org
Usemake-kpkgto generate kernel image, kernel debug symbol image and kernel headers. I love this tool, please google it for help.
Thendpkg -i ***, * indicate the generated Debian packages.
Use available debug images for your running kernel, BUT you may not be always lucky!
One debug symbol image download link is http://ddebs.ubuntu.com/pool/main/l/linux/.
I have tried the first solution, BUT It always complains that the debug symbol image does not match the kernel image for unknown reason. If you success at this solution, please tell me :-P.
So, I use the second solution instead. After that, do
#apt-get install systemtap
POST-INSTALL
In order to test if the systemtap is ok, do
#systap-prep
If nothing complains, it is ok!
Install systemtap IDE
Please read this reference first, please do not trust on it fully!
http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.linuxtools.systemtap.ui.doc%2FLinux_Tools_Project%2FSystemtap%2FUser_Guide%2FSystemTap-IDE.html.
Download the newest eclipse(LUNA for me), of course java runtime should be installed properly.
Start eclipe with root privilege ,install systemtap IDE as the help page.
Run a simple test case
This simple script will dispaly the counting number of read and write syscall respectively in 1s.
Fanially, refer to the help page, do this simple test.
global read, write, start
probe begin {
start = gettimeofday_s()
}
probe syscall.write
{
write += count
}
probe syscall.read
{
read += count
}
probe timer.ms(1000)
{
printf("%d\t%d\t%d\n", (gettimeofday_s()-start), read, write)
read=0 write=0
}
Remember to run eclipse with root, in Run Configurations -> User mark theExecute script as current user.