summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6be1b3f)
raw | patch | inline | side by side (parent: 6be1b3f)
author | Claudius Zingerli <gitmail@zeuz.ch> | |
Sun, 6 Sep 2015 21:39:22 +0000 (23:39 +0200) | ||
committer | Claudius Zingerli <gitmail@zeuz.ch> | |
Fri, 29 Apr 2016 15:23:17 +0000 (17:23 +0200) |
src/chrony.c | patch | blob | history | |
src/collectd.conf.in | patch | blob | history |
diff --git a/src/chrony.c b/src/chrony.c
index 1d7bdcea84c3ef058e28d1628e881cf746d61702..cbbc108918854c7e8224d155f68650aecd0ca879 100644 (file)
--- a/src/chrony.c
+++ b/src/chrony.c
static int chrony_connect()
{
+ DEBUG("chrony plugin: Connecting to %s:%s", g_chrony_host, g_chrony_port);
int socket = connect_client(g_chrony_host, g_chrony_port, AF_UNSPEC, SOCK_DGRAM);
if (socket < 0)
{
ERROR ("chrony plugin: Error connecting to daemon. Errno = %d", errno);
return (1);
}
+ //TODO: Set timeouts!
+ DEBUG("chrony plugin: Connected");
g_chrony_socket = socket;
return (0);
}
@@ -222,14 +225,19 @@ static int chrony_query(int p_command, tChrony_Request *p_req, tChrony_Response
p_req->header.f_cmd_try = 0;
p_req->header.f_seq = g_chrony_seq++;
+ DEBUG("chrony plugin: Sending request");
if (chrony_send_request(p_req,req_size) != 0)
{
break;
}
+
+ DEBUG("chrony plugin: Waiting for response");
if (chrony_recv_response(p_resp,resp_size,p_resp_size) != 0)
{
break;
}
+ DEBUG("chrony plugin: Received response");
+
return (0);
} while (0);
tChrony_Response chrony_resp;
size_t chrony_resp_size;
+ DEBUG("chrony plugin: Requesting data");
chrony_init_req(&chrony_req);
status = chrony_query (REQ_N_SOURCES, &chrony_req, &chrony_resp, &chrony_resp_size);
if (status != 0)
static int chrony_shutdown()
{
+ if (g_is_connected != 0)
+ {
+ close(g_chrony_socket);
+ g_is_connected = 0;
+ }
+ if (g_chrony_host != NULL)
+ {
+ free (g_chrony_host);
+ g_chrony_host = NULL;
+ }
+ if (g_chrony_port != NULL)
+ {
+ free (g_chrony_port);
+ g_chrony_port = NULL;
+ }
return (0);
}
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index d00cfe294014bb00ee768b298be32d71af93b541..3b55a8b50c549f58a427d7d13ab0802037228554 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
#<Plugin chrony>
# Host "localhost"
-# Port 323
+# Port "323"
#</Plugin>
#<Plugin cgroups>