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 = str2i(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 int8_t *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 * sizeof(int8_t));
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 (int)major_configs[major];
199 int do_proc_diskstats(int update_every, usec_t dt) {
200 static procfile *ff = NULL;
201 static int global_enable_new_disks_detected_at_runtime = CONFIG_ONDEMAND_YES,
202 global_enable_performance_for_physical_disks = CONFIG_ONDEMAND_ONDEMAND,
203 global_enable_performance_for_virtual_disks = CONFIG_ONDEMAND_ONDEMAND,
204 global_enable_performance_for_partitions = CONFIG_ONDEMAND_NO,
205 global_do_io = CONFIG_ONDEMAND_ONDEMAND,
206 global_do_ops = CONFIG_ONDEMAND_ONDEMAND,
207 global_do_mops = CONFIG_ONDEMAND_ONDEMAND,
208 global_do_iotime = CONFIG_ONDEMAND_ONDEMAND,
209 global_do_qops = CONFIG_ONDEMAND_ONDEMAND,
210 global_do_util = CONFIG_ONDEMAND_ONDEMAND,
211 global_do_backlog = CONFIG_ONDEMAND_ONDEMAND,
212 globals_initialized = 0;
214 if(unlikely(!globals_initialized)) {
215 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);
217 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);
218 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);
219 global_enable_performance_for_partitions = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "performance metrics for partitions", global_enable_performance_for_partitions);
221 global_do_io = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "bandwidth for all disks", global_do_io);
222 global_do_ops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "operations for all disks", global_do_ops);
223 global_do_mops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "merged operations for all disks", global_do_mops);
224 global_do_iotime = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "i/o time for all disks", global_do_iotime);
225 global_do_qops = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "queued operations for all disks", global_do_qops);
226 global_do_util = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "utilization percentage for all disks", global_do_util);
227 global_do_backlog = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "backlog for all disks", global_do_backlog);
229 globals_initialized = 1;
232 // --------------------------------------------------------------------------
235 char filename[FILENAME_MAX + 1];
236 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/diskstats");
237 ff = procfile_open(config_get("plugin:proc:/proc/diskstats", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
239 if(unlikely(!ff)) return 0;
241 ff = procfile_readall(ff);
242 if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
244 size_t lines = procfile_lines(ff), l;
246 for(l = 0; l < lines ;l++) {
247 // --------------------------------------------------------------------------
251 unsigned long major = 0, minor = 0;
253 collected_number reads = 0, mreads = 0, readsectors = 0, readms = 0,
254 writes = 0, mwrites = 0, writesectors = 0, writems = 0,
255 queued_ios = 0, busy_ms = 0, backlog_ms = 0;
257 collected_number last_reads = 0, last_readsectors = 0, last_readms = 0,
258 last_writes = 0, last_writesectors = 0, last_writems = 0,
261 size_t words = procfile_linewords(ff, l);
262 if(unlikely(words < 14)) continue;
264 major = str2ul(procfile_lineword(ff, l, 0));
265 minor = str2ul(procfile_lineword(ff, l, 1));
266 disk = procfile_lineword(ff, l, 2);
268 // # of reads completed # of writes completed
269 // This is the total number of reads or writes completed successfully.
270 reads = str2ull(procfile_lineword(ff, l, 3)); // rd_ios
271 writes = str2ull(procfile_lineword(ff, l, 7)); // wr_ios
273 // # of reads merged # of writes merged
274 // Reads and writes which are adjacent to each other may be merged for
275 // efficiency. Thus two 4K reads may become one 8K read before it is
276 // ultimately handed to the disk, and so it will be counted (and queued)
277 mreads = str2ull(procfile_lineword(ff, l, 4)); // rd_merges_or_rd_sec
278 mwrites = str2ull(procfile_lineword(ff, l, 8)); // wr_merges
280 // # of sectors read # of sectors written
281 // This is the total number of sectors read or written successfully.
282 readsectors = str2ull(procfile_lineword(ff, l, 5)); // rd_sec_or_wr_ios
283 writesectors = str2ull(procfile_lineword(ff, l, 9)); // wr_sec
285 // # of milliseconds spent reading # of milliseconds spent writing
286 // This is the total number of milliseconds spent by all reads or writes (as
287 // measured from __make_request() to end_that_request_last()).
288 readms = str2ull(procfile_lineword(ff, l, 6)); // rd_ticks_or_wr_sec
289 writems = str2ull(procfile_lineword(ff, l, 10)); // wr_ticks
291 // # of I/Os currently in progress
292 // The only field that should go to zero. Incremented as requests are
293 // given to appropriate struct request_queue and decremented as they finish.
294 queued_ios = str2ull(procfile_lineword(ff, l, 11)); // ios_pgr
296 // # of milliseconds spent doing I/Os
297 // This field increases so long as field queued_ios is nonzero.
298 busy_ms = str2ull(procfile_lineword(ff, l, 12)); // tot_ticks
300 // weighted # of milliseconds spent doing I/Os
301 // This field is incremented at each I/O start, I/O completion, I/O
302 // merge, or read of these stats by the number of I/Os in progress
303 // (field queued_ios) times the number of milliseconds spent doing I/O since the
304 // last update of this field. This can provide an easy measure of both
305 // I/O completion time and the backlog that may be accumulating.
306 backlog_ms = str2ull(procfile_lineword(ff, l, 13)); // rq_ticks
309 // --------------------------------------------------------------------------
310 // remove slashes from disk names
312 for(s = disk; *s ;s++)
313 if(*s == '/') *s = '_';
315 // --------------------------------------------------------------------------
316 // get a disk structure for the disk
318 struct disk *d = get_disk(major, minor, disk);
321 // --------------------------------------------------------------------------
322 // Set its family based on mount point
324 char *family = d->mount_point;
325 if(!family) family = disk;
328 // --------------------------------------------------------------------------
329 // Check the configuration for the device
331 if(unlikely(!d->configured)) {
332 char var_name[4096 + 1];
333 snprintfz(var_name, 4096, "plugin:proc:/proc/diskstats:%s", disk);
335 int def_enable = config_get_boolean_ondemand(var_name, "enable", global_enable_new_disks_detected_at_runtime);
336 if(unlikely(def_enable == CONFIG_ONDEMAND_NO)) {
337 // the user does not want any metrics for this disk
338 d->do_io = CONFIG_ONDEMAND_NO;
339 d->do_ops = CONFIG_ONDEMAND_NO;
340 d->do_mops = CONFIG_ONDEMAND_NO;
341 d->do_iotime = CONFIG_ONDEMAND_NO;
342 d->do_qops = CONFIG_ONDEMAND_NO;
343 d->do_util = CONFIG_ONDEMAND_NO;
344 d->do_backlog = CONFIG_ONDEMAND_NO;
347 // this disk is enabled
348 // check its direct settings
350 int def_performance = CONFIG_ONDEMAND_ONDEMAND;
352 // since this is 'on demand' we can figure the performance settings
353 // based on the type of disk
356 case DISK_TYPE_PHYSICAL:
357 def_performance = global_enable_performance_for_physical_disks;
360 case DISK_TYPE_PARTITION:
361 def_performance = global_enable_performance_for_partitions;
364 case DISK_TYPE_CONTAINER:
365 def_performance = global_enable_performance_for_virtual_disks;
369 // check if we have to disable performance for this disk
371 def_performance = is_major_enabled((int)major);
373 // ------------------------------------------------------------
374 // now we have def_performance and def_space
378 // check the user configuration (this will also show our 'on demand' decision)
379 def_performance = config_get_boolean_ondemand(var_name, "enable performance metrics", def_performance);
381 int ddo_io = CONFIG_ONDEMAND_NO,
382 ddo_ops = CONFIG_ONDEMAND_NO,
383 ddo_mops = CONFIG_ONDEMAND_NO,
384 ddo_iotime = CONFIG_ONDEMAND_NO,
385 ddo_qops = CONFIG_ONDEMAND_NO,
386 ddo_util = CONFIG_ONDEMAND_NO,
387 ddo_backlog = CONFIG_ONDEMAND_NO;
389 // we enable individual performance charts only when def_performance is not disabled
390 if(unlikely(def_performance != CONFIG_ONDEMAND_NO)) {
391 ddo_io = global_do_io,
392 ddo_ops = global_do_ops,
393 ddo_mops = global_do_mops,
394 ddo_iotime = global_do_iotime,
395 ddo_qops = global_do_qops,
396 ddo_util = global_do_util,
397 ddo_backlog = global_do_backlog;
400 d->do_io = config_get_boolean_ondemand(var_name, "bandwidth", ddo_io);
401 d->do_ops = config_get_boolean_ondemand(var_name, "operations", ddo_ops);
402 d->do_mops = config_get_boolean_ondemand(var_name, "merged operations", ddo_mops);
403 d->do_iotime = config_get_boolean_ondemand(var_name, "i/o time", ddo_iotime);
404 d->do_qops = config_get_boolean_ondemand(var_name, "queued operations", ddo_qops);
405 d->do_util = config_get_boolean_ondemand(var_name, "utilization percentage", ddo_util);
406 d->do_backlog = config_get_boolean_ondemand(var_name, "backlog", ddo_backlog);
414 // --------------------------------------------------------------------------
415 // Do performance metrics
417 if(d->do_io == CONFIG_ONDEMAND_YES || (d->do_io == CONFIG_ONDEMAND_ONDEMAND && (readsectors || writesectors))) {
418 d->do_io = CONFIG_ONDEMAND_YES;
420 st = rrdset_find_bytype(RRD_TYPE_DISK, disk);
422 st = rrdset_create(RRD_TYPE_DISK, disk, NULL, family, "disk.io", "Disk I/O Bandwidth", "kilobytes/s", 2000, update_every, RRDSET_TYPE_AREA);
424 rrddim_add(st, "reads", NULL, d->sector_size, 1024, RRDDIM_INCREMENTAL);
425 rrddim_add(st, "writes", NULL, d->sector_size * -1, 1024, RRDDIM_INCREMENTAL);
427 else rrdset_next(st);
429 last_readsectors = rrddim_set(st, "reads", readsectors);
430 last_writesectors = rrddim_set(st, "writes", writesectors);
434 // --------------------------------------------------------------------
436 if(d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes))) {
437 d->do_ops = CONFIG_ONDEMAND_YES;
439 st = rrdset_find_bytype("disk_ops", disk);
441 st = rrdset_create("disk_ops", disk, NULL, family, "disk.ops", "Disk Completed I/O Operations", "operations/s", 2001, update_every, RRDSET_TYPE_LINE);
444 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
445 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
447 else rrdset_next(st);
449 last_reads = rrddim_set(st, "reads", reads);
450 last_writes = rrddim_set(st, "writes", writes);
454 // --------------------------------------------------------------------
456 if(d->do_qops == CONFIG_ONDEMAND_YES || (d->do_qops == CONFIG_ONDEMAND_ONDEMAND && queued_ios)) {
457 d->do_qops = CONFIG_ONDEMAND_YES;
459 st = rrdset_find_bytype("disk_qops", disk);
461 st = rrdset_create("disk_qops", disk, NULL, family, "disk.qops", "Disk Current I/O Operations", "operations", 2002, update_every, RRDSET_TYPE_LINE);
464 rrddim_add(st, "operations", NULL, 1, 1, RRDDIM_ABSOLUTE);
466 else rrdset_next(st);
468 rrddim_set(st, "operations", queued_ios);
472 // --------------------------------------------------------------------
474 if(d->do_backlog == CONFIG_ONDEMAND_YES || (d->do_backlog == CONFIG_ONDEMAND_ONDEMAND && backlog_ms)) {
475 d->do_backlog = CONFIG_ONDEMAND_YES;
477 st = rrdset_find_bytype("disk_backlog", disk);
479 st = rrdset_create("disk_backlog", disk, NULL, family, "disk.backlog", "Disk Backlog", "backlog (ms)", 2003, update_every, RRDSET_TYPE_AREA);
482 rrddim_add(st, "backlog", NULL, 1, 10, RRDDIM_INCREMENTAL);
484 else rrdset_next(st);
486 rrddim_set(st, "backlog", backlog_ms);
490 // --------------------------------------------------------------------
492 if(d->do_util == CONFIG_ONDEMAND_YES || (d->do_util == CONFIG_ONDEMAND_ONDEMAND && busy_ms)) {
493 d->do_util = CONFIG_ONDEMAND_YES;
495 st = rrdset_find_bytype("disk_util", disk);
497 st = rrdset_create("disk_util", disk, NULL, family, "disk.util", "Disk Utilization Time", "% of time working", 2004, update_every, RRDSET_TYPE_AREA);
500 rrddim_add(st, "utilization", NULL, 1, 10, RRDDIM_INCREMENTAL);
502 else rrdset_next(st);
504 last_busy_ms = rrddim_set(st, "utilization", busy_ms);
508 // --------------------------------------------------------------------
510 if(d->do_mops == CONFIG_ONDEMAND_YES || (d->do_mops == CONFIG_ONDEMAND_ONDEMAND && (mreads || mwrites))) {
511 d->do_mops = CONFIG_ONDEMAND_YES;
513 st = rrdset_find_bytype("disk_mops", disk);
515 st = rrdset_create("disk_mops", disk, NULL, family, "disk.mops", "Disk Merged Operations", "merged operations/s", 2021, update_every, RRDSET_TYPE_LINE);
518 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
519 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
521 else rrdset_next(st);
523 rrddim_set(st, "reads", mreads);
524 rrddim_set(st, "writes", mwrites);
528 // --------------------------------------------------------------------
530 if(d->do_iotime == CONFIG_ONDEMAND_YES || (d->do_iotime == CONFIG_ONDEMAND_ONDEMAND && (readms || writems))) {
531 d->do_iotime = CONFIG_ONDEMAND_YES;
533 st = rrdset_find_bytype("disk_iotime", disk);
535 st = rrdset_create("disk_iotime", disk, NULL, family, "disk.iotime", "Disk Total I/O Time", "milliseconds/s", 2022, update_every, RRDSET_TYPE_LINE);
538 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
539 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
541 else rrdset_next(st);
543 last_readms = rrddim_set(st, "reads", readms);
544 last_writems = rrddim_set(st, "writes", writems);
548 // --------------------------------------------------------------------
549 // calculate differential charts
550 // only if this is not the first time we run
553 if( (d->do_iotime == CONFIG_ONDEMAND_YES || (d->do_iotime == CONFIG_ONDEMAND_ONDEMAND && (readms || writems))) &&
554 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
555 st = rrdset_find_bytype("disk_await", disk);
557 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);
560 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_ABSOLUTE);
561 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_ABSOLUTE);
563 else rrdset_next(st);
565 rrddim_set(st, "reads", (reads - last_reads) ? (readms - last_readms) / (reads - last_reads) : 0);
566 rrddim_set(st, "writes", (writes - last_writes) ? (writems - last_writems) / (writes - last_writes) : 0);
570 if( (d->do_io == CONFIG_ONDEMAND_YES || (d->do_io == CONFIG_ONDEMAND_ONDEMAND && (readsectors || writesectors))) &&
571 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
572 st = rrdset_find_bytype("disk_avgsz", disk);
574 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);
577 rrddim_add(st, "reads", NULL, d->sector_size, 1024, RRDDIM_ABSOLUTE);
578 rrddim_add(st, "writes", NULL, d->sector_size * -1, 1024, RRDDIM_ABSOLUTE);
580 else rrdset_next(st);
582 rrddim_set(st, "reads", (reads - last_reads) ? (readsectors - last_readsectors) / (reads - last_reads) : 0);
583 rrddim_set(st, "writes", (writes - last_writes) ? (writesectors - last_writesectors) / (writes - last_writes) : 0);
587 if( (d->do_util == CONFIG_ONDEMAND_YES || (d->do_util == CONFIG_ONDEMAND_ONDEMAND && busy_ms)) &&
588 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
589 st = rrdset_find_bytype("disk_svctm", disk);
591 st = rrdset_create("disk_svctm", disk, NULL, family, "disk.svctm", "Average Service Time", "ms per operation", 2007, update_every, RRDSET_TYPE_LINE);
594 rrddim_add(st, "svctm", NULL, 1, 1, RRDDIM_ABSOLUTE);
596 else rrdset_next(st);
598 rrddim_set(st, "svctm", ((reads - last_reads) + (writes - last_writes)) ? (busy_ms - last_busy_ms) / ((reads - last_reads) + (writes - last_writes)) : 0);