Linux ups nut2: различия между версиями

Материал из noname.com.ua
Перейти к навигацииПерейти к поиску
Строка 96: Строка 96:
   
 
== Настройка Zabbix==
 
== Настройка Zabbix==
  +
===zabbix-agent===
  +
<PRE>
  +
UserParameter=ups.battery.capacity,/usr/bin/upsc riello@172.31.100.13:3493 battery.capacity 2>/dev/null
  +
UserParameter=ups.battery.charge,/usr/bin/upsc riello@172.31.100.13:3493 battery.charge 2>/dev/null
  +
UserParameter=ups.battery.runtime,/usr/bin/upsc riello@172.31.100.13:3493 battery.runtime 2>/dev/null
  +
UserParameter=ups.battery.voltage,/usr/bin/upsc riello@172.31.100.13:3493 battery.voltage 2>/dev/null
  +
UserParameter=ups.battery.voltage.nominal,/usr/bin/upsc riello@172.31.100.13:3493 battery.voltage.nominal 2>/dev/null
  +
UserParameter=ups.input.bypass.frequency,/usr/bin/upsc riello@172.31.100.13:3493 input.bypass.frequency 2>/dev/null
  +
UserParameter=ups.input.bypass.voltage,/usr/bin/upsc riello@172.31.100.13:3493 input.bypass.voltage 2>/dev/null
  +
UserParameter=ups.input.frequency,/usr/bin/upsc riello@172.31.100.13:3493 input.frequency 2>/dev/null
  +
UserParameter=ups.input.voltage,/usr/bin/upsc riello@172.31.100.13:3493 input.voltage 2>/dev/null
  +
UserParameter=ups.output.frequency,/usr/bin/upsc riello@172.31.100.13:3493 output.frequency 2>/dev/null
  +
UserParameter=ups.output.frequency.nominal,/usr/bin/upsc riello@172.31.100.13:3493 output.frequency.nominal 2>/dev/null
  +
UserParameter=ups.output.power.percent,/usr/bin/upsc riello@172.31.100.13:3493 output.power.percent 2>/dev/null
  +
UserParameter=ups.output.voltage,/usr/bin/upsc riello@172.31.100.13:3493 output.voltage 2>/dev/null
  +
UserParameter=ups.output.voltage.nominal,/usr/bin/upsc riello@172.31.100.13:3493 output.voltage.nominal 2>/dev/null
  +
UserParameter=ups.ups.load,/usr/bin/upsc riello@172.31.100.13:3493 ups.load 2>/dev/null
  +
UserParameter=ups.ups.power.nominal,/usr/bin/upsc riello@172.31.100.13:3493 ups.power.nominal 2>/dev/null
  +
UserParameter=ups.ups.realpower.nominal,/usr/bin/upsc riello@172.31.100.13:3493 ups.realpower.nominal 2>/dev/null
  +
UserParameter=ups.ups.temperature,/usr/bin/upsc riello@172.31.100.13:3493 ups.temperature 2>/dev/null
  +
#UserParameter=ups.ups.status,/usr/bin/upsc riello@172.31.100.13:3493 ups.status 2>/dev/null
  +
UserParameter=ups.ups.status,/bin/bash -c "if [ \"$(/usr/bin/upsc riello@172.31.100.13:3493 ups.status 2>/dev/null | awk '{print $1}' )\" == \"OL\" ]; then echo 0; else echo 1; fi"
  +
</PRE>
   
 
=Материалы=
 
=Материалы=

Версия 12:53, 28 июля 2021


Linux UPS 2

Тут короткая заметка про настройку мониторигна бесперебойника через нагиос

Настройка NUT

  • Пакеты
ii  nut                                      2.7.4-11ubuntu4                                 all          network UPS tools - metapackage
ii  nut-cgi                                  2.7.4-11ubuntu4                                 amd64        network UPS tools - web interface
ii  nut-client                               2.7.4-11ubuntu4                                 amd64        network UPS tools - clients
ii  nut-doc                                  2.7.4-11ubuntu4                                 all          network UPS tools - documentation
ii  nut-ipmi                                 2.7.4-11ubuntu4                                 amd64        network UPS tools - IPMI driver
ii  nut-server                               2.7.4-11ubuntu4                                 amd64        network UPS tools - core system
ii  nut-snmp                                 2.7.4-11ubuntu4                                 amd64        network UPS tools - SNMP driver
ii  nut-xml                                  2.7.4-11ubuntu4                                 amd64        network UPS tools - XML/HTTP driver
  • Конфиги (минимальные)

Мне не требуется ничего кроме как возможность снимать параметры с UPS - никакой обработки событий вроде выключения сервера при низком заряде батареи не предусмотрено

/etc/ nut.conf

 nut.conf  | grep -v '#'
MODE=standalone

/etc/ups.conf

