From de3d8a453fe7207451400323b6162b2d1cfa3258 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 10 Jul 2006 13:33:55 +0200 Subject: [PATCH] disk plugin: Use `plugin_complain' and `plugin_relief'. --- src/disk.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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); -- 2.11.0