Solved Controlled Shutdown of your NAS(es) in case of defined Level of Battery in UPS

Currently reading
Solved Controlled Shutdown of your NAS(es) in case of defined Level of Battery in UPS

jeyare

Subscriber
1,619
545
So,
I spent several hours with discovering of this:

1. Each DSM contains a feature "Synology UPS server"
you can setup it by Control panel/Hardware & Power/UPS/Network UPS Type + Enable UPS Server
it can helps you to manage another NASes connected to your LAN as the Synology UPS server

2. Then each DSM contains installation of well known Network UPS Tools (NUT).
This installation is part of Default DSM installation.
Otherwise you can't connect Network UPS.

3. You can check it by several methods:
a) in official NUT web:
Synology has worked closely with Arnaud to integrate UPS support on all its devices.

b) in SSH for your DSM:
/usr/syno/etc/ups/ups.conf
/usr/syno/etc/ups/upsd.users
/usr/syno/etc/ups/upsmon.conf
/usr/syno/etc/ups/upssched.conf
..... and here is link to official NUT page (configs and commands documentation):

4. Then doesn't matter how is your NAS connected to your UPS:
a) by USB
b) by network
all UPS management in the DSM is driven by NUT.

5. One of the common NUT command is:
when you don't know how is name of your UPS in DSM, just put:
Code:
upsc -l
you will get list all UPS names configured at host
then:
Code:
and you can get all necessary info directly from your UPS:

1598616425761.png


6. There is a hard-coded script by Syno engineers in DSM:
/usr/syno/bin/synoups
which doesn't work properly
1598617976905.png


Verdict:
1. Synology Support (1st line) is traditionally out of the understanding, that this isn't question related to: "How to switch ON the NAS."
Now we need wait again next 14 days for some from deep support level.

2. Maybe a challenge for some, who can write a script based on:
- status of UPS - ONBATT - when UPS is running on batteries .... taken from NUT
- "battery.charge" variable from "upsc [email protected]" ... when 100 means 100% .... taken from NUT
- then we can setup in new variable (e.g. ups_custom.conf) a level in % of the UPS batteries for regular shutdown of the NAS, or for Safemode, or for ...
what is 100x better than today status, when Syno engineers can do just Safe mode by defined time or by "Until low battery" triggers.
 

jeyare

Subscriber
1,619
545
Last edited:
btw:
follow this research SYNO uses in DSM a general usbhid-ups driver (MIB) for all UPS connected (USB/network)
what was defined in line with RFC 1628 - UPS Management Information Base

then there you can find all supported UPS statuses
-----
Edit:
the MIB filename: SYNOLOGY-UPS-MIB.txt
location: /usr/share/snmp/mibs/

and contains all safe & controlled shutdown related statuses
 

jeyare

Subscriber
1,619
545
btw you can install NUT client at your PC and use the NAS as NUT server, when you have just USB connection from UPS to NAS:
- IP address of NAS is known
- device name is: ups
- user is: monuser
- password is: secret
 

fredbert

Moderator
NAS Support
Subscriber
1,700
692
NAS
DS1520+, DS218+, DS215j
Router
  1. RT2600ac
  2. MR2200ac
Operating system
  1. macOS
Mobile operating system
  1. iOS
Thanks for all this info.

I already uses the DS215j as the UPS server and DS218+ monitors it. But it's interesting to know about the rest of it as I wondered what I'd do if I get a bigger UPS for all the kit, inc. Mac, (but only one monitor interface).

Cheers!

🍪🍪🍪
 
75
27
NAS
2x DS1621xs+, DS220+
Router
  1. RT2600ac
  2. MR2200ac
Operating system
  1. macOS
Mobile operating system
  1. iOS
I think there should be a frequently repeated catch phrase on this forum about the importance of a UPS with a NAS --- something simple --- similar to "RAID is not backup".

Appreciate your research on this @jeyare. Hope someone will take up the challenge of writing the script you mentioned.
 

jeyare

Subscriber
1,619
545
So seems to be Syno support needs additional education about DSM, because their statement is negating all this thread written info:
As you can see here,,Synology DiskStation Manager (DSM) allows users to monitor the status of their Synology servers through Network Management Systems (NMS) via Simple Network Management Protocol (SNMP). However, Synology DSM does not provide SNMP trap capability''

to be sure:
SNMP trap is - asynchronous, unpacked messages used to notify an entity in your network management system, i.e. central management, of significant issues and events.
In this case about each statuses of your connected UPS, operated by NUT in DSM.
Is the guy who hard coded this part (NUT client/server) of DSM out?

update of my research:
Syno DSM coordinate all communication with NUT (config files) by:
synoups
synoupscommon
location: /usr/syno/bin/

synoupscommon .... define all activities related to conf files of NUT (mentioned in previous post)
synoups ... define master/slave operation of NUT for the NAS, safemode, ...

there is possible to define SHUTDOWNCMD in upsmon.conf .... updated shutdown command path in DSM
SHUTDOWNCMD "/usr/sbin/shutdown -h 1"
where 1 means 1 minute
but there isn't related record in synoups file