cat ups.conf | grep -v '#'
[riello]
    driver = riello_ser
    port = /dev/ttyUSB0
    port = /dev/serial/by-id/usb-Cypress_Semiconductor_USB_to_Serial-if00-port0
    pollinterval = 5
    desc = "Something descriptive"

/etc/upsd.conf

cat upsd.conf | grep -v '#'
LISTEN 127.0.0.1 3493
LISTEN 172.31.100.13 3493

/etc/upsmon.conf

cat upsmon.conf | grep -v '#'
MINSUPPLIES 0
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5

/etc/upssched.conf

cat upssched.conf | grep -v '#'
CMDSCRIPT /bin/upssched-cmd


  • Сервисы

Всего 2 сервеса - драйвер и сервер (запускать сначала сервер, насколько я могу судить серис драйвера сам остановится если нет сервера которому он нужен)

systemctl status nut-server
● nut-server.service - Network UPS Tools - power devices information server
     Loaded: loaded (/lib/systemd/system/nut-server.service; disabled; vendor preset: enabled)
     Active: active (running) since Mon 2021-07-26 11:58:47 EEST; 2 days ago
   Main PID: 506891 (upsd)
      Tasks: 1 (limit: 76762)
     Memory: 1.2M
     CGroup: /system.slice/nut-server.service
             └─506891 /lib/nut/upsd
systemctl status nut-driver
● nut-driver.service - Network UPS Tools - power device driver controller
     Loaded: loaded (/lib/systemd/system/nut-driver.service; static; vendor preset: enabled)
     Active: active (running) since Mon 2021-07-26 11:26:56 EEST; 2 days ago
   Main PID: 484091 (riello_ser)
      Tasks: 1 (limit: 76762)
     Memory: 1.1M
     CGroup: /system.slice/nut-driver.service
             └─484091 /lib/nut/riello_ser -a riello


Настройка Zabbix

zabbix-agent

UserParameter=ups.battery.capacity,/usr/bin/upsc         riello@172.31.100.13:3493 battery.capacity             2>/dev/null
UserParameter=ups.battery.charge,/usr/bin/upsc           riello@172.31.100.13:3493 battery.charge               2>/dev/null
UserParameter=ups.battery.runtime,/usr/bin/upsc          riello@172.31.100.13:3493 battery.runtime              2>/dev/null
UserParameter=ups.battery.voltage,/usr/bin/upsc          riello@172.31.100.13:3493 battery.voltage              2>/dev/null
UserParameter=ups.battery.voltage.nominal,/usr/bin/upsc  riello@172.31.100.13:3493 battery.voltage.nominal      2>/dev/null
UserParameter=ups.input.bypass.frequency,/usr/bin/upsc   riello@172.31.100.13:3493 input.bypass.frequency       2>/dev/null
UserParameter=ups.input.bypass.voltage,/usr/bin/upsc     riello@172.31.100.13:3493 input.bypass.voltage         2>/dev/null
UserParameter=ups.input.frequency,/usr/bin/upsc          riello@172.31.100.13:3493 input.frequency              2>/dev/null
UserParameter=ups.input.voltage,/usr/bin/upsc            riello@172.31.100.13:3493 input.voltage                2>/dev/null
UserParameter=ups.output.frequency,/usr/bin/upsc         riello@172.31.100.13:3493 output.frequency             2>/dev/null
UserParameter=ups.output.frequency.nominal,/usr/bin/upsc riello@172.31.100.13:3493 output.frequency.nominal     2>/dev/null
UserParameter=ups.output.power.percent,/usr/bin/upsc     riello@172.31.100.13:3493 output.power.percent         2>/dev/null
UserParameter=ups.output.voltage,/usr/bin/upsc           riello@172.31.100.13:3493 output.voltage               2>/dev/null
UserParameter=ups.output.voltage.nominal,/usr/bin/upsc   riello@172.31.100.13:3493 output.voltage.nominal       2>/dev/null
UserParameter=ups.ups.load,/usr/bin/upsc                 riello@172.31.100.13:3493 ups.load                     2>/dev/null
UserParameter=ups.ups.power.nominal,/usr/bin/upsc        riello@172.31.100.13:3493 ups.power.nominal            2>/dev/null
UserParameter=ups.ups.realpower.nominal,/usr/bin/upsc    riello@172.31.100.13:3493 ups.realpower.nominal        2>/dev/null
UserParameter=ups.ups.temperature,/usr/bin/upsc          riello@172.31.100.13:3493 ups.temperature              2>/dev/null
#UserParameter=ups.ups.status,/usr/bin/upsc              riello@172.31.100.13:3493 ups.status             2>/dev/null
UserParameter=ups.ups.status,/bin/bash -c "if [ \"$(/usr/bin/upsc riello@172.31.100.13:3493 ups.status 2>/dev/null | awk '{print $1}' )\" == \"OL\" ]; then echo 0; else echo 1; fi"

Материалы