mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Fix for pull req #833
This commit is contained in:
parent
726abac461
commit
0670445765
4 changed files with 53 additions and 65 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue