can someone help out, i want to create a shell script that calls shutdown.sh, which i believe is the script that invokes a controlled/graceful shutdown of the EX2.
i want to use the script in Network UPS Tools, having upsmon.conf call it after NUT detects a notify event.
i just would like some help with how the script should be written, i can use vi editor and then make the sh file executable.
if i can run some tests on this and make it work, i would be glad to post a how-to on it.
the fundamental problem i experience here is that this NAS is not doing any controlled shutdown based on UPS power events, which is a problem if the NAS is still on when the UPS battery dies.
i can’t make changes to the file upsmon.conf, in order to call the script when ONBATT is detected. Reason why i can’t make changes is that the file system is mounted read-only. i would try accessing the files again if i were able to boot the nas from an external flash drive (don’t know how to do that). in that way I could go into the NAS, mount the file system and make changes to upsmon.conf.
the user guide for the EX2 doesn’t state anything along the lines of controlled or graceful shutdown in the event of low power notifications from the UPS. so the EX2 will not do a controlled shutdown unless commanded by the user.
it does have Network UPS Tools installed and running, so I don’t know what keeps WD from adding the feature to the dashboard so users can select the behaviors they want relative to UPS power. lack of programming funds or experience ?
We do have some very smart user who have posted on how to make OS changes and have them stay in the system after a reboot. I have not wanted to do that to the office NAS.
I plan to do a workaround that uses a relay and control circuit to uses the front panel switch to force a shutdown ( hibernate ) then cut power to the NAS to prevent it coming back on tell the all clear is given.
Not all the WD NAS systems have a control button.
When having power problem ie a large storm the other way of having a Raspberry Pi to auto log in to each NAS may not work all the time BUT I will still try this as well.
All data on the NAS is backed up ( raid is mirrored ) and extra spare NAS is available so we can use a more more relaxed response to power problems.
I do like the all software solution you are looking to use.
shutdown.sh script is already there in the NAS OS. don’t know why NUT is not calling it when a NOTIFYFLAG is pushed by NUT (an event happens) … I also don’t understand why FINALDELAY value is 6000 seconds … that is 100 minutes ! as if someone screwed up entering the value … or i’m not understanding it correctly.
I’m simply looking to change SHUTDOWNCMD to:
shutdown.sh
here is my upsmon.conf from the EX2:
# Network UPS Tools:upsmon configuration
RUN_AS_USER root
MONITOR usbhid@localhost 1 root 123 master
# --------------------------------------------------------------------------
# upsmon.conf
# --------------------------------------------------------------------------
# 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
# --------------------------------------------------------------------------
SHUTDOWNCMD "/usr/sbin/shutdown"
NOTIFYCMD /usr/sbin/upssched
NOTIFYFLAG ONLINE EXEC
NOTIFYFLAG ONBATT EXEC
NOTIFYFLAG LOWBATT EXEC
NOTIFYFLAG NOCOMM EXEC
NOTIFYFLAG FSD EXEC
NOTIFYFLAG COMMBAD IGNORE
NOTIFYFLAG COMMOK IGNORE
NOTIFYFLAG SHUTDOWN IGNORE
# --------------------------------------------------------------------------
# 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
# --------------------------------------------------------------------------
# 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.
# 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
# --------------------------------------------------------------------------
# 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 6000
the location highlighted needs to be unmounted and remounted read-write … in order for me to make changes to upsmon.conf. before i do that, i just need to review and make sure of the changes i want to make to the file in order to get the NAS shutdown behavior correct.
does anyone know if any of the changes would be overwritten/reverted after a reboot ?