beostat_count_idle_cpus

Name

beostat_count_idle_cpus -- count number of idle CPUS in cluster

Synopsis

#include <sys/beostat.h>

int beostat_count_idle_cpus (float threshold);

Arguments

threshold

The value of cpu usage below which the CPU will be considered idle.

Description

beostat_count_idle_cpus will count the number of CPU in the entire cluster that available to the current user/group and have CPU usage below a given threshold. Note: An easy way to count the total number of CPUs available to a user independent of the usage is to set the threshold arbitrarily large.

Example:

int max, fif;
max = beostat_count_idle_cpus (9999.0);
fif = beostat_count_idle_cpus (0.5);
printf ("%d of the %d CPUs available are busy.\n", (max-fif), max); 

Return Value

Returns the number of CPUs that are both available for the caller and have usage below the threshold. 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 sendstatsdaemon 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.