diff --git a/plugins/solaris/forks b/plugins/solaris/forks index fd79393c..5edf0a81 100755 --- a/plugins/solaris/forks +++ b/plugins/solaris/forks @@ -52,7 +52,7 @@ data_attr=" # Functions autoconf() { - if [ -x "$( which kstat )" ]; then + if which kstat >/dev/null ; then echo yes else echo "no (failed to find executable 'kstat')" @@ -63,16 +63,14 @@ config() { local label_max_length=45 # print global attributes - sed -e 's/^ *//' -e '/^$/d' <<< "${global_attr}" + echo "$global_attr" | sed -e 's/^ *//' -e '/^$/d' # print data source attributes # split line into field,type,draw,label - local fields field type draw label - fields= - while read -r field type draw label + local field type draw label + echo "$data_attr" | while read -r field type draw label do [ -z "$field" ] && continue - fields="${fields} ${field}" echo "${field}.type ${type}" echo "${field}.draw ${draw}" @@ -80,19 +78,17 @@ config() { if [ "${type}" = DERIVE ]; then echo "${field}.min 0" fi - done <<< "${data_attr}" - - echo graph_order "$fields" + done } -getvalue() { +fetch() { local field type draw label - while read -r field type draw label + echo "$data_attr" | while read -r field type draw label do [ -z "$field" ] && continue value=$( kstat -p "cpu::sys:${field}" | awk '{ sum += $2 } END { print sum }' ) echo "${field}.value ${value}" - done <<< "${data_attr}" + done } # Main @@ -102,10 +98,10 @@ autoconf) ;; config) config - [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && getvalue + [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch ;; *) - getvalue + fetch ;; esac diff --git a/plugins/solaris/fsstat_act_ b/plugins/solaris/fsstat_act_ index 07af4e58..c9113586 100755 --- a/plugins/solaris/fsstat_act_ +++ b/plugins/solaris/fsstat_act_ @@ -29,7 +29,7 @@ ln -s /path/to/munin/lib/plugins/fsstat_act_ fsstat_act_nfs4 ... -=head1 ENVIRONMET VARIABLES +=head1 ENVIRONMENT VARIABLES None @@ -62,11 +62,11 @@ stat_regexp='/^(?!(class|crtime|snaptime|.*_bytes))/' # Graph settings global_attr=" - graph_title File system statictics - Activities of ${fs_type^^} + graph_title File system statictics - Activities of $( echo "$fs_type" | tr '[:lower:]' '[:upper:]' ) graph_category disk graph_args --base 1000 graph_vlabel Counts per second - graph_info File system statictics - Activities of ${fs_type^^} + graph_info File system statictics - Activities of $( echo "$fs_type" | tr '[:lower:]' '[:upper:]' ) " # Functions @@ -74,6 +74,8 @@ global_attr=" get_zone_id() { local osver zonename zoneid + # Note: Solaris 11 fsstat supports statistics per zone. Solaris 10 does not. + zoneid=0 osver=$( uname -r | cut -d. -f2 ) @@ -86,7 +88,7 @@ get_zone_id() { } autoconf() { - if [ -x "$( which kstat )" ]; then + if which kstat >/dev/null ; then echo yes else echo "no (failed to find executable 'kstat')" @@ -96,9 +98,9 @@ autoconf() { suggest() { # Print file systems which look active - kstat -p "unix:${zone_id}:${name_regexp}:/^(read_bytes|write_bytes)\$/" | \ - sed -e 's/vopstats_//' -e 's/:/ /g' | \ - awk '{ + kstat -p "unix:${zone_id}:${name_regexp}:/^(read_bytes|write_bytes)\$/" \ + | sed -e 's/vopstats_//' -e 's/:/ /g' \ + | awk '{ sum[ $3 ] += $5 } END { @@ -114,12 +116,12 @@ config() { local stat # Print global attributes - echo "${global_attr}" | sed -e 's/^ *//' -e '/^$/d' + echo "$global_attr" | sed -e 's/^ *//' -e '/^$/d' # Get stat names by kstat - kstat -p "unix:${zone_id}:vopstats_${fs_type}:${stat_regexp}" | \ - sed -e 's/vopstats_//' -e 's/:/ /g' | awk '{ print $4 }' | sort -u | \ - while read -r stat + kstat -p "unix:${zone_id}:vopstats_${fs_type}:${stat_regexp}" \ + | sed -e 's/vopstats_//' -e 's/:/ /g' | awk '{ print $4 }' | sort \ + | while read -r stat do # Print data attributes echo "${stat}.label ${stat#n}" @@ -127,11 +129,9 @@ config() { echo "${stat}.type DERIVE" echo "${stat}.min 0" done - - echo } -getvalue() { +fetch() { local stat value # Get fs names, stat names and values by kstat @@ -142,14 +142,12 @@ getvalue() { # unix:0:vopstats_hsfs:nread 407790 # ... - kstat -p "unix:${zone_id}:vopstats_${fs_type}:${stat_regexp}" | \ - sed -e 's/vopstats_//' -e 's/:/ /g' | awk '{ print $4,$5 }' | \ - while read -r stat value + kstat -p "unix:${zone_id}:vopstats_${fs_type}:${stat_regexp}" \ + | sed -e 's/vopstats_//' -e 's/:/ /g' | awk '{ print $4,$5 }' \ + | while read -r stat value do echo "${stat}.value ${value}" done - - echo } # Main @@ -165,10 +163,10 @@ suggest) ;; config) config - [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && getvalue + [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch ;; *) - getvalue + fetch ;; esac diff --git a/plugins/solaris/fsstat_bytes b/plugins/solaris/fsstat_bytes index f2078d4a..c95bfdfc 100755 --- a/plugins/solaris/fsstat_bytes +++ b/plugins/solaris/fsstat_bytes @@ -20,7 +20,7 @@ cd /path/to/munin/etc/plugins ln -s /path/to/munin/lib/plugins/fsstat_bytes . -=head1 ENVIRONMET VARIABLES +=head1 ENVIRONMENT VARIABLES env.exclude - file system(s) to exclude seperated by white-space. example: env.exclude autofs @@ -82,6 +82,8 @@ is_excluded() { get_zone_id() { local osver zonename zoneid + # Note: Solaris 11 fsstat supports statistics per zone. Solaris 10 does not. + zoneid=0 osver=$( uname -r | cut -d. -f2 ) @@ -94,7 +96,7 @@ get_zone_id() { } autoconf() { - if [ -x "$( which kstat )" ]; then + if which kstat >/dev/null ; then echo yes else echo "no (failed to find executable 'kstat')" @@ -105,12 +107,12 @@ config() { local fs # Print global attributes - echo "${global_attr}" | sed -e 's/^ *//' -e '/^$/d' + echo "$global_attr" | sed -e 's/^ *//' -e '/^$/d' # Get fs names by kstat - kstat -p "unix:${zone_id}:${name_regexp}:${data_in}" | \ - sed -e 's/vopstats_//' -e 's/:/ /g' | awk '{ print $3 }' | sort -u | \ - while read -r fs + kstat -p "unix:${zone_id}:${name_regexp}:${data_in}" \ + | sed -e 's/vopstats_//' -e 's/:/ /g' | awk '{ print $3 }' | sort \ + | while read -r fs do is_excluded "$fs" && continue @@ -125,11 +127,9 @@ config() { echo "${fs}_${data_in}.type DERIVE" echo "${fs}_${data_in}.min 0" done - - echo } -getvalue() { +fetch() { local fs stat value # Get fs names, stat names and values by kstat @@ -140,16 +140,14 @@ getvalue() { # unix:0:vopstats_hsfs:nread 407790 # ... - kstat -p "unix:${zone_id}:${name_regexp}:/^(${data_in}|${data_out})\$/" | \ - sed -e 's/vopstats_//' -e 's/:/ /g' | awk '{ print $3,$4,$5 }' | \ - while read -r fs stat value + kstat -p "unix:${zone_id}:${name_regexp}:/^(${data_in}|${data_out})\$/" \ + | sed -e 's/vopstats_//' -e 's/:/ /g' | awk '{ print $3,$4,$5 }' \ + | while read -r fs stat value do is_excluded "$fs" && continue echo "${fs}_${stat}.value ${value}" done - - echo } # Main @@ -162,10 +160,10 @@ autoconf) ;; config) config - [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && getvalue + [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch ;; *) - getvalue + fetch ;; esac diff --git a/plugins/solaris/interrupts b/plugins/solaris/interrupts index bb34b5ef..d421004e 100755 --- a/plugins/solaris/interrupts +++ b/plugins/solaris/interrupts @@ -64,7 +64,7 @@ data_attr=" # Functions autoconf() { - if [ -x "$( which kstat )" ]; then + if which kstat >/dev/null ; then echo yes else echo "no (failed to find executable 'kstat')" @@ -75,16 +75,14 @@ config() { local label_max_length=45 # print global attributes - sed -e 's/^ *//' -e '/^$/d' <<< "${global_attr}" + echo "$global_attr" | sed -e 's/^ *//' -e '/^$/d' # print data source attributes # split line into field,type,draw,label - local fields field type draw label - fields= - while read -r field type draw label + local field type draw label + echo "$data_attr" | while read -r field type draw label do [ -z "$field" ] && continue - fields="${fields} ${field}" echo "${field}.type ${type}" echo "${field}.draw ${draw}" @@ -92,14 +90,12 @@ config() { if [ "${type}" = DERIVE ]; then echo "${field}.min 0" fi - done <<< "${data_attr}" - - echo graph_order "$fields" + done } -getvalue() { +fetch() { local field type draw label - while read -r field type draw label + echo "$data_attr" | while read -r field type draw label do [ -z "$field" ] && continue @@ -112,7 +108,7 @@ getvalue() { value=$( kstat -p "cpu::sys:${field}" | awk '{ sum += $2 } END { print sum }' ) echo "${field}.value ${value}" - done <<< "${data_attr}" + done } # Main @@ -122,10 +118,10 @@ autoconf) ;; config) config - [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && getvalue + [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch ;; *) - getvalue + fetch ;; esac