If you don't reset the diskstats_t for a given diskname when it
disappear and the disk name is reused later (for exemple an iSCSI disk)
The "disk" plugin detect an int overflow because linux /proc/diskstats are
reseted to 0 for that diskname and the plugin send incorrect stats for
the new disk.
char buffer[1024];
char *fields[32];
char buffer[1024];
char *fields[32];
+ static unsigned int local_poll_count = 0;
derive_t read_sectors = 0;
derive_t write_sectors = 0;
derive_t read_sectors = 0;
derive_t write_sectors = 0;
disklist = ds;
else
pre_ds->next = ds;
disklist = ds;
else
pre_ds->next = ds;
+ ds->poll_count = local_poll_count;
#endif
} /* while (fgets (buffer, sizeof (buffer), fh) != NULL) */
#endif
} /* while (fgets (buffer, sizeof (buffer), fh) != NULL) */
+ local_poll_count++;
+ for (ds = disklist, pre_ds = disklist; ds != NULL;) {
+ /* test if we have seen the disk in diskstats */
+ if (ds->poll_count != local_poll_count) {
+ diskstats_t *old_ds = ds;
+ /* free the ds */
+ if (pre_ds == disklist) {
+ /* first element */
+ disklist = ds->next;
+ ds = disklist;
+ pre_ds = ds;
+ } else {
+ pre_ds->next = ds->next;
+ ds = ds->next;
+ }
+ free(old_ds);
+ } else {
+ pre_ds = ds;
+ ds = ds->next;
+ }
+ }
fclose(fh);
/* #endif defined(KERNEL_LINUX) */
fclose(fh);
/* #endif defined(KERNEL_LINUX) */