beostat_get_stat_cpu¶
Name¶
beostat_get_stat_cpu – get the statistics of CPU utilization
Synopsis¶
#include <sys/beostat.h>
int beostat_get_stat_cpu (int node, int cpu, struct beostat_stat_cpu *stat_cpu);
Arguments¶
node
The node to query
cpu
The CPU index on the particular node
stat_cpu
A pointer to a
struct beostat_stat_cpu
, which will be filled upon successful completion.struct beostat_stat_cpu
is defined as follows:struct beostat_stat_cpu { long user; long system; long nice; long idle; };
The members of this structure have the following meanings:
user
The number of CPU ticks spend processing normal priority (0) user level instructions.
nice
The number of CPU ticks spend processing nice priority (>0) user level instructions.
system
The number of CPU ticks spend processing system (kernel) level instructions.
idle
The number of CPU ticks spend idle.
Description¶
beostat_get_stat_cpu
executes on the master node and returns the cpu
ticks counts on a given node/CPU. These ticks just keep incrementing
over time until they overflow and wrap back around. To get actual CPU
usage over some time period, you must either take the derivative of
these values or use the beostat
convenience function
beostat_get_cpu_percent
.
Examples¶
struct beostat_stat_cpu stat_cpu;
beostat_get_stat_cpu (3, 0, &stat_cpu);
printf ("There have been %ld idle ticks on cpu 0 for node 3 is %s\n", stat_cpu.idle);
free (name);
Return Value¶
Return 0 on success. If an error occurs, it will return -1.
Errors¶
This function relies on the Beostat
subsystem, which consists of the
proc
filesystem on the remote node, the sendstats
daemon on the
remote node, the recvstats
daemon on the master node, and two shared
memory files in the directory /var/shm
. If any part of the system
breaks down, this function could fail.