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
31 static struct disk *get_disk(unsigned long major, unsigned long minor, char *disk) {
32 static char path_to_get_hw_sector_size[FILENAME_MAX + 1] = "";
33 static char path_to_get_hw_sector_size_partitions[FILENAME_MAX + 1] = "";
34 static char path_find_block_device[FILENAME_MAX + 1] = "";
35 static struct mountinfo *disk_mountinfo_root = NULL;
39 // search for it in our RAM list.
40 // this is sequential, but since we just walk through
41 // and the number of disks / partitions in a system
42 // should not be that many, it should be acceptable
43 for(d = disk_root; d ; d = d->next)
44 if(unlikely(d->major == major && d->minor == minor))
48 // create a new disk structure
49 d = (struct disk *)mallocz(sizeof(struct disk));
51 d->disk = strdupz(disk);
54 d->type = DISK_TYPE_PHYSICAL; // Default type. Changed later if not correct.
56 d->sector_size = 512; // the default, will be changed below
59 // append it to the list
60 if(unlikely(!disk_root))
64 for(last = disk_root; last->next ;last = last->next);
68 // ------------------------------------------------------------------------
69 // find the type of the device
71 char buffer[FILENAME_MAX + 1];
73 // get the default path for finding info about the block device
74 if(unlikely(!path_find_block_device[0])) {
75 snprintfz(buffer, FILENAME_MAX, "%s%s", global_host_prefix, "/sys/dev/block/%lu:%lu/%s");
76 snprintfz(path_find_block_device, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get block device infos", buffer));
79 // find if it is a partition
80 // by checking if /sys/dev/block/MAJOR:MINOR/partition is readable.
81 snprintfz(buffer, FILENAME_MAX, path_find_block_device, major, minor, "partition");
82 if(likely(access(buffer, R_OK) == 0)) {
83 d->type = DISK_TYPE_PARTITION;
86 // find if it is a container
87 // by checking if /sys/dev/block/MAJOR:MINOR/slaves has entries
88 snprintfz(buffer, FILENAME_MAX, path_find_block_device, major, minor, "slaves/");
89 DIR *dirp = opendir(buffer);
90 if(likely(dirp != NULL)) {
92 while( (dp = readdir(dirp)) ) {
93 // . and .. are also files in empty folders.
94 if(unlikely(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)) {
98 d->type = DISK_TYPE_CONTAINER;
100 // Stop the loop after we found one file.
103 if(unlikely(closedir(dirp) == -1))
104 error("Unable to close dir %s", buffer);
108 // ------------------------------------------------------------------------
109 // check if we can find its mount point
111 // mountinfo_find() can be called with NULL disk_mountinfo_root
112 struct mountinfo *mi = mountinfo_find(disk_mountinfo_root, d->major, d->minor);
114 // mountinfo_free can be called with NULL
115 mountinfo_free(disk_mountinfo_root);
116 disk_mountinfo_root = mountinfo_read(0);
117 mi = mountinfo_find(disk_mountinfo_root, d->major, d->minor);
121 d->mount_point = strdupz(mi->mount_point);
123 d->mount_point = NULL;
125 // ------------------------------------------------------------------------
126 // find the disk sector size
128 if(unlikely(!path_to_get_hw_sector_size[0])) {
129 snprintfz(buffer, FILENAME_MAX, "%s%s", global_host_prefix, "/sys/block/%s/queue/hw_sector_size");
130 snprintfz(path_to_get_hw_sector_size, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get h/w sector size", buffer));
132 if(unlikely(!path_to_get_hw_sector_size_partitions[0])) {
133 snprintfz(buffer, FILENAME_MAX, "%s%s", global_host_prefix, "/sys/dev/block/%lu:%lu/subsystem/%s/../queue/hw_sector_size");
134 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));
138 char tf[FILENAME_MAX + 1], *t;
139 strncpyz(tf, d->disk, FILENAME_MAX);
141 // replace all / with !
143 if(unlikely(*t == '/')) *t = '!';
145 if(likely(d->type == DISK_TYPE_PARTITION))
146 snprintfz(buffer, FILENAME_MAX, path_to_get_hw_sector_size_partitions, d->major, d->minor, tf);
148 snprintfz(buffer, FILENAME_MAX, path_to_get_hw_sector_size, tf);
150 FILE *fpss = fopen(buffer, "r");
152 char buffer2[1024 + 1];
153 char *tmp = fgets(buffer2, 1024, fpss);
156 d->sector_size = atoi(tmp);
157 if(unlikely(d->sector_size <= 0)) {
158 error("Invalid sector size %d for device %s in %s. Assuming 512.", d->sector_size, d->disk, buffer);
159 d->sector_size = 512;
162 else error("Cannot read data for sector size for device %s from %s. Assuming 512.", d->disk, buffer);
166 else error("Cannot read sector size for device %s from %s. Assuming 512.", d->disk, buffer);
172 static inline int is_major_enabled(int major) {
173 static char *major_configs = NULL;
174 static size_t major_size = 0;
176 if(major < 0) return 1;
178 size_t wanted_size = (size_t)major + 1;
180 if(major_size < wanted_size) {
181 major_configs = reallocz(major_configs, wanted_size);
184 for(i = major_size; i < wanted_size ; i++)
185 major_configs[i] = -1;
187 major_size = wanted_size;
190 if(major_configs[major] == -1) {
191 char buffer[CONFIG_MAX_NAME + 1];
192 snprintfz(buffer, CONFIG_MAX_NAME, "performance metrics for disks with major %d", major);
193 major_configs[major] = (char)config_get_boolean("plugin:proc:/proc/diskstats", buffer, 1);
196 return major_configs[major];
199 int do_proc_diskstats(int update_every, usec_t dt) {
202 static procfile *ff = NULL;
203 static int global_enable_new_disks_detected_at_runtime = CONFIG_ONDEMAND_YES,
204 global_enable_performance_for_physical_disks = CONFIG_ONDEMAND_ONDEMAND,
205 global_enable_performance_for_virtual_disks = CONFIG_ONDEMAND_ONDEMAND,
206 global_enable_performance_for_partitions = CONFIG_ONDEMAND_NO,
207 global_do_io = CONFIG_ONDEMAND_ONDEMAND,
208 global_do_ops = CONFIG_ONDEMAND_ONDEMAND,
209 global_do_mops = CONFIG_ONDEMAND_ONDEMAND,
210 global_do_iotime = CONFIG_ONDEMAND_ONDEMAND,
211 global_do_qops = CONFIG_ONDEMAND_ONDEMAND,
212 global_do_util = CONFIG_ONDEMAND_ONDEMAND,
213 global_do_backlog = CONFIG_ONDEMAND_ONDEMAND,
214 globals_initialized = 0;
216 if(unlikely(!globals_initialized)) {
217 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);
219 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);
220 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);
221 global_enable_performance_for_partitions = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "performance metrics for partitions", global_enable_performance_for_partitions);
223 global_do_io = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "bandwidth for all disks", global_do_io);
224 global_do_ops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "operations for all disks", global_do_ops);
225 global_do_mops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "merged operations for all disks", global_do_mops);
226 global_do_iotime = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "i/o time for all disks", global_do_iotime);
227 global_do_qops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "queued operations for all disks", global_do_qops);
228 global_do_util = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "utilization percentage for all disks", global_do_util);
229 global_do_backlog = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "backlog for all disks", global_do_backlog);
231 globals_initialized = 1;
234 // --------------------------------------------------------------------------
237 char filename[FILENAME_MAX + 1];
238 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/diskstats");
239 ff = procfile_open(config_get("plugin:proc:/proc/diskstats", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
241 if(unlikely(!ff)) return 0;
243 ff = procfile_readall(ff);
244 if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
246 uint32_t lines = procfile_lines(ff), l;
248 for(l = 0; l < lines ;l++) {
249 // --------------------------------------------------------------------------
253 unsigned long major = 0, minor = 0;
255 collected_number reads = 0, mreads = 0, readsectors = 0, readms = 0,
256 writes = 0, mwrites = 0, writesectors = 0, writems = 0,
257 queued_ios = 0, busy_ms = 0, backlog_ms = 0;
259 collected_number last_reads = 0, last_readsectors = 0, last_readms = 0,
260 last_writes = 0, last_writesectors = 0, last_writems = 0,
263 uint32_t words = procfile_linewords(ff, l);
264 if(unlikely(words < 14)) continue;
266 major = strtoul(procfile_lineword(ff, l, 0), NULL, 10);
267 minor = strtoul(procfile_lineword(ff, l, 1), NULL, 10);
268 disk = procfile_lineword(ff, l, 2);
270 // # of reads completed # of writes completed
271 // This is the total number of reads or writes completed successfully.
272 reads = strtoull(procfile_lineword(ff, l, 3), NULL, 10); // rd_ios
273 writes = strtoull(procfile_lineword(ff, l, 7), NULL, 10); // wr_ios
275 // # of reads merged # of writes merged
276 // Reads and writes which are adjacent to each other may be merged for
277 // efficiency. Thus two 4K reads may become one 8K read before it is
278 // ultimately handed to the disk, and so it will be counted (and queued)
279 mreads = strtoull(procfile_lineword(ff, l, 4), NULL, 10); // rd_merges_or_rd_sec
280 mwrites = strtoull(procfile_lineword(ff, l, 8), NULL, 10); // wr_merges
282 // # of sectors read # of sectors written
283 // This is the total number of sectors read or written successfully.
284 readsectors = strtoull(procfile_lineword(ff, l, 5), NULL, 10); // rd_sec_or_wr_ios
285 writesectors = strtoull(procfile_lineword(ff, l, 9), NULL, 10); // wr_sec
287 // # of milliseconds spent reading # of milliseconds spent writing
288 // This is the total number of milliseconds spent by all reads or writes (as
289 // measured from __make_request() to end_that_request_last()).
290 readms = strtoull(procfile_lineword(ff, l, 6), NULL, 10); // rd_ticks_or_wr_sec
291 writems = strtoull(procfile_lineword(ff, l, 10), NULL, 10); // wr_ticks
293 // # of I/Os currently in progress
294 // The only field that should go to zero. Incremented as requests are
295 // given to appropriate struct request_queue and decremented as they finish.
296 queued_ios = strtoull(procfile_lineword(ff, l, 11), NULL, 10); // ios_pgr
298 // # of milliseconds spent doing I/Os
299 // This field increases so long as field queued_ios is nonzero.
300 busy_ms = strtoull(procfile_lineword(ff, l, 12), NULL, 10); // tot_ticks
302 // weighted # of milliseconds spent doing I/Os
303 // This field is incremented at each I/O start, I/O completion, I/O
304 // merge, or read of these stats by the number of I/Os in progress
305 // (field queued_ios) times the number of milliseconds spent doing I/O since the
306 // last update of this field. This can provide an easy measure of both
307 // I/O completion time and the backlog that may be accumulating.
308 backlog_ms = strtoull(procfile_lineword(ff, l, 13), NULL, 10); // rq_ticks
311 // --------------------------------------------------------------------------
312 // remove slashes from disk names
314 for(s = disk; *s ;s++)
315 if(*s == '/') *s = '_';
317 // --------------------------------------------------------------------------
318 // get a disk structure for the disk
320 struct disk *d = get_disk(major, minor, disk);
323 // --------------------------------------------------------------------------
324 // Set its family based on mount point
326 char *family = d->mount_point;
327 if(!family) family = disk;
330 // --------------------------------------------------------------------------
331 // Check the configuration for the device
333 if(unlikely(!d->configured)) {
334 char var_name[4096 + 1];
335 snprintfz(var_name, 4096, "plugin:proc:/proc/diskstats:%s", disk);
337 int def_enable = config_get_boolean_ondemand(var_name, "enable", global_enable_new_disks_detected_at_runtime);
338 if(unlikely(def_enable == CONFIG_ONDEMAND_NO)) {
339 // the user does not want any metrics for this disk
340 d->do_io = CONFIG_ONDEMAND_NO;
341 d->do_ops = CONFIG_ONDEMAND_NO;
342 d->do_mops = CONFIG_ONDEMAND_NO;
343 d->do_iotime = CONFIG_ONDEMAND_NO;
344 d->do_qops = CONFIG_ONDEMAND_NO;
345 d->do_util = CONFIG_ONDEMAND_NO;
346 d->do_backlog = CONFIG_ONDEMAND_NO;
349 // this disk is enabled
350 // check its direct settings
352 int def_performance = CONFIG_ONDEMAND_ONDEMAND;
354 // since this is 'on demand' we can figure the performance settings
355 // based on the type of disk
358 case DISK_TYPE_PHYSICAL:
359 def_performance = global_enable_performance_for_physical_disks;
362 case DISK_TYPE_PARTITION:
363 def_performance = global_enable_performance_for_partitions;
366 case DISK_TYPE_CONTAINER:
367 def_performance = global_enable_performance_for_virtual_disks;
371 // check if we have to disable performance for this disk
373 def_performance = is_major_enabled((int)major);
375 // ------------------------------------------------------------
376 // now we have def_performance and def_space
380 // check the user configuration (this will also show our 'on demand' decision)
381 def_performance = config_get_boolean_ondemand(var_name, "enable performance metrics", def_performance);
383 int ddo_io = CONFIG_ONDEMAND_NO,
384 ddo_ops = CONFIG_ONDEMAND_NO,
385 ddo_mops = CONFIG_ONDEMAND_NO,
386 ddo_iotime = CONFIG_ONDEMAND_NO,
387 ddo_qops = CONFIG_ONDEMAND_NO,
388 ddo_util = CONFIG_ONDEMAND_NO,
389 ddo_backlog = CONFIG_ONDEMAND_NO;
391 // we enable individual performance charts only when def_performance is not disabled
392 if(unlikely(def_performance != CONFIG_ONDEMAND_NO)) {
393 ddo_io = global_do_io,
394 ddo_ops = global_do_ops,
395 ddo_mops = global_do_mops,
396 ddo_iotime = global_do_iotime,
397 ddo_qops = global_do_qops,
398 ddo_util = global_do_util,
399 ddo_backlog = global_do_backlog;
402 d->do_io = config_get_boolean_ondemand(var_name, "bandwidth", ddo_io);
403 d->do_ops = config_get_boolean_ondemand(var_name, "operations", ddo_ops);
404 d->do_mops = config_get_boolean_ondemand(var_name, "merged operations", ddo_mops);
405 d->do_iotime = config_get_boolean_ondemand(var_name, "i/o time", ddo_iotime);
406 d->do_qops = config_get_boolean_ondemand(var_name, "queued operations", ddo_qops);
407 d->do_util = config_get_boolean_ondemand(var_name, "utilization percentage", ddo_util);
408 d->do_backlog = config_get_boolean_ondemand(var_name, "backlog", ddo_backlog);
416 // --------------------------------------------------------------------------
417 // Do performance metrics
419 if(d->do_io == CONFIG_ONDEMAND_YES || (d->do_io == CONFIG_ONDEMAND_ONDEMAND && (readsectors || writesectors))) {
420 d->do_io = CONFIG_ONDEMAND_YES;
422 st = rrdset_find_bytype(RRD_TYPE_DISK, disk);
424 st = rrdset_create(RRD_TYPE_DISK, disk, NULL, family, "disk.io", "Disk I/O Bandwidth", "kilobytes/s", 2000, update_every, RRDSET_TYPE_AREA);
426 rrddim_add(st, "reads", NULL, d->sector_size, 1024, RRDDIM_INCREMENTAL);
427 rrddim_add(st, "writes", NULL, d->sector_size * -1, 1024, RRDDIM_INCREMENTAL);
429 else rrdset_next(st);
431 last_readsectors = rrddim_set(st, "reads", readsectors);
432 last_writesectors = rrddim_set(st, "writes", writesectors);
436 // --------------------------------------------------------------------
438 if(d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes))) {
439 d->do_ops = CONFIG_ONDEMAND_YES;
441 st = rrdset_find_bytype("disk_ops", disk);
443 st = rrdset_create("disk_ops", disk, NULL, family, "disk.ops", "Disk Completed I/O Operations", "operations/s", 2001, update_every, RRDSET_TYPE_LINE);
446 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
447 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
449 else rrdset_next(st);
451 last_reads = rrddim_set(st, "reads", reads);
452 last_writes = rrddim_set(st, "writes", writes);
456 // --------------------------------------------------------------------
458 if(d->do_qops == CONFIG_ONDEMAND_YES || (d->do_qops == CONFIG_ONDEMAND_ONDEMAND && queued_ios)) {
459 d->do_qops = CONFIG_ONDEMAND_YES;
461 st = rrdset_find_bytype("disk_qops", disk);
463 st = rrdset_create("disk_qops", disk, NULL, family, "disk.qops", "Disk Current I/O Operations", "operations", 2002, update_every, RRDSET_TYPE_LINE);
466 rrddim_add(st, "operations", NULL, 1, 1, RRDDIM_ABSOLUTE);
468 else rrdset_next(st);
470 rrddim_set(st, "operations", queued_ios);
474 // --------------------------------------------------------------------
476 if(d->do_backlog == CONFIG_ONDEMAND_YES || (d->do_backlog == CONFIG_ONDEMAND_ONDEMAND && backlog_ms)) {
477 d->do_backlog = CONFIG_ONDEMAND_YES;
479 st = rrdset_find_bytype("disk_backlog", disk);
481 st = rrdset_create("disk_backlog", disk, NULL, family, "disk.backlog", "Disk Backlog", "backlog (ms)", 2003, update_every, RRDSET_TYPE_AREA);
484 rrddim_add(st, "backlog", NULL, 1, 10, RRDDIM_INCREMENTAL);
486 else rrdset_next(st);
488 rrddim_set(st, "backlog", backlog_ms);
492 // --------------------------------------------------------------------
494 if(d->do_util == CONFIG_ONDEMAND_YES || (d->do_util == CONFIG_ONDEMAND_ONDEMAND && busy_ms)) {
495 d->do_util = CONFIG_ONDEMAND_YES;
497 st = rrdset_find_bytype("disk_util", disk);
499 st = rrdset_create("disk_util", disk, NULL, family, "disk.util", "Disk Utilization Time", "% of time working", 2004, update_every, RRDSET_TYPE_AREA);
502 rrddim_add(st, "utilization", NULL, 1, 10, RRDDIM_INCREMENTAL);
504 else rrdset_next(st);
506 last_busy_ms = rrddim_set(st, "utilization", busy_ms);
510 // --------------------------------------------------------------------
512 if(d->do_mops == CONFIG_ONDEMAND_YES || (d->do_mops == CONFIG_ONDEMAND_ONDEMAND && (mreads || mwrites))) {
513 d->do_mops = CONFIG_ONDEMAND_YES;
515 st = rrdset_find_bytype("disk_mops", disk);
517 st = rrdset_create("disk_mops", disk, NULL, family, "disk.mops", "Disk Merged Operations", "merged operations/s", 2021, update_every, RRDSET_TYPE_LINE);
520 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
521 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
523 else rrdset_next(st);
525 rrddim_set(st, "reads", mreads);
526 rrddim_set(st, "writes", mwrites);
530 // --------------------------------------------------------------------
532 if(d->do_iotime == CONFIG_ONDEMAND_YES || (d->do_iotime == CONFIG_ONDEMAND_ONDEMAND && (readms || writems))) {
533 d->do_iotime = CONFIG_ONDEMAND_YES;
535 st = rrdset_find_bytype("disk_iotime", disk);
537 st = rrdset_create("disk_iotime", disk, NULL, family, "disk.iotime", "Disk Total I/O Time", "milliseconds/s", 2022, update_every, RRDSET_TYPE_LINE);
540 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
541 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
543 else rrdset_next(st);
545 last_readms = rrddim_set(st, "reads", readms);
546 last_writems = rrddim_set(st, "writes", writems);
550 // --------------------------------------------------------------------
551 // calculate differential charts
552 // only if this is not the first time we run
555 if( (d->do_iotime == CONFIG_ONDEMAND_YES || (d->do_iotime == CONFIG_ONDEMAND_ONDEMAND && (readms || writems))) &&
556 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
557 st = rrdset_find_bytype("disk_await", disk);
559 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);
562 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_ABSOLUTE);
563 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_ABSOLUTE);
565 else rrdset_next(st);
567 rrddim_set(st, "reads", (reads - last_reads) ? (readms - last_readms) / (reads - last_reads) : 0);
568 rrddim_set(st, "writes", (writes - last_writes) ? (writems - last_writems) / (writes - last_writes) : 0);
572 if( (d->do_io == CONFIG_ONDEMAND_YES || (d->do_io == CONFIG_ONDEMAND_ONDEMAND && (readsectors || writesectors))) &&
573 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
574 st = rrdset_find_bytype("disk_avgsz", disk);
576 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);
579 rrddim_add(st, "reads", NULL, d->sector_size, 1024, RRDDIM_ABSOLUTE);
580 rrddim_add(st, "writes", NULL, d->sector_size * -1, 1024, RRDDIM_ABSOLUTE);
582 else rrdset_next(st);
584 rrddim_set(st, "reads", (reads - last_reads) ? (readsectors - last_readsectors) / (reads - last_reads) : 0);
585 rrddim_set(st, "writes", (writes - last_writes) ? (writesectors - last_writesectors) / (writes - last_writes) : 0);
589 if( (d->do_util == CONFIG_ONDEMAND_YES || (d->do_util == CONFIG_ONDEMAND_ONDEMAND && busy_ms)) &&
590 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
591 st = rrdset_find_bytype("disk_svctm", disk);
593 st = rrdset_create("disk_svctm", disk, NULL, family, "disk.svctm", "Average Service Time", "ms per operation", 2007, update_every, RRDSET_TYPE_LINE);
596 rrddim_add(st, "svctm", NULL, 1, 1, RRDDIM_ABSOLUTE);
598 else rrdset_next(st);
600 rrddim_set(st, "svctm", ((reads - last_reads) + (writes - last_writes)) ? (busy_ms - last_busy_ms) / ((reads - last_reads) + (writes - last_writes)) : 0);