lot of tests, lack of time
 

jeyare

Subscriber
1,619
545
This is another attitude of the Syno First level support:

All informationen listed in MIB PDF guide are official. Access to SNMP via CMD is possible, but not supported by Synology DSM("deep dive"), because there is no guarantee if the commands will still work in a next DSM version.

... and such attitude will kill all possible opportunities to open wide enterprise market for Synology.
 
1,109
362
NAS
DS418play, DS213j, DS3621+, DSM 7.0.4-11091
This so disheartening... It underscores my consensus that Synology's mantra is "good enough".
 

jeyare

Subscriber
1,619
545
There is a significant segment of NAS owners - cheap small boxes for home usage. What is ok (same in smartphones). They don’t care about UPS, security, operation. They need just plug the device to socket and “play” the services. They don’t need understand the background, just need quick answer - how to switch on or off. Nothing more, nothing scientific.
Then vendor needs:
- massive e-commerce sales channels, box movers, w/o support
- cheap level of support services.

Then there is smaller group of NAS owners what need more and what expect different attitude from first level support From the first level, what is primary served for the above mentioned group.
Because there is one DSM for each level of users, then same level of support is provided for “j” class and same for SA or FS range of NASes.
As I wrote in past, this business model isn’t sustainable. Nothing is for free and free is too costly.
Still don’t understand, why Syno is introducing an Enterprise level NASes, DSM features, SSDs. When they don’t care about basic SMB needs, even more interesting enterprise segments. This is Achilles tendon of their future development out of the mass market.
 

jeyare

Subscriber
1,619
545
Some news from 2nd level of support, that was in touch with me in Drive case. I wrote them about this UPS problem and ask them for a support. Answer:
After confirming with the senior engineer, the request is not supported currently, either from the ssh command.

Therefore, I have passed this message to our developers and product management group.
They will have more research on such feature.

Thank you for bringing this issue to our attention.

Seems to be there is really different approach from professionals, than from the 1st line support.
Hope it will help them (and also you) to achieve better UPS support for your NASes.
Cheers.
 

Shadow

Subscriber
568
188
NAS
DS216+II, DS118, DS718+
Router
  1. RT2600ac
  2. MR2200ac
Operating system
  1. Windows
Mobile operating system
  1. Android
Well, probaly good news that this 'missing feature' has been brought to attention to the devvers. I would wonder why nobody within Synology tought about this themselves... I would expect Synology to only run their own server gear, and as a server admin I would not feel comfortable that I can't set a NAS or any other server to shutdown at xx% battery level.

(Surprisingly enough they have their own stuff running in AWS......)
 

jeyare

Subscriber
1,619
545
follow my observations - Synology 1st level support is the main Achilles tendon for the DSM development:
- they have flat knowledge about DSM and Linux kernel dependencies. Based on “need to care about how to switch on/of the NAS” first line support.
- maybe badly set of evaluation for ticket handling. I meet this often in corporation, that no one cares how was ticket closed, they care just about how is % rate of closed tickets from all in queue. This is a highway to hell.
- when person from 1st line support doesn’t understand the issue behavior and impact to DSM improvements, then such person can’t decide if the ticket needs to be transferred to deep level of support. Just KPI driven task = close ticket. Because opened ticket makes impact to the % rate (KPI)
and this is standard example of Gordian knot in support.

But some must be responsible in Syno for such setup. Another example of CFO‘s cost cutting strategy? When cheap setup & service is perfect for EBITDA?
 

fredbert

Moderator
NAS Support
Subscriber
1,700
692
NAS
DS1520+, DS218+, DS215j
Router
  1. RT2600ac
  2. MR2200ac
Operating system
  1. macOS
Mobile operating system
  1. iOS
How much of the one-off purchase price (that gets back to Synology) is assigned to support? Every $ spent on support will be a $ off the bottom line.

For business services I would expect a subscription service either direct to Synology or through a partner (with good direct to Syno-engineering level support). But to expect business customers to use their in-house techs backed up by Synology's home-user style tech support is not a realistic model.
 

jeyare

Subscriber
1,619
545
Agree.
Syno doesn’t have a special support channel for business customers in EU. They (Syno) expect, that it will be covered by partners and distributors. But partners and distributors doesn’t care about Syno support channel when Syno can’t prepare for them direct Vendor support touch. Then Syno needs change their mindset:
- when we can make enterprise level of NASes
- we need understand basic needs of the enterprise segment.
Cheap price is interesting. But some basic features/services must be fulfilled. If no, then Syno plays with hot potatoes in their hands.
 

jeyare

Subscriber
1,619
545
so two different answers for the same topic (this thread) from Synology support (diff levels of support). My last question was:
Why do I need waste my 14days and literally “fight for an understanding” with 1st line support from Syno Germany?

Synology 2nd line support from Taiwan (understand in previous communication the potential of the solution for next DSM development):
Thanks for your feedback, and we're sorry for the issue you have faced and the time you have been waiting to solve the issue.

