#
# Copyright (C) 2016-2021 Red Hat.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# 
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#

#
# IOSTAT derived metrics (per-device for regular block devices)
# These derived metrics complement the disk.dev.* metrics tree.
#

disk.dev.await = delta(disk.dev.total) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.dev.total_rawactive) / delta(disk.dev.total)
disk.dev.await(oneline) = average time read and write requests queued and serviced
disk.dev.await(helptext) = '\
average time in milliseconds that read and write requests
were queued (and serviced) during the reporting interval.'

disk.dev.r_await = delta(disk.dev.read) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.dev.read_rawactive) / delta(disk.dev.read)
disk.dev.r_await(oneline) = average time read requests queued and serviced 
disk.dev.r_await(helptext) = '\
average time in milliseconds that read requests were queued
(and serviced) during the reporting interval.'

disk.dev.w_await = delta(disk.dev.write) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.dev.write_rawactive) / delta(disk.dev.write)
disk.dev.w_await(oneline) = average time write requests queued and serviced
disk.dev.w_await(helptext) = '\
average time in milliseconds that write requests were queued
(and serviced) during the reporting interval.'

disk.dev.d_await = delta(disk.dev.discard) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.dev.discard_rawactive) / delta(disk.dev.discard)
disk.dev.d_await(oneline) = average time discard requests queued and serviced
disk.dev.d_await(helptext) = '\
average time in milliseconds that discard requests were queued
(and serviced) during the reporting interval.'

disk.dev.f_await = delta(disk.dev.flush) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.dev.flush_rawactive) / delta(disk.dev.flush)
disk.dev.f_await(oneline) = average time flush requests queued and serviced
disk.dev.f_await(helptext) = '\
average time in milliseconds that flush requests were queued
(and serviced) during the reporting interval.'

disk.dev.avg_qlen = rate(disk.dev.read_rawactive) + rate(disk.dev.write_rawactive)
disk.dev.avg_qlen(oneline) = average read and write queue length
disk.dev.avg_qlen(helptext) = '\
average read and write I/O queue length to the device during the reporting interval.'

disk.dev.avg_rqsz = (delta(disk.dev.read) + delta(disk.dev.write)) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : rescale(delta(disk.dev.read_bytes) + delta(disk.dev.write_bytes), "kbyte") / (delta(disk.dev.read) + delta(disk.dev.write))
disk.dev.avg_rqsz(oneline) = average I/O request size for both reads and writes
disk.dev.avg_rqsz(helptext) = '\
average I/O request size for both reads and writes during the reporting interval.'

disk.dev.r_avg_rqsz = delta(disk.dev.read) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : rescale(delta(disk.dev.read_bytes), "kbyte") / delta(disk.dev.read)
disk.dev.r_avg_rqsz(oneline) = average I/O request size for reads to the device
disk.dev.r_avg_rqsz(helptext) = '\
average I/O request size for reads to the device during the reporting interval.'

disk.dev.w_avg_rqsz = delta(disk.dev.write) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : rescale(delta(disk.dev.write_bytes), "kbyte") / delta(disk.dev.write)
disk.dev.w_avg_rqsz(oneline) = average I/O request size for writes to the device
disk.dev.w_avg_rqsz(helptext) = '\
average I/O request size for writes to the device during the reporting interval.'

disk.dev.d_avg_rqsz = delta(disk.dev.discard) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : rescale(delta(disk.dev.discard_bytes), "kbyte") / delta(disk.dev.discard)
disk.dev.d_avg_rqsz(oneline) = average I/O request size for discards to the device
disk.dev.d_avg_rqsz(helptext) = '\
average I/O request size for discards to the device during the reporting interval.'

disk.dev.util = 100 * rate(disk.dev.avactive)
disk.dev.util(oneline) = percentage of time device was busy processing requests
disk.dev.util(helptext) = '\
The percentage of time during the reporting interval that the
device was busy processing requests (reads and writes). A value
of 100% indicates device saturation.'

