Ralfs

NUT config

Network UPS Tools Home
Good help: How to use UPS with nut Copy: copy there
Tested on Fedora Core 2 / Fedora 14
Install:
yum -y install nut nut-client nut-cgi
Install make user nut(57) and group nut(57)
Config in /etc/ups/

/etc/sysconfig/ups
setup model and device for locally attached UPS
MODEL=apcsmart
DEVICE=/dev/ttyS0
Fix permissions (Fedora Core 2):
cd /etc/ups
chown root:nut ups*
chmod 640 ups*
Configure /etc/ups/ups.conf
# /etc/ups/ups.conf
[myups]
        driver = apcsmart
        port = /dev/ttyS0
Configure /etc/ups/upsd.users
# /etc/ups/upsd.users
[monuser]
	password  = mypass
	upsmon master

[admin]
	password = admpass
	# No more in Fedora 12:
	#allowfrom = localhost 192.168.123.99
	actions = SET
	instcmds = ALL
Configure /etc/ups/upsmon.conf
# /etc/ups/upsmon.conf
MONITOR myups@localhost 1 monuser mypass master

# reboot, not halt and after 1 minute
SHUTDOWNCMD "/sbin/shutdown -r +1"

# If you wish:
NOTIFYCMD /usr/local/bin/upsnotify

# Notify messages:
NOTIFYMSG ONBATT "I'm on battery only :( %s"
NOTIFYMSG LOWBATT "My battery is too low :( %s"
NOTIFYMSG SHUTDOWN "Going down... %s"

# NOTIFYFLAG - change behavior of upsmon when NOTIFY events occur
NOTIFYFLAG ONLINE SYSLOG
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
### NOTIFYFLAG LOWBATT IGNORE
For access from other box:
# /etc/ups/upsd.conf
LISTEN 127.0.0.1
LISTEN 192.168.123.99
Determines which part of the NUT is to be started
# /etc/ups/nut.conf
MODE = netserver
For CGI - web access
On UPS box:
Files /etc/ups/hosts.conf and /etc/ups/upsset.conf
/etc/ups/hosts.conf
MONITOR myups@upshost "Host Description"
/etc/ups/upsset.conf
# uncomment:
I_HAVE_SECURED_MY_CGI_DIRECTORY
On http box configure apache:
/etc/httpd/conf.d/nut.conf
ScriptAlias /nut    /var/www/nut-cgi-bin
<Location /nut>
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
        Allow from 192.168.123.21

        AuthType Basic
        AuthName "Password Required"
        Require valid-user
        AuthUserFile /etc/httpd/passwd
        Satisfy Any
</Location>
Web access:
http://localhost/nut/upsstats.cgi
http://localhost/nut/upsset.cgi

Usage
$ service ups start
# or
$ /etc/init.d/ups start
$ grep ups /var/log/messages
$ ps ax|grep ups
komandas:
dig UPS status with upsc
$ upsc myups@localhost
$ upscmd -l myups@localhost

UPS LOG

Nav automātiski, tad Vismaz šādi:
upslog -u nut -s myups@localhost -l /var/log/ups.log

Back to Home: Ralfs Home Page
Last modified: 18.01.2011
© 2004-2011 Ralfs