aboutsummaryrefslogtreecommitdiff
path: root/src/sysmon
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-01-14 15:53:30 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-01-14 15:53:30 +0000
commitf23c2885ec8d5a0976b8beeebdd1f0f6bde1941e (patch)
treee4e8b142e499f3dca33cfc96804a56a6209a2a25 /src/sysmon
parent03541adeae1cecf7389ff579fa2a575ef355eeba (diff)
downloadgnunet-f23c2885ec8d5a0976b8beeebdd1f0f6bde1941e.tar.gz
gnunet-f23c2885ec8d5a0976b8beeebdd1f0f6bde1941e.zip
changes
Diffstat (limited to 'src/sysmon')
-rw-r--r--src/sysmon/gnunet-service-sysmon.c93
-rw-r--r--src/sysmon/sysmon.conf.in1
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 @@
30enum operation 30enum 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 */
128struct 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 */
124static int ret; 139static int ret;
@@ -142,6 +157,9 @@ GNUNET_SCHEDULER_TaskIdentifier end_task;
142struct SysmonProperty *sp_head; 157struct SysmonProperty *sp_head;
143struct SysmonProperty *sp_tail; 158struct SysmonProperty *sp_tail;
144 159
160struct SysmonGtopProcProperty *pp_head;
161struct SysmonGtopProcProperty *pp_tail;
162
145static void 163static void
146shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 164shutdown_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
291static void 308static void
309exec_gtop_proc_mon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
310{
311 //struct SysmonGtopProcProperty *sp = cls;
312}
313
314static void
292load_property (void *cls, 315load_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
504static int
505load_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
482static void 547static void
483run_property (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 548run_property (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -525,7 +590,18 @@ run_properties (void)
525static void 590static void
526cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 591cleanup_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
6BINARY = gnunet-daemon-sysmon 6BINARY = gnunet-daemon-sysmon
7CFGFILE = sysmon-properties.conf 7CFGFILE = sysmon-properties.conf
8UNIXPATH = /tmp/gnunet-service-sysmon.sock 8UNIXPATH = /tmp/gnunet-service-sysmon.sock
9MONITOR_SERVICES = fs transport \ No newline at end of file