From: Florian Forster Date: Mon, 10 Jul 2006 11:43:28 +0000 (+0200) Subject: cpu plugin: Use `plugin_complain' and `plugin_relief'. X-Git-Tag: collectd-3.11.0~79 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f5bbe1f3146b3d002e77293df8e08caa42fc5cc5;p=collectd.git cpu plugin: Use `plugin_complain' and `plugin_relief'. --- diff --git a/src/cpu.c b/src/cpu.c index ca782941..b087d665 100644 --- 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' */