X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdisk.c;h=e2ae14e1a4c8c4fd021cd2c7343ef8930a040f34;hb=d5ad844588fcbcdcdd36a889c94ac33d36c1d52c;hp=5491dcbd625f99124a4abf456a22ac5976aaafea;hpb=8c30c4c84066525fd3efc4bd14b195e27b4ccde3;p=collectd.git diff --git a/src/disk.c b/src/disk.c index 5491dcbd..e2ae14e1 100644 --- a/src/disk.c +++ b/src/disk.c @@ -59,6 +59,10 @@ # define UINT_MAX 4294967295U #endif +#if HAVE_STATGRAB_H +# include +#endif + #if HAVE_IOKIT_IOKITLIB_H static mach_port_t io_master_port = MACH_PORT_NULL; /* #endif HAVE_IOKIT_IOKITLIB_H */ @@ -98,6 +102,9 @@ static kstat_t *ksp[MAX_NUMDISK]; static int numdisk = 0; /* #endif HAVE_LIBKSTAT */ +#elif defined(HAVE_LIBSTATGRAB) +/* #endif HAVE_LIBKSTATGRAB */ + #else # error "No applicable input method." #endif @@ -659,7 +666,23 @@ static int disk_read (void) kio.KIO_ROPS, kio.KIO_WOPS); } } -#endif /* defined(HAVE_LIBKSTAT) */ +/* #endif defined(HAVE_LIBKSTAT) */ + +#elif defined(HAVE_LIBSTATGRAB) + sg_disk_io_stats *ds; + int disks, counter; + char name[16]; + + if ((ds = sg_get_disk_io_stats(&disks)) == NULL) + return (0); + + for (counter=0; counter < disks; counter++) { + strncpy(name, ds->disk_name, sizeof(name)); + name[sizeof(name)-1] = '\0'; /* strncpy doesn't terminate longer strings */ + disk_submit (name, "disk_octets", ds->read_bytes, ds->write_bytes); + ds++; + } +#endif /* defined(HAVE_LIBSTATGRAB) */ return (0); } /* int disk_read */