aboutsummaryrefslogtreecommitdiff
path: root/src/sysmon
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-01-14 16:22:25 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-01-14 16:22:25 +0000
commitaa61c135381eb883e4739620b23ccdd5969d3f16 (patch)
treecebdd5625f5c448bf69b28d8a1fb40c755e19926 /src/sysmon
parentf23c2885ec8d5a0976b8beeebdd1f0f6bde1941e (diff)
downloadgnunet-aa61c135381eb883e4739620b23ccdd5969d3f16.tar.gz
gnunet-aa61c135381eb883e4739620b23ccdd5969d3f16.zip
changes
Diffstat (limited to 'src/sysmon')
-rw-r--r--src/sysmon/gnunet-service-sysmon.c74
1 files changed, 36 insertions, 38 deletions
diff --git a/src/sysmon/gnunet-service-sysmon.c b/src/sysmon/gnunet-service-sysmon.c
index d319e9912..fc31ba4fb 100644
--- a/src/sysmon/gnunet-service-sysmon.c
+++ b/src/sysmon/gnunet-service-sysmon.c
@@ -120,6 +120,10 @@ struct SysmonProperty
120 */ 120 */
121 GNUNET_SCHEDULER_Task task; 121 GNUNET_SCHEDULER_Task task;
122 122
123 /**
124 * Task closure
125 */
126 void *task_cls;
123}; 127};
124 128
125/** 129/**
@@ -165,6 +169,9 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
165{ 169{
166 struct SysmonProperty *sp; 170 struct SysmonProperty *sp;
167 struct SysmonProperty *next; 171 struct SysmonProperty *next;
172 struct SysmonGtopProcProperty *gt_cur;
173 struct SysmonGtopProcProperty *gt_next;
174
168 175
169 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon stopping ... \n"); 176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon stopping ... \n");
170 177
@@ -179,9 +186,9 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
179 next = sp_head; 186 next = sp_head;
180 while (NULL != (sp = next)) 187 while (NULL != (sp = next))
181 { 188 {
182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping `%s' \n", sp->desc); 189 next = sp->next;
190 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping `%s' \n", sp->desc);
183 GNUNET_CONTAINER_DLL_remove (sp_head, sp_tail, sp); 191 GNUNET_CONTAINER_DLL_remove (sp_head, sp_tail, sp);
184 next = sp->next;
185 if (GNUNET_SCHEDULER_NO_TASK != sp->task_id) 192 if (GNUNET_SCHEDULER_NO_TASK != sp->task_id)
186 { 193 {
187 GNUNET_SCHEDULER_cancel (sp->task_id); 194 GNUNET_SCHEDULER_cancel (sp->task_id);
@@ -193,6 +200,15 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
193 GNUNET_free (sp); 200 GNUNET_free (sp);
194 } 201 }
195 202
203 gt_next = pp_head;
204 while (NULL != (gt_cur = gt_next))
205 {
206 gt_next = gt_cur->next;
207 GNUNET_CONTAINER_DLL_remove (pp_head, pp_tail, gt_cur);
208 GNUNET_free (gt_cur->binary);
209 GNUNET_free (gt_cur);
210 }
211
196} 212}
197 213
198static void 214static void
@@ -308,7 +324,8 @@ exec_cmd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
308static void 324static void
309exec_gtop_proc_mon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 325exec_gtop_proc_mon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
310{ 326{
311 //struct SysmonGtopProcProperty *sp = cls; 327 struct SysmonGtopProcProperty *sp = cls;
328 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property `%s'\n", sp->binary);
312} 329}
313 330
314static void 331static void
@@ -497,6 +514,7 @@ load_default_properties (void)
497 sp->interval = GNUNET_TIME_UNIT_MINUTES; 514 sp->interval = GNUNET_TIME_UNIT_MINUTES;
498 sp->task_id = GNUNET_SCHEDULER_NO_TASK; 515 sp->task_id = GNUNET_SCHEDULER_NO_TASK;
499 sp->task = update_uptime; 516 sp->task = update_uptime;
517 sp->task_cls = sp;
500 GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp); 518 GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
501 return GNUNET_OK; 519 return GNUNET_OK;
502} 520}
@@ -508,7 +526,7 @@ load_gtop_properties (void)
508 char *s; 526 char *s;
509 char *binary; 527 char *binary;
510 struct SysmonGtopProcProperty *pp; 528 struct SysmonGtopProcProperty *pp;
511 int c; 529 struct SysmonProperty *sp;
512 /* Load network monitoring tasks */ 530 /* Load network monitoring tasks */
513 531
514 /* Load service memory monitoring tasks */ 532 /* Load service memory monitoring tasks */
@@ -519,7 +537,6 @@ load_gtop_properties (void)
519 return GNUNET_SYSERR; 537 return GNUNET_SYSERR;
520 538
521 s = strtok (services, " "); 539 s = strtok (services, " ");
522 c = 0;
523 while (NULL != s) 540 while (NULL != s)
524 { 541 {
525 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, s, "BINARY", &binary)) 542 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, s, "BINARY", &binary))
@@ -528,17 +545,24 @@ load_gtop_properties (void)
528 pp = GNUNET_malloc (sizeof (struct SysmonGtopProcProperty)); 545 pp = GNUNET_malloc (sizeof (struct SysmonGtopProcProperty));
529 pp->binary = binary; 546 pp->binary = binary;
530 GNUNET_CONTAINER_DLL_insert (pp_head, pp_tail, pp); 547 GNUNET_CONTAINER_DLL_insert (pp_head, pp_tail, pp);
531 c++ 548
549 /* GNUnet sysmon daemon uptime in seconds */
550
551 sp = GNUNET_malloc (sizeof (struct SysmonProperty));
552 GNUNET_asprintf(&sp->desc, "Process Monitoring for service %s", s);
553 sp->type = t_continous;
554 sp->value_type = v_numeric;
555 sp->num_val = (uint64_t) 0;
556 sp->interval = GNUNET_TIME_UNIT_SECONDS;
557 sp->task_id = GNUNET_SCHEDULER_NO_TASK;
558 sp->task = exec_gtop_proc_mon;
559 sp->task_cls = pp;
560 GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
532 } 561 }
533 s = strtok (NULL, " "); 562 s = strtok (NULL, " ");
534 } 563 }
535 GNUNET_free (services); 564 GNUNET_free (services);
536 565
537 if (c > 0)
538 {
539
540 }
541
542 return GNUNET_OK; 566 return GNUNET_OK;
543 567
544} 568}
@@ -550,7 +574,7 @@ run_property (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
550 struct SysmonProperty *sp = cls; 574 struct SysmonProperty *sp = cls;
551 sp->task_id = GNUNET_SCHEDULER_NO_TASK; 575 sp->task_id = GNUNET_SCHEDULER_NO_TASK;
552 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running continous property `%s' \n", sp->desc); 576 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running continous property `%s' \n", sp->desc);
553 sp->task (cls, tc); 577 sp->task (sp->task_cls, tc);
554 sp->task_id = GNUNET_SCHEDULER_add_delayed (sp->interval, &run_property, sp); 578 sp->task_id = GNUNET_SCHEDULER_add_delayed (sp->interval, &run_property, sp);
555} 579}
556 580
@@ -582,30 +606,6 @@ run_properties (void)
582 606
583 607
584/** 608/**
585 * Task run during shutdown.
586 *
587 * @param cls unused
588 * @param tc unused
589 */
590static void
591cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
592{
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
605}
606
607
608/**
609 * Process template requests. 609 * Process template requests.
610 * 610 *
611 * @param cls closure 611 * @param cls closure
@@ -622,8 +622,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
622 }; 622 };
623 /* FIXME: do setup here */ 623 /* FIXME: do setup here */
624 GNUNET_SERVER_add_handlers (server, handlers); 624 GNUNET_SERVER_add_handlers (server, handlers);
625 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task,
626 NULL);
627 625
628 struct GNUNET_CONFIGURATION_Handle *properties; 626 struct GNUNET_CONFIGURATION_Handle *properties;
629 char *file; 627 char *file;