1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
#!@@BASH@@
# -*- sh -*-
: << =cut
=head1 NAME
ipmi_ - Plugin to monitor temperature, fan speed, watts or volts using IPMI
=head1 CONFIGURATION
=head2 ENVIRONMENT VARIABLES
This plugin does not use environment variables
=head2 WILDCARD PLUGIN
This plugin should be linked as ipmi_temp, ipmi_fans, ipmi_power or ipmi_volts,
and will show either temperatures, fan speeds, watts or volts based on its link
name.
=head1 NOTE
WARNING: Munin has a 10 second default timeout on plugins. On some
hosts ipmitool takes longer than that to probe all your hardware. In
this case this plugin us unusable.
=head1 AUTHOR
Nicolai Langfeldt <janl@linpro.no>
=head1 LICENSE
Donated to the public domain by Nicolai Langfeldt (janl@linpro.no)
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf suggest
=cut
#### Parse commandline to determine what the job is
CONFIG=no
case $1 in
autoconf)
type -p ipmitool &>/dev/null ||
{ echo 'no (missing ipmitool command)' && exit 0; }
ipmitool sensor &>/dev/null ||
{ echo 'no (unable to access IPMI device)' && exit 0; }
echo yes
exit 0
;;
suggest) echo fans
echo temp
echo power
echo volts
exit 0;;
config) CONFIG=config;;
esac
case $0 in
*_temp) MEASURE=temp;;
*_fans) MEASURE=fans;;
*_power) MEASURE=power;;
*_volts) MEASURE=volts;;
*) echo "Please invoke as ipmi_temp, ipmi_fans, ipmi_power or ipmi_volts" >&2
exit 1;;
esac
export CONFIG MEASURE
#### Work is done in this awk script
ipmitool sensor | gawk -F'|' '
BEGIN {
FANS = "";
TEMPS = "";
POWER = "";
VOLTS = "";
CFANS = "graph_title Fan speeds based on IPMI\ngraph_vlabel RPM or %\ngraph_category Sensors\n";
CTEMPS = "graph_title Machine temperature based on IPMI\ngraph_vlabel Degrees celcius\ngraph_category Sensors\n";
CPOWER = "graph_title Power usage based on IPMI\ngraph_vlabel W\ngraph_category Sensors\n";
CVOLTS = "graph_title Volts based on IPMI\ngraph_vlabel V\ngraph_category Sensors\n";
}
# Remove extraneous spaces to make output prettyer
{ gsub(/\t/," "); gsub(/ +/," "); gsub(/ +\|/,"|"); gsub(/\| +/,"|") }
# Skip lines with 0x0 in first column
/^[^|]+\|0x0\|/ { next; };
# Skip lines with na in first column
/^[^|]+\|na\|/ { next; };
# Parse temperatures
/degrees C/ {
NAME=THING=$1;
gsub(/[^A-Za-z0-9]/,"",NAME);
TEMP=$2;
# Find unique name
while (NAMES[NAME] >= 1) {
NAME=sprintf("%si",NAME);
}
NAMES[NAME]=1;
WARN=$8;
CRIT=$9;
TEMPS = sprintf("%s%s.value %s\n",TEMPS,NAME,TEMP);
CTEMPS = sprintf("%s%s.label %s\n",CTEMPS,NAME,THING);
if (CRIT !~ /na/ && CRIT != /^0.000/) {
CTEMPS = sprintf("%s%s.critical 0:%s\n",CTEMPS,NAME,CRIT);
}
if (WARN !~ /na/ && WARN != /^0.000/) {
CTEMPS = sprintf("%s%s.warning 0:%s\n",CTEMPS,NAME,WARN);
}
}
/(RPM|^Fan.*percent)/ {
NAME=THING=$1;
gsub(/[^A-Za-z0-9]/,"",NAME);
SPEED=$2;
# Find unique name
while (NAMES[NAME] >= 1) {
NAME=sprintf("%si",NAME);
}
NAMES[NAME]=1;
FANS = sprintf("%s%s.value %s\n",FANS,NAME,SPEED);
CFANS = sprintf("%s%s.label %s\n",CFANS,NAME,THING);
OK=$4;
MIN=$6;
if (MIN !~ /na/) {
CFANS = sprintf("%s%s.warning %s:\n",CFANS,NAME,MIN);
}
}
/Watts/ {
NAME=THING=$1;
gsub(/[^A-Za-z0-9]/,"",NAME);
WATTS=$2;
# Find unique name
while (NAMES[NAME] >= 1) {
NAME=sprintf("%si",NAME);
}
NAMES[NAME]=1;
POWER = sprintf("%s%s.value %s\n",POWER,NAME,WATTS);
CPOWER = sprintf("%s%s.label %s\n",CPOWER,NAME,THING);
}
/Volts/ {
NAME=THING=$1
gsub(/[^A-Za-z0-9]/,"",NAME);
VOLTS_SENSOR=$2;
# Find unique name
while (NAMES[NAME] >= 1) {
NAME=sprintf("%si",NAME);
}
NAMES[NAME]=1;
VOLTS = sprintf("%s%s.value %s\n",VOLTS,NAME,VOLTS_SENSOR);
CVOLTS = sprintf("%s%s.label %s\n",CVOLTS,NAME,THING);
}
END {
if (ENVIRON["MEASURE"] == "temp") {
VALUE=TEMPS;
CONFIG=CTEMPS;
} else if (ENVIRON["MEASURE"] == "power") {
VALUE=POWER;
CONFIG=CPOWER;
} else if (ENVIRON["MEASURE"] == "volts") {
VALUE=VOLTS;
CONFIG=CVOLTS;
} else {
VALUE=FANS;
CONFIG=CFANS;
}
if (ENVIRON["CONFIG"] == "config")
printf "%s",CONFIG;
else
printf "%s",VALUE;
}
'
# vim: syntax=sh ts=4 et
|