1
0
mirror of https://github.com/librenms/librenms-agent.git synced 2024-05-09 09:54:52 +00:00
priiduonu 2e8c6b07d6 Update ups-apcups.sh (#361)
Filter out `LINEV` value as some APC models also return `MAXLINEV` and `MINLINEV` values in `apcaccess` output, therefore ruining the final output.
2021-03-22 14:09:20 +01:00

31 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
################################################################
# copy this script to /etc/snmp/ and make it executable: #
# chmod +x /etc/snmp/ups-apcups.sh #
# ------------------------------------------------------------ #
# edit your snmpd.conf and include: #
# extend ups-apcups /etc/snmp/ups-apcups.sh #
#--------------------------------------------------------------#
# restart snmpd and activate the app for desired host #
#--------------------------------------------------------------#
# please make sure you have the path/binaries below #
################################################################
BIN_APCS='/sbin/apcaccess'
BIN_TR='/usr/bin/tr'
BIN_CUT='/usr/bin/cut'
BIN_GREP='/usr/bin/grep'
################################################################
# Don't change anything unless you know what are you doing #
################################################################
TMP=$($BIN_APCS 2>/dev/null)
for value in "^LINEV:[0-9]+" "LOADPCT:[0-9.]+" "BCHARGE:[0-9.]+" "TIMELEFT:[0-9.]+" "^BATTV:[0-9.]+" "NOMINV:[0-9]+" "NOMBATTV:[0-9.]+"
do
OUT=$(echo "$TMP" | $BIN_TR -d ' ' | $BIN_GREP -Eo "$value" | $BIN_CUT -d ":" -f 2)
if [ -n "$OUT" ]; then
echo "$OUT"
else
echo "Unknown"
fi
done