Выключение "сервера" через определенный промежуток времени при отсутствии внешнего питания на Smart UPS.
Включение в нужной последовательности: ATEN PN9108 (около $650), IPMI, WoL (?)
/usr/local/bin/check-ups#!/bin/sh# Shutdown delay in sec.shutdown_delay=600# Temp file namepoff_file="/usr/local/bin/poweroff"input_voltage=$(snmpget -v1 -c public -O qv 192.168.1.200 1.3.6.1.4.1.318.1.1.1.3.2.1.0)if [ $input_voltage -eq 0 ]; then if [ -e $poff_file ]; then if [ `expr $(date +%s) - $(date -r $poff_file +%s)` -ge $shutdown_delay ]; then # Remove power off temp file and shuting down rm $poff_file /sbin/shutdown -P now fi else touch $poff_file fielse if [ -e $poff_file ]; then rm $poff_file fifiЗапихиваем это в root crontab выполняться каждую минуту. Сильно гадит в логи.
/usr/local/bin/power-monitor#!/bin/shcnt=0 # Shutdown delay countershutdown_delay=60 # Count of 10-sec intervals before shutdownwhile :; dosleep 10if [ $(snmpget -v1 -c public -O qv 192.168.1.200 1.3.6.1.4.1.318.1.1.1.3.2.1.0) -eq 0 ]; then cnt=`expr $cnt + 1`else cnt=0fiif [ $cnt -gt $shutdown_delay ]; then /sbin/shutdown -P nowfidone/etc/systemd/system/power-monitor.service[Unit]Description=Power Monitor ServiceAfter=network.targetRequires=network.target[Service]Type=simpleExecStart=/usr/local/bin/power-monitorUser=rootGroup=root[Install]WantedBy=multi-user.target$ sudo systemctl enable power-monitorПротестировать.