#!/bin/sh
#
# Plugin to monitor voltage from UPS APC 9619
# 2009/04/10 12:27:02  radar AT aol DOT pl
# 
# ln -s /usr/share/munin/plugins/snmp__ups_voltage /etc/munin/plugins/snmp_UPS.IP_ups_voltage
#
# Magic markers (optional - only used by munin-config and some installation scripts):
#%# family=contrib

UPSHOST=$(basename $0 | awk -F'_|_' '{print $2}')

if [ "$1" = "config" ]; then
        UPSMODEL=$(snmpwalk -v 2c -c public $UPSHOST .1.3.6.1.4.1.318.1.1.1.1.1.1.0 | awk -F'"|"' '{print $2}')
        echo "graph_title $UPSMODEL - Voltage"
        echo "graph_args --base 1000"
        echo "graph_vlabel Voltage in (-) / out (+)"
        echo "graph_category sensors"
        echo "graph_info This graph shows the voltage read from $UPSMODEL"
        echo "voltagein.label V"
        echo "voltagein.type GAUGE"
        echo "voltagein.info Voltage."
        echo "voltagein.graph no"
        echo "voltageout.label V"
        echo "voltageout.type GAUGE"
        echo "voltageout.info Voltage."
        echo "voltageout.negative voltagein"
        exit 0
fi

echo -n "voltagein.value "
snmpwalk -v 2c -c public $UPSHOST .1.3.6.1.4.1.318.1.1.1.3.2.1.0 | awk '{print $NF}'
echo -n "voltageout.value "
snmpwalk -v 2c -c public $UPSHOST .1.3.6.1.4.1.318.1.1.1.4.2.1.0 | awk '{print $NF}'
