You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.6 KiB
77 lines
2.6 KiB
## About
|
|
|
|
**Bash APC scripts** - other method for APC AP96xx than apcupsd or nut.
|
|
|
|
*I express my gratitude to [Alexey Maksimov](https://blog.it-kb.ru/about-this-blog/) for examples of working snmp handlers - (fork of [his code](https://github.com/Aleksey-Maksimov/check_snmp_apc_ups_state) 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**
|
|
|
|
<br/>
|
|
|
|
## Usage
|
|
To start you need:
|
|
1. add IP (string number 14 variable IPS)
|
|
2. add the user (string number 15 variable SUSER)
|
|
3. add the bot token (string number 20 variable TOKEN)
|
|
4. add chat ID (string number 21 variable CHAT_ID)
|
|
5. add the directory (optional - defalts creates in ```$(pwd)``` dir)
|
|
6. 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
|
|
|
|
<br/>
|
|
|
|
### 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
|
|
|
|
<br/>
|
|
|
|
### Also have fun! Bash rules!
|
|
|
|
 |