From 7175a261ca86fee7143a2a2766923117d5c64e5d Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Sun, 8 Feb 2015 15:45:16 -0500 Subject: [PATCH] decrease sleep time of graphite loop --- daemon/graphite.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/daemon/graphite.c b/daemon/graphite.c index 5ef134387..38a9278e1 100644 --- a/daemon/graphite.c +++ b/daemon/graphite.c @@ -18,6 +18,7 @@ static u_int32_t graphite_ipaddress; static int graphite_port=0; static struct callmaster* cm=0; //struct totalstats totalstats_prev; +static time_t g_now, next_run; int connect_to_graphite_server(u_int32_t ipaddress, int port) { @@ -120,6 +121,12 @@ void graphite_loop_run(struct callmaster* callmaster, int seconds) { int rc=0; + g_now = time(NULL); + if (g_now < next_run) + goto sleep; + + next_run = g_now + seconds; + if (!cm) cm = callmaster; @@ -134,5 +141,6 @@ void graphite_loop_run(struct callmaster* callmaster, int seconds) { } } - sleep(seconds); +sleep: + usleep(100000); }