|
2 years ago | |
---|---|---|
check_snmp_apc_ups_state | 2 years ago | |
README.md | 2 years ago | |
Screenshot_20231112_014602.png | 2 years ago | |
apc_read_sql_strings.sh | 2 years ago | |
apc_snmp_metrics.sh | 2 years ago | |
apcups_telegram.service | 2 years ago | |
apcups_telegram.sh | 2 years ago |
README.md
About
Bash APC scripts - other method for APC AP96xx than apcupsd or nut.
I express my gratitude to Alexey Maksimov for examples of working snmp handlers - (fork of his code is in the attachment)
This apc_snmp_metrics.sh script can show current state from networked APC UPS.
Tested on Centos 7 GNU/Linux with AP9618 in SURTD3000XLI, with external termistor AP9512TBLK
Usage
To start you need:
- add IP (string number 14 variable IPS)
- add the user (string number 15 variable SUSER)
- add the bot token (string number 20 variable TOKEN)
- add chat ID (string number 21 variable CHAT_ID)
- add the directory (optional - defalts creates in
$(pwd)
dir) - create an init file (optional, see the example apcups_telegram.service file)
For one-shot (non-interactive) - simple run in bash:
~# bash apc_snmp_metrics.sh
And there is example of success result (database not created, only verbosed hypothetic name with path) :
DB 2023.1112.0043_apc-metric.db
WATTS 16
AMPRS 2
CBATT 17
CEEXT 22
INPWA 221
PRBAT 100
REMAT 1:15:05.00
BAREP 1
DATES 1699739034
DATEN 491653013
EXITS 0
WATTS - percent of UPS load in watts
AMPRS - current load in amperes
CBATT - internal battery temperature
CEEXT - external AP9512TBLK temperature
INPWA - input line voltage
PRBAT - percent of charge batteries
REMAT - remain time for current load if 220/230 line turns off
BAREP - battery replasing key - 1 is OK, 2 is REPLACE
DATES - unix-seconds (date) of local machine
DATEN - nano-seconds, each string need for being unique
EXITS - exit-code from snmpget utility, used in Telegram function
For daemonized use --run
argument (mode for systemd unit)
This mode creates sqlite database file, than you can get logged data from it.
The database is created anew every time you start it, create a separate directory within /usr/share/ for example.
$ bash apc_snmp_metrics.sh --run
DB /root/2023.1112.0043_apc-metric.db
Warning! Monitor the disk usage, this script cat write more than 2 MB of data per hour!
For reading sqlite database (daemonized data-log) - run
~# bash apc_read_sql_strings.sh
This script searching for last writed .db file in specified folder and SELECTing from