tool to obtain statistics More...
Go to the source code of this file.
Data Structures | |
struct | Node |
Representation of all (testbed) nodes. More... | |
struct | ValueSet |
Set of values for a combination of subsystem and name. More... | |
Functions | |
static struct ValueSet * | new_value_set (const char *subsys, const char *new_name, unsigned num_values, int is_persistent) |
Create a new ValueSet. More... | |
static int | printer (void *cls, const struct GNUNET_HashCode *key, void *value) |
Print the (collected) values. More... | |
static int | printer_watch (void *cls, const char *subsys, const char *print_name, uint64_t value, int is_persistent) |
Callback function to process statistic values. More... | |
static void | clean_node (void *cls) |
Clean all data structures related to given node. More... | |
static void | print_finish (void *cls) |
Print and shutdown. More... | |
static void | continuation_print (void *cls, int success) |
Called once all statistic values are available. More... | |
static void | cleanup (void *cls, int success) |
Function called last by the statistics code. More... | |
static int | collector (void *cls, const char *subsys, const char *coll_name, uint64_t value, int is_persistent) |
Iterate over statistics values and store them in values. More... | |
static void | main_task (void *cls) |
Main task that does the actual work. More... | |
static int | iter_check_config (void *cls, const char *filename) |
Iter over content of a node's directory to check for existence of a config file. More... | |
static int | iter_testbed_path (void *cls, const char *filename) |
Iterates over filenames in testbed directory. More... | |
static int | discover_testbed_nodes (const char *path_testbed_discovered) |
Count the number of nodes running in the testbed. More... | |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Main function that will be run by the scheduler. More... | |
int | main (int argc, char *const *argv) |
The main function to obtain statistics in GNUnet. More... | |
Variables | |
static int | ret |
Final status code. More... | |
static char * | subsystem |
Set to subsystem that we're going to get stats for (or NULL for all). More... | |
static char * | path_testbed |
The path of the testbed data. More... | |
static char * | name |
Set to the specific stat value that we are after (or NULL for all). More... | |
static int | persistent |
Make the value that is being set persistent. More... | |
static int | watch |
Watch value continuously. More... | |
static int | quiet |
Quiet mode. More... | |
static char * | csv_separator_opt |
Separator string for csv. More... | |
static const char * | csv_separator |
Separator string for csv. More... | |
static char * | remote_host |
Remote host. More... | |
static unsigned long long | remote_port |
Remote host's port. More... | |
static unsigned long long | set_val |
Value to set. More... | |
static int | set_value |
Set operation. More... | |
static struct Node * | nodes |
static unsigned | num_nodes |
Number of configurations of all (testbed) nodes. More... | |
static struct GNUNET_CONTAINER_MultiHashMap * | values |
Collection of all values (represented with ValueSet). More... | |
static int | num_nodes_ready |
Number of nodes that have their values ready. More... | |
static int | num_nodes_ready_shutdown |
Number of nodes that have their values ready. More... | |
tool to obtain statistics
Definition in file gnunet-statistics.c.
|
static |
Create a new ValueSet.
subsystem | Subsystem of the valueset. |
name | Name of the valueset. |
num_values | Number of values in valueset - number of peers. |
is_persistent | Persistence status of values. |
Definition at line 185 of file gnunet-statistics.c.
References GNUNET_new, GNUNET_new_array, GNUNET_strdup, ValueSet::is_persistent, ValueSet::name, persistent, ValueSet::subsystem, and ValueSet::values.
Referenced by collector().
|
static |
Print the (collected) values.
Implements #GNUNET_CONTAINER_HashMapIterator.
cls | Closure - unused |
key | GNUNET_HashCode key of GNUNET_CONTAINER_MultiHashMap iterator - unused |
value | Values represented as ValueSet. |
Definition at line 214 of file gnunet-statistics.c.
References _, csv_separator, GNUNET_free, GNUNET_NO, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_YES, ValueSet::is_persistent, ValueSet::name, num_nodes, quiet, ValueSet::subsystem, value, ValueSet::values, and watch.
Referenced by print_finish().
|
static |
Callback function to process statistic values.
cls | closure |
subsystem | name of subsystem that created the statistic |
name | the name of the datum |
value | the current value |
is_persistent | GNUNET_YES if the value is persistent, GNUNET_NO if not |
Definition at line 281 of file gnunet-statistics.c.
References _, csv_separator, GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_YES, quiet, value, and watch.
Referenced by clean_node(), and main_task().
|
static |
Clean all data structures related to given node.
Also clears global structures if we are the last node to clean.
cls | the index of the node |
Definition at line 339 of file gnunet-statistics.c.
References Node::conf, Node::gh, GNUNET_assert, GNUNET_CONFIGURATION_destroy(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_destroy(), GNUNET_STATISTICS_get_cancel(), GNUNET_STATISTICS_watch_cancel(), GNUNET_YES, h, Node::handle, name, nodes, num_nodes_ready_shutdown, path_testbed, printer_watch(), subsystem, and watch.
Referenced by continuation_print(), and main_task().
|
static |
Print and shutdown.
cls | unused |
Definition at line 387 of file gnunet-statistics.c.
References csv_separator_opt, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_SCHEDULER_shutdown(), printer(), and values.
Referenced by continuation_print().
|
static |
Called once all statistic values are available.
Implements GNUNET_STATISTICS_Callback
cls | Closure - The index of the node. |
success | Whether statistics were obtained successfully. |
Definition at line 407 of file gnunet-statistics.c.
References _, clean_node(), GNUNET_STATISTICS_GetHandle::cls, Node::gh, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), nodes, num_nodes, num_nodes_ready, print_finish(), remote_host, remote_port, ret, shutdown_task, and Node::shutdown_task.
Referenced by main_task().
|
static |
Function called last by the statistics code.
cls | closure |
success | GNUNET_OK if statistics were successfully obtained, GNUNET_SYSERR if not. |
Definition at line 450 of file gnunet-statistics.c.
References _, Node::gh, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), nodes, num_nodes, remote_host, remote_port, and ret.
Referenced by main_task().
|
static |
Iterate over statistics values and store them in values.
They will be printed once all are available.
cls | Cosure - Node index. |
subsystem | Subsystem of the value. |
name | Name of the value. |
value | Value itself. |
is_persistent | Persistence. |
Definition at line 484 of file gnunet-statistics.c.
References GNUNET_STATISTICS_GetHandle::cls, GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_YES, ValueSet::is_persistent, key, new_value_set(), num_nodes, value, ValueSet::values, and values.
Referenced by main_task().
|
static |
Main task that does the actual work.
cls | closure with our configuration |
Definition at line 528 of file gnunet-statistics.c.
References _, cfg, clean_node(), cleanup(), collector(), Node::conf, continuation_print(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_STATISTICS_create(), GNUNET_STATISTICS_destroy(), GNUNET_STATISTICS_get(), GNUNET_STATISTICS_set(), GNUNET_STATISTICS_watch(), GNUNET_SYSERR, GNUNET_YES, Node::handle, handle, name, nodes, persistent, printer_watch(), ret, set_val, set_value, Node::shutdown_task, subsystem, and watch.
Referenced by run().
|
static |
Iter over content of a node's directory to check for existence of a config file.
Implements GNUNET_FileNameCallback
cls | pointer to indicate success |
filename | filename inside the directory of the potential node |
Definition at line 617 of file gnunet-statistics.c.
References Node::conf, filename, GNUNET_array_grow, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_load(), GNUNET_NO, GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_STRINGS_get_short_name(), GNUNET_SYSERR, Node::index_node, nodes, and num_nodes.
Referenced by iter_testbed_path().
|
static |
Iterates over filenames in testbed directory.
Implements GNUNET_FileNameCallback
Checks if the file is a directory for a testbed node and counts the nodes.
cls | counter of nodes |
filename | full path of the file in testbed |
Definition at line 656 of file gnunet-statistics.c.
References filename, GNUNET_assert, GNUNET_DISK_directory_scan(), GNUNET_OK, GNUNET_STRINGS_get_short_name(), and iter_check_config().
Referenced by discover_testbed_nodes().
|
static |
Count the number of nodes running in the testbed.
path_testbed | path to the testbed data |
Definition at line 688 of file gnunet-statistics.c.
References GNUNET_DISK_directory_scan(), and iter_testbed_path().
Referenced by run().
|
static |
Main function that will be run by the scheduler.
cls | closure |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
cfg | configuration |
Definition at line 716 of file gnunet-statistics.c.
References _, consensus-simulation::args, cfg, Node::conf, csv_separator, discover_testbed_nodes(), GNUNET_array_grow, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_set_value_number(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, GNUNET_YES, Node::index_node, main_task(), nodes, num_nodes, path_testbed, remote_host, remote_port, ret, set_val, set_value, values, and watch.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function to obtain statistics in GNUnet.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 815 of file gnunet-statistics.c.
References csv_separator_opt, gettext_noop, GNUNET_array_grow, GNUNET_free, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_filename(), GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_ulong(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), name, nodes, num_nodes, options, path_testbed, persistent, quiet, remote_host, remote_port, ret, run(), subsystem, and watch.
|
static |
Final status code.
Definition at line 35 of file gnunet-statistics.c.
Referenced by cleanup(), continuation_print(), main(), main_task(), and run().
|
static |
Set to subsystem that we're going to get stats for (or NULL for all).
Definition at line 40 of file gnunet-statistics.c.
Referenced by clean_node(), GNUNET_STATISTICS_create(), GNUNET_STATISTICS_get(), GNUNET_STATISTICS_watch(), GNUNET_STATISTICS_watch_cancel(), handle_uri(), main(), main_task(), process_stats(), run(), and stats_iterator().
|
static |
The path of the testbed data.
Definition at line 45 of file gnunet-statistics.c.
Referenced by clean_node(), main(), and run().
|
static |
Set to the specific stat value that we are after (or NULL for all).
Definition at line 50 of file gnunet-statistics.c.
Referenced by clean_node(), main(), and main_task().
|
static |
Make the value that is being set persistent.
Definition at line 55 of file gnunet-statistics.c.
Referenced by main(), main_task(), and new_value_set().
|
static |
Watch value continuously.
Definition at line 60 of file gnunet-statistics.c.
Referenced by clean_node(), main(), main_task(), printer(), printer_watch(), run(), and schedule_watch_request().
|
static |
Quiet mode.
Definition at line 65 of file gnunet-statistics.c.
Referenced by main(), printer(), and printer_watch().
|
static |
Separator string for csv.
Definition at line 70 of file gnunet-statistics.c.
Referenced by main(), and print_finish().
|
static |
Separator string for csv.
Definition at line 75 of file gnunet-statistics.c.
Referenced by printer(), printer_watch(), and run().
|
static |
Remote host.
Definition at line 80 of file gnunet-statistics.c.
Referenced by cleanup(), continuation_print(), main(), and run().
|
static |
Remote host's port.
Definition at line 85 of file gnunet-statistics.c.
Referenced by add_services(), cleanup(), continuation_print(), main(), and run().
|
static |
Value to set.
Definition at line 90 of file gnunet-statistics.c.
Referenced by main_task(), and run().
|
static |
Set operation.
Definition at line 95 of file gnunet-statistics.c.
Referenced by main_task(), and run().
|
static |
Referenced by clean_node(), cleanup(), continuation_print(), iter_check_config(), main(), main_task(), and run().
|
static |
Number of configurations of all (testbed) nodes.
Definition at line 130 of file gnunet-statistics.c.
Referenced by cleanup(), collector(), continuation_print(), iter_check_config(), main(), printer(), and run().
|
static |
Collection of all values (represented with ValueSet).
Definition at line 162 of file gnunet-statistics.c.
Referenced by collector(), heap_plugin_get_closest(), print_finish(), and run().
|
static |
Number of nodes that have their values ready.
Definition at line 167 of file gnunet-statistics.c.
Referenced by continuation_print().
|
static |
Number of nodes that have their values ready.
Definition at line 172 of file gnunet-statistics.c.
Referenced by clean_node().