# 20020619 bog@deol.ru http://www.bog.pp.ru/hard/UPS.html#rrdtool
# $1 is UPS number
#
if [ -z "$1" ]
then
  echo Usage: ups_update.sh ups-number
  exit
fi
if [ "$1" = "1" ]
then
  host=адрес-UPS
  community=имя-сообщества
  index=имя-UPS
else
  echo Wrong UPS number
  exit
fi
string=`snmpget -On -Oq -Oe -m PowerNet-MIB $host $community upsBasicBatteryStatus.0 upsAdvBatteryCapacity.0 upsAdvBatteryTemperature.0 upsAdvBatteryReplaceIndicator.0 upsAdvInputLineVoltage.0 upsAdvInputMaxLineVoltage.0 upsAdvInputMinLineVoltage.0 upsAdvInputFrequency.0 upsAdvInputLineFailCause.0 upsBasicOutputStatus.0 upsAdvOutputVoltage.0 upsAdvOutputFrequency.0 upsAdvOutputLoad.0 upsAdvTestDiagnosticsResults.0 upsAdvTestCalibrationResults.0 upsCommStatus.0 | awk '{printf ":"$2}'`

string2=`snmpget -On -m PowerNet-MIB $host $community upsBasicBatteryTimeOnBattery.0 upsAdvBatteryRunTimeRemaining.0 | awk '{printf ":"substr($4,2,length($4)-2)}'`

/usr/local/bin/rrdtool update ups.$index.rrd N$string$string2

