#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
+enum operation
+{
+ o_internal,
+ o_command
+};
+
+
enum type
{
t_static,
v_string
};
+/**
+ * A system property to monitor
+ */
struct SysmonProperty
{
+ /**
+ * Next element in in the DLL
+ */
struct SysmonProperty *next;
- struct SysmonProperty *prev;
-
- char * desc;
- int type;
- int value_type;
- struct GNUNET_TIME_Relative interval;
-
- char * cmd;
- char * cmd_args;
- void * cmd_exec_handle;
- uint64_t num_val;
- char * str_val;
+ /**
+ * Previous element in in the DLL
+ */
+ struct SysmonProperty *prev;
- GNUNET_SCHEDULER_TaskIdentifier task_id;
- GNUNET_SCHEDULER_Task task;
+ /**
+ * Description used for statistics valuesd
+ */
+ char * desc;
+
+ /**
+ * Type
+ */
+ int type;
+
+ /**
+ * Value type
+ */
+ int value_type;
+
+ /**
+ * Execution interval
+ */
+ struct GNUNET_TIME_Relative interval;
+
+ /**
+ * Command
+ */
+ char * cmd;
+
+ /**
+ * Command arguments
+ */
+ char * cmd_args;
+
+ /**
+ * Command execution handle
+ */
+ void * cmd_exec_handle;
+
+ /**
+ * Numerical value
+ */
+ uint64_t num_val;
+
+ /**
+ * String value
+ */
+ char * str_val;
+
+ /**
+ * Task id
+ */
+ GNUNET_SCHEDULER_TaskIdentifier task_id;
+
+ /**
+ * Task handle
+ */
+ GNUNET_SCHEDULER_Task task;
};
/**
* Shutdown task
*/
-
GNUNET_SCHEDULER_TaskIdentifier end_task;
struct SysmonProperty *sp_head;
exec_cmd_proc (void *cls, const char *line)
{
struct SysmonProperty *sp = cls;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property output: `%s'\n", line);
if (NULL == line)
{
GNUNET_OS_command_stop (sp->cmd_exec_handle);
return;
}
-
+ switch (sp->value_type) {
+ case v_numeric:
+ if (1 != sscanf (line, "%lu", &sp->num_val))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Command output was not a numerical value: `%s'\n", line);
+ return;
+ }
+ break;
+ case v_string:
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NOT IMPLEMENTED\n");
+ break;
+ default:
+ break;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property output: `%s'\n", line);
+ put_property (sp);
+
+
}
static void
sp->cmd_exec_handle = NULL;
GNUNET_break (0);
}
-
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Trying to exec : `%s'\n", sp->cmd);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property `%s': command `%s' `%s'\n", sp->desc, sp->cmd, sp->cmd_args);
if (NULL == (sp->cmd_exec_handle = GNUNET_OS_command_run (&exec_cmd_proc, sp,
GNUNET_TIME_UNIT_SECONDS,
sp->cmd, sp->cmd,
sp->cmd_args,
NULL)))
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property `%s': command `%s' failed\n", sp->desc, sp->cmd);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property `%s': command `%s' DONE\n", sp->desc, sp->cmd);
}
static void