3 #define RRD_TYPE_DISK "disk"
5 #define DISK_TYPE_PHYSICAL 1
6 #define DISK_TYPE_PARTITION 2
7 #define DISK_TYPE_CONTAINER 3
9 #ifndef NETDATA_RELOAD_MOUNTINFO_EVERY
10 #define NETDATA_RELOAD_MOUNTINFO_EVERY 60
14 char *disk; // the name of the disk (sda, sdb, etc)
22 // disk options caching
35 static struct mountinfo *disk_mountinfo_root = NULL;
37 static inline void mountinfo_reload(int force) {
38 static time_t last_loaded = 0;
39 time_t now = now_realtime_sec();
41 if(force || now - last_loaded >= NETDATA_RELOAD_MOUNTINFO_EVERY) {
42 // mountinfo_free() can be called with NULL disk_mountinfo_root
43 mountinfo_free(disk_mountinfo_root);
45 // re-read mountinfo in case something changed
46 disk_mountinfo_root = mountinfo_read();
52 static struct disk *get_disk(unsigned long major, unsigned long minor, char *disk) {
53 static char path_to_get_hw_sector_size[FILENAME_MAX + 1] = "";
54 static char path_to_get_hw_sector_size_partitions[FILENAME_MAX + 1] = "";
55 static char path_find_block_device[FILENAME_MAX + 1] = "";
58 // search for it in our RAM list.
59 // this is sequential, but since we just walk through
60 // and the number of disks / partitions in a system
61 // should not be that many, it should be acceptable
62 for(d = disk_root; d ; d = d->next)
63 if(unlikely(d->major == major && d->minor == minor))
66 // if we found it, return it
71 // create a new disk structure
72 d = (struct disk *)mallocz(sizeof(struct disk));
74 d->disk = strdupz(disk);
77 d->type = DISK_TYPE_PHYSICAL; // Default type. Changed later if not correct.
79 d->sector_size = 512; // the default, will be changed below
82 // append it to the list
83 if(unlikely(!disk_root))
87 for(last = disk_root; last->next ;last = last->next);
91 // ------------------------------------------------------------------------
92 // find the type of the device
94 char buffer[FILENAME_MAX + 1];
96 // get the default path for finding info about the block device
97 if(unlikely(!path_find_block_device[0])) {
98 snprintfz(buffer, FILENAME_MAX, "%s%s", global_host_prefix, "/sys/dev/block/%lu:%lu/%s");
99 snprintfz(path_find_block_device, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get block device infos", buffer));
102 // find if it is a partition
103 // by checking if /sys/dev/block/MAJOR:MINOR/partition is readable.
104 snprintfz(buffer, FILENAME_MAX, path_find_block_device, major, minor, "partition");
105 if(likely(access(buffer, R_OK) == 0)) {
106 d->type = DISK_TYPE_PARTITION;
109 // find if it is a container
110 // by checking if /sys/dev/block/MAJOR:MINOR/slaves has entries
111 snprintfz(buffer, FILENAME_MAX, path_find_block_device, major, minor, "slaves/");
112 DIR *dirp = opendir(buffer);
113 if(likely(dirp != NULL)) {
115 while( (dp = readdir(dirp)) ) {
116 // . and .. are also files in empty folders.
117 if(unlikely(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)) {
121 d->type = DISK_TYPE_CONTAINER;
123 // Stop the loop after we found one file.
126 if(unlikely(closedir(dirp) == -1))
127 error("Unable to close dir %s", buffer);
131 // ------------------------------------------------------------------------
132 // check if we can find its mount point
134 // mountinfo_find() can be called with NULL disk_mountinfo_root
135 struct mountinfo *mi = mountinfo_find(disk_mountinfo_root, d->major, d->minor);
137 d->mount_point = strdupz(mi->mount_point);
139 d->mount_point = NULL;
141 // ------------------------------------------------------------------------
142 // find the disk sector size
144 if(unlikely(!path_to_get_hw_sector_size[0])) {
145 snprintfz(buffer, FILENAME_MAX, "%s%s", global_host_prefix, "/sys/block/%s/queue/hw_sector_size");
146 snprintfz(path_to_get_hw_sector_size, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get h/w sector size", buffer));
148 if(unlikely(!path_to_get_hw_sector_size_partitions[0])) {
149 snprintfz(buffer, FILENAME_MAX, "%s%s", global_host_prefix, "/sys/dev/block/%lu:%lu/subsystem/%s/../queue/hw_sector_size");
150 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));
154 char tf[FILENAME_MAX + 1], *t;
155 strncpyz(tf, d->disk, FILENAME_MAX);
157 // replace all / with !
159 if(unlikely(*t == '/')) *t = '!';
161 if(likely(d->type == DISK_TYPE_PARTITION))
162 snprintfz(buffer, FILENAME_MAX, path_to_get_hw_sector_size_partitions, d->major, d->minor, tf);
164 snprintfz(buffer, FILENAME_MAX, path_to_get_hw_sector_size, tf);
166 FILE *fpss = fopen(buffer, "r");
168 char buffer2[1024 + 1];
169 char *tmp = fgets(buffer2, 1024, fpss);
172 d->sector_size = atoi(tmp);
173 if(unlikely(d->sector_size <= 0)) {
174 error("Invalid sector size %d for device %s in %s. Assuming 512.", d->sector_size, d->disk, buffer);
175 d->sector_size = 512;
178 else error("Cannot read data for sector size for device %s from %s. Assuming 512.", d->disk, buffer);
182 else error("Cannot read sector size for device %s from %s. Assuming 512.", d->disk, buffer);
188 static inline int is_major_enabled(int major) {
189 static char *major_configs = NULL;
190 static size_t major_size = 0;
192 if(major < 0) return 1;
194 size_t wanted_size = (size_t)major + 1;
196 if(major_size < wanted_size) {
197 major_configs = reallocz(major_configs, wanted_size);
200 for(i = major_size; i < wanted_size ; i++)
201 major_configs[i] = -1;
203 major_size = wanted_size;
206 if(major_configs[major] == -1) {
207 char buffer[CONFIG_MAX_NAME + 1];
208 snprintfz(buffer, CONFIG_MAX_NAME, "performance metrics for disks with major %d", major);
209 major_configs[major] = (char)config_get_boolean("plugin:proc:/proc/diskstats", buffer, 1);
212 return major_configs[major];
215 int do_proc_diskstats(int update_every, usec_t dt) {
218 static procfile *ff = NULL;
219 static int global_enable_new_disks_detected_at_runtime = CONFIG_ONDEMAND_YES,
220 global_enable_performance_for_physical_disks = CONFIG_ONDEMAND_ONDEMAND,
221 global_enable_performance_for_virtual_disks = CONFIG_ONDEMAND_ONDEMAND,
222 global_enable_performance_for_partitions = CONFIG_ONDEMAND_NO,
223 global_do_io = CONFIG_ONDEMAND_ONDEMAND,
224 global_do_ops = CONFIG_ONDEMAND_ONDEMAND,
225 global_do_mops = CONFIG_ONDEMAND_ONDEMAND,
226 global_do_iotime = CONFIG_ONDEMAND_ONDEMAND,
227 global_do_qops = CONFIG_ONDEMAND_ONDEMAND,
228 global_do_util = CONFIG_ONDEMAND_ONDEMAND,
229 global_do_backlog = CONFIG_ONDEMAND_ONDEMAND,
230 globals_initialized = 0;
232 if(unlikely(!globals_initialized)) {
233 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);
235 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);
236 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);
237 global_enable_performance_for_partitions = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "performance metrics for partitions", global_enable_performance_for_partitions);
239 global_do_io = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "bandwidth for all disks", global_do_io);
240 global_do_ops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "operations for all disks", global_do_ops);
241 global_do_mops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "merged operations for all disks", global_do_mops);
242 global_do_iotime = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "i/o time for all disks", global_do_iotime);
243 global_do_qops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "queued operations for all disks", global_do_qops);
244 global_do_util = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "utilization percentage for all disks", global_do_util);
245 global_do_backlog = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "backlog for all disks", global_do_backlog);
247 globals_initialized = 1;
250 // --------------------------------------------------------------------------
251 // this is smart enough not to reload it every time
255 // --------------------------------------------------------------------------
258 char filename[FILENAME_MAX + 1];
259 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/diskstats");
260 ff = procfile_open(config_get("plugin:proc:/proc/diskstats", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
262 if(unlikely(!ff)) return 0;
264 ff = procfile_readall(ff);
265 if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
267 uint32_t lines = procfile_lines(ff), l;
269 for(l = 0; l < lines ;l++) {
270 // --------------------------------------------------------------------------
274 unsigned long major = 0, minor = 0;
276 collected_number reads = 0, mreads = 0, readsectors = 0, readms = 0,
277 writes = 0, mwrites = 0, writesectors = 0, writems = 0,
278 queued_ios = 0, busy_ms = 0, backlog_ms = 0;
280 collected_number last_reads = 0, last_readsectors = 0, last_readms = 0,
281 last_writes = 0, last_writesectors = 0, last_writems = 0,
284 uint32_t words = procfile_linewords(ff, l);
285 if(unlikely(words < 14)) continue;
287 major = strtoul(procfile_lineword(ff, l, 0), NULL, 10);
288 minor = strtoul(procfile_lineword(ff, l, 1), NULL, 10);
289 disk = procfile_lineword(ff, l, 2);
291 // # of reads completed # of writes completed
292 // This is the total number of reads or writes completed successfully.
293 reads = strtoull(procfile_lineword(ff, l, 3), NULL, 10); // rd_ios
294 writes = strtoull(procfile_lineword(ff, l, 7), NULL, 10); // wr_ios
296 // # of reads merged # of writes merged
297 // Reads and writes which are adjacent to each other may be merged for
298 // efficiency. Thus two 4K reads may become one 8K read before it is
299 // ultimately handed to the disk, and so it will be counted (and queued)
300 mreads = strtoull(procfile_lineword(ff, l, 4), NULL, 10); // rd_merges_or_rd_sec
301 mwrites = strtoull(procfile_lineword(ff, l, 8), NULL, 10); // wr_merges
303 // # of sectors read # of sectors written
304 // This is the total number of sectors read or written successfully.
305 readsectors = strtoull(procfile_lineword(ff, l, 5), NULL, 10); // rd_sec_or_wr_ios
306 writesectors = strtoull(procfile_lineword(ff, l, 9), NULL, 10); // wr_sec
308 // # of milliseconds spent reading # of milliseconds spent writing
309 // This is the total number of milliseconds spent by all reads or writes (as
310 // measured from __make_request() to end_that_request_last()).
311 readms = strtoull(procfile_lineword(ff, l, 6), NULL, 10); // rd_ticks_or_wr_sec
312 writems = strtoull(procfile_lineword(ff, l, 10), NULL, 10); // wr_ticks
314 // # of I/Os currently in progress
315 // The only field that should go to zero. Incremented as requests are
316 // given to appropriate struct request_queue and decremented as they finish.
317 queued_ios = strtoull(procfile_lineword(ff, l, 11), NULL, 10); // ios_pgr
319 // # of milliseconds spent doing I/Os
320 // This field increases so long as field queued_ios is nonzero.
321 busy_ms = strtoull(procfile_lineword(ff, l, 12), NULL, 10); // tot_ticks
323 // weighted # of milliseconds spent doing I/Os
324 // This field is incremented at each I/O start, I/O completion, I/O
325 // merge, or read of these stats by the number of I/Os in progress
326 // (field queued_ios) times the number of milliseconds spent doing I/O since the
327 // last update of this field. This can provide an easy measure of both
328 // I/O completion time and the backlog that may be accumulating.
329 backlog_ms = strtoull(procfile_lineword(ff, l, 13), NULL, 10); // rq_ticks
332 // --------------------------------------------------------------------------
333 // remove slashes from disk names
335 for(s = disk; *s ;s++)
336 if(*s == '/') *s = '_';
338 // --------------------------------------------------------------------------
339 // get a disk structure for the disk
341 struct disk *d = get_disk(major, minor, disk);
344 // --------------------------------------------------------------------------
345 // Set its family based on mount point
347 char *family = d->mount_point;
348 if(!family) family = disk;
351 // --------------------------------------------------------------------------
352 // Check the configuration for the device
354 if(unlikely(!d->configured)) {
355 char var_name[4096 + 1];
356 snprintfz(var_name, 4096, "plugin:proc:/proc/diskstats:%s", disk);
358 int def_enable = config_get_boolean_ondemand(var_name, "enable", global_enable_new_disks_detected_at_runtime);
359 if(unlikely(def_enable == CONFIG_ONDEMAND_NO)) {
360 // the user does not want any metrics for this disk
361 d->do_io = CONFIG_ONDEMAND_NO;
362 d->do_ops = CONFIG_ONDEMAND_NO;
363 d->do_mops = CONFIG_ONDEMAND_NO;
364 d->do_iotime = CONFIG_ONDEMAND_NO;
365 d->do_qops = CONFIG_ONDEMAND_NO;
366 d->do_util = CONFIG_ONDEMAND_NO;
367 d->do_backlog = CONFIG_ONDEMAND_NO;
370 // this disk is enabled
371 // check its direct settings
373 int def_performance = CONFIG_ONDEMAND_ONDEMAND;
375 // since this is 'on demand' we can figure the performance settings
376 // based on the type of disk
379 case DISK_TYPE_PHYSICAL:
380 def_performance = global_enable_performance_for_physical_disks;
383 case DISK_TYPE_PARTITION:
384 def_performance = global_enable_performance_for_partitions;
387 case DISK_TYPE_CONTAINER:
388 def_performance = global_enable_performance_for_virtual_disks;
392 // check if we have to disable performance for this disk
394 def_performance = is_major_enabled((int)major);
396 // ------------------------------------------------------------
397 // now we have def_performance and def_space
401 // check the user configuration (this will also show our 'on demand' decision)
402 def_performance = config_get_boolean_ondemand(var_name, "enable performance metrics", def_performance);
404 int ddo_io = CONFIG_ONDEMAND_NO,
405 ddo_ops = CONFIG_ONDEMAND_NO,
406 ddo_mops = CONFIG_ONDEMAND_NO,
407 ddo_iotime = CONFIG_ONDEMAND_NO,
408 ddo_qops = CONFIG_ONDEMAND_NO,
409 ddo_util = CONFIG_ONDEMAND_NO,
410 ddo_backlog = CONFIG_ONDEMAND_NO;
412 // we enable individual performance charts only when def_performance is not disabled
413 if(unlikely(def_performance != CONFIG_ONDEMAND_NO)) {
414 ddo_io = global_do_io,
415 ddo_ops = global_do_ops,
416 ddo_mops = global_do_mops,
417 ddo_iotime = global_do_iotime,
418 ddo_qops = global_do_qops,
419 ddo_util = global_do_util,
420 ddo_backlog = global_do_backlog;
423 d->do_io = config_get_boolean_ondemand(var_name, "bandwidth", ddo_io);
424 d->do_ops = config_get_boolean_ondemand(var_name, "operations", ddo_ops);
425 d->do_mops = config_get_boolean_ondemand(var_name, "merged operations", ddo_mops);
426 d->do_iotime = config_get_boolean_ondemand(var_name, "i/o time", ddo_iotime);
427 d->do_qops = config_get_boolean_ondemand(var_name, "queued operations", ddo_qops);
428 d->do_util = config_get_boolean_ondemand(var_name, "utilization percentage", ddo_util);
429 d->do_backlog = config_get_boolean_ondemand(var_name, "backlog", ddo_backlog);
437 // --------------------------------------------------------------------------
438 // Do performance metrics
440 if(d->do_io == CONFIG_ONDEMAND_YES || (d->do_io == CONFIG_ONDEMAND_ONDEMAND && (readsectors || writesectors))) {
441 d->do_io = CONFIG_ONDEMAND_YES;
443 st = rrdset_find_bytype(RRD_TYPE_DISK, disk);
445 st = rrdset_create(RRD_TYPE_DISK, disk, NULL, family, "disk.io", "Disk I/O Bandwidth", "kilobytes/s", 2000, update_every, RRDSET_TYPE_AREA);
447 rrddim_add(st, "reads", NULL, d->sector_size, 1024, RRDDIM_INCREMENTAL);
448 rrddim_add(st, "writes", NULL, d->sector_size * -1, 1024, RRDDIM_INCREMENTAL);
450 else rrdset_next(st);
452 last_readsectors = rrddim_set(st, "reads", readsectors);
453 last_writesectors = rrddim_set(st, "writes", writesectors);
457 // --------------------------------------------------------------------
459 if(d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes))) {
460 d->do_ops = CONFIG_ONDEMAND_YES;
462 st = rrdset_find_bytype("disk_ops", disk);
464 st = rrdset_create("disk_ops", disk, NULL, family, "disk.ops", "Disk Completed I/O Operations", "operations/s", 2001, update_every, RRDSET_TYPE_LINE);
467 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
468 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
470 else rrdset_next(st);
472 last_reads = rrddim_set(st, "reads", reads);
473 last_writes = rrddim_set(st, "writes", writes);
477 // --------------------------------------------------------------------
479 if(d->do_qops == CONFIG_ONDEMAND_YES || (d->do_qops == CONFIG_ONDEMAND_ONDEMAND && queued_ios)) {
480 d->do_qops = CONFIG_ONDEMAND_YES;
482 st = rrdset_find_bytype("disk_qops", disk);
484 st = rrdset_create("disk_qops", disk, NULL, family, "disk.qops", "Disk Current I/O Operations", "operations", 2002, update_every, RRDSET_TYPE_LINE);
487 rrddim_add(st, "operations", NULL, 1, 1, RRDDIM_ABSOLUTE);
489 else rrdset_next(st);
491 rrddim_set(st, "operations", queued_ios);
495 // --------------------------------------------------------------------
497 if(d->do_backlog == CONFIG_ONDEMAND_YES || (d->do_backlog == CONFIG_ONDEMAND_ONDEMAND && backlog_ms)) {
498 d->do_backlog = CONFIG_ONDEMAND_YES;
500 st = rrdset_find_bytype("disk_backlog", disk);
502 st = rrdset_create("disk_backlog", disk, NULL, family, "disk.backlog", "Disk Backlog", "backlog (ms)", 2003, update_every, RRDSET_TYPE_AREA);
505 rrddim_add(st, "backlog", NULL, 1, 10, RRDDIM_INCREMENTAL);
507 else rrdset_next(st);
509 rrddim_set(st, "backlog", backlog_ms);
513 // --------------------------------------------------------------------
515 if(d->do_util == CONFIG_ONDEMAND_YES || (d->do_util == CONFIG_ONDEMAND_ONDEMAND && busy_ms)) {
516 d->do_util = CONFIG_ONDEMAND_YES;
518 st = rrdset_find_bytype("disk_util", disk);
520 st = rrdset_create("disk_util", disk, NULL, family, "disk.util", "Disk Utilization Time", "% of time working", 2004, update_every, RRDSET_TYPE_AREA);
523 rrddim_add(st, "utilization", NULL, 1, 10, RRDDIM_INCREMENTAL);
525 else rrdset_next(st);
527 last_busy_ms = rrddim_set(st, "utilization", busy_ms);
531 // --------------------------------------------------------------------
533 if(d->do_mops == CONFIG_ONDEMAND_YES || (d->do_mops == CONFIG_ONDEMAND_ONDEMAND && (mreads || mwrites))) {
534 d->do_mops = CONFIG_ONDEMAND_YES;
536 st = rrdset_find_bytype("disk_mops", disk);
538 st = rrdset_create("disk_mops", disk, NULL, family, "disk.mops", "Disk Merged Operations", "merged operations/s", 2021, update_every, RRDSET_TYPE_LINE);
541 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
542 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
544 else rrdset_next(st);
546 rrddim_set(st, "reads", mreads);
547 rrddim_set(st, "writes", mwrites);
551 // --------------------------------------------------------------------
553 if(d->do_iotime == CONFIG_ONDEMAND_YES || (d->do_iotime == CONFIG_ONDEMAND_ONDEMAND && (readms || writems))) {
554 d->do_iotime = CONFIG_ONDEMAND_YES;
556 st = rrdset_find_bytype("disk_iotime", disk);
558 st = rrdset_create("disk_iotime", disk, NULL, family, "disk.iotime", "Disk Total I/O Time", "milliseconds/s", 2022, update_every, RRDSET_TYPE_LINE);
561 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
562 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
564 else rrdset_next(st);
566 last_readms = rrddim_set(st, "reads", readms);
567 last_writems = rrddim_set(st, "writes", writems);
571 // --------------------------------------------------------------------
572 // calculate differential charts
573 // only if this is not the first time we run
576 if( (d->do_iotime == CONFIG_ONDEMAND_YES || (d->do_iotime == CONFIG_ONDEMAND_ONDEMAND && (readms || writems))) &&
577 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
578 st = rrdset_find_bytype("disk_await", disk);
580 st = rrdset_create("disk_await", disk, NULL, family, "disk.await", "Average Completed I/O Operation Time", "ms per operation", 2005, update_every, RRDSET_TYPE_LINE);
583 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_ABSOLUTE);
584 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_ABSOLUTE);
586 else rrdset_next(st);
588 rrddim_set(st, "reads", (reads - last_reads) ? (readms - last_readms) / (reads - last_reads) : 0);
589 rrddim_set(st, "writes", (writes - last_writes) ? (writems - last_writems) / (writes - last_writes) : 0);
593 if( (d->do_io == CONFIG_ONDEMAND_YES || (d->do_io == CONFIG_ONDEMAND_ONDEMAND && (readsectors || writesectors))) &&
594 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
595 st = rrdset_find_bytype("disk_avgsz", disk);
597 st = rrdset_create("disk_avgsz", disk, NULL, family, "disk.avgsz", "Average Completed I/O Operation Bandwidth", "kilobytes per operation", 2006, update_every, RRDSET_TYPE_AREA);
600 rrddim_add(st, "reads", NULL, d->sector_size, 1024, RRDDIM_ABSOLUTE);
601 rrddim_add(st, "writes", NULL, d->sector_size * -1, 1024, RRDDIM_ABSOLUTE);
603 else rrdset_next(st);
605 rrddim_set(st, "reads", (reads - last_reads) ? (readsectors - last_readsectors) / (reads - last_reads) : 0);
606 rrddim_set(st, "writes", (writes - last_writes) ? (writesectors - last_writesectors) / (writes - last_writes) : 0);
610 if( (d->do_util == CONFIG_ONDEMAND_YES || (d->do_util == CONFIG_ONDEMAND_ONDEMAND && busy_ms)) &&
611 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
612 st = rrdset_find_bytype("disk_svctm", disk);
614 st = rrdset_create("disk_svctm", disk, NULL, family, "disk.svctm", "Average Service Time", "ms per operation", 2007, update_every, RRDSET_TYPE_LINE);
617 rrddim_add(st, "svctm", NULL, 1, 1, RRDDIM_ABSOLUTE);
619 else rrdset_next(st);
621 rrddim_set(st, "svctm", ((reads - last_reads) + (writes - last_writes)) ? (busy_ms - last_busy_ms) / ((reads - last_reads) + (writes - last_writes)) : 0);