#
# IOSTAT derived metrics (per dm device for device-mapper)
# These derived metrics complement the disk.dm.* metrics tree.
#
disk.dm.await = delta(disk.dm.total) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.dm.total_rawactive) / delta(disk.dm.total)
disk.dm.await(oneline) = average time read and write requests queued and serviced
disk.dm.await(helptext) = '\
average time in milliseconds that read and write requests
were queued (and serviced) to the device-mapper logical
device during the reporting interval.'

disk.dm.r_await = delta(disk.dm.read) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.dm.read_rawactive) / delta(disk.dm.read)
disk.dm.r_await(oneline) = average time read requests queued and serviced
disk.dm.r_await(helptext) = '\
average time in milliseconds that read requests were queued
(and serviced) to the device-mapper logical device during
the reporting interval.'

disk.dm.w_await = delta(disk.dm.write) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.dm.write_rawactive) / delta(disk.dm.write)
disk.dm.w_await(oneline) = average time write requests queued and serviced
disk.dm.w_await(helptext) = '\
average time in milliseconds that write requests were queued
(and serviced) to the device-mapper logical device during
the reporting interval.'

disk.dm.d_await = delta(disk.dm.discard) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.dm.discard_rawactive) / delta(disk.dm.discard)
disk.dm.d_await(oneline) = average time discard requests queued and serviced
disk.dm.d_await(helptext) = '\
average time in milliseconds that discard requests were queued
(and serviced) to the device-mapper logical device during
the reporting interval.'

disk.dm.f_await = delta(disk.dm.flush) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.dm.flush_rawactive) / delta(disk.dm.flush)
disk.dm.f_await(oneline) = average time flush requests queued and serviced
disk.dm.f_await(helptext) = '\
average time in milliseconds that flush requests were queued
(and serviced) to the device-mapper logical device during
the reporting interval.'

disk.dm.avg_qlen = rate(disk.dm.read_rawactive) + rate(disk.dm.write_rawactive)
disk.dm.avg_qlen(oneline) = average read and write queue length
disk.dm.avg_qlen(helptext) = '\
average read and write I/O queue length to the device-mapper logical
device during the reporting interval.'

disk.dm.avg_rqsz = (delta(disk.dm.read) + delta(disk.dm.write)) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : (delta(disk.dm.read_bytes) + delta(disk.dm.write_bytes)) / (delta(disk.dm.read) + delta(disk.dm.write))
disk.dm.avg_rqsz(oneline) = average I/O request size for reads and writes to the device
disk.dm.avg_rqsz(helptext) = '\
average I/O request size for reads and writes to the device-mapper logical
device during the reporting interval.'

disk.dm.r_avg_rqsz = delta(disk.dm.read) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : delta(disk.dm.read_bytes) / delta(disk.dm.read)
disk.dm.r_avg_rqsz(oneline) = average I/O request size for reads to the device
disk.dm.r_avg_rqsz(helptext) = '\
average I/O request size for reads to the device-mapper logical device
during the reporting interval.'

disk.dm.w_avg_rqsz = delta(disk.dm.write) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : delta(disk.dm.write_bytes) / delta(disk.dm.write)
disk.dm.w_avg_rqsz(oneline) = average I/O request size for writes to the device
disk.dm.w_avg_rqsz(helptext) = '\
average I/O request size for writes to the device-mapper logical device
during the reporting interval.'

disk.dm.d_avg_rqsz = delta(disk.dm.discard) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : delta(disk.dm.discard_bytes) / delta(disk.dm.discard)
disk.dm.d_avg_rqsz(oneline) = average I/O request size for discards to the device
disk.dm.d_avg_rqsz(helptext) = '\
average I/O request size for discards to the device-mapper logical device
during the reporting interval.'

disk.dm.util = 100 * rate(disk.dm.avactive)
disk.dm.util(oneline) = percentage of time device was busy processing requests
disk.dm.util(helptext) = '\
The percentage of time during the reporting interval that the
device-mapper logical device was busy processing requests (reads
and writes). A value of 100% indicates device saturation.'

