From 789ab1dfc5af77cfe8c343b3b4f4662a996645df Mon Sep 17 00:00:00 2001 From: octo Date: Wed, 31 May 2006 07:04:40 +0000 Subject: [PATCH] ntpd branch: Added config-code to the ntpd plugin, so one can configure the host and port to use/query. --- src/ntpd.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/ntpd.c b/src/ntpd.c index 0fa3b349..b9e73445 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -55,6 +55,14 @@ # include #endif +static char *config_keys[] = +{ + "Host", + "Port", + NULL +}; +static int config_keys_num = 2; + /* drift */ static char *time_offset_file = "ntpd/time_offset-%s.rrd"; static char *time_offset_ds_def[] = @@ -253,6 +261,30 @@ struct info_kernel * End of the copied stuff.. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +static int ntpd_config (char *key, char *value) +{ + if (strcasecmp (key, "host") == 0) + { + if (ntpd_host != NULL) + free (ntpd_host); + if ((ntpd_host = strdup (value)) == NULL) + return (1); + } + else if (strcasecmp (key, "port") == 0) + { + if (ntpd_port != NULL) + free (ntpd_port); + if ((ntpd_port = strdup (value)) == NULL) + return (1); + } + else + { + return (-1); + } + + return (0); +} + static void ntpd_init (void) { return; @@ -882,6 +914,7 @@ void module_register (void) plugin_register (MODULE_NAME, ntpd_init, ntpd_read, NULL); plugin_register ("ntpd_time_offset", NULL, NULL, ntpd_write_time_offset); plugin_register ("ntpd_frequency_offset", NULL, NULL, ntpd_write_frequency_offset); + cf_register (MODULE_NAME, ntpd_config, config_keys, config_keys_num); } #undef MODULE_NAME -- 2.11.0