- it's java. I haven't got too much memory =)
- monitor show error and doesn't start.
- its installer broke you boot. It added mount usbfs to fstab, but usbfs has been deprecated for a long time already and you kernel build without it.
NUT has many parts:
- driver - reads ups info from usb.
- server - sends this info and events to client when they request it. Server has own user/pass list.
- client - periodically reads info/events from server and does some actions. It needs login/pass for some action.
- scheduler - script that help us with timer.
- turn off beeper, because it my home server machine and I like sleep well.
- turn server after ~90 sec on battery or less. Not when ups has low battery.
- don't turn off ups after server. I need to supply ADSL modem and have WIFI as long as possible.
All things we did from root, so you first command:
$ sudo -s
# apt-get install nut
Config driver:
You can get correct driver for you ups here# nano /etc/nut/ups.conf
[ippon]
driver = blazer_usb
port = auto
desc = "IPPON 400 UPS, USB interface"
Change mode to standalone. Without this and restart service driver get errors.
# nano /etc/nut/nut.conf
MODE=standalone
reboot, than# upsdrvctl start
and you get smth like thisNetwork UPS Tools - UPS driver controller 2.7.1
Network UPS Tools - Megatec/Q1 protocol USB driver 0.10 (2.7.1)
Supported UPS detected with megatec protocol
Vendor information unavailable
No values provided for battery high/low voltages in ups.conf
Using 'guestimation' (low: 10.400000, high: 13.000000)!
Battery runtime will not be calculated (runtimecal not set)
Config server:
Server need listen only localhost# nano /etc/nut/upsd.conf
LISTEN 127.0.0.1 3493
Add one master server user. It can change ups config.# nano /etc/nut/upsd.users
[upsmon]
password = secret
actions = SET FSD
instcmds = ALL
upsmon master
Config client monitor:
# nano /etc/nut/upsmon.conf
MONITOR ippon@localhost 1 upsmon secret master
#this is default config setting
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
# Config for timer, email and console notification
# I don't know NUT well, so this maybe is redundant
NOTIFYCMD /sbin/upssched
NOTIFYMSG ONLINE "UPS %s on line power"
NOTIFYMSG ONBATT "UPS %s on battery"
NOTIFYMSG LOWBATT "UPS %s battery is low"
NOTIFYMSG FSD "UPS %s: forced shutdown in progress"
NOTIFYMSG COMMOK "Communications with UPS %s established"
NOTIFYMSG COMMBAD "Communications with UPS %s lost"
NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding"
NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced"
NOTIFYMSG NOCOMM "UPS %s is unavailable"
NOTIFYMSG NOPARENT "upsmon parent process died - shutdown impossible"
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC
To start client and server on one machine# nano /etc/nut/nut.conf
MODE=standalone
Restart service# service nut-server restart
# service nut-client restart
Get ups status$ upsc ippon@localhost
You get smth like this:Init SSL without certificate database
battery.charge: 100
battery.voltage: 13.60
battery.voltage.high: 13.00
battery.voltage.low: 10.40
battery.voltage.nominal: 12.0
device.type: ups
driver.name: blazer_usb
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.version: 2.7.1
driver.version.internal: 0.10
input.current.nominal: 1.0
input.frequency: 50.3
input.frequency.nominal: 50
input.voltage: 232.0
input.voltage.fault: 232.0
input.voltage.nominal: 220
output.voltage: 232.0
ups.beeper.status: disabled
ups.delay.shutdown: 30
ups.delay.start: 180
ups.load: 30
ups.productid: 5161
ups.status: OL
ups.temperature: 25.0
ups.type: offline / line interactive
ups.vendorid: 0665
Ok. Now all basic NUT works.Turn off beeper
Get all supported command# upscmd -l ippon@localhost
IPPON is cheap ups, so you haven't many commandsbeeper.toggle - Toggle the UPS beeper
load.off - Turn off the load immediately
load.on - Turn on the load immediately
shutdown.return - Turn off the load and return when power is back
shutdown.stayoff - Turn off the load and remain off
shutdown.stop - Stop a shutdown in progress
test.battery.start - Start a battery test
test.battery.start.deep - Start a deep battery test
test.battery.start.quick - Start a quick battery test
test.battery.stop - Stop the battery test
Create script to turn off beeper# nano /etc/nut/beeper.off.sh
# chmod 750 /etc/nut/beeper.off.sh
# chown root:nut /etc/nut/beeper.off.sh
#!/bin/sh
upsc ippon@localhost ups.beeper.status 2>&1 | grep enabled && upscmd -u upsmon -p secret ippon@localhost beeper.toggle
I don't know upstart well so we modify client start script to because we need run turn off every time when we shutdown ups. Add sleep and beeper.off.sh
# nano /etc/init.d/nut-client
...
start)
log_daemon_msg "Starting $DESC" "$NAME"
check_var_directory
start_stop_client start
sleep 1
/etc/nut/beeper.off.sh
log_end_msg $?
;;)
...
Config timer and mail notification
You need nullmailer or smth like it to have email notification or just comment it.# nano /etc/nut/upssched.conf
CMDSCRIPT /etc/nut/cmd.sh
PIPEFN /tmp/upspipe
LOCKFN /tmp/upslock
AT ONBATT * EXECUTE powerout
AT ONBATT * START-TIMER shutdownnow 90
AT ONLINE * CANCEL-TIMER shutdownnow
AT ONLINE * EXECUTE powerup
After timer end, nut run CMDSCRIPT. EXECUTE run CMDSCRIPT too.# nano /etc/nut/cmd.sh
# chown root:nut /etc/nut/cmd.sh
# chmod 750 /etc/nut/cmd.sh
#!/bin/sh
case $1 in
powerout)
logger "UPS on battery. Shutdown in 90 seconds...."
echo -e "Subject: UPS monitor. On battery.\nThe UPS has been on battery for awhile" \
| sendmail lex2d.by@gmail.com
;;
powerup)
logger "UPS on line. Shutdown aborted."
echo -e "Subject: UPS monitor. On line.\nUPS on line. Shutdown aborted." \
| sendmail lex2d.by@gmail.com
;;
shutdownnow)
logger "UPS has been on battery for 90 seconds. Starting orderly shutdown"
/usr/bin/sudo /sbin/shutdown -h +0
;;
shutdowncritical)
logger "UPS battery level CRITICAL. Shutting down NOW!!!!"
/usr/bin/sudo /sbin/shutdown -h +0
;;
*)
logger "Unrecognized command: $1"
;;
esac
Add nut to sudo. We can't shutdown server without it.# visudo
# Add this to the end of file
nut ALL = (root) NOPASSWD: /sbin/shutdown
Maybe now you don't like NUT too...
No comments:
Post a Comment