224 "%24s%s %s%s%12s%s %s%50s%s%s ",
239 "%s%s%12s%s %s%50s%s%s ",
254 (
unsigned long long) value_set->
values[i],
257 fprintf (stdout,
"\n");
292 "%24s%s %s%s%12s%s %s%50s%s%s %16llu\n",
295 is_persistent ?
"!" :
" ",
303 (
unsigned long long) value);
308 "%s%s%12s%s %s%50s%s%s %16llu\n",
309 is_persistent ?
"!" :
" ",
317 (
unsigned long long) value);
321 fprintf (stdout,
"%llu\n", (
unsigned long long) value);
337 const unsigned index_node = *(
unsigned *) cls;
364 &
nodes[index_node].index_node));
405 const unsigned index_node = *(
unsigned *) cls;
413 _ (
"Failed to obtain statistics.\n"));
416 _ (
"Failed to obtain statistics from host `%s:%llu'\n"),
427 &
nodes[index_node].index_node);
455 fprintf (stderr,
"%s",
_ (
"Failed to obtain statistics.\n"));
458 _ (
"Failed to obtain statistics from host `%s:%llu'\n"),
485 const unsigned index_node = *(
unsigned *) cls;
489 unsigned len_subsys_name;
492 len_subsys_name = strlen (subsystem) + 3 + strlen (name) + 1;
494 sprintf (subsys_name,
"%s---%s", subsystem, name);
532 fprintf (stderr,
"%s",
_ (
"Missing argument: subsystem \n"));
538 fprintf (stderr,
"%s",
_ (
"Missing argument: name\n"));
564 if (NULL == (
nodes[index_node].
gh =
570 &
nodes[index_node].index_node)))
577 printf (
_ (
"No subsystem or name given\n"));
587 &
nodes[index_node].index_node))
589 fprintf (stderr,
_ (
"Failed to initialize watch routine\n"));
624 fprintf (stderr,
"Failed loading config `%s'\n", filename);
690 if (-1 == num_dir_entries)
693 "Failure during scanning directory `%s'\n",
723 if (1 != sscanf (args[0],
"%llu", &
set_val))
725 fprintf (stderr,
_ (
"Invalid argument `%s'\n"), args[0]);
742 _ (
"A port is required to connect to host `%s'\n"),
751 "A port has to be between 1 and 65535 to connect to host `%s'\n"),
783 _ (
"Not able to watch testbed nodes (yet - feel free to implement)\n"));
809 main (
int argc,
char *
const *argv)
816 "limit output to statistics for the given NAME"),
821 "make the value being set persistent"),
827 "limit output to the given SUBSYSTEM"),
838 "path to the folder containing the testbed data"),
843 "just print the statistics value"),
872 "gnunet-statistics [options [value]]",
874 "Print statistics about GNUnet operations."),
char * subsystem
Subsystem of the valueset.
static char * remote_host
Remote host.
static unsigned long long remote_port
Remote host's port.
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
Set of values for a combination of subsystem and name.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int collector(void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Iterate over statistics values and store them in values.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
static struct GNUNET_CONTAINER_MultiHashMap * values
Collection of all values (represented with ValueSet).
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
static char * csv_separator
Separator string for csv.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_STATISTICS_get_cancel(struct GNUNET_STATISTICS_GetHandle *gh)
Cancel a GNUNET_STATISTICS_get request.
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.
Representation of all (testbed) nodes.
int is_persistent
Persistence of the values.
void GNUNET_CONFIGURATION_set_value_number(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long number)
Set a configuration value that should be a number.
struct GNUNET_STATISTICS_GetHandle * gh
Handle for pending GET operation.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
Linked list of things we still need to do.
static unsigned long long set_val
Value to set.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Definition of a command line option.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
static char * path_testbed
The path of the testbed data.
static void print_finish(void *cls)
Print and shutdown.
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
static unsigned int num_values
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
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.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Internal representation of the hash map.
uint64_t * values
The values.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
static struct GNUNET_ARM_Handle * h
Connection with ARM.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
static char * name
Set to the specific stat value that we are after (or NULL for all).
static int ret
Final status code.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
static void continuation_print(void *cls, int success)
Called once all statistic values are available.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_filename(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a filename (automatically path expanded).
static struct Node * nodes
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
static char * value
Value of the record to add/remove.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
int main(int argc, char *const *argv)
The main function to obtain statistics in GNUnet.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
struct GNUNET_CONFIGURATION_Handle * conf
Configuration handle for this node.
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
#define GNUNET_free_nz(ptr)
Wrapper around free.
const char * GNUNET_STRINGS_get_short_name(const char *filename)
"man basename" Returns a pointer to a part of filename (allocates nothing)!
There must only be one value per key; storing a value should fail if a value under the same key alrea...
static unsigned num_nodes
Number of configurations of all (testbed) nodes.
struct GNUNET_HashCode key
The key used in the DHT.
static int watch
Watch value continuously.
static void cleanup(void *cls, int success)
Function called last by the statistics code.
static int set_value
Set operation.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_ulong(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned long long *val)
Allow user to specify an unsigned long long.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
unsigned index_node
Index of the node in this array.
static struct ValueSet * new_value_set(const char *subsystem, const char *name, unsigned num_values, int is_persistent)
Create a new ValueSet.
static int persistent
Make the value that is being set persistent.
static int printer(void *cls, const struct GNUNET_HashCode *key, void *value)
Print the (collected) values.
struct GNUNET_SCHEDULER_Task * shutdown_task
Identifier for shutdown task for this node.
int GNUNET_STATISTICS_watch_cancel(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Iterator proc, void *proc_cls)
Stop watching statistics from the peer.
struct GNUNET_STATISTICS_GetHandle * GNUNET_STATISTICS_get(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Callback cont, GNUNET_STATISTICS_Iterator proc, void *cls)
Get statistic from the peer.
static int iter_testbed_path(void *cls, const char *filename)
Iterates over filenames in testbed directory.
int GNUNET_STATISTICS_watch(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Iterator proc, void *proc_cls)
Watch statistics from the peer (be notified whenever they change).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
void * cls
Closure for proc and cont.
Entry in list of pending tasks.
static int num_nodes_ready
Number of nodes that have their values ready.
static void clean_node(void *cls)
Clean all data structures related to given node.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static int num_nodes_ready_shutdown
Number of nodes that have their values ready.
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_STATISTICS_Handle * handle
Statistics handle nodes.
static void main_task(void *cls)
Main task that does the actual work.
static int quiet
Quiet mode.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
static int discover_testbed_nodes(const char *path_testbed)
Count the number of nodes running in the testbed.
char * name
Name of the valueset.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_malloc(size)
Wrapper around malloc.
static int printer_watch(void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Callback function to process statistic values.
#define GNUNET_free(ptr)
Wrapper around free.
#define gettext_noop(String)
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.