#
# IOSTAT derived metrics (per md device for multiple devices)
# These derived metrics complement the disk.md.* metrics tree.
#
disk.md.await = delta(disk.md.total) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.md.total_rawactive) / delta(disk.md.total)
disk.md.await(oneline) = average time read and write requests queued and serviced
disk.md.await(helptext) = '\
average time in milliseconds that read and write requests
were queued (and serviced) to the per-multi-device logical
device during the reporting interval.'

disk.md.r_await = delta(disk.md.read) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.md.read_rawactive) / delta(disk.md.read)
disk.md.r_await(oneline) = average time read requests queued and serviced
disk.md.r_await(helptext) = '\
average time in milliseconds that read requests were queued
(and serviced) to the per-multi-device logical device during
the reporting interval.'

disk.md.w_await = delta(disk.md.write) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.md.write_rawactive) / delta(disk.md.write)
disk.md.w_await(oneline) = average time write requests queued and serviced
disk.md.w_await(helptext) = '\
average time in milliseconds that write requests were queued
(and serviced) to the per-multi-device logical device during
the reporting interval.'

disk.md.d_await = delta(disk.md.discard) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.md.discard_rawactive) / delta(disk.md.discard)
disk.md.d_await(oneline) = average time discard requests queued and serviced
disk.md.d_await(helptext) = '\
average time in milliseconds that discard requests were queued
(and serviced) to the per-multi-device logical device during
the reporting interval.'

disk.md.f_await = delta(disk.md.flush) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.md.flush_rawactive) / delta(disk.md.flush)
disk.md.f_await(oneline) = average time flush requests queued and serviced
disk.md.f_await(helptext) = '\
average time in milliseconds that flush requests were queued
(and serviced) to the per-multi-device logical device during
the reporting interval.'

disk.md.avg_qlen = rate(disk.md.read_rawactive) + rate(disk.md.write_rawactive)
disk.md.avg_qlen(oneline) = average read and write queue length
disk.md.avg_qlen(helptext) = '\
average read and write I/O queue length to the per-multi-device logical
device during the reporting interval.'

disk.md.avg_rqsz = (delta(disk.md.read) + delta(disk.md.write)) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : (delta(disk.md.read_bytes) + delta(disk.md.write_bytes)) / (delta(disk.md.read) + delta(disk.md.write))
disk.md.avg_rqsz(oneline) = average I/O request size for reads and writes to the device
disk.md.avg_rqsz(helptext) = '\
average I/O request size for reads and writes to the per-multi-device logical
device during the reporting interval.'

disk.md.r_avg_rqsz = delta(disk.md.read) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : delta(disk.md.read_bytes) / delta(disk.md.read)
disk.md.r_avg_rqsz(oneline) = average I/O request size for reads to the device
disk.md.r_avg_rqsz(helptext) = '\
average I/O request size for reads to the per-multi-device logical device
during the reporting interval.'

disk.md.w_avg_rqsz = delta(disk.md.write) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : delta(disk.md.write_bytes) / delta(disk.md.write)
disk.md.w_avg_rqsz(oneline) = average I/O request size for writes to the device
disk.md.w_avg_rqsz(helptext) = '\
average I/O request size for writes to the per-multi-device logical device
during the reporting interval.'

disk.md.d_avg_rqsz = delta(disk.md.discard) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : delta(disk.md.discard_bytes) / delta(disk.md.discard)
disk.md.d_avg_rqsz(oneline) = average I/O request size for discards to the device
disk.md.d_avg_rqsz(helptext) = '\
average I/O request size for discards to the per-multi-device logical device
during the reporting interval.'

disk.md.util = 100 * rate(disk.md.avactive)
disk.md.util(oneline) = percentage of time device was busy processing requests
disk.md.util(helptext) = '\
The percentage of time during the reporting interval that the
per-multi-device logical device was busy processing requests
(reads and writes). A value of 100% indicates device saturation.'

