3 #define RRD_TYPE_DISK "disk"
5 #define DISK_TYPE_PHYSICAL 1
6 #define DISK_TYPE_PARTITION 2
7 #define DISK_TYPE_CONTAINER 3
10 char *disk; // the name of the disk (sda, sdb, etc)
18 // disk options caching
44 #define rrdset_obsolete_and_pointer_null(st) do { if(st) { rrdset_flag_set(st, RRDSET_FLAG_OBSOLETE); st = NULL; } } while(st)
46 static struct disk *get_disk(unsigned long major, unsigned long minor, char *disk) {
47 static char path_to_get_hw_sector_size[FILENAME_MAX + 1] = "";
48 static char path_to_get_hw_sector_size_partitions[FILENAME_MAX + 1] = "";
49 static char path_find_block_device[FILENAME_MAX + 1] = "";
50 static struct mountinfo *disk_mountinfo_root = NULL;
54 // search for it in our RAM list.
55 // this is sequential, but since we just walk through
56 // and the number of disks / partitions in a system
57 // should not be that many, it should be acceptable
58 for(d = disk_root; d ; d = d->next)
59 if(unlikely(d->major == major && d->minor == minor))
63 // create a new disk structure
64 d = (struct disk *)callocz(1, sizeof(struct disk));
66 d->disk = strdupz(disk);
69 d->type = DISK_TYPE_PHYSICAL; // Default type. Changed later if not correct.
71 d->sector_size = 512; // the default, will be changed below
74 // append it to the list
75 if(unlikely(!disk_root))
79 for(last = disk_root; last->next ;last = last->next);
83 // ------------------------------------------------------------------------
84 // find the type of the device
86 char buffer[FILENAME_MAX + 1];
88 // get the default path for finding info about the block device
89 if(unlikely(!path_find_block_device[0])) {
90 snprintfz(buffer, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/dev/block/%lu:%lu/%s");
91 snprintfz(path_find_block_device, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get block device infos", buffer));
94 // find if it is a partition
95 // by checking if /sys/dev/block/MAJOR:MINOR/partition is readable.
96 snprintfz(buffer, FILENAME_MAX, path_find_block_device, major, minor, "partition");
97 if(likely(access(buffer, R_OK) == 0)) {
98 d->type = DISK_TYPE_PARTITION;
101 // find if it is a container
102 // by checking if /sys/dev/block/MAJOR:MINOR/slaves has entries
103 snprintfz(buffer, FILENAME_MAX, path_find_block_device, major, minor, "slaves/");
104 DIR *dirp = opendir(buffer);
105 if(likely(dirp != NULL)) {
107 while( (dp = readdir(dirp)) ) {
108 // . and .. are also files in empty folders.
109 if(unlikely(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)) {
113 d->type = DISK_TYPE_CONTAINER;
115 // Stop the loop after we found one file.
118 if(unlikely(closedir(dirp) == -1))
119 error("Unable to close dir %s", buffer);
123 // ------------------------------------------------------------------------
124 // check if we can find its mount point
126 // mountinfo_find() can be called with NULL disk_mountinfo_root
127 struct mountinfo *mi = mountinfo_find(disk_mountinfo_root, d->major, d->minor);
129 // mountinfo_free can be called with NULL
130 mountinfo_free(disk_mountinfo_root);
131 disk_mountinfo_root = mountinfo_read(0);
132 mi = mountinfo_find(disk_mountinfo_root, d->major, d->minor);
136 d->mount_point = strdupz(mi->mount_point);
138 d->mount_point = NULL;
140 // ------------------------------------------------------------------------
141 // find the disk sector size
143 if(unlikely(!path_to_get_hw_sector_size[0])) {
144 snprintfz(buffer, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/block/%s/queue/hw_sector_size");
145 snprintfz(path_to_get_hw_sector_size, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get h/w sector size", buffer));
147 if(unlikely(!path_to_get_hw_sector_size_partitions[0])) {
148 snprintfz(buffer, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/dev/block/%lu:%lu/subsystem/%s/../queue/hw_sector_size");
149 snprintfz(path_to_get_hw_sector_size_partitions, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get h/w sector size for partitions", buffer));
153 char tf[FILENAME_MAX + 1], *t;
154 strncpyz(tf, d->disk, FILENAME_MAX);
156 // replace all / with !
158 if(unlikely(*t == '/')) *t = '!';
160 if(likely(d->type == DISK_TYPE_PARTITION))
161 snprintfz(buffer, FILENAME_MAX, path_to_get_hw_sector_size_partitions, d->major, d->minor, tf);
163 snprintfz(buffer, FILENAME_MAX, path_to_get_hw_sector_size, tf);
165 FILE *fpss = fopen(buffer, "r");
167 char buffer2[1024 + 1];
168 char *tmp = fgets(buffer2, 1024, fpss);
171 d->sector_size = str2i(tmp);
172 if(unlikely(d->sector_size <= 0)) {
173 error("Invalid sector size %d for device %s in %s. Assuming 512.", d->sector_size, d->disk, buffer);
174 d->sector_size = 512;
177 else error("Cannot read data for sector size for device %s from %s. Assuming 512.", d->disk, buffer);
181 else error("Cannot read sector size for device %s from %s. Assuming 512.", d->disk, buffer);
187 static inline int is_major_enabled(int major) {
188 static int8_t *major_configs = NULL;
189 static size_t major_size = 0;
191 if(major < 0) return 1;
193 size_t wanted_size = (size_t)major + 1;
195 if(major_size < wanted_size) {
196 major_configs = reallocz(major_configs, wanted_size * sizeof(int8_t));
199 for(i = major_size; i < wanted_size ; i++)
200 major_configs[i] = -1;
202 major_size = wanted_size;
205 if(major_configs[major] == -1) {
206 char buffer[CONFIG_MAX_NAME + 1];
207 snprintfz(buffer, CONFIG_MAX_NAME, "performance metrics for disks with major %d", major);
208 major_configs[major] = (char)config_get_boolean("plugin:proc:/proc/diskstats", buffer, 1);
211 return (int)major_configs[major];
214 int do_proc_diskstats(int update_every, usec_t dt) {
215 static procfile *ff = NULL;
216 static int global_enable_new_disks_detected_at_runtime = CONFIG_BOOLEAN_YES,
217 global_enable_performance_for_physical_disks = CONFIG_BOOLEAN_AUTO,
218 global_enable_performance_for_virtual_disks = CONFIG_BOOLEAN_AUTO,
219 global_enable_performance_for_partitions = CONFIG_BOOLEAN_NO,
220 global_do_io = CONFIG_BOOLEAN_AUTO,
221 global_do_ops = CONFIG_BOOLEAN_AUTO,
222 global_do_mops = CONFIG_BOOLEAN_AUTO,
223 global_do_iotime = CONFIG_BOOLEAN_AUTO,
224 global_do_qops = CONFIG_BOOLEAN_AUTO,
225 global_do_util = CONFIG_BOOLEAN_AUTO,
226 global_do_backlog = CONFIG_BOOLEAN_AUTO,
227 globals_initialized = 0;
229 if(unlikely(!globals_initialized)) {
230 global_enable_new_disks_detected_at_runtime = config_get_boolean("plugin:proc:/proc/diskstats", "enable new disks detected at runtime", global_enable_new_disks_detected_at_runtime);
232 global_enable_performance_for_physical_disks = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "performance metrics for physical disks", global_enable_performance_for_physical_disks);
233 global_enable_performance_for_virtual_disks = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "performance metrics for virtual disks", global_enable_performance_for_virtual_disks);
234 global_enable_performance_for_partitions = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "performance metrics for partitions", global_enable_performance_for_partitions);
236 global_do_io = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "bandwidth for all disks", global_do_io);
237 global_do_ops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "operations for all disks", global_do_ops);
238 global_do_mops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "merged operations for all disks", global_do_mops);
239 global_do_iotime = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "i/o time for all disks", global_do_iotime);
240 global_do_qops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "queued operations for all disks", global_do_qops);
241 global_do_util = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "utilization percentage for all disks", global_do_util);
242 global_do_backlog = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "backlog for all disks", global_do_backlog);
244 globals_initialized = 1;
247 // --------------------------------------------------------------------------
250 char filename[FILENAME_MAX + 1];
251 snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/diskstats");
252 ff = procfile_open(config_get("plugin:proc:/proc/diskstats", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
254 if(unlikely(!ff)) return 0;
256 ff = procfile_readall(ff);
257 if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
259 size_t lines = procfile_lines(ff), l;
261 for(l = 0; l < lines ;l++) {
262 // --------------------------------------------------------------------------
266 unsigned long major = 0, minor = 0;
268 collected_number reads = 0, mreads = 0, readsectors = 0, readms = 0,
269 writes = 0, mwrites = 0, writesectors = 0, writems = 0,
270 queued_ios = 0, busy_ms = 0, backlog_ms = 0;
272 collected_number last_reads = 0, last_readsectors = 0, last_readms = 0,
273 last_writes = 0, last_writesectors = 0, last_writems = 0,
276 size_t words = procfile_linewords(ff, l);
277 if(unlikely(words < 14)) continue;
279 major = str2ul(procfile_lineword(ff, l, 0));
280 minor = str2ul(procfile_lineword(ff, l, 1));
281 disk = procfile_lineword(ff, l, 2);
283 // # of reads completed # of writes completed
284 // This is the total number of reads or writes completed successfully.
285 reads = str2ull(procfile_lineword(ff, l, 3)); // rd_ios
286 writes = str2ull(procfile_lineword(ff, l, 7)); // wr_ios
288 // # of reads merged # of writes merged
289 // Reads and writes which are adjacent to each other may be merged for
290 // efficiency. Thus two 4K reads may become one 8K read before it is
291 // ultimately handed to the disk, and so it will be counted (and queued)
292 mreads = str2ull(procfile_lineword(ff, l, 4)); // rd_merges_or_rd_sec
293 mwrites = str2ull(procfile_lineword(ff, l, 8)); // wr_merges
295 // # of sectors read # of sectors written
296 // This is the total number of sectors read or written successfully.
297 readsectors = str2ull(procfile_lineword(ff, l, 5)); // rd_sec_or_wr_ios
298 writesectors = str2ull(procfile_lineword(ff, l, 9)); // wr_sec
300 // # of milliseconds spent reading # of milliseconds spent writing
301 // This is the total number of milliseconds spent by all reads or writes (as
302 // measured from __make_request() to end_that_request_last()).
303 readms = str2ull(procfile_lineword(ff, l, 6)); // rd_ticks_or_wr_sec
304 writems = str2ull(procfile_lineword(ff, l, 10)); // wr_ticks
306 // # of I/Os currently in progress
307 // The only field that should go to zero. Incremented as requests are
308 // given to appropriate struct request_queue and decremented as they finish.
309 queued_ios = str2ull(procfile_lineword(ff, l, 11)); // ios_pgr
311 // # of milliseconds spent doing I/Os
312 // This field increases so long as field queued_ios is nonzero.
313 busy_ms = str2ull(procfile_lineword(ff, l, 12)); // tot_ticks
315 // weighted # of milliseconds spent doing I/Os
316 // This field is incremented at each I/O start, I/O completion, I/O
317 // merge, or read of these stats by the number of I/Os in progress
318 // (field queued_ios) times the number of milliseconds spent doing I/O since the
319 // last update of this field. This can provide an easy measure of both
320 // I/O completion time and the backlog that may be accumulating.
321 backlog_ms = str2ull(procfile_lineword(ff, l, 13)); // rq_ticks
324 // --------------------------------------------------------------------------
325 // remove slashes from disk names
327 for(s = disk; *s ;s++)
328 if(*s == '/') *s = '_';
330 // --------------------------------------------------------------------------
331 // get a disk structure for the disk
333 struct disk *d = get_disk(major, minor, disk);
336 // --------------------------------------------------------------------------
337 // Set its family based on mount point
339 char *family = d->mount_point;
340 if(!family) family = disk;
343 // --------------------------------------------------------------------------
344 // Check the configuration for the device
346 if(unlikely(!d->configured)) {
347 char var_name[4096 + 1];
348 snprintfz(var_name, 4096, "plugin:proc:/proc/diskstats:%s", disk);
350 int def_enable = config_get_boolean_ondemand(var_name, "enable", global_enable_new_disks_detected_at_runtime);
351 if(unlikely(def_enable == CONFIG_BOOLEAN_NO)) {
352 // the user does not want any metrics for this disk
353 d->do_io = CONFIG_BOOLEAN_NO;
354 d->do_ops = CONFIG_BOOLEAN_NO;
355 d->do_mops = CONFIG_BOOLEAN_NO;
356 d->do_iotime = CONFIG_BOOLEAN_NO;
357 d->do_qops = CONFIG_BOOLEAN_NO;
358 d->do_util = CONFIG_BOOLEAN_NO;
359 d->do_backlog = CONFIG_BOOLEAN_NO;
362 // this disk is enabled
363 // check its direct settings
365 int def_performance = CONFIG_BOOLEAN_AUTO;
367 // since this is 'on demand' we can figure the performance settings
368 // based on the type of disk
371 case DISK_TYPE_PHYSICAL:
372 def_performance = global_enable_performance_for_physical_disks;
375 case DISK_TYPE_PARTITION:
376 def_performance = global_enable_performance_for_partitions;
379 case DISK_TYPE_CONTAINER:
380 def_performance = global_enable_performance_for_virtual_disks;
384 // check if we have to disable performance for this disk
386 def_performance = is_major_enabled((int)major);
388 // ------------------------------------------------------------
389 // now we have def_performance and def_space
393 // check the user configuration (this will also show our 'on demand' decision)
394 def_performance = config_get_boolean_ondemand(var_name, "enable performance metrics", def_performance);
396 int ddo_io = CONFIG_BOOLEAN_NO,
397 ddo_ops = CONFIG_BOOLEAN_NO,
398 ddo_mops = CONFIG_BOOLEAN_NO,
399 ddo_iotime = CONFIG_BOOLEAN_NO,
400 ddo_qops = CONFIG_BOOLEAN_NO,
401 ddo_util = CONFIG_BOOLEAN_NO,
402 ddo_backlog = CONFIG_BOOLEAN_NO;
404 // we enable individual performance charts only when def_performance is not disabled
405 if(unlikely(def_performance != CONFIG_BOOLEAN_NO)) {
406 ddo_io = global_do_io,
407 ddo_ops = global_do_ops,
408 ddo_mops = global_do_mops,
409 ddo_iotime = global_do_iotime,
410 ddo_qops = global_do_qops,
411 ddo_util = global_do_util,
412 ddo_backlog = global_do_backlog;
415 d->do_io = config_get_boolean_ondemand(var_name, "bandwidth", ddo_io);
416 d->do_ops = config_get_boolean_ondemand(var_name, "operations", ddo_ops);
417 d->do_mops = config_get_boolean_ondemand(var_name, "merged operations", ddo_mops);
418 d->do_iotime = config_get_boolean_ondemand(var_name, "i/o time", ddo_iotime);
419 d->do_qops = config_get_boolean_ondemand(var_name, "queued operations", ddo_qops);
420 d->do_util = config_get_boolean_ondemand(var_name, "utilization percentage", ddo_util);
421 d->do_backlog = config_get_boolean_ondemand(var_name, "backlog", ddo_backlog);
427 // --------------------------------------------------------------------------
428 // Do performance metrics
430 if(d->do_io == CONFIG_BOOLEAN_YES || (d->do_io == CONFIG_BOOLEAN_AUTO && (readsectors || writesectors))) {
431 d->do_io = CONFIG_BOOLEAN_YES;
433 if(unlikely(!d->st_io)) {
434 d->st_io = rrdset_create_localhost(
440 , "Disk I/O Bandwidth"
447 rrddim_add(d->st_io, "reads", NULL, d->sector_size, 1024, RRD_ALGORITHM_INCREMENTAL);
448 rrddim_add(d->st_io, "writes", NULL, d->sector_size * -1, 1024, RRD_ALGORITHM_INCREMENTAL);
450 else rrdset_next(d->st_io);
452 last_readsectors = rrddim_set(d->st_io, "reads", readsectors);
453 last_writesectors = rrddim_set(d->st_io, "writes", writesectors);
454 rrdset_done(d->st_io);
457 // --------------------------------------------------------------------
459 if(d->do_ops == CONFIG_BOOLEAN_YES || (d->do_ops == CONFIG_BOOLEAN_AUTO && (reads || writes))) {
460 d->do_ops = CONFIG_BOOLEAN_YES;
462 if(unlikely(!d->st_ops)) {
463 d->st_ops = rrdset_create_localhost(
469 , "Disk Completed I/O Operations"
476 rrdset_flag_set(d->st_ops, RRDSET_FLAG_DETAIL);
478 rrddim_add(d->st_ops, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
479 rrddim_add(d->st_ops, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
481 else rrdset_next(d->st_ops);
483 last_reads = rrddim_set(d->st_ops, "reads", reads);
484 last_writes = rrddim_set(d->st_ops, "writes", writes);
485 rrdset_done(d->st_ops);
488 // --------------------------------------------------------------------
490 if(d->do_qops == CONFIG_BOOLEAN_YES || (d->do_qops == CONFIG_BOOLEAN_AUTO && queued_ios)) {
491 d->do_qops = CONFIG_BOOLEAN_YES;
493 if(unlikely(!d->st_qops)) {
494 d->st_qops = rrdset_create_localhost(
500 , "Disk Current I/O Operations"
507 rrdset_flag_set(d->st_qops, RRDSET_FLAG_DETAIL);
509 rrddim_add(d->st_qops, "operations", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
511 else rrdset_next(d->st_qops);
513 rrddim_set(d->st_qops, "operations", queued_ios);
514 rrdset_done(d->st_qops);
517 // --------------------------------------------------------------------
519 if(d->do_backlog == CONFIG_BOOLEAN_YES || (d->do_backlog == CONFIG_BOOLEAN_AUTO && backlog_ms)) {
520 d->do_backlog = CONFIG_BOOLEAN_YES;
522 if(unlikely(!d->st_backlog)) {
523 d->st_backlog = rrdset_create_localhost(
536 rrdset_flag_set(d->st_backlog, RRDSET_FLAG_DETAIL);
538 rrddim_add(d->st_backlog, "backlog", NULL, 1, 10, RRD_ALGORITHM_INCREMENTAL);
540 else rrdset_next(d->st_backlog);
542 rrddim_set(d->st_backlog, "backlog", backlog_ms);
543 rrdset_done(d->st_backlog);
546 // --------------------------------------------------------------------
548 if(d->do_util == CONFIG_BOOLEAN_YES || (d->do_util == CONFIG_BOOLEAN_AUTO && busy_ms)) {
549 d->do_util = CONFIG_BOOLEAN_YES;
551 if(unlikely(!d->st_util)) {
552 d->st_util = rrdset_create_localhost(
558 , "Disk Utilization Time"
559 , "% of time working"
565 rrdset_flag_set(d->st_util, RRDSET_FLAG_DETAIL);
567 rrddim_add(d->st_util, "utilization", NULL, 1, 10, RRD_ALGORITHM_INCREMENTAL);
569 else rrdset_next(d->st_util);
571 last_busy_ms = rrddim_set(d->st_util, "utilization", busy_ms);
572 rrdset_done(d->st_util);
575 // --------------------------------------------------------------------
577 if(d->do_mops == CONFIG_BOOLEAN_YES || (d->do_mops == CONFIG_BOOLEAN_AUTO && (mreads || mwrites))) {
578 d->do_mops = CONFIG_BOOLEAN_YES;
580 if(unlikely(!d->st_mops)) {
581 d->st_mops = rrdset_create_localhost(
587 , "Disk Merged Operations"
588 , "merged operations/s"
594 rrdset_flag_set(d->st_mops, RRDSET_FLAG_DETAIL);
596 rrddim_add(d->st_mops, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
597 rrddim_add(d->st_mops, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
599 else rrdset_next(d->st_mops);
601 rrddim_set(d->st_mops, "reads", mreads);
602 rrddim_set(d->st_mops, "writes", mwrites);
603 rrdset_done(d->st_mops);
606 // --------------------------------------------------------------------
608 if(d->do_iotime == CONFIG_BOOLEAN_YES || (d->do_iotime == CONFIG_BOOLEAN_AUTO && (readms || writems))) {
609 d->do_iotime = CONFIG_BOOLEAN_YES;
611 if(unlikely(!d->st_iotime)) {
612 d->st_iotime = rrdset_create_localhost(
618 , "Disk Total I/O Time"
625 rrdset_flag_set(d->st_iotime, RRDSET_FLAG_DETAIL);
627 rrddim_add(d->st_iotime, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
628 rrddim_add(d->st_iotime, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
630 else rrdset_next(d->st_iotime);
632 last_readms = rrddim_set(d->st_iotime, "reads", readms);
633 last_writems = rrddim_set(d->st_iotime, "writes", writems);
634 rrdset_done(d->st_iotime);
637 // --------------------------------------------------------------------
638 // calculate differential charts
639 // only if this is not the first time we run
642 if( (d->do_iotime == CONFIG_BOOLEAN_YES || (d->do_iotime == CONFIG_BOOLEAN_AUTO && (readms || writems))) &&
643 (d->do_ops == CONFIG_BOOLEAN_YES || (d->do_ops == CONFIG_BOOLEAN_AUTO && (reads || writes)))) {
645 if(unlikely(!d->st_await)) {
646 d->st_await = rrdset_create_localhost(
652 , "Average Completed I/O Operation Time"
659 rrdset_flag_set(d->st_await, RRDSET_FLAG_DETAIL);
661 rrddim_add(d->st_await, "reads", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
662 rrddim_add(d->st_await, "writes", NULL, -1, 1, RRD_ALGORITHM_ABSOLUTE);
664 else rrdset_next(d->st_await);
666 rrddim_set(d->st_await, "reads", (reads - last_reads) ? (readms - last_readms) / (reads - last_reads) : 0);
667 rrddim_set(d->st_await, "writes", (writes - last_writes) ? (writems - last_writems) / (writes - last_writes) : 0);
668 rrdset_done(d->st_await);
671 if( (d->do_io == CONFIG_BOOLEAN_YES || (d->do_io == CONFIG_BOOLEAN_AUTO && (readsectors || writesectors))) &&
672 (d->do_ops == CONFIG_BOOLEAN_YES || (d->do_ops == CONFIG_BOOLEAN_AUTO && (reads || writes)))) {
674 if(unlikely(!d->st_avgsz)) {
675 d->st_avgsz = rrdset_create_localhost(
681 , "Average Completed I/O Operation Bandwidth"
682 , "kilobytes per operation"
688 rrdset_flag_set(d->st_avgsz, RRDSET_FLAG_DETAIL);
690 rrddim_add(d->st_avgsz, "reads", NULL, d->sector_size, 1024, RRD_ALGORITHM_ABSOLUTE);
691 rrddim_add(d->st_avgsz, "writes", NULL, d->sector_size * -1, 1024, RRD_ALGORITHM_ABSOLUTE);
693 else rrdset_next(d->st_avgsz);
695 rrddim_set(d->st_avgsz, "reads", (reads - last_reads) ? (readsectors - last_readsectors) / (reads - last_reads) : 0);
696 rrddim_set(d->st_avgsz, "writes", (writes - last_writes) ? (writesectors - last_writesectors) / (writes - last_writes) : 0);
697 rrdset_done(d->st_avgsz);
700 if( (d->do_util == CONFIG_BOOLEAN_YES || (d->do_util == CONFIG_BOOLEAN_AUTO && busy_ms)) &&
701 (d->do_ops == CONFIG_BOOLEAN_YES || (d->do_ops == CONFIG_BOOLEAN_AUTO && (reads || writes)))) {
703 if(unlikely(!d->st_svctm)) {
704 d->st_svctm = rrdset_create_localhost(
710 , "Average Service Time"
717 rrdset_flag_set(d->st_svctm, RRDSET_FLAG_DETAIL);
719 rrddim_add(d->st_svctm, "svctm", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
721 else rrdset_next(d->st_svctm);
723 rrddim_set(d->st_svctm, "svctm", ((reads - last_reads) + (writes - last_writes)) ? (busy_ms - last_busy_ms) / ((reads - last_reads) + (writes - last_writes)) : 0);
724 rrdset_done(d->st_svctm);
729 // cleanup removed disks
731 struct disk *d = disk_root, *last = NULL;
733 if(unlikely(!d->updated)) {
736 rrdset_obsolete_and_pointer_null(d->st_avgsz);
737 rrdset_obsolete_and_pointer_null(d->st_await);
738 rrdset_obsolete_and_pointer_null(d->st_backlog);
739 rrdset_obsolete_and_pointer_null(d->st_io);
740 rrdset_obsolete_and_pointer_null(d->st_iotime);
741 rrdset_obsolete_and_pointer_null(d->st_mops);
742 rrdset_obsolete_and_pointer_null(d->st_ops);
743 rrdset_obsolete_and_pointer_null(d->st_qops);
744 rrdset_obsolete_and_pointer_null(d->st_svctm);
745 rrdset_obsolete_and_pointer_null(d->st_util);
748 disk_root = d = d->next;
752 last->next = d = d->next;
756 freez(t->mount_point);