diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-14 15:53:30 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-14 15:53:30 +0000 |
commit | f23c2885ec8d5a0976b8beeebdd1f0f6bde1941e (patch) | |
tree | e4e8b142e499f3dca33cfc96804a56a6209a2a25 /src/sysmon | |
parent | 03541adeae1cecf7389ff579fa2a575ef355eeba (diff) | |
download | gnunet-f23c2885ec8d5a0976b8beeebdd1f0f6bde1941e.tar.gz gnunet-f23c2885ec8d5a0976b8beeebdd1f0f6bde1941e.zip |
changes
Diffstat (limited to 'src/sysmon')
-rw-r--r-- | src/sysmon/gnunet-service-sysmon.c | 93 | ||||
-rw-r--r-- | src/sysmon/sysmon.conf.in | 1 |
2 files changed, 89 insertions, 5 deletions
diff --git a/src/sysmon/gnunet-service-sysmon.c b/src/sysmon/gnunet-service-sysmon.c index 30ea30ac1..d319e9912 100644 --- a/src/sysmon/gnunet-service-sysmon.c +++ b/src/sysmon/gnunet-service-sysmon.c | |||
@@ -30,6 +30,7 @@ | |||
30 | enum operation | 30 | enum operation |
31 | { | 31 | { |
32 | o_internal, | 32 | o_internal, |
33 | o_ligbtop, | ||
33 | o_command | 34 | o_command |
34 | }; | 35 | }; |
35 | 36 | ||
@@ -61,6 +62,9 @@ struct SysmonProperty | |||
61 | */ | 62 | */ |
62 | struct SysmonProperty *prev; | 63 | struct SysmonProperty *prev; |
63 | 64 | ||
65 | struct SysmonGtopProcProperty *gtop_proc_head; | ||
66 | struct SysmonGtopProcProperty *gtop_proc_tail; | ||
67 | |||
64 | /** | 68 | /** |
65 | * Description used for statistics valuesd | 69 | * Description used for statistics valuesd |
66 | */ | 70 | */ |
@@ -119,6 +123,17 @@ struct SysmonProperty | |||
119 | }; | 123 | }; |
120 | 124 | ||
121 | /** | 125 | /** |
126 | * A system property to monitor | ||
127 | */ | ||
128 | struct SysmonGtopProcProperty | ||
129 | { | ||
130 | struct SysmonGtopProcProperty *prev; | ||
131 | struct SysmonGtopProcProperty *next; | ||
132 | char * binary; | ||
133 | }; | ||
134 | |||
135 | |||
136 | /** | ||
122 | * Final status code. | 137 | * Final status code. |
123 | */ | 138 | */ |
124 | static int ret; | 139 | static int ret; |
@@ -142,6 +157,9 @@ GNUNET_SCHEDULER_TaskIdentifier end_task; | |||
142 | struct SysmonProperty *sp_head; | 157 | struct SysmonProperty *sp_head; |
143 | struct SysmonProperty *sp_tail; | 158 | struct SysmonProperty *sp_tail; |
144 | 159 | ||
160 | struct SysmonGtopProcProperty *pp_head; | ||
161 | struct SysmonGtopProcProperty *pp_tail; | ||
162 | |||
145 | static void | 163 | static void |
146 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 164 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
147 | { | 165 | { |
@@ -198,16 +216,15 @@ put_property (struct SysmonProperty *sp) | |||
198 | { | 216 | { |
199 | if (v_numeric ==sp->value_type) | 217 | if (v_numeric ==sp->value_type) |
200 | { | 218 | { |
201 | /* GNUNET_STATISTICS_set (stats, sp->desc, sp->num_val, GNUNET_NO); */ | ||
202 | |||
203 | fprintf (stderr, "%s : %s : %llu\n", | 219 | fprintf (stderr, "%s : %s : %llu\n", |
204 | GNUNET_STRINGS_absolute_time_to_string(GNUNET_TIME_absolute_get()), | 220 | GNUNET_STRINGS_absolute_time_to_string(GNUNET_TIME_absolute_get()), |
205 | sp->desc, (unsigned long long) sp->num_val); | 221 | sp->desc, (unsigned long long) sp->num_val); |
206 | } | 222 | } |
207 | else if (v_string ==sp->value_type) | 223 | else if (v_string ==sp->value_type) |
208 | { | 224 | { |
209 | /* GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NOT IMPLEMENTED\n"); */ | 225 | fprintf (stderr, "%s : %s : %s\n", |
210 | fprintf (stderr, "SYSMON STRING\n"); | 226 | GNUNET_STRINGS_absolute_time_to_string(GNUNET_TIME_absolute_get()), |
227 | sp->desc, sp->str_val); | ||
211 | } | 228 | } |
212 | else | 229 | else |
213 | { | 230 | { |
@@ -289,6 +306,12 @@ exec_cmd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
289 | } | 306 | } |
290 | 307 | ||
291 | static void | 308 | static void |
309 | exec_gtop_proc_mon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
310 | { | ||
311 | //struct SysmonGtopProcProperty *sp = cls; | ||
312 | } | ||
313 | |||
314 | static void | ||
292 | load_property (void *cls, | 315 | load_property (void *cls, |
293 | const char *section) | 316 | const char *section) |
294 | { | 317 | { |
@@ -478,6 +501,48 @@ load_default_properties (void) | |||
478 | return GNUNET_OK; | 501 | return GNUNET_OK; |
479 | } | 502 | } |
480 | 503 | ||
504 | static int | ||
505 | load_gtop_properties (void) | ||
506 | { | ||
507 | char *services; | ||
508 | char *s; | ||
509 | char *binary; | ||
510 | struct SysmonGtopProcProperty *pp; | ||
511 | int c; | ||
512 | /* Load network monitoring tasks */ | ||
513 | |||
514 | /* Load service memory monitoring tasks */ | ||
515 | if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (cfg, "sysmon", "MONITOR_SERVICES")) | ||
516 | return GNUNET_OK; | ||
517 | |||
518 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "sysmon", "MONITOR_SERVICES", &services)) | ||
519 | return GNUNET_SYSERR; | ||
520 | |||
521 | s = strtok (services, " "); | ||
522 | c = 0; | ||
523 | while (NULL != s) | ||
524 | { | ||
525 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, s, "BINARY", &binary)) | ||
526 | { | ||
527 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Monitoring service `%s' with binary `%s'\n", s, binary); | ||
528 | pp = GNUNET_malloc (sizeof (struct SysmonGtopProcProperty)); | ||
529 | pp->binary = binary; | ||
530 | GNUNET_CONTAINER_DLL_insert (pp_head, pp_tail, pp); | ||
531 | c++ | ||
532 | } | ||
533 | s = strtok (NULL, " "); | ||
534 | } | ||
535 | GNUNET_free (services); | ||
536 | |||
537 | if (c > 0) | ||
538 | { | ||
539 | |||
540 | } | ||
541 | |||
542 | return GNUNET_OK; | ||
543 | |||
544 | } | ||
545 | |||
481 | 546 | ||
482 | static void | 547 | static void |
483 | run_property (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 548 | run_property (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -525,7 +590,18 @@ run_properties (void) | |||
525 | static void | 590 | static void |
526 | cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 591 | cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
527 | { | 592 | { |
528 | /* FIXME: do clean up here */ | 593 | struct SysmonGtopProcProperty *cur; |
594 | struct SysmonGtopProcProperty *next; | ||
595 | |||
596 | next = pp_head; | ||
597 | while (NULL != (cur = next)) | ||
598 | { | ||
599 | next = cur->next; | ||
600 | GNUNET_CONTAINER_DLL_remove (pp_head, pp_tail, cur); | ||
601 | GNUNET_free (cur->binary); | ||
602 | GNUNET_free (cur); | ||
603 | } | ||
604 | |||
529 | } | 605 | } |
530 | 606 | ||
531 | 607 | ||
@@ -606,6 +682,13 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
606 | return; | 682 | return; |
607 | } | 683 | } |
608 | 684 | ||
685 | #if HAVE_LIBGTOP | ||
686 | if (GNUNET_SYSERR == load_gtop_properties ()) | ||
687 | { | ||
688 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to load gtop properties \n"); | ||
689 | } | ||
690 | #endif | ||
691 | |||
609 | /* run properties */ | 692 | /* run properties */ |
610 | if (GNUNET_SYSERR == run_properties ()) | 693 | if (GNUNET_SYSERR == run_properties ()) |
611 | { | 694 | { |
diff --git a/src/sysmon/sysmon.conf.in b/src/sysmon/sysmon.conf.in index 471bd14ef..208da1ae7 100644 --- a/src/sysmon/sysmon.conf.in +++ b/src/sysmon/sysmon.conf.in | |||
@@ -6,3 +6,4 @@ HOME = $SERVICEHOME | |||
6 | BINARY = gnunet-daemon-sysmon | 6 | BINARY = gnunet-daemon-sysmon |
7 | CFGFILE = sysmon-properties.conf | 7 | CFGFILE = sysmon-properties.conf |
8 | UNIXPATH = /tmp/gnunet-service-sysmon.sock | 8 | UNIXPATH = /tmp/gnunet-service-sysmon.sock |
9 | MONITOR_SERVICES = fs transport \ No newline at end of file | ||