===========================
What is systemtap?
Ans : Scripting tool to debug and monitor the whole system processes or any events.
How to install it on linux machine ?
Ans :
yum install kernel-devel
yum install kernel-debuginfo
yum install systemtap
Tool to do the job :
Ans : stap
Syntax to use it :
-------------
probe
Where event is kernel.function, process.statement, timer.ms, begin, end etc
and handler can be filtering/control statement and
helper function : log, printf, pid etc
-------------
Example :
[root@vm80 systamexample]# cat hellworld.stp
probe begin
{
print("This is hello world\n")
exit()
}
[root@vm80 systamexample]
Execution :
[root@vm80 systamexample]# stap hellworld.stp
This is hello world
[root@vm80 systamexample]#
[root@vm80 systamexample]# cat primecheck.stp
function isprime (x) {
if (x < 2) return 0
for (i = 2; i < x; i++) {
if (x % i == 0) return 0
if (i * i > x) break
}
return 1
}
probe begin {
for (i = 0; i < 50; i++)
if (isprime (i)) printf("%d\n", i)
exit()
}
stap-authorize-signing-cert stap-report
[root@vm80 systamexample]# stap primecheck.stp
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
[root@vm80 systamexample]#
==============================
Try :)
0 comments:
Post a Comment