#
# IOSTAT derived metrics (per wwid device for aggregated multipath statistics)
# These derived metrics complement the disk.wwid.* metrics tree.
#
disk.wwid.await = delta(disk.wwid.total) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.wwid.total_rawactive) / delta(disk.wwid.total)
disk.wwid.await(oneline) = average time read and write requests queued and serviced
disk.wwid.await(helptext) = '\
average time in milliseconds that read and write requests
were queued (and serviced) during the reporting interval.'

disk.wwid.r_await = delta(disk.wwid.read) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.wwid.read_rawactive) / delta(disk.wwid.read)
disk.wwid.r_await(oneline) = average time read requests queued and serviced 
disk.wwid.r_await(helptext) = '\
average time in milliseconds that read requests were queued
(and serviced) during the reporting interval.'

disk.wwid.w_await = delta(disk.wwid.write) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.wwid.write_rawactive) / delta(disk.wwid.write)
disk.wwid.w_await(oneline) = average time write requests queued and serviced
disk.wwid.w_await(helptext) = '\
average time in milliseconds that write requests were queued
(and serviced) during the reporting interval.'

disk.wwid.d_await = delta(disk.wwid.discard) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.wwid.discard_rawactive) / delta(disk.wwid.discard)
disk.wwid.d_await(oneline) = average time discard requests queued and serviced
disk.wwid.d_await(helptext) = '\
average time in milliseconds that discard requests were queued
(and serviced) during the reporting interval.'

disk.wwid.f_await = delta(disk.wwid.flush) == 0 ? mkconst(0, type="double", semantics="instant", units="millisec / count") : delta(disk.wwid.flush_rawactive) / delta(disk.wwid.flush)
disk.wwid.f_await(oneline) = average time flush requests queued and serviced
disk.wwid.f_await(helptext) = '\
average time in milliseconds that flush requests were queued
(and serviced) during the reporting interval.'

disk.wwid.avg_qlen = rate(disk.wwid.read_rawactive) + rate(disk.wwid.write_rawactive)
disk.wwid.avg_qlen(oneline) = average read and write queue length
disk.wwid.avg_qlen(helptext) = '\
average read and write I/O queue length to the device during the reporting interval.'

disk.wwid.avg_rqsz = (delta(disk.wwid.read) + delta(disk.wwid.write)) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : rescale(delta(disk.wwid.read_bytes) + delta(disk.wwid.write_bytes), "kbyte") / (delta(disk.wwid.read) + delta(disk.wwid.write))
disk.wwid.avg_rqsz(oneline) = average I/O request size for both reads and writes
disk.wwid.avg_rqsz(helptext) = '\
average I/O request size for both reads and writes during the reporting interval.'

disk.wwid.r_avg_rqsz = delta(disk.wwid.read) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : rescale(delta(disk.wwid.read_bytes), "kbyte") / delta(disk.wwid.read)
disk.wwid.r_avg_rqsz(oneline) = average I/O request size for reads to the device
disk.wwid.r_avg_rqsz(helptext) = '\
average I/O request size for reads to the device during the reporting interval.'

disk.wwid.w_avg_rqsz = delta(disk.wwid.write) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : rescale(delta(disk.wwid.write_bytes), "kbyte") / delta(disk.wwid.write)
disk.wwid.w_avg_rqsz(oneline) = average I/O request size for writes to the device
disk.wwid.w_avg_rqsz(helptext) = '\
average I/O request size for writes to the device during the reporting interval.'

disk.wwid.d_avg_rqsz = delta(disk.wwid.discard) == 0 ? mkconst(0, type="double", semantics="instant", units="kbyte / count") : rescale(delta(disk.wwid.discard_bytes), "kbyte") / delta(disk.wwid.discard)
disk.wwid.d_avg_rqsz(oneline) = average I/O request size for discards to the device
disk.wwid.d_avg_rqsz(helptext) = '\
average I/O request size for discards to the device during the reporting interval.'

disk.wwid.util = 100 * rate(disk.wwid.avactive)
disk.wwid.util(oneline) = percentage of time device was busy processing requests
disk.wwid.util(helptext) = '\
The percentage of time during the reporting interval that the
device was busy processing requests (reads and writes). A value
of 100% indicates device saturation.'
