Hello all.
I set up monitoring of remote APC UPS SMT3000 using SNMP on the server (windows) connected to the UPS.
Here is the instruction:
On a server running an OS, for example Windows, to which UPS APC is connected, you must install / start the SNMP service. It will collect statistics on the operation of the UPS and provide information to customers.
The Domoticz management server (SNMP service client) will request information from the / UPS server for further processing.
Install / configure the SNMP service in Windows
Install/configure the SNMP service in Windows
Programs -> Programs and Components -> Windows Components (choose SNMP)
Start the service control and select the SNMP service
On the “Security” tab, add the community name “Public” with “read only” rights and select the “Receive SNMP packets from any node” option (it is possible to specify only specific addresses of clients).
On the “SNMP Agent” tab, fill in the data as you wish:
You also need to add a “trap” as in the picture, the ip address is Domoticz
image5.png
2. Install APC PowerChute
On the manufacturer's website, download the APC PowerChute suitable for your UPS
https://www.apc.com/shop/ru/ru/categori ... /N-13kn0i4
I used the version - PowerChute Business Edition v9.2, it does not support SNMP v3 and settings are easier.
During installation, the system will automatically query the ports and configure the connection to the UPS(USB), and also request a password for the UPS Web Management Interface.
After installation, you must go to the Web interface at:
https://localhost:6547 . Most likely, the browser will block the transition and write that we’ll ignore the “connection is not protected” and proceed.
On the “PowerChute” tab, select “SNMP Settings” and activate “SNMPv1”
image3.png
Reboot.
The server is ready to transfer the UPS parameters, now we will configure Domoticz to read them.
Install SNMP on Raspberry Pi
Code: Select all
sudo apt-get install snmpd
sudo apt-get install snmp
Reboot the Pi
Run to check:
Code: Select all
snmpget -v 1 -c public -O qv IPserver 1.3.6.1.4.1.318.1.1.1.1.1.1.0
Where is the “public” community that you specified when configuring SNMP,, “IPserver ” - is the IP address of the server with UPS
We will get a response with the name:
Now creating in Domoticz 1 virtual switch and several sensors (3 for voltage, 2 for %, 1 text and 1 temperature)
The script itself is created here:
UPS_APC.sh in the /domoticz/scripts/ folder
script
#!/bin/bash
Code: Select all
# Settings
UPSIP="192.x.x.x" # UPS (SNMP server) IP Address
PASSWORD="public" # SNMP Password
DOMO_IP="192.x.x.x" # Domoticz IP Address
DOMO_PORT="8080" # Domoticz Port
# Monitoring parameters
UPS_IDX="53" # UPS Switch IDX (ON/OFF State)
upsAdvInputLineVoltage_IDX="50" # APC UPS Input Voltage (V AC)
upsAdvBatteryTemperature_IDX="52" # APC UPS Internal Temperature (C)
upsAdvBatteryCapacity_IDX="54" # APC UPS Battery Capacity (%)
upsAdvBatteryRunTimeRemaining_IDX="55" # APC UPS Battery Runtime Remaining (TimeTicks)
upsAdvBatteryActualVoltage_IDX="56" # APC UPS Battery Voltage (V DC)
upsAdvOutputLoad_IDX="57" # APC UPS Output Load (%) VA
upsAdvOutputVoltage_IDX="58" # APC UPS Output Voltage (V AC)
# Check if UPS in online
PINGTIME=`ping -c 1 -q $UPSIP | awk -F"/" '{print $5}' | xargs`
echo $PINGTIME
if expr "$PINGTIME" '>' 0
then
curl -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=devices&rid=$UPS_IDX" | grep "Status" | grep "On" > /dev/null
if [ $? -eq 0 ] ; then
echo "UPS already ON"
else
echo "UPS ON"
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=switchlight&idx=$UPS_IDX&switchcmd=On"
fi
# UPS Input Voltage (V AC)
UPSInVolt=`snmpget -v 1 -c $PASSWORD -O qv $UPSIP 1.3.6.1.4.1.318.1.1.1.3.2.1.0`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$upsAdvInputLineVoltage_IDX&nvalue=0&svalue=$UPSInVolt"
# UPS Battery Temperature
UPSBattemp=`snmpget -v 1 -c $PASSWORD -O qv $UPSIP 1.3.6.1.4.1.318.1.1.1.2.2.2.0`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$upsAdvBatteryTemperature_IDX&nvalue=0&svalue=$UPSBattemp"
# UPS Battery Capacity (%)
UPSBatCapst=`snmpget -v 1 -c $PASSWORD -O qv $UPSIP 1.3.6.1.4.1.318.1.1.1.2.2.1.0`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$upsAdvBatteryCapacity_IDX&nvalue=0&svalue=$UPSBatCapst"
# UPS Battery Runtime Remaining (TimeTicks)
UPSTimeRem=`snmpget -v 1 -c $PASSWORD -O qv $UPSIP 1.3.6.1.4.1.318.1.1.1.2.2.3.0`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$upsAdvBatteryRunTimeRemaining_IDX&nvalue=0&svalue=$UPSTimeRem"
# UPS Battery Voltage (V DC)
UPSBatVolt=`snmpget -v 1 -c $PASSWORD -O qv $UPSIP 1.3.6.1.4.1.318.1.1.1.2.2.8.0`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$upsAdvBatteryActualVoltage_IDX&nvalue=0&svalue=$UPSBatVolt"
# UPS Output Load (%) VA
UPSOutLoad=`snmpget -v 1 -c $PASSWORD -O qv $UPSIP 1.3.6.1.4.1.318.1.1.1.4.2.3.0`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$upsAdvOutputLoad_IDX&nvalue=0&svalue=$UPSOutLoad"
# UPS Output Voltage (V AC)
UPSOutVolt=`snmpget -v 1 -c $PASSWORD -O qv $UPSIP 1.3.6.1.4.1.318.1.1.1.4.2.1.0`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$upsAdvOutputVoltage_IDX&nvalue=0&svalue=$UPSOutVolt"
else
curl -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=devices&rid=$UPS_IDX" | grep "Status" | grep "Off" > /dev/null
if [ $? -eq 0 ] ; then
echo "UPS already OFF"
else
echo "UPS OFF"
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=switchlight&idx=$UPS_IDX&switchcmd=Off"
fi
fi
In the script IP addresses and identifiers (№ IDX) replace with your own.
If Domoticz is password protected, you need to add 2 variables:
Code: Select all
DOMO_LOGIN="yourusername"
DOMO_PASS="yourpassword"
And change the link in the request to this view:
Code: Select all
http://$DOMO_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT
Instead:
Making the script executable:
In the folder with the script type:
Run to check:
Configure the scheduler
Updating once a minute:
Code: Select all
*/1 * * * * /home/pi/domoticz/scripts/UPS_APC.sh
Done!
image3.png
p.s. sorry for my english