# define UINT_MAX 4294967295U
#endif
-#if HAVE_IOKIT_IOKITLIB_H || KERNEL_LINUX || HAVE_LIBKSTAT
-# define DISK_HAVE_READ 1
-#else
-# define DISK_HAVE_READ 0
-#endif
-
-#if DISK_HAVE_READ
#if HAVE_IOKIT_IOKITLIB_H
static mach_port_t io_master_port = MACH_PORT_NULL;
/* #endif HAVE_IOKIT_IOKITLIB_H */
extern kstat_ctl_t *kc;
static kstat_t *ksp[MAX_NUMDISK];
static int numdisk = 0;
-#endif /* HAVE_LIBKSTAT */
+/* #endif HAVE_LIBKSTAT */
+
+#else
+# error "No applicable input method."
+#endif
static int disk_init (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)
{
- plugin_complain (LOG_ERR, &complain_obj, "disk plugin: "
- "IOServiceGetMatchingServices failed.");
+ ERROR ("disk plugin: IOServiceGetMatchingServices failed.");
return (-1);
}
- else if (complain_obj.interval != 0)
- {
- plugin_relief (LOG_NOTICE, &complain_obj, "disk plugin: "
- "IOServiceGetMatchingServices succeeded.");
- }
while ((disk = IOIteratorNext (disk_list)) != 0)
{
diskstats_t *ds, *pre_ds;
- static complain_t complain_obj;
-
if ((fh = fopen ("/proc/diskstats", "r")) == NULL)
{
- if ((fh = fopen ("/proc/partitions", "r")) == NULL)
+ fh = fopen ("/proc/partitions", "r");
+ if (fh == NULL)
{
- plugin_complain (LOG_ERR, &complain_obj,
- "disk plugin: Failed to open /proc/"
- "{diskstats,partitions}.");
+ ERROR ("disk plugin: fopen (/proc/{diskstats,partitions}) failed.");
return (-1);
}
fieldshift = 1;
}
- plugin_relief (LOG_NOTICE, &complain_obj, "disk plugin: "
- "Succeeded to open /proc/{diskstats,partitions}.");
-
while (fgets (buffer, sizeof (buffer), fh) != NULL)
{
char *disk_name;
if (is_disk)
{
- if ((read_merged != -1LL) || (write_merged != -1LL))
- disk_submit (disk_name, "disk_merged",
- read_merged, write_merged);
+ disk_submit (disk_name, "disk_merged",
+ read_merged, write_merged);
} /* if (is_disk) */
} /* while (fgets (buffer, sizeof (buffer), fh) != NULL) */
return (0);
} /* int disk_read */
-#endif /* DISK_HAVE_READ */
void module_register (void)
{
-#if DISK_HAVE_READ
plugin_register_init ("disk", disk_init);
plugin_register_read ("disk", disk_read);
-#endif /* DISK_HAVE_READ */
} /* void module_register */