From: Florian Forster Date: Mon, 10 Jul 2006 11:33:55 +0000 (+0200) Subject: disk plugin: Use `plugin_complain' and `plugin_relief'. X-Git-Tag: collectd-3.11.0~80 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=de3d8a453fe7207451400323b6162b2d1cfa3258;p=collectd.git disk plugin: Use `plugin_complain' and `plugin_relief'. --- diff --git a/src/disk.c b/src/disk.c index ca3531eb..c809fdb6 100644 --- a/src/disk.c +++ b/src/disk.c @@ -315,14 +315,22 @@ static void disk_read (void) int disk_minor; char disk_name[64]; + static complain_t complain_obj; + /* Get the list of all disk objects. */ if (IOServiceGetMatchingServices (io_master_port, IOServiceMatching (kIOBlockStorageDriverClass), &disk_list) != kIOReturnSuccess) { - syslog (LOG_ERR, "disk-plugin: IOServiceGetMatchingServices failed."); + plugin_complain (LOG_ERR, &complain_obj, "disk plugin: " + "IOServiceGetMatchingServices failed."); return; } + else if (complain_obj.interval != 0) + { + plugin_relief (LOG_NOTICE, &complain_obj, "disk plugin: " + "IOServiceGetMatchingServices succeeded."); + } while ((disk = IOIteratorNext (disk_list)) != 0) { @@ -460,15 +468,22 @@ static void disk_read (void) diskstats_t *ds, *pre_ds; + static complain_t complain_obj; + if ((fh = fopen ("/proc/diskstats", "r")) == NULL) { if ((fh = fopen ("/proc/partitions", "r")) == NULL) + { + plugin_complain (LOG_ERR, &complain_obj, "disk plugin: Failed to open /proc/{diskstats,partitions}."); return; + } /* Kernel is 2.4.* */ fieldshift = 1; } + plugin_relief (LOG_NOTICE, &complain_obj, "disk plugin: Succeeded to open /proc/{diskstats,partitions}."); + while (fgets (buffer, 1024, fh) != NULL) { numfields = strsplit (buffer, fields, 32);