diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-15 12:55:14 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-15 12:55:14 +0000 |
commit | 90f33c1c0fdc2cc75ddeb1163d656955c527b34a (patch) | |
tree | a4eb1d8daf8fbb7a3b021ce9a50b5f35be423808 /src/sysmon | |
parent | 45886cda009c9914fb6a8c79780a64e2ea0e90b2 (diff) | |
download | gnunet-90f33c1c0fdc2cc75ddeb1163d656955c527b34a.tar.gz gnunet-90f33c1c0fdc2cc75ddeb1163d656955c527b34a.zip |
changes
Diffstat (limited to 'src/sysmon')
-rw-r--r-- | src/sysmon/gnunet-service-sysmon.c | 70 | ||||
-rw-r--r-- | src/sysmon/sysmon.conf.in | 4 | ||||
-rw-r--r-- | src/sysmon/test_glibtop_network.c | 4 |
3 files changed, 66 insertions, 12 deletions
diff --git a/src/sysmon/gnunet-service-sysmon.c b/src/sysmon/gnunet-service-sysmon.c index b4a775cc7..c7f87dc45 100644 --- a/src/sysmon/gnunet-service-sysmon.c +++ b/src/sysmon/gnunet-service-sysmon.c | |||
@@ -34,6 +34,8 @@ | |||
34 | #include <glibtop/procargs.h> | 34 | #include <glibtop/procargs.h> |
35 | #include <glibtop/procmem.h> | 35 | #include <glibtop/procmem.h> |
36 | #include <glibtop/proctime.h> | 36 | #include <glibtop/proctime.h> |
37 | #include <glibtop/netlist.h> | ||
38 | #include <glibtop/netload.h> | ||
37 | #endif | 39 | #endif |
38 | 40 | ||
39 | 41 | ||
@@ -146,6 +148,7 @@ struct SysmonGtopProcProperty | |||
146 | { | 148 | { |
147 | struct SysmonGtopProcProperty *prev; | 149 | struct SysmonGtopProcProperty *prev; |
148 | struct SysmonGtopProcProperty *next; | 150 | struct SysmonGtopProcProperty *next; |
151 | char * srv; | ||
149 | char * binary; | 152 | char * binary; |
150 | }; | 153 | }; |
151 | 154 | ||
@@ -216,6 +219,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
216 | { | 219 | { |
217 | gt_next = gt_cur->next; | 220 | gt_next = gt_cur->next; |
218 | GNUNET_CONTAINER_DLL_remove (pp_head, pp_tail, gt_cur); | 221 | GNUNET_CONTAINER_DLL_remove (pp_head, pp_tail, gt_cur); |
222 | GNUNET_free (gt_cur->srv); | ||
219 | GNUNET_free (gt_cur->binary); | 223 | GNUNET_free (gt_cur->binary); |
220 | GNUNET_free (gt_cur); | 224 | GNUNET_free (gt_cur); |
221 | } | 225 | } |
@@ -356,8 +360,6 @@ exec_gtop_proc_mon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
356 | ret = 1; | 360 | ret = 1; |
357 | return; | 361 | return; |
358 | } | 362 | } |
359 | |||
360 | printf("Found %lu processes\n", (unsigned long) proc_list.number); | ||
361 | for (i = 0; i < proc_list.number; ++i) | 363 | for (i = 0; i < proc_list.number; ++i) |
362 | { | 364 | { |
363 | //printf("PID %u:\n", pids[i]); | 365 | //printf("PID %u:\n", pids[i]); |
@@ -375,7 +377,8 @@ exec_gtop_proc_mon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
375 | { | 377 | { |
376 | /* get memory info */ | 378 | /* get memory info */ |
377 | glibtop_get_proc_mem (&proc_mem, pids[i]); | 379 | glibtop_get_proc_mem (&proc_mem, pids[i]); |
378 | printf ("\tMemory information:\n"); | 380 | printf ("%s process information:\n", sp->srv); |
381 | printf ("\t%s memory information:\n", sp->binary); | ||
379 | printf ("\t%-50s: %llu\n", "total # of pages of memory", (long long unsigned int) proc_mem.size); | 382 | printf ("\t%-50s: %llu\n", "total # of pages of memory", (long long unsigned int) proc_mem.size); |
380 | printf ("\t%-50s: %llu\n", "number of pages of virtual memory", (long long unsigned int) proc_mem.vsize); | 383 | printf ("\t%-50s: %llu\n", "number of pages of virtual memory", (long long unsigned int) proc_mem.vsize); |
381 | printf ("\t%-50s: %llu\n", "number of resident set", (long long unsigned int) proc_mem.resident); | 384 | printf ("\t%-50s: %llu\n", "number of resident set", (long long unsigned int) proc_mem.resident); |
@@ -384,19 +387,49 @@ exec_gtop_proc_mon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
384 | 387 | ||
385 | /* get time info */ | 388 | /* get time info */ |
386 | glibtop_get_proc_time (&proc_time, pids[i]); | 389 | glibtop_get_proc_time (&proc_time, pids[i]); |
387 | printf ("\tTime information:\n"); | 390 | printf ("\t%s time information:\n", sp->binary); |
388 | printf ("\t%-50s: %llu\n", "real time accumulated by process", (long long unsigned int) proc_time.rtime); | 391 | printf ("\t%-50s: %llu\n", "real time accumulated by process", (long long unsigned int) proc_time.rtime); |
389 | printf ("\t%-50s: %llu\n", "user-mode CPU time accumulated by process", (long long unsigned int) proc_time.utime); | 392 | printf ("\t%-50s: %llu\n", "user-mode CPU time accumulated by process", (long long unsigned int) proc_time.utime); |
390 | printf ("\t%-50s: %llu\n", "kernel-mode CPU time accumulated by process", (long long unsigned int) proc_time.stime); | 393 | printf ("\t%-50s: %llu\n", "kernel-mode CPU time accumulated by process", (long long unsigned int) proc_time.stime); |
391 | } | 394 | } |
392 | g_free (argss); | 395 | g_free (argss); |
393 | } | 396 | } |
394 | 397 | printf ("\n"); | |
395 | g_free(pids); | 398 | g_free(pids); |
396 | pids = NULL; | 399 | pids = NULL; |
397 | } | 400 | } |
398 | #endif | 401 | #endif |
399 | 402 | ||
403 | #if HAVE_LIBGTOP | ||
404 | static void | ||
405 | exec_gtop_net_mon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
406 | { | ||
407 | glibtop_netlist netlist; | ||
408 | glibtop_netload netload; | ||
409 | int i; | ||
410 | char ** tmp; | ||
411 | uint8_t *address; | ||
412 | uint8_t *netmask; | ||
413 | |||
414 | tmp = glibtop_get_netlist (&netlist); | ||
415 | |||
416 | printf ("Network information: %u devices\n", netlist.number); | ||
417 | for (i = 0; i < netlist.number; ++i) | ||
418 | { | ||
419 | printf ("Device %i: %s\n", i, tmp[i]); | ||
420 | glibtop_get_netload (&netload, tmp[i]); | ||
421 | address = (uint8_t *) &netload.address; | ||
422 | netmask = (uint8_t *) &netload.subnet; | ||
423 | printf ("\t%-50s: %u.%u.%u.%u\n", "IPv4 subnet", netmask[0], netmask[1], netmask[2],netmask[3]); | ||
424 | printf ("\t%-50s: %u.%u.%u.%u\n", "IPv4 address", address[0], address[1], address[2],address[3]); | ||
425 | |||
426 | printf ("\t%-50s: %llu\n", "bytes in", (long long unsigned int) netload.bytes_in); | ||
427 | printf ("\t%-50s: %llu\n", "bytes out", (long long unsigned int) netload.bytes_out); | ||
428 | printf ("\t%-50s: %llu\n", "bytes total", (long long unsigned int) netload.bytes_total); | ||
429 | } | ||
430 | } | ||
431 | #endif | ||
432 | |||
400 | static void | 433 | static void |
401 | load_property (void *cls, | 434 | load_property (void *cls, |
402 | const char *section) | 435 | const char *section) |
@@ -598,7 +631,7 @@ load_gtop_properties (void) | |||
598 | char *binary; | 631 | char *binary; |
599 | struct SysmonGtopProcProperty *pp; | 632 | struct SysmonGtopProcProperty *pp; |
600 | struct SysmonProperty *sp; | 633 | struct SysmonProperty *sp; |
601 | /* Load network monitoring tasks */ | 634 | struct GNUNET_TIME_Relative interval; |
602 | 635 | ||
603 | /* Load service memory monitoring tasks */ | 636 | /* Load service memory monitoring tasks */ |
604 | if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (cfg, "sysmon", "MONITOR_SERVICES")) | 637 | if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (cfg, "sysmon", "MONITOR_SERVICES")) |
@@ -607,6 +640,9 @@ load_gtop_properties (void) | |||
607 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "sysmon", "MONITOR_SERVICES", &services)) | 640 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "sysmon", "MONITOR_SERVICES", &services)) |
608 | return GNUNET_SYSERR; | 641 | return GNUNET_SYSERR; |
609 | 642 | ||
643 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,"sysmon", "MONITOR_SERVICES_INTERVAL", &interval)) | ||
644 | interval = GNUNET_TIME_UNIT_MINUTES; | ||
645 | |||
610 | s = strtok (services, " "); | 646 | s = strtok (services, " "); |
611 | while (NULL != s) | 647 | while (NULL != s) |
612 | { | 648 | { |
@@ -614,17 +650,16 @@ load_gtop_properties (void) | |||
614 | { | 650 | { |
615 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Monitoring service `%s' with binary `%s'\n", s, binary); | 651 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Monitoring service `%s' with binary `%s'\n", s, binary); |
616 | pp = GNUNET_malloc (sizeof (struct SysmonGtopProcProperty)); | 652 | pp = GNUNET_malloc (sizeof (struct SysmonGtopProcProperty)); |
653 | pp->srv = GNUNET_strdup (s); | ||
617 | pp->binary = binary; | 654 | pp->binary = binary; |
618 | GNUNET_CONTAINER_DLL_insert (pp_head, pp_tail, pp); | 655 | GNUNET_CONTAINER_DLL_insert (pp_head, pp_tail, pp); |
619 | 656 | ||
620 | /* GNUnet sysmon daemon uptime in seconds */ | ||
621 | |||
622 | sp = GNUNET_malloc (sizeof (struct SysmonProperty)); | 657 | sp = GNUNET_malloc (sizeof (struct SysmonProperty)); |
623 | GNUNET_asprintf(&sp->desc, "Process Monitoring for service %s", s); | 658 | GNUNET_asprintf(&sp->desc, "Process Monitoring for service %s", s); |
624 | sp->type = t_continous; | 659 | sp->type = t_continous; |
625 | sp->value_type = v_numeric; | 660 | sp->value_type = v_numeric; |
626 | sp->num_val = (uint64_t) 0; | 661 | sp->num_val = (uint64_t) 0; |
627 | sp->interval = GNUNET_TIME_UNIT_MINUTES; | 662 | sp->interval = interval; |
628 | sp->task_id = GNUNET_SCHEDULER_NO_TASK; | 663 | sp->task_id = GNUNET_SCHEDULER_NO_TASK; |
629 | sp->task = exec_gtop_proc_mon; | 664 | sp->task = exec_gtop_proc_mon; |
630 | sp->task_cls = pp; | 665 | sp->task_cls = pp; |
@@ -634,10 +669,27 @@ load_gtop_properties (void) | |||
634 | } | 669 | } |
635 | GNUNET_free (services); | 670 | GNUNET_free (services); |
636 | 671 | ||
672 | /* Load network monitoring tasks */ | ||
673 | |||
674 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,"sysmon", "MONITOR_NETWORK_INTERVAL", &interval)) | ||
675 | interval = GNUNET_TIME_UNIT_MINUTES; | ||
676 | |||
677 | sp = GNUNET_malloc (sizeof (struct SysmonProperty)); | ||
678 | GNUNET_asprintf(&sp->desc, "Network interface monitoring"); | ||
679 | sp->type = t_continous; | ||
680 | sp->value_type = v_numeric; | ||
681 | sp->num_val = (uint64_t) 0; | ||
682 | sp->interval = interval; | ||
683 | sp->task_id = GNUNET_SCHEDULER_NO_TASK; | ||
684 | sp->task = exec_gtop_net_mon; | ||
685 | sp->task_cls = sp; | ||
686 | GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp); | ||
687 | |||
637 | return GNUNET_OK; | 688 | return GNUNET_OK; |
638 | } | 689 | } |
639 | #endif | 690 | #endif |
640 | 691 | ||
692 | |||
641 | static void | 693 | static void |
642 | run_property (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 694 | run_property (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
643 | { | 695 | { |
diff --git a/src/sysmon/sysmon.conf.in b/src/sysmon/sysmon.conf.in index e9f95cc81..e9d9f5adc 100644 --- a/src/sysmon/sysmon.conf.in +++ b/src/sysmon/sysmon.conf.in | |||
@@ -6,4 +6,6 @@ HOME = $SERVICEHOME | |||
6 | BINARY = gnunet_service_sysmon | 6 | BINARY = gnunet_service_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 sysmon \ No newline at end of file | 9 | MONITOR_SERVICES = transport sysmon |
10 | MONITOR_SERVICES_INTERVAL = 5 s | ||
11 | MONITOR_NETWORK_INTERVAL = 5 s \ No newline at end of file | ||
diff --git a/src/sysmon/test_glibtop_network.c b/src/sysmon/test_glibtop_network.c index d24d8dd80..5cc41c671 100644 --- a/src/sysmon/test_glibtop_network.c +++ b/src/sysmon/test_glibtop_network.c | |||
@@ -55,8 +55,8 @@ print_netlist () | |||
55 | printf ("\t%-50s: %u.%u.%u.%u\n", "IPv4 subnet", netmask[0], netmask[1], netmask[2],netmask[3]); | 55 | printf ("\t%-50s: %u.%u.%u.%u\n", "IPv4 subnet", netmask[0], netmask[1], netmask[2],netmask[3]); |
56 | printf ("\t%-50s: %u.%u.%u.%u\n", "IPv4 address", address[0], address[1], address[2],address[3]); | 56 | printf ("\t%-50s: %u.%u.%u.%u\n", "IPv4 address", address[0], address[1], address[2],address[3]); |
57 | 57 | ||
58 | printf ("\t%-50s: %llu\n", "packets in", (long long unsigned int) netload.packets_in); | 58 | printf ("\t%-50s: %llu\n", "bytes in", (long long unsigned int) netload.bytes_in); |
59 | printf ("\t%-50s: %llu\n", "packets out", (long long unsigned int) netload.packets_out); | 59 | printf ("\t%-50s: %llu\n", "bytes out", (long long unsigned int) netload.bytes_out); |
60 | printf ("\t%-50s: %llu\n", "packets total", (long long unsigned int) netload.packets_total); | 60 | printf ("\t%-50s: %llu\n", "packets total", (long long unsigned int) netload.packets_total); |
61 | } | 61 | } |
62 | } | 62 | } |