diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-15 11:14:13 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-15 11:14:13 +0000 |
commit | 45886cda009c9914fb6a8c79780a64e2ea0e90b2 (patch) | |
tree | aa42cd55878e90863830e2459709919ffdc72aa2 /src/sysmon | |
parent | 5f1f0e22c3a4857e358bf6a888a9b6959f8c5f1b (diff) | |
download | gnunet-45886cda009c9914fb6a8c79780a64e2ea0e90b2.tar.gz gnunet-45886cda009c9914fb6a8c79780a64e2ea0e90b2.zip |
changes
Diffstat (limited to 'src/sysmon')
-rw-r--r-- | src/sysmon/Makefile.am | 3 | ||||
-rw-r--r-- | src/sysmon/gnunet-service-sysmon.c | 80 | ||||
-rw-r--r-- | src/sysmon/sysmon-properties.conf | 14 | ||||
-rw-r--r-- | src/sysmon/sysmon.conf.in | 2 |
4 files changed, 54 insertions, 45 deletions
diff --git a/src/sysmon/Makefile.am b/src/sysmon/Makefile.am index bb14d8c46..16fed202f 100644 --- a/src/sysmon/Makefile.am +++ b/src/sysmon/Makefile.am | |||
@@ -68,3 +68,6 @@ endif | |||
68 | if ENABLE_TEST_RUN | 68 | if ENABLE_TEST_RUN |
69 | TESTS = $(check_PROGRAMS) | 69 | TESTS = $(check_PROGRAMS) |
70 | endif | 70 | endif |
71 | |||
72 | EXTRA_DIST = \ | ||
73 | sysmon-properties.conf | ||
diff --git a/src/sysmon/gnunet-service-sysmon.c b/src/sysmon/gnunet-service-sysmon.c index 6597319da..b4a775cc7 100644 --- a/src/sysmon/gnunet-service-sysmon.c +++ b/src/sysmon/gnunet-service-sysmon.c | |||
@@ -20,7 +20,8 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file sysmon/gnunet-service-sysmon.c | 22 | * @file sysmon/gnunet-service-sysmon.c |
23 | * @brief system monitoring service | 23 | * @brief system monitoring service, can use libgtop to retrieve system information |
24 | * in a plattform independent way | ||
24 | * @author Matthias Wachs | 25 | * @author Matthias Wachs |
25 | */ | 26 | */ |
26 | #include "platform.h" | 27 | #include "platform.h" |
@@ -50,6 +51,9 @@ enum type | |||
50 | t_continous | 51 | t_continous |
51 | }; | 52 | }; |
52 | 53 | ||
54 | #define V_NUMERIC_STR "numeric" | ||
55 | #define V_STRING_STR "string" | ||
56 | |||
53 | enum value | 57 | enum value |
54 | { | 58 | { |
55 | v_numeric, | 59 | v_numeric, |
@@ -447,6 +451,7 @@ load_property (void *cls, | |||
447 | args++; | 451 | args++; |
448 | } | 452 | } |
449 | } | 453 | } |
454 | sp->task_cls = sp; | ||
450 | sp->cmd = GNUNET_strdup (tmp); | 455 | sp->cmd = GNUNET_strdup (tmp); |
451 | sp->cmd_args = GNUNET_strdup (args); | 456 | sp->cmd_args = GNUNET_strdup (args); |
452 | GNUNET_free (tmp); | 457 | GNUNET_free (tmp); |
@@ -472,9 +477,9 @@ load_property (void *cls, | |||
472 | /* value */ | 477 | /* value */ |
473 | GNUNET_CONFIGURATION_get_value_string (properties, section, "VALUE", &tmp); | 478 | GNUNET_CONFIGURATION_get_value_string (properties, section, "VALUE", &tmp); |
474 | to_lower_str (tmp); | 479 | to_lower_str (tmp); |
475 | if (0 == strcasecmp(tmp, "numeric")) | 480 | if (0 == strcasecmp(tmp, V_NUMERIC_STR)) |
476 | sp->value_type = v_numeric; | 481 | sp->value_type = v_numeric; |
477 | else if (0 == strcasecmp(tmp, "string")) | 482 | else if (0 == strcasecmp(tmp, V_STRING_STR)) |
478 | sp->value_type = v_string; | 483 | sp->value_type = v_string; |
479 | else | 484 | else |
480 | { | 485 | { |
@@ -681,7 +686,7 @@ static void | |||
681 | run (void *cls, struct GNUNET_SERVER_Handle *server, | 686 | run (void *cls, struct GNUNET_SERVER_Handle *server, |
682 | const struct GNUNET_CONFIGURATION_Handle *mycfg) | 687 | const struct GNUNET_CONFIGURATION_Handle *mycfg) |
683 | { | 688 | { |
684 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 689 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
685 | /* FIXME: add handlers here! */ | 690 | /* FIXME: add handlers here! */ |
686 | {NULL, NULL, 0, 0} | 691 | {NULL, NULL, 0, 0} |
687 | }; | 692 | }; |
@@ -694,47 +699,34 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
694 | end_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); | 699 | end_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); |
695 | cfg = mycfg; | 700 | cfg = mycfg; |
696 | 701 | ||
697 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon starting ... \n"); | 702 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysmon starting ... \n"); |
698 | |||
699 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (mycfg, "sysmon", "CFGFILE", &file)) | ||
700 | { | ||
701 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sysmon configuration file not set, exit! \n"); | ||
702 | shutdown_now(); | ||
703 | ret = 1; | ||
704 | return; | ||
705 | } | ||
706 | |||
707 | properties = GNUNET_CONFIGURATION_create(); | ||
708 | if (NULL == properties) | ||
709 | { | ||
710 | GNUNET_break (0); | ||
711 | shutdown_now(); | ||
712 | ret = 1; | ||
713 | return; | ||
714 | } | ||
715 | if (GNUNET_YES == GNUNET_DISK_file_test(file)) | ||
716 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (properties, file)) | ||
717 | { | ||
718 | GNUNET_break (0); | ||
719 | GNUNET_CONFIGURATION_destroy (properties); | ||
720 | GNUNET_free (file); | ||
721 | ret = 1; | ||
722 | shutdown_now(); | ||
723 | return; | ||
724 | } | ||
725 | GNUNET_free (file); | ||
726 | GNUNET_CONFIGURATION_iterate_sections (properties, &load_property, properties); | ||
727 | |||
728 | GNUNET_CONFIGURATION_destroy (properties); | ||
729 | 703 | ||
730 | /* Creating statistics */ | 704 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (mycfg, "sysmon", "CFGFILE", &file)) |
731 | stats = GNUNET_STATISTICS_create ("sysmon", mycfg); | ||
732 | if (NULL == stats) | ||
733 | { | 705 | { |
734 | GNUNET_break (0); | 706 | properties = GNUNET_CONFIGURATION_create(); |
735 | shutdown_now(); | 707 | if (NULL == properties) |
736 | ret = 1; | 708 | { |
737 | return; | 709 | GNUNET_break (0); |
710 | shutdown_now(); | ||
711 | ret = 1; | ||
712 | return; | ||
713 | } | ||
714 | if ((GNUNET_YES == GNUNET_DISK_file_test(file)) && | ||
715 | (GNUNET_OK == GNUNET_CONFIGURATION_load (properties, file))) | ||
716 | GNUNET_CONFIGURATION_iterate_sections (properties, &load_property, properties); | ||
717 | |||
718 | GNUNET_CONFIGURATION_destroy (properties); | ||
719 | GNUNET_free (file); | ||
720 | |||
721 | /* Creating statistics */ | ||
722 | stats = GNUNET_STATISTICS_create ("sysmon", mycfg); | ||
723 | if (NULL == stats) | ||
724 | { | ||
725 | GNUNET_break (0); | ||
726 | shutdown_now(); | ||
727 | ret = 1; | ||
728 | return; | ||
729 | } | ||
738 | } | 730 | } |
739 | 731 | ||
740 | /* load properties */ | 732 | /* load properties */ |
@@ -766,7 +758,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
766 | 758 | ||
767 | 759 | ||
768 | /** | 760 | /** |
769 | * The main function for the template service. | 761 | * The main function for the sysmon service. |
770 | * | 762 | * |
771 | * @param argc number of arguments from the command line | 763 | * @param argc number of arguments from the command line |
772 | * @param argv command line arguments | 764 | * @param argv command line arguments |
diff --git a/src/sysmon/sysmon-properties.conf b/src/sysmon/sysmon-properties.conf new file mode 100644 index 000000000..114404e50 --- /dev/null +++ b/src/sysmon/sysmon-properties.conf | |||
@@ -0,0 +1,14 @@ | |||
1 | #[sysmon-memory_transport] | ||
2 | #DESCRIPTION = memory transport | ||
3 | #VALUE = numeric | ||
4 | #TYPE = continous | ||
5 | #INTERVAL = 10 s | ||
6 | #CMD = ps axo c,pcpu | awk {'print $1 $0'} | ||
7 | #CMD = echo "TEST" | ||
8 | |||
9 | [sysmon-test_b] | ||
10 | DESCRIPTION = test b | ||
11 | VALUE = string | ||
12 | TYPE = continous | ||
13 | INTERVAL = 1 s | ||
14 | CMD = echo "TEST" | ||
diff --git a/src/sysmon/sysmon.conf.in b/src/sysmon/sysmon.conf.in index 4f692faa2..e9f95cc81 100644 --- a/src/sysmon/sysmon.conf.in +++ b/src/sysmon/sysmon.conf.in | |||
@@ -4,6 +4,6 @@ AUTOSTART = YES | |||
4 | HOSTNAME = localhost | 4 | HOSTNAME = localhost |
5 | HOME = $SERVICEHOME | 5 | 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 = fs transport sysmon \ No newline at end of file |