Due to the time difference, the Germany support might be not able to contact the senior engineer in HQ to consult wit the question they have.

We will forward the message to our senior support who charge to training the support member in other branched and make our best to improve it.

and parallel answer (primary ticket) from 1st line support in Germany:

please understand DSM as a product, and not a Linux distribution. It is not recommended nor designed to run any commands or do any access outside from the official documented steps. This you can find on the official web page http://www.synology.com only.

The subsystem is built and modified from our developers to work smoothly with the web management. For example changing configuration files that would be common on a Linux distribution might not have the same result on DSM, the configuration might get lost at next load of the web management - or the system might malfunction.

We can not guarantee any access outside from the official documentation on the web pages, means even when we would help to with your special request it would be only valid for the exact version you are currently using, and might not work anymore after any next update. For this reason we do not hand out any internal commands - besides of the official documentation.

.... to be sure - there are two Synology files needs to be upgraded - created by Synology. But as you can read, Synology Germany support doesn’t have touch with Taiwan HQ engineers to consult of issue background.
It’s really bad setup. Bad for customers and also bad for DSM next development.
 

Shadow

Subscriber
568
188
NAS
DS216+II, DS118, DS718+
Router
  1. RT2600ac
  2. MR2200ac
Operating system
  1. Windows
Mobile operating system
  1. Android
Synology Germany support doesn’t have touch with Taiwan HQ engineers to consult of issue background.

What kind of nonsense is this..... There is e-mail, WebEx and/or MS Teams (or even Synology Chat itself!!) and a little bit of time planning to get in touch with colleagues in a different timezone... Especially the corona pandemic should have teached people how to work virtually...
 

jeyare

Subscriber
1,619
545
hello,
finally found a time. Solution is here:

1. You need create file, e.g. "upstest.sh" and copy+paste content attached below
2. then you need copy the file into your NAS, e.g. /usr/syno/bin
3. then you need create right chmod parameters for the file, e.g. chmod a+x upstest.sh (really up to you)
4. finally you need created Scheduled Task in Control panel (attached screenshots)

With this my small script you will get:
Controlled Shutdown of your NAS based on EXACT battery level, e.g. 20%.
Performed only when is the UPS on Battery (no one want shutdown of charged UPS) :cool:
Tested 5 times. Works.

Hope, it will save your mental health. Maybe Syno will use this script for GUI users operation.

Next stage - controlled Shutdown of all NASes, based on NUT upsmon feature.

PS: you can un-comment some (echo) rows, just for clean code. It will help you understand, how it's easy now.


Bash:
#!/bin/sh
#
#Shutdown action def ("P" for PowerOff; "now" for an immediate action)
SHTD='/usr/sbin/shutdown -P now'
#
# main check of UPS status by "upsc" command and "localhost or IP address
STATUS=`/usr/bin/upsc [email protected] ups.status`
if [ $STATUS = 'OB' ];
    then
        echo "UPS on Battery"
    else
        echo "UPS On Line"
fi
# # OB = On Battery; OL = On Line
#
# second check of battery level in %
BATT=`/usr/bin/upsc [email protected] battery.charge`
echo "$BATT % of battery level"
#
#
# change the BATT level value to proper format (integer) = BATINT
float=`/usr/bin/upsc [email protected] battery.charge`
BATINT=${float%.*}
#
# For the proper Shutdown of the NAS we have to test 2 scenarios:
# First: UPS in on Battery from the "$STATUS" variable
# Second: UPS battery level is Equal or Lower than variable (in my case = 20%)
if [ $BATINT -le 20 ] && [ $STATUS = 'OB' ];
    then
        $SHTD
        echo "shutdown"
    else
        echo "no need Shutdown"
fi

Task Scheduler.jpg
 

jeyare

Subscriber
1,619
545
follow this script you can setup multiple conditions for the Shutdown action:
1. Battery ON + Battery level (%) .. as is now
2. Point 1 + Battery temperature .... what is one of important trigger. Then you need to check:
Code:
/usr/bin/upsc [email protected] battery.temperature
and many of them. All possibilities you can find in my previous research posts in this thread.
 

jeyare

Subscriber
1,619
545
For those, who can't properly read the Task screenshots:
1. Create Task
2. as root (NUT needs root)
3. Schedule: Daily/ from 00:00 to 23:59 / every minute ..... the frequency is up to your conditions
4. Run command: bash /usr/syno/bin/upstest.sh ..... up to your chosen location
 

Shadow

Subscriber
568
188
NAS
DS216+II, DS118, DS718+
Router
  1. RT2600ac
  2. MR2200ac
Operating system
  1. Windows
Mobile operating system
  1. Android
Wow very nice. Thanks @jeyare . I will definitly put this to work.
2 questions:
1. does your NAS also automatically boot up again when the power is back online after it has been shutdown by this script?
2. How did you leave your UPS settings in the Synology interface? Still like this?
1600793794531.png
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Similar threads

Similar threads

Trending threads

Top