From: Florian Forster Date: Mon, 15 Oct 2018 19:17:55 +0000 (+0200) Subject: disk plugin: Drop support for Linux 2.4. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=42f8dc033f5009dda7202ceee97e57bbbedf6fc3;p=collectd.git disk plugin: Drop support for Linux 2.4. --- diff --git a/src/disk.c b/src/disk.c index 23354a69..c0408cec 100644 --- a/src/disk.c +++ b/src/disk.c @@ -663,7 +663,6 @@ static int disk_read(void) { char *fields[32]; int numfields; - int fieldshift = 0; int minor = 0; @@ -684,14 +683,8 @@ static int disk_read(void) { diskstats_t *ds, *pre_ds; if ((fh = fopen("/proc/diskstats", "r")) == NULL) { - fh = fopen("/proc/partitions", "r"); - if (fh == NULL) { - ERROR("disk plugin: fopen (/proc/{diskstats,partitions}) failed."); - return -1; - } - - /* Kernel is 2.4.* */ - fieldshift = 1; + ERROR("disk plugin: fopen(\"/proc/diskstats\"): %s", STRERRNO); + return -1; } while (fgets(buffer, sizeof(buffer), fh) != NULL) { @@ -699,13 +692,12 @@ static int disk_read(void) { char *output_name; numfields = strsplit(buffer, fields, 32); - - if ((numfields != (14 + fieldshift)) && (numfields != 7)) + if ((numfields != 14) && (numfields != 7)) continue; minor = atoll(fields[1]); - disk_name = fields[2 + fieldshift]; + disk_name = fields[2]; for (ds = disklist, pre_ds = disklist; ds != NULL; pre_ds = ds, ds = ds->next) @@ -734,24 +726,24 @@ static int disk_read(void) { read_sectors = atoll(fields[4]); write_ops = atoll(fields[5]); write_sectors = atoll(fields[6]); - } else if (numfields == (14 + fieldshift)) { - read_ops = atoll(fields[3 + fieldshift]); - write_ops = atoll(fields[7 + fieldshift]); + } else if (numfields == 14) { + read_ops = atoll(fields[3]); + write_ops = atoll(fields[7]); - read_sectors = atoll(fields[5 + fieldshift]); - write_sectors = atoll(fields[9 + fieldshift]); + read_sectors = atoll(fields[5]); + write_sectors = atoll(fields[9]); - if ((fieldshift == 0) || (minor == 0)) { + if (minor == 0) { is_disk = 1; - read_merged = atoll(fields[4 + fieldshift]); - read_time = atoll(fields[6 + fieldshift]); - write_merged = atoll(fields[8 + fieldshift]); - write_time = atoll(fields[10 + fieldshift]); + read_merged = atoll(fields[4]); + read_time = atoll(fields[6]); + write_merged = atoll(fields[8]); + write_time = atoll(fields[10]); - in_progress = atof(fields[11 + fieldshift]); + in_progress = atof(fields[11]); - io_time = atof(fields[12 + fieldshift]); - weighted_time = atof(fields[13 + fieldshift]); + io_time = atof(fields[12]); + weighted_time = atof(fields[13]); } } else { DEBUG("numfields = %i; => unknown file format.", numfields);