From fe097689f945f6b2d2d5da1f9fe95e6668ecd3e6 Mon Sep 17 00:00:00 2001 From: "K.Cima" Date: Mon, 27 Mar 2017 16:23:33 +0900 Subject: [PATCH] Fix for https://github.com/munin-monitoring/contrib/pull/826 --- plugins/solaris/io_disk | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/plugins/solaris/io_disk b/plugins/solaris/io_disk index ee2c11d8..3e222d48 100755 --- a/plugins/solaris/io_disk +++ b/plugins/solaris/io_disk @@ -9,10 +9,11 @@ These functions are implemented: ops : similar to iostat r/s, w/s bytes : similar to iostat kr/s, kw/s - busy : similar to iostat %b, %w + busy : similar to iostat %b, %w (%w usually indicates 0 in Sol10,11) queue : similar to iostat actv, wait latency : similar to iostat asvc_t, wsvc_t + This plugin is improved from Solaris io_busy_, io_ops_, io_bytes_ plugins. Any device found in /usr/bin/kstat can be monitored. Tested with Solaris 10 and 11, and it should work with Solaris 8, 9. @@ -30,19 +31,26 @@ By default, this plugin monitors disk devices. And also it can monitor NFS and Tape devices as much as io_* plugins with setting environments. + Note that instance names of nfs (e.g. nfs1) can be changed after reboot or + remount, this plugin may not monitor nfs properly. (same as original ones) + =head1 ENVIRONMENT VARIABLES env.class - kstat class. See man kstat -c option. example: env.class /disk|nfs|tape/ default: disk - env.module - Module name. Only used in internal graph name. If you would not - to like to take over RRDs generated by io_*_sd plugins, please change it - to another name. - + env.module - Module name. Only used in internal graph name. example: env.module something default: sd + If you would not like to take over RRDs generated by io_*_sd plugins, + please change it to another name. + + And also, if you would like to take over RRDs of nfs, tape devices, + please set it 'nfs' or 'tape' (and set env.class, env.module_regex). + It may be good to link like ln -s /path/to/io_disk io_nfs if necessary. + env.module_regex - kstat module. See man kstat -m option. example: env.module_regex /^(s?sd|vdc|zvblk|dad|md|nfs|tape)$/ default: /^(s?sd|vdc|zvblk|dad|md)$/ @@ -187,16 +195,15 @@ do_config() { echo "graph_width $graph_width" fi + # Get device instance names by kstat kstat -p -c "$class" -m "$module_regex" -s "/^${conf_in}\$/" | sed 's/:/ /g' | awk '{ print $3 }' | \ while read -r dev do - if is_excluded "$dev" ; then - continue - fi + is_excluded "$dev" && continue - # replace instance name to logical device name if exists + # Replace instance name to logical device name if exists ref="name_$dev" - devname=${!ref:-} + devname=${!ref:-} # ${!varname} means indirect evaluation (similar to eval) # reads and writes are necessary to calculate latency if [ "$func" = 'latency' ]; then @@ -244,12 +251,18 @@ do_getvalue() { echo "multigraph ${plugin_name}_${func}_${module}" + # Get device instance names, stat names and values by kstat + + # kstat output example: + # $ kstat -p -c disk -m '/^sd$/' -s '/^reads$/' + # sd:0:sd0:reads 51432610 + # sd:1:sd1:reads 52671435 + # ... + kstat -p -c "$class" -m "$module_regex" -s "$stat_regex" | sed 's/:/ /g' | awk '{ print $3,$4,$5 }' | \ while read -r dev stat value do - if is_excluded "$dev" ; then - continue - fi + is_excluded "$dev" && continue echo "${dev}_${stat}.value ${value%.*}" done @@ -285,7 +298,7 @@ getvalue() { done } -# main +# Main case ${1:-} in autoconf) autoconf