To all kinds of programming languages, type of variables means the data language could manipulate.
For example, with the pointer type in C, it could be used in low level programs.
systemtap provides almost the same type of variables as in C. This is easy to understand, since the script will be translated to C and then to be made a kernel module.
Common variables
To define and use a variable is easy. Different from C, variables in systemtap is type-less.
global times = 0
probe begin
{
world = "World";
lucky_number = 666;
printf("Hello%s %d\n", world, lucky_number);
times++;
exit();
}
probe end
{
times++;
printf("%d times of probe event\n", times);
}
The example above defines variables with type
string
integer
Also it shows how to define a global variable times.
This example shows how to get the statistics of vfs.read in 3 seconds by assign the times into corresponding reads[] slot.
One more interesting thing is we can order it by putting +/- at the related field in foreach() clause. And get limit number of result by the limit keyword.
Try this example by yourself to feel the behavior.
You could get more information in Ref 1 and Ref 2.
Aggregate statistics
This type is more suitable for statistic analysis.