1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 14:16:00 +00:00

Added multigraph capabilities and fixed regex

This commit is contained in:
Tobias 2014-12-07 18:41:13 +01:00
parent 8e18199f16
commit bda87a3756

View file

@ -1,33 +1,55 @@
#!/bin/sh #!/bin/sh
# #
# (c) Andreas Kreisl # (c) Andreas Kreisl extended by Tobias Schramm
# #
# Link name will be used as title: apc_{$title} # Link name will be used as title: apc_{$title}
# #
# env.keys LOADPCT BCHARGE LINEV BATTV TIMELEFT # env.keys LOADPCT BCHARGE LINEV BATTV TIMELEFT
# env.unit % or Volt or Minutes
# #
if [ -z "$keys" ]; then if [ -z "$keys" ]; then
keys="TIMELEFT" keys="LINEV LOADPCT BCHARGE NUMXFERS TIMELEFT"
fi fi
apcinfo=`/sbin/apcaccess`
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then
title=`basename $0 | sed 's/^apc_//g' | awk '{ sub(/^./,toupper(substr($0,1,1))); print; }'` title=`basename $0 | sed 's/^apc_//g' | awk '{ sub(/^./,toupper(substr($0,1,1))); print; }'`
echo "graph_title APC Status - $title" echo 'multigraph apc_status'
echo 'graph_args --base 1000 -l 0 ' echo "graph_title UPS Status - $title"
echo "graph_vlabel $unit" echo 'graph_args --base 1000'
echo 'graph_category sensors' echo 'graph_category hardware'
title=`/sbin/apcaccess | egrep "^MODEL" | awk '{print $3" "$4" "$5" "$6" "$7" "$8" "$9;}'` title=`/sbin/apcaccess | egrep "^MODEL" | awk '{print $3" "$4" "$5" "$6" "$7" "$8" "$9;}'`
echo "graph_info $title" echo "graph_info $title"
for key in $keys; do for key in $keys; do
echo "$key.label $key" echo "$key.label $key"
echo "$key.info Value of $key." echo "$key.info Value of $key"
echo "$key.draw LINE2" echo "$key.draw LINE1"
done
for key in $keys; do
key_lower=`echo "$key" | awk '{print tolower($0);}'`
unit=`echo "$apcinfo" | egrep "^$key" | awk '{print $4;}'`
echo "multigraph apc_status.$key_lower"
echo "graph_title $key"
echo 'graph_args --base 1000'
if [ -n "$unit" ]; then
echo "graph_vlabel $unit"
fi
echo 'graph_category hardware'
echo "$key.label $key"
echo "$key.info $key."
echo "$key.draw LINE1"
done done
exit 0 exit 0
fi fi
searchkey=`echo "$keys" | tr " " "\|"` echo 'multigraph apc_status'
/sbin/apcaccess | egrep "$searchkey" | awk '{print $1".value "$3;}' for key in $keys; do
echo "$apcinfo" | egrep "^$key" | awk '{print $1".value "$3;}'
done
for key in $keys; do
key_lower=`echo "$key" | awk '{print tolower($0)}'`
echo "multigraph apc_status.$key_lower"
echo "$apcinfo" | egrep "^$key" | awk '{print $1".value "$3;}'
done