186 const char *new_name,
228 "%24s%s %s%s%12s%s %s%50s%s%s ",
243 "%s%s%12s%s %s%50s%s%s ",
258 (
unsigned long long) value_set->
values[i],
261 fprintf (stdout,
"\n");
283 const char *print_name,
296 "%24s%s %s%s%12s%s %s%50s%s%s %16llu\n",
299 is_persistent ?
"!" :
" ",
307 (
unsigned long long)
value);
312 "%s%s%12s%s %s%50s%s%s %16llu\n",
313 is_persistent ?
"!" :
" ",
321 (
unsigned long long)
value);
325 fprintf (stdout,
"%llu\n", (
unsigned long long)
value);
341 const unsigned index_node = *(
unsigned *) cls;
368 &
nodes[index_node].index_node));
410 const unsigned index_node = *(
unsigned *)
cls;
418 _ (
"Failed to obtain statistics.\n"));
421 _ (
"Failed to obtain statistics from host `%s:%llu'\n"),
432 &
nodes[index_node].index_node);
460 fprintf (stderr,
"%s",
_ (
"Failed to obtain statistics.\n"));
463 _ (
"Failed to obtain statistics from host `%s:%llu'\n"),
486 const char *coll_name,
490 const unsigned index_node = *(
unsigned *)
cls;
494 unsigned len_subsys_name;
497 len_subsys_name = strlen (subsys) + 3 + strlen (coll_name) + 1;
499 sprintf (subsys_name,
"%s---%s", subsys, coll_name);
530 unsigned index_node = *(
unsigned *) cls;
537 fprintf (stderr,
"%s",
_ (
"Missing argument: subsystem \n"));
543 fprintf (stderr,
"%s",
_ (
"Missing argument: name\n"));
569 if (NULL == (
nodes[index_node].gh =
575 &
nodes[index_node].index_node)))
582 printf (
_ (
"No subsystem or name given\n"));
592 &
nodes[index_node].index_node))
594 fprintf (stderr,
_ (
"Failed to initialize watch routine\n"));
629 fprintf (stderr,
"Failed loading config `%s'\n",
filename);
695 if (-1 == num_dir_entries)
698 "Failure during scanning directory `%s'\n",
699 path_testbed_discovered);
730 fprintf (stderr,
_ (
"Invalid argument `%s'\n"),
args[0]);
747 _ (
"A port is required to connect to host `%s'\n"),
756 "A port has to be between 1 and 65535 to connect to host `%s'\n"),
788 _ (
"Not able to watch testbed nodes (yet - feel free to implement)\n"));
814main (
int argc,
char *
const *argv)
821 "limit output to statistics for the given NAME"),
826 "make the value being set persistent"),
832 "limit output to the given SUBSYSTEM"),
843 "path to the folder containing the testbed data"),
848 "just print the statistics value"),
877 "gnunet-statistics [options [value]]",
879 "Print statistics about GNUnet operations."),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_SCHEDULER_Task * shutdown_task
static char * value
Value of the record to add/remove.
static unsigned long long set_val
Value to set.
static char * csv_separator_opt
Separator string for csv.
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.
static int persistent
Make the value that is being set persistent.
static int set_value
Set operation.
static char * path_testbed
The path of the testbed data.
static struct GNUNET_CONTAINER_MultiHashMap * values
Collection of all values (represented with ValueSet).
static int quiet
Quiet mode.
static void print_finish(void *cls)
Print and shutdown.
static char * name
Set to the specific stat value that we are after (or NULL for all).
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.
static int discover_testbed_nodes(const char *path_testbed_discovered)
Count the number of nodes running in the testbed.
static int ret
Final status code.
static int num_nodes_ready
Number of nodes that have their values ready.
static struct Node * nodes
static const char * csv_separator
Separator string for csv.
static void continuation_print(void *cls, int success)
Called once all statistic values are available.
static void cleanup(void *cls, int success)
Function called last by the statistics code.
static void clean_node(void *cls)
Clean all data structures related to given node.
static int watch
Watch value continuously.
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.
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.
int main(int argc, char *const *argv)
The main function to obtain statistics in GNUnet.
static char * remote_host
Remote host.
static int num_nodes_ready_shutdown
Number of nodes that have their values ready.
static int iter_testbed_path(void *cls, const char *filename)
Iterates over filenames in testbed directory.
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
static int printer(void *cls, const struct GNUNET_HashCode *key, void *value)
Print the (collected) values.
static unsigned num_nodes
Number of configurations of all (testbed) nodes.
static struct ValueSet * new_value_set(const char *subsys, const char *new_name, unsigned num_values, int is_persistent)
Create a new ValueSet.
static void main_task(void *cls)
Main task that does the actual work.
static unsigned long long remote_port
Remote host's port.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
API to create, modify and access statistics.
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.
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.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
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_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
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).
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.
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.
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.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
enum GNUNET_GenericReturnValue 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).
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
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.
enum GNUNET_GenericReturnValue 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.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
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,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
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,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
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.
void GNUNET_STATISTICS_get_cancel(struct GNUNET_STATISTICS_GetHandle *gh)
Cancel a GNUNET_STATISTICS_get request.
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_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.
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).
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
const char * GNUNET_STRINGS_get_short_name(const char *filename)
"man basename" Returns a pointer to a part of filename (allocates nothing)!
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Internal representation of the hash map.
Definition of a command line option.
Entry in list of pending tasks.
Linked list of things we still need to do.
void * cls
Closure for proc and cont.
Time for absolute times used by GNUnet, in microseconds.
Representation of all (testbed) nodes.
struct GNUNET_STATISTICS_GetHandle * gh
Handle for pending GET operation.
struct GNUNET_STATISTICS_Handle * handle
Statistics handle nodes.
struct GNUNET_CONFIGURATION_Handle * conf
Configuration handle for this node.
struct GNUNET_SCHEDULER_Task * shutdown_task
Identifier for shutdown task for this node.
unsigned index_node
Index of the node in this array.
Set of values for a combination of subsystem and name.
char * name
Name of the valueset.
int is_persistent
Persistence of the values.
char * subsystem
Subsystem of the valueset.
uint64_t * values
The values.