From 0d5b6e2d31f477167bdfe6fa1b80e1400e0d890f Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 10 Jul 2006 12:10:23 +0200 Subject: [PATCH] apcups plugin: Use `plugin_complain' and `plugin_relief'. --- src/apcups.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/apcups.c b/src/apcups.c index 9117bdae..a9227ab2 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -300,7 +300,7 @@ static int apc_query_server (char *host, int port, double value; static int sockfd = -1; - static unsigned int complain = 0; + static complain_t compl; #if APCMAIN # define PRINT_VALUE(name, val) printf(" Found property: name = %s; value = %f;\n", name, val) @@ -312,19 +312,14 @@ static int apc_query_server (char *host, int port, { if ((sockfd = net_open (host, NULL, port)) < 0) { - /* Complain once every six hours. */ - int complain_step = 21600 / atoi (COLLECTD_STEP); - - if ((complain % complain_step) == 0) - syslog (LOG_ERR, "apcups plugin: Connecting to the apcupsd failed."); - complain++; - + plugin_complain (LOG_ERR, &compl, "apcups plugin: " + "Connecting to the apcupsd failed."); return (-1); } - else if (complain > 1) + else { - syslog (LOG_NOTICE, "apcups plugin: Connection re-established to the apcupsd."); - complain = 0; + plugin_relief (LOG_NOTICE, &compl, "apcups plugin: " + "Connection re-established to the apcupsd."); } } -- 2.30.2