cpu plugin: Use `plugin_complain' and `plugin_relief'.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 10 Jul 2006 11:43:28 +0000 (13:43 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 10 Jul 2006 11:43:28 +0000 (13:43 +0200)
src/cpu.c

index ca78294..b087d66 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -312,12 +312,19 @@ static void cpu_read (void)
        char *fields[9];
        int numfields;
 
+       static complain_t complain_obj;
+
        if ((fh = fopen ("/proc/stat", "r")) == NULL)
        {
-               syslog (LOG_WARNING, "cpu: fopen: %s", strerror (errno));
+               plugin_complain (LOG_ERR, &complain_obj, "cpu plugin: "
+                               "fopen (/proc/stat) failed: %s",
+                               strerror (errno));
                return;
        }
 
+       plugin_relief (LOG_NOTICE, &complain_obj, "cpu plugin: "
+                       "fopen (/proc/stat) succeeded.");
+
        while (fgets (buf, BUFSIZE, fh) != NULL)
        {
                if (strncmp (buf, "cpu", 3))
@@ -384,14 +391,21 @@ static void cpu_read (void)
        long cpuinfo[CPUSTATES];
        size_t cpuinfo_size;
 
+       static complain_t complain_obj;
+
        cpuinfo_size = sizeof (cpuinfo);
 
        if (sysctlbyname("kern.cp_time", &cpuinfo, &cpuinfo_size, NULL, 0) < 0)
        {
-               syslog (LOG_WARNING, "cpu: sysctlbyname: %s", strerror (errno));
+               plugin_complain (LOG_ERR, &complain_obj, "cpu plugin: "
+                               "sysctlbyname failed: %s.",
+                               strerror (errno));
                return;
        }
 
+       plugin_relief (LOG_NOTICE, &complain_obj, "cpu plugin: "
+                       "sysctlbyname succeeded.");
+
        cpuinfo[CP_SYS] += cpuinfo[CP_INTR];
 
        /* FIXME: Instance is always `0' */