diff --git a/axpert_grid_offline.sh b/axpert_grid_offline.sh new file mode 100755 index 0000000..0496da5 --- /dev/null +++ b/axpert_grid_offline.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +### This script connects to a axpert inverter, using https://github.com/b48736/axpert-monitor +### It checks if the grid power is "on", and in case it's not alerts the server and informs about the battery percentage status and loads + +topicurl=https://172.26.0.15/hangar_servers +GRID_STATUS=$(/usr/local/bin/axpert-query -c QPIGS | grep "gridVoltage" | awk '{print substr($2, 1, length($2)-1)}') +BATTERY_STATUS=$(/usr/local/bin/axpert-query -c QPIGS | grep "batteryCapacity" | awk '{print substr($2, 1, length($2)-1)}') +OUTPUT_LOAD=$(/usr/local/bin/axpert-query -c QPIGS | grep "outputLoadPercent" | awk '{print substr($2, 1, length($2)-1)}') +OUTPUT_APPARENT=$(/usr/local/bin/axpert-query -c QPIGS | grep "outputPowerApparent" | awk '{print substr($2, 1, length($2)-1)}') +OUTPUT_TRUE=$(/usr/local/bin/axpert-query -c QPIGS | grep "outputPowerActive" | awk '{print substr($2, 1, length($2)-1)}') + + if [ ${GRID_STATUS} = 0 ]; then + curl -k --retry 3 \ + -d "Grid power loss in Axpert Inverter, electrical problem! " \ + -d "Lithium battery charge percentage: $BATTERY_STATUS % " \ + -d "Output load percentage: $OUTPUT_LOAD % " \ + -d "Output load apparent: $OUTPUT_APPARENT VA " \ + -d "Output load true: $OUTPUT_TRUE P " \ + -H "Title: grid power loss in Axpert Inverter" \ + -H "Priority: urgent" \ + -H "Tags: rotating_light,boar" \ + $topicurl + + fi