update: 26. 04. 2016
Pozice: Linux / QNAP a NUT /

Propojení Úložiště QNAP s Linux UPS NUT

TEST CLIENT on QNAP

ssh shell on qnap:
[~] # upsc netups@192.168.60.1

battery.capacity.nominal: 10.00
battery.charge: 74.4
battery.runtime: 1140
battery.voltage: 26.10
battery.voltage.maximum: 28.20
battery.voltage.minimum: 20.00
battery.voltage.nominal: 24.00
driver.name: upscode2
driver.parameter.pollinterval: 2
driver.parameter.port: /dev/ttyS0
driver.version: 2.2.2
driver.version.internal: 0.85
input.phases: 1
input.voltage: 225.90
input.voltage.maximum: 276.00
input.voltage.minimum: 162.00
input.voltage.nominal: 230.00
output.current: 1.56
output.current.maximum: 4.50
output.current.nominal: 4.40
output.frequency: 50.00
output.frequency.maximum: 53.00
output.frequency.minimum: 47.00
output.phases: 1
output.power: 0.35
output.realpower: 250.00
output.realpower.nominal: 670.00
output.voltage: 225.90
output.voltage.maximum: 244.00
output.voltage.minimum: 207.00
output.voltage.nominal: 230.00
ups.delay.reboot: 000
ups.delay.shutdown: 000
ups.load: 35.5
ups.mfr: unknown
ups.model: UPS 1000 VA FW -0021
ups.power.nominal: 1000.00
ups.serial: LP433A533
ups.status: OL

CONFIGURATION UPSMON on QNAP

ssh shell on qnap: find and edit MONITOR line for connect to nut.


[~] # vi /etc/config/ups/upsmon.conf

# Examples:
#
# MONITOR myups@bigserver 1 monmaster blah master
# MONITOR su700@server.example.com 1 upsmon secretpass slave

MONITOR netups@192.168.60.1 1 monslave slavepassw slave

# --------------------------------------------------------------------------
# MINSUPPLIES 
#
# 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 ""
#
# 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/poweroff"

# --------------------------------------------------------------------------
# NOTIFYCMD 
#
# 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 
#
# 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 
#
# 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

# --------------------------------------------------------------------------
# NOTIFYMSG - change messages sent by upsmon when certain events occur
#
# You can change the default messages to something else if you like.
#
# NOTIFYMSG  "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 :
#
# 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  [+][+] ...
#
# 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 300


CREATE START UPSMON SCRIPT on QNAP

[~] # cd /etc/config/ups/ && wget www.mtom.cz/dl/Linux/QNAP a NUT/upsmon.sh && chmod 0754 /etc/config/ups/upsmon.sh && cd /
[~] # cat /etc/config/ups/upsmon.sh

#!/bin/sh

UPSMONLOCK="/tmp/upsmon.lock"
UPSMONSH="/usr/sbin/upsmon"

case "$1" in
  start)
        # Start daemons.

        #/etc/init.d/ups.sh stop
        if [ ! -f $UPSMONLOCK ]; then
            killall upsutil
            $UPSMONSH && echo "running.." > $UPSMONLOCK
        fi
        ;;
  stop)
        # Stop daemons.
        $UPSMONSH -c stop
        ;;
  restart)
        $0 stop
        rm $UPSMONLOCK
        $0 start
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac


CREATE START UPSMON CRON on QNAP


[~] # echo "* * * * * /etc/config/ups/upsmon.sh start" >> /etc/config/crontab
[~] # cat /etc/config/crontab

# m h dom m dow cmd
0 4 * * * /sbin/hwclock -s
0 3 * * * /sbin/vs_refresh
0 3 * * 0 /etc/init.d/idmap.sh dump
0 3 * * * /sbin/clean_reset_pwd
0-59/15 * * * * /etc/init.d/nss2_dusg.sh
40 3 * * 6 /sbin/qsmart -t short -d 1
40 3 * * 6 /sbin/qsmart -t short -d 2
40 3 * * 6 /sbin/qsmart -t short -d 3
40 3 * * 6 /sbin/qsmart -t short -d 4
4 3 * * 3 /etc/init.d/backup_conf.sh
* * * * * /etc/config/ups/upsmon.sh start

Soubory ke stažení

NazevtypDelkaVytvořeno
upsmonsh568 B17. 06. 2013