From: Florian Forster Date: Fri, 6 Apr 2007 08:08:03 +0000 (+0200) Subject: disk, tape plugin: Handle different `kstat_io_t' correctly. X-Git-Tag: collectd-4.0.0~100 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=9ac1de503689f86a1fff10c152d273251acb9fa9;p=collectd.git disk, tape plugin: Handle different `kstat_io_t' correctly. --- diff --git a/src/disk.c b/src/disk.c index 74071cfd..77122706 100644 --- a/src/disk.c +++ b/src/disk.c @@ -559,6 +559,23 @@ static int disk_read (void) /* #endif defined(KERNEL_LINUX) */ #elif HAVE_LIBKSTAT +# if HAVE_KSTAT_IO_T_WRITES && HAVE_KSTAT_IO_T_NWRITES && HAVE_KSTAT_IO_T_WTIME +# define KIO_ROCTETS reads +# define KIO_WOCTETS writes +# define KIO_ROPS nreads +# define KIO_WOPS nwrites +# define KIO_RTIME rtime +# define KIO_WTIME wtime +# elif HAVE_KSTAT_IO_T_NWRITTEN && HAVE_KSTAT_IO_T_WRITES && HAVE_KSTAT_IO_T_WTIME +# define KIO_ROCTETS nread +# define KIO_WOCTETS nwritten +# define KIO_ROPS reads +# define KIO_WOPS writes +# define KIO_RTIME rtime +# define KIO_WTIME wtime +# else +# error "kstat_io_t does not have the required members" +# endif static kstat_io_t kio; int i; @@ -572,15 +589,20 @@ static int disk_read (void) if (strncmp (ksp[i]->ks_class, "disk", 4) == 0) { - disk_submit (ksp[i]->ks_name, "disk_octets", kio.nread, kio.nwritten); - disk_submit (ksp[i]->ks_name, "disk_ops", kio.reads, kio.writes); + disk_submit (ksp[i]->ks_name, "disk_octets", + kio.KIO_ROCTETS, kio.KIO_WOCTETS); + disk_submit (ksp[i]->ks_name, "disk_ops", + kio.KIO_ROPS, kio.KIO_WOPS); /* FIXME: Convert this to microseconds if necessary */ - disk_submit (ksp[i]->ks_name, "disk_time", kio.rtime, kio.wtime); + disk_submit (ksp[i]->ks_name, "disk_time", + kio.KIO_RTIME, kio.KIO_WTIME); } else if (strncmp (ksp[i]->ks_class, "partition", 9) == 0) { - disk_submit (ksp[i]->ks_name, "disk_octets", kio.nread, kio.nwritten); - disk_submit (ksp[i]->ks_name, "disk_ops", kio.reads, kio.writes); + disk_submit (ksp[i]->ks_name, "disk_octets", + kio.KIO_ROCTETS, kio.KIO_WOCTETS); + disk_submit (ksp[i]->ks_name, "disk_ops", + kio.KIO_ROPS, kio.KIO_WOPS); } } #endif /* defined(HAVE_LIBKSTAT) */ diff --git a/src/tape.c b/src/tape.c index 2345cb34..61ce3ac7 100644 --- a/src/tape.c +++ b/src/tape.c @@ -134,6 +134,23 @@ static int tape_read (void) { #if defined(HAVE_LIBKSTAT) +# if HAVE_KSTAT_IO_T_WRITES && HAVE_KSTAT_IO_T_NWRITES && HAVE_KSTAT_IO_T_WTIME +# define KIO_ROCTETS reads +# define KIO_WOCTETS writes +# define KIO_ROPS nreads +# define KIO_WOPS nwrites +# define KIO_RTIME rtime +# define KIO_WTIME wtime +# elif HAVE_KSTAT_IO_T_NWRITTEN && HAVE_KSTAT_IO_T_WRITES && HAVE_KSTAT_IO_T_WTIME +# define KIO_ROCTETS nread +# define KIO_WOCTETS nwritten +# define KIO_ROPS reads +# define KIO_WOPS writes +# define KIO_RTIME rtime +# define KIO_WTIME wtime +# else +# error "kstat_io_t does not have the required members" +# endif static kstat_io_t kio; int i; @@ -150,10 +167,13 @@ static int tape_read (void) if (strncmp (ksp[i]->ks_class, "tape", 4) == 0) { - tape_submit (ksp[i]->ks_name, "tape_octets", kio.reads, kio.writes); - tape_submit (ksp[i]->ks_name, "tape_ops", kio.nreads, kio.nwrites); + tape_submit (ksp[i]->ks_name, "tape_octets", + kio.KIO_ROCTETS, kio.KIO_WOCTETS); + tape_submit (ksp[i]->ks_name, "tape_ops", + kio.KIO_ROPS, kio.KIO_WOPS); /* FIXME: Convert this to microseconds if necessary */ - tape_submit (ksp[i]->ks_name, "tape_time", kio.rtime, kio.wtime); + tape_submit (ksp[i]->ks_name, "tape_time", + kio.KIO_RTIME, kio.KIO_WTIME); } } #endif /* defined(HAVE_LIBKSTAT) */