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

index ca3531e..c809fdb 100644 (file)
@@ -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);