A top page has explanation.

nut top

      Network slave

The master side host (server) connects with UPS1200LX with a USB cable.
The master side host's (server) IP address is set to 192.168.2.5.
The slave side host's (server) IP address is set to 192.168.2.100.
The master side host's (server) TCP ports 22 and 3493 open.

In centos6.4, an EPEL repository is installed in NUT2.6.5-2 by the after-installation following command.

yum install nut nut-client nut-cgi

Please change the after-installation following configuration file.



It is unnecessary to change the following file.
/lib/udev/rules.d/62-nut-usbups.rules


It is unnecessary to change the following file.
/etc/ups/hosts.conf


Please give the right to access to create the following file and to be able to perform as a program.
upsmon of Network UPS Tool starts by performing this script.
When it registers with /etc/rc.d/rc.local etc., a system crashes certainly. (Being -D option use of upsmon -D)
-D can start the command of a NOTIFYCMD setup now by adding an option.
I spent time for round one week until this was found. A manual is not written anywhere.
Since -D option does not function in debian GNU/linux 7.2.0, the shutdown by a charge rate is impossible.
/usr/sbin/nutslave

#!/bin/bash
#
# nut slave start
#
#/usr/sbin/


/usr/sbin/upsmon -D



It is unnecessary to change the following file.
/etc/ups/nut.conf

# Network UPS Tools: example nut.conf
#
##############################################################################
# General section
##############################################################################
# The MODE determines which part of the NUT is to be started, and which
# configuration files must be modified.
#
# This file try to standardize the various files being found in the field, like
# /etc/default/nut on Debian based systems, /etc/sysconfig/ups on RedHat based
# systems, ... Distribution's init script should source this file to see which
# component(s) has to be started.
#
# The values of MODE can be:
# - none: NUT is not configured, or use the Integrated Power Management, or use
# some external system to startup NUT components. So nothing is to be started.
# - standalone: This mode address a local only configuration, with 1 UPS
# protecting the local system. This implies to start the 3 NUT layers (driver,
# upsd and upsmon) and the matching configuration files. This mode can also
# address UPS redundancy.
# - netserver: same as for the standalone configuration, but also need
# some more network access controls (firewall, tcp-wrappers) and possibly a
# specific LISTEN directive in upsd.conf.
# Since this MODE is opened to the network, a special care should be applied
# to security concerns.
# - netclient: this mode only requires upsmon.
#
# IMPORTANT NOTE:
# This file is intended to be sourced by shell scripts.
# You MUST NOT use spaces around the equal sign!

MODE=netclient <------------------------------------------------This line change



It is unnecessary to change the following file.
/etc/ups/ups.conf



It is unnecessary to change the following file.
/etc/ups/upsd.conf



It is unnecessary to change the following file.
/etc/ups/upsd.users



The following file needs to be changed.
SHUTDOWNCMD "/sbin/shutdown -h+0" <--- please comment out this line.
Shut [ only the master side ] when it keeps not commented out.
Please set the self-IP address set up by LISTEN of upsd.conf to the IP address of MONITOR.
/etc/ups/upsmon.conf

# Network UPS Tools: example upsmon configuration
#
# This file contains passwords, so keep it secure.

# --------------------------------------------------------------------------
# RUN_AS_USER <userid>
#
# By default, upsmon splits into two processes. One stays as root and
# waits to run the SHUTDOWNCMD. The other one switches to another userid
# and does everything else.
#
# The default nonprivileged user is set at compile-time with
# 'configure --with-user=...'.
#
# You can override it with '-u <user>' when starting upsmon, or just
# define it here for convenience.
#
# Note: if you plan to use the reload feature, this file (upsmon.conf)
# must be readable by this user! Since it contains passwords, DO NOT
# make it world-readable. Also, do not make it writable by the upsmon
# user, since it creates an opportunity for an attack by changing the
# SHUTDOWNCMD to something malicious.
#
# For best results, you should create a new normal user like "nutmon",
# and make it a member of a "nut" group or similar. Then specify it
# here and grant read access to the upsmon.conf for that group.
#
# This user should not have write access to upsmon.conf.
#
# RUN_AS_USER nutmon

