calls to determine current CPU load More...
Go to the source code of this file.
Macros | |
#define | DEBUG_STATUSCALLS GNUNET_NO |
Functions | |
static int | updateUsage () |
Update the currentCPU and currentIO load (and on Linux, memory) values. More... | |
static void | updateAgedLoad () |
Update load values (if enough time has expired), including computation of averages. More... | |
static int | cpu_get_load () |
Get the load of the CPU relative to what is allowed. More... | |
static int | disk_get_load () |
Get the load of the CPU relative to what is allowed. More... | |
static unsigned int | mem_get_usage () |
Get the percentage of memory used. More... | |
static void | sample_load_task (void *cls) |
void | GST_stats_init (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Initialize logging CPU and IO statisticfs. More... | |
void | GST_stats_destroy () |
Shutdown the status calls module. More... | |
Variables | |
static int | currentCPULoad |
Current CPU load, as percentage of CPU cycles not idle or blocked on IO. More... | |
static double | agedCPULoad = -1 |
static int | currentIOLoad |
Current IO load, as percentage of CPU cycles blocked on IO. More... | |
static double | agedIOLoad = -1 |
struct GNUNET_BIO_WriteHandle * | bw |
handle to the file to write the load statistics to More... | |
struct GNUNET_SCHEDULER_Task * | sample_load_task_id |
calls to determine current CPU load
Definition in file gnunet-service-testbed_cpustatus.c.
#define DEBUG_STATUSCALLS GNUNET_NO |
Definition at line 58 of file gnunet-service-testbed_cpustatus.c.
|
static |
Update the currentCPU and currentIO load (and on Linux, memory) values.
Before its first invocation the method initStatusCalls() must be called. If there is an error the method returns -1.
Definition at line 132 of file gnunet-service-testbed_cpustatus.c.
References currentCPULoad, currentIOLoad, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_log_strerror_file, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, idle(), consensus-simulation::int, line, ret, and stats.
Referenced by GST_stats_init(), and updateAgedLoad().
|
static |
Update load values (if enough time has expired), including computation of averages.
Code assumes that lock has already been obtained.
Definition at line 417 of file gnunet-service-testbed_cpustatus.c.
References agedCPULoad, agedIOLoad, currentCPULoad, currentIOLoad, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_Relative::rel_value_us, and updateUsage().
Referenced by cpu_get_load(), and disk_get_load().
|
static |
Get the load of the CPU relative to what is allowed.
Definition at line 476 of file gnunet-service-testbed_cpustatus.c.
References agedCPULoad, and updateAgedLoad().
Referenced by sample_load_task().
|
static |
Get the load of the CPU relative to what is allowed.
Definition at line 489 of file gnunet-service-testbed_cpustatus.c.
References agedIOLoad, and updateAgedLoad().
Referenced by sample_load_task().
|
static |
Get the percentage of memory used.
Definition at line 502 of file gnunet-service-testbed_cpustatus.c.
References kb_main_total, kb_main_used, and meminfo().
Referenced by sample_load_task().
|
static |
Definition at line 544 of file gnunet-service-testbed_cpustatus.c.
References GNUNET_TIME_Absolute::abs_value_us, bw, cpu_get_load(), disk_get_load(), GNUNET_asprintf(), GNUNET_BIO_write(), GNUNET_break, GNUNET_free, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_SECONDS, mem_get_usage(), and sample_load_task_id.
Referenced by GST_stats_init().
void GST_stats_init | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg | ) |
Initialize logging CPU and IO statisticfs.
Checks the configuration for "STATS_DIR" and logs to a file in that directory. The file is name is generated from the hostname and the process's PID.
Definition at line 590 of file gnunet-service-testbed_cpustatus.c.
References _, bw, cfg, GNUNET_asprintf(), GNUNET_BIO_write_open_file(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror, GNUNET_log_strerror_file, GNUNET_malloc, GNUNET_OK, GNUNET_OS_get_hostname_max_length, GNUNET_SCHEDULER_add_now(), hostname, len, sample_load_task(), sample_load_task_id, and updateUsage().
Referenced by testbed_run().
void GST_stats_destroy | ( | void | ) |
Shutdown the status calls module.
Definition at line 641 of file gnunet-service-testbed_cpustatus.c.
References bw, GNUNET_BIO_write_close(), GNUNET_break, GNUNET_free, GNUNET_OK, GNUNET_SCHEDULER_cancel(), and sample_load_task_id.
Referenced by shutdown_task().
|
static |
Current CPU load, as percentage of CPU cycles not idle or blocked on IO.
Definition at line 68 of file gnunet-service-testbed_cpustatus.c.
Referenced by updateAgedLoad(), and updateUsage().
|
static |
Definition at line 70 of file gnunet-service-testbed_cpustatus.c.
Referenced by cpu_get_load(), and updateAgedLoad().
|
static |
Current IO load, as percentage of CPU cycles blocked on IO.
Definition at line 75 of file gnunet-service-testbed_cpustatus.c.
Referenced by updateAgedLoad(), and updateUsage().
|
static |
Definition at line 77 of file gnunet-service-testbed_cpustatus.c.
Referenced by disk_get_load(), and updateAgedLoad().
struct GNUNET_BIO_WriteHandle* bw |
handle to the file to write the load statistics to
Definition at line 83 of file gnunet-service-testbed_cpustatus.c.
Referenced by call_flush_completion(), GNUNET_TRANSPORT_application_suggest(), GST_stats_destroy(), GST_stats_init(), and sample_load_task().
struct GNUNET_SCHEDULER_Task* sample_load_task_id |
Definition at line 85 of file gnunet-service-testbed_cpustatus.c.
Referenced by GST_stats_destroy(), GST_stats_init(), and sample_load_task().