# --------------------------------------------------------------------------
# MONITOR <system> <powervalue> <username> <password> ("master"|"slave")
#
# List systems you want to monitor. Not all of these may supply power
# to the system running upsmon, but if you want to watch it, it has to
# be in this section.
#
# You must have at least one of these declared.
#
# <system> is a UPS identifier in the form <upsname>@<hostname>[:<port>]
# like ups@localhost, su700@mybox, etc.
#
# Examples:
#
# - "su700@mybox" means a UPS called "su700" on a system called "mybox"
#
# - "fenton@bigbox:5678" is a UPS called "fenton" on a system called
# "bigbox" which runs upsd on port "5678".
#
# The UPS names like "su700" and "fenton" are set in your ups.conf
# in [brackets] which identify a section for a particular driver.
#
# If the ups.conf on host "doghouse" has a section called "snoopy", the
# identifier for it would be "snoopy@doghouse".
#
# <powervalue> is an integer - the number of power supplies that this UPS
# feeds on this system. Most computers only have one power supply, so this
# is normally set to 1. You need a pretty big or special box to have any
# other value here.
#
# You can also set this to 0 for a system that doesn't supply any power,
# but you still want to monitor. Use this when you want to hear about
# changes for a given UPS without shutting down when it goes critical,
# unless <powervalue> is 0.
#
# <username> and <password> must match an entry in that system's
# upsd.users. If your username is "monmaster" and your password is
# "blah", the upsd.users would look like this:
#
# [monmaster]
# password = blah
# upsmon master (or slave)
#
# "master" means this system will shutdown last, allowing the slaves
# time to shutdown first.
#
# "slave" means this system shuts down immediately when power goes critical.
#
# Examples:
#
# MONITOR myups@bigserver 1 monmaster blah master
# MONITOR su700@server.example.com 1 upsmon secretpass slave
# MONITOR myups@localhost 1 upsmon pass master (or slave)

# --------------------------------------------------------------------------
# MINSUPPLIES <num>
#
# Give the number of power supplies that must be receiving power to keep
# this system running. Most systems have one power supply, so you would
# put "1" in this field.
#
# Large/expensive server type systems usually have more, and can run with
# a few missing. The HP NetServer LH4 can run with 2 out of 4, for example,
# so you'd set that to 2. The idea is to keep the box running as long
# as possible, right?
#
# Obviously you have to put the redundant supplies on different UPS circuits
# for this to make sense! See big-servers.txt in the docs subdirectory
# for more information and ideas on how to use this feature.

MINSUPPLIES 1

# --------------------------------------------------------------------------
# SHUTDOWNCMD "<command>"
#
# upsmon runs this command when the system needs to be brought down.
#
# This should work just about everywhere ... if it doesn't, well, change it.

#SHUTDOWNCMD "/sbin/shutdown -h +0" <-------------------------This line comment out

# --------------------------------------------------------------------------
# NOTIFYCMD <command>
#
# upsmon calls this to send messages when things happen
#
# This command is called with the full text of the message as one argument.
# The environment string NOTIFYTYPE will contain the type string of
# whatever caused this event to happen.
#
# Note that this is only called for NOTIFY events that have EXEC set with
# NOTIFYFLAG. See NOTIFYFLAG below for more details.
#
# Making this some sort of shell script might not be a bad idea. For more
# information and ideas, see pager.txt in the docs directory.
#
# Example:
# NOTIFYCMD /usr/local/ups/bin/notifyme

# --------------------------------------------------------------------------
# POLLFREQ <n>
#
# Polling frequency for normal activities, measured in seconds.
#
# Adjust this to keep upsmon from flooding your network, but don't make
# it too high or it may miss certain short-lived power events.

POLLFREQ 5

# --------------------------------------------------------------------------
# POLLFREQALERT <n>
#
# Polling frequency in seconds while UPS on battery.
#
# You can make this number lower than POLLFREQ, which will make updates
# faster when any UPS is running on battery. This is a good way to tune
# network load if you have a lot of these things running.
#
# The default is 5 seconds for both this and POLLFREQ.

POLLFREQALERT 5

# --------------------------------------------------------------------------
# HOSTSYNC - How long upsmon will wait before giving up on another upsmon
#
# The master upsmon process uses this number when waiting for slaves to
# disconnect once it has set the forced shutdown (FSD) flag. If they
# don't disconnect after this many seconds, it goes on without them.
#
# Similarly, upsmon slave processes wait up to this interval for the
# master upsmon to set FSD when a UPS they are monitoring goes critical -
# that is, on battery and low battery. If the master doesn't do its job,
# the slaves will shut down anyway to avoid damage to the file systems.
#
# This "wait for FSD" is done to avoid races where the status changes
# to critical and back between polls by the master.

HOSTSYNC 15

# --------------------------------------------------------------------------
# DEADTIME - Interval to wait before declaring a stale ups "dead"
#
# upsmon requires a UPS to provide status information every few seconds
# (see POLLFREQ and POLLFREQALERT) to keep things updated. If the status
# fetch fails, the UPS is marked stale. If it stays stale for more than
# DEADTIME seconds, the UPS is marked dead.
#
# A dead UPS that was last known to be on battery is assumed to have gone
# to a low battery condition. This may force a shutdown if it is providing
# a critical amount of power to your system.
#
# Note: DEADTIME should be a multiple of POLLFREQ and POLLFREQALERT.
# Otherwise you'll have "dead" UPSes simply because upsmon isn't polling
# them quickly enough. Rule of thumb: take the larger of the two
# POLLFREQ values, and multiply by 3.

DEADTIME 15

# --------------------------------------------------------------------------
# POWERDOWNFLAG - Flag file for forcing UPS shutdown on the master system
#
# upsmon will create a file with this name in master mode when it's time
# to shut down the load. You should check for this file's existence in
# your shutdown scripts and run 'upsdrvctl shutdown' if it exists.
#
# See the shutdown.txt file in the docs subdirectory for more information.

#POWERDOWNFLAG /etc/killpower <-------------------------------This line comment out

# --------------------------------------------------------------------------
# NOTIFYMSG - change messages sent by upsmon when certain events occur
#
# You can change the default messages to something else if you like.
#
# NOTIFYMSG <notify type> "message"
#
# 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"
#
# Note that %s is replaced with the identifier of the UPS in question.
#
# Possible values for <notify type>:
#
# ONLINE : UPS is back online
# ONBATT : UPS is on battery
# LOWBATT : UPS has a low battery (if also on battery, it's "critical")
# FSD : UPS is being shutdown by the master (FSD = "Forced Shutdown")
# COMMOK : Communications established with the UPS
# COMMBAD : Communications lost to the UPS
# SHUTDOWN : The system is being shutdown
# REPLBATT : The UPS battery is bad and needs to be replaced
# NOCOMM : A UPS is unavailable (can't be contacted for monitoring)
# NOPARENT : The process that shuts down the system has died (shutdown impossible)

# --------------------------------------------------------------------------
# NOTIFYFLAG - change behavior of upsmon when NOTIFY events occur
#
# By default, upsmon sends walls (global messages to all logged in users)
# and writes to the syslog when things happen. You can change this.
#
# NOTIFYFLAG <notify type> <flag>[+<flag>][+<flag>] ...
#
# NOTIFYFLAG ONLINE SYSLOG+WALL
# NOTIFYFLAG ONBATT SYSLOG+WALL
# NOTIFYFLAG LOWBATT SYSLOG+WALL
# NOTIFYFLAG FSD SYSLOG+WALL
# NOTIFYFLAG COMMOK SYSLOG+WALL
# NOTIFYFLAG COMMBAD SYSLOG+WALL
# NOTIFYFLAG SHUTDOWN SYSLOG+WALL
# NOTIFYFLAG REPLBATT SYSLOG+WALL
# NOTIFYFLAG NOCOMM SYSLOG+WALL
# NOTIFYFLAG NOPARENT SYSLOG+WALL
#
# Possible values for the flags:
#
# SYSLOG - Write the message in the syslog
# WALL - Write the message to all users on the system
# EXEC - Execute NOTIFYCMD (see above) with the message
# IGNORE - Don't do anything
#
# If you use IGNORE, don't use any other flags on the same line.

# --------------------------------------------------------------------------
# RBWARNTIME - replace battery warning time in seconds
#
# upsmon will normally warn you about a battery that needs to be replaced
# every 43200 seconds, which is 12 hours. It does this by triggering a
# NOTIFY_REPLBATT which is then handled by the usual notify structure
# you've defined above.
#
# If this number is not to your liking, override it here.

RBWARNTIME 43200

# --------------------------------------------------------------------------
# NOCOMMWARNTIME - no communications warning time in seconds
#
# upsmon will let you know through the usual notify system if it can't
# talk to any of the UPS entries that are defined in this file. It will
# trigger a NOTIFY_NOCOMM by default every 300 seconds unless you
# change the interval with this directive.

NOCOMMWARNTIME 300

# --------------------------------------------------------------------------
# FINALDELAY - last sleep interval before shutting down the system
#
# On a master, upsmon will wait this long after sending the NOTIFY_SHUTDOWN
# before executing your SHUTDOWNCMD. If you need to do something in between
# those events, increase this number. Remember, at this point your UPS is
# almost depleted, so don't make this too high.
#
# Alternatively, you can set this very low so you don't wait around when
# it's time to shut down. Some UPSes don't give much warning for low
# battery and will require a value of 0 here for a safe shutdown.
#
# Note: If FINALDELAY on the slave is greater than HOSTSYNC on the master,
# the master will give up waiting for the slave to disconnect.

FINALDELAY 5

RUN_AS_USER root <------------------------------------------------------This line addition
#MONITOR ups1200lx-1@hogehogeserver:3493 1 monslave passw2 slave
MONITOR ups1200lx-1@192.168.2.5:3493 1 monslave passw2 slave <---------------This line addition

NOTIFYCMD /etc/ups/upsslave <--------------------------------------------This line addition

NOTIFYMSG ONLINE "UPS %s on line power" <---------------------------------This line addition
NOTIFYMSG ONBATT "UPS %s on battery" <----------------------------------This line addition
NOTIFYMSG LOWBATT "UPS %s battery is low" <------------------------------This line addition
NOTIFYMSG FSD "UPS %s: forced shutdown in progress" <-----------------------This line addition
NOTIFYMSG COMMOK "Communications with UPS %s established" <--------------This line addition
NOTIFYMSG COMMBAD "Communications with UPS %s lost" <-------------------This line addition
NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding" <---------------This line addition
NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced" <----------------This line addition
NOTIFYMSG NOCOMM "UPS %s is unavailable" <-------------------------------This line addition
NOTIFYMSG NOPARENT "upsmon parent process died - shutdown impossible" <----This line addition

NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC <--------------------------------This line addition
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC <-------------------------------This line addition
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC <------------------------------This line addition
NOTIFYFLAG FSD SYSLOG+WALL+EXEC <-----------------------------------This line addition
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC <------------------------------This line addition
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC <-----------------------------This line addition
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC <----------------------------This line addition
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC <-----------------------------This line addition
NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC <------------------------------This line addition
NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC <-----------------------------This line addition



Please give the right to access to create the following file and to be able to perform as a program.

/etc/ups/upsslave

   1 : #!/bin/bash
   2 : # upsslave
   3 : # Shut [ with the report from a master ]. The report from a master stops processing.
   4 : # & report to a master before a shutdown. 
   5 : # NUT NOTIFYCMD script
   6 : 
   7 : PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/etc/ups/
   8 : 
   9 : TIME=0
  10 : STIME=0
  11 : UPSLOG="/etc/ups/upslog"
  12 : ONL="/etc/ups/onl"
  13 : BATTSDF="/etc/ups/battsdf"
  14 : SDF="/etc/ups/sdf"
  15 : SDFOK="/etc/ups/sdfok"
  16 : SDFOKEND="/etc/ups/sdfokend"
  17 : SHUTDOWNF=0
  18 : BATTSDFF=0
  19 : ONLF=0
  20 : SDFF=0
  21 : SDFOKF=0
  22 : MASTERBATTSDF="/home/bssh/battsdf"
  23 : MASTERONL="/home/bssh/onl"
  24 : MASTERSDF="/home/bssh/sdf"
  25 : MASTERSDFOK="/home/bssh/sdfok"
  26 : MASTERUSER="bssh@192.168.2.5"
  27 : 
  28 : if [ "$NOTIFYTYPE" = "ONBATT" ] ; then
  29 :         rm $BATTSDF
  30 :         rm $ONL
  31 :         scp $MASTERUSER:$MASTERBATTSDF $BATTSDF
  32 :         while [ $? = 1 ] ; do
  33 :                 sleep $TIME
  34 :                 scp $MASTERUSER:$MASTERONL $ONL
  35 :                 if [ $? = 0 ] ; then
  36 :                         exit 0
  37 :                 fi
  38 :                 echo $(date) NOTIFYTYPE=$NOTIFYTYPE
  39 :                 echo $(date) NOTIFYTYPE=$NOTIFYTYPE >> $UPSLOG
  40 :                 scp $MASTERUSER:$MASTERBATTSDF $BATTSDF
  41 :         done
  42 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE
  43 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE >> $UPSLOG
  44 :         SHUTDOWNF=1 
  45 : 
  46 : elif  [ "$NOTIFYTYPE" = "ONLINE" ] ; then
  47 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE
  48 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE >> $UPSLOG
  49 :         SHUTDOWNF=0
  50 : 
  51 : elif  [ "$NOTIFYTYPE" = "LOWBATT" ] ; then
  52 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE
  53 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE >> $UPSLOG
  54 :         SHUTDOWNF=1
  55 : 
  56 : elif  [ "$NOTIFYTYPE" = "FSD" ] ; then
  57 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE
  58 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE >> $UPSLOG
  59 :         SHUTDOWNF=1
  60 : 
  61 : elif  [ "$NOTIFYTYPE" = "SHUTDOWN" ] ; then
  62 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE
  63 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE >> $UPSLOG
  64 :         SHUTDOWNF=1
  65 : 
  66 : elif  [ "$NOTIFYTYPE" = "NOPARENT" ] ; then
  67 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE
  68 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE >> $UPSLOG
  69 :         SHUTDOWNF=1
  70 : 
  71 : elif  [ "$NOTIFYTYPE" = "COMMBAD" ] ; then
  72 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE
  73 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE >> $UPSLOG
  74 :         SHUTDOWNF=0
  75 : 
  76 : else
  77 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE
  78 :         echo $(date) NOTIFYTYPE=$NOTIFYTYPE >> $UPSLOG
  79 :         SHUTDOWNF=0
  80 : fi
  81 : echo SHUTDOWN=$SHUTDOWNF
  82 : 
  83 : if [ $SHUTDOWNF = 1 ] ; then
  84 :         scp $MASTERUSER:$MASTERSDF $SDF
  85 :         while [ $? = 1 ] ; do
  86 :                 sleep $STIME
  87 :                 scp $MASTERUSER:$MASTERSDF $SDF
  88 :         done
  89 :         touch $SDFOK
  90 :         scp $SDFOK $MASTERUSER:$MASTERSDFOK
  91 :         cp $ONL $SDFOKEND
  92 :         ONLF=$?
  93 :         cp $BATTSDF $SDFOKEND
  94 :         BATTSDFF=$?
  95 :         cp $SDF $SDFOKEND
  96 :         SDFF=$?
  97 :         cp $SDFOK $SDFOKEND
  98 :         SDFOKF=$?
  99 :         echo ONL=$ONLF BATTSDF=$BATTSDFF SDF=$SDFF SDFOK=$SDFOKF
 100 :         echo ONL=$ONLF BATTSDF=$BATTSDFF SDF=$SDFF SDFOK=$SDFOKF >> $UPSLOG
 101 :         rm $ONL
 102 :         rm $BATTSDF
 103 :         rm $SDF
 104 :         rm $SDFOK
 105 :         rm $SDFOKEND
 106 :         shutdown -h +0
 107 : fi
 108 : 
 109 : 



It starts nut at a master host's (server) terminal after file change and creation, and starts nutslave at a slave host's (server) terminal.
The shut [ the master side host (server) ] after the slave side host (server) shutdown start if UPS becomes below the charge rate set up
by STDWCHARGE=.
Moreover, the shut at the time of various abnormalities, etc.



The following is a log by the side of a slave. Please refer to it.
/etc/ups/upslog

2013 11 12日 火曜日 19:48:51 JST NOTIFYTYPE=ONBATT
2013
11 12日 火曜日 19:49:07 JST NOTIFYTYPE=ONBATT
2013
11 12日 火曜日 19:49:19 JST NOTIFYTYPE=ONBATT
2013
11 12日 火曜日 19:49:40 JST NOTIFYTYPE=ONBATT
2013
11 12日 火曜日 19:49:50 JST NOTIFYTYPE=ONLINE
2013
11 12日 火曜日 19:49:57 JST NOTIFYTYPE=ONBATT
2013
11 12日 火曜日 19:53:06 JST NOTIFYTYPE=ONBATT
2013
11 12日 火曜日 19:53:23 JST NOTIFYTYPE=ONBATT
2013
11 12日 火曜日 19:53:44 JST NOTIFYTYPE=ONBATT
2013
11 12日 火曜日 19:53:55 JST NOTIFYTYPE=ONBATT
ONL=1 BATTSDF=0 SDF=0 SDFOK=0
2013
11 12日 火曜日 20:10:38 JST NOTIFYTYPE=ONBATT
2013 11 12日 火曜日 20:10:49 JST NOTIFYTYPE=ONBATT
2013
11 12日 火曜日 20:10:51 JST NOTIFYTYPE=COMMBAD
2013
11 12日 火曜日 20:11:06 JST NOTIFYTYPE=ONBATT
2013
11 12日 火曜日 20:11:06 JST NOTIFYTYPE=SHUTDOWN
2013
11 12日 火曜日 20:11:17 JST NOTIFYTYPE=ONBATT
ONL=1 BATTSDF=0 SDF=0 SDFOK=0


A top page has explanation.

nut top