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

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

I have a Cyberpower UPS connected to my NAS, which i want to tell my computer to power down 30 mins after a power cut.



But I can't even work out how to install NUT and get to the GUI.
"Windows (complete port, Beta): Windows MSI installer 2.6.5-6"
Just seems to dump a load of files in Program Files (X86).

Cany anyone give me a pointer please, on how to configure NUT ? I have been able to install it, but none of the information appears to be for Windows, everything is re linux.

What I'm trying to achieve is the NAS to tell the desktop when to shutdown...
 
Last edited:
Guide, how to setup Windows NUT client (incl GUI)


:coffee:
 
Guide, how to setup Windows NUT client (incl GUI)



:coffee:

What a champion - thank you very much.

The odd thing is that DSM and NUT approach shutdown in different ways:

- DSM will shutdown with low battery (amount unknown??), or after x amount of time on battery
- NUT will shutdown if battery less than x, or if runtime is lower than x

So there isn't really a best option for the settings, because it is entirely possible that the DSM shuts down prior to a NUT threshold being reached. It's weird that they would approach the same problem in different ways, or at least, not give you the option to choose one or the other.

So the solution is based on a best guess, rather than being able to say "battery less than 40%: shut down PC, battery less than 30%: shut down NAS"
 
all of my NASes will shut down when the batt level is under <=XX%
when you will setup defined in this thread you will get same option
-- post merged: --

Bash:
# 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' ];

$BATINT -le 20 ... is the feature
 
Thanks @jeyare . I haven't used bash/ssh at all with the DSM because I am scared of destroying it, only with a Raspberry Pi where I am "practising", so maybe this is something for the future.

don't worry, you will use the RESET button a few more times and you will be a master in resetting. I already have a lot of such 'honorable' titles ;)
 
don't worry, you will use the RESET button a few more times and you will be a master in resetting. I already have a lot of such 'honorable' titles ;)
that's what i want to avoid... i have no idea what the rammifications are and as a noob it would take me ages to set everything up again!

then again - i could just back up the config file and assume that would take care of the synology packages.....
 
Updated setup for newbies:

Creation and Edit of the User-defined script for Shutdown
1. Download the attached file "upstest.zip".
2. Unzip it somewhere on your computer.
3. It will create a new file "upstest.sh"
4. Open "upstest.sh" in your preferred simple text editor (no MS Word), e.g. Notepad and make simple edition in row no. 32:
Bash:
if [ $BATINT -le 20 ] && [ $STATUS = 'OB' ];

- there is the number '20' in the code
- it is variably defined value in % of your UPS battery status for the NAS shutdown threshold ... then value 20 means 20% of the battery remains
- you can change the value to whatever value, up to you. 30 = 30%; 25 = 25%
- when the UPS battery will reach this value (%) and NUT upsmon (monitor) will get this information from NUT upsc (status) it will automatically run $SHTD, in this case, SHUTDOWN of the NAS.

Save the file.

Deployment of the "upstest.sh" file to the NAS
1. Use putty or something quite better for 'ssh' into your NAS - in my case I like more the MobaXterm
1640004999816.png

2. Create a session (plenty of guides here or on the Internet, YT). You need: IP address of the NAS, admin usr/psw.
4. Use 'sudo -i' to get root session
5. In the MobaXterm terminal you can find in the left upper part (arrow) menu for upload a file. But you need to open a working directory first. So open 'opt' directory (this will be not overwritten after NAS upgrade)
1640005254753.png
click there
when opened, use UPLOAD ICON and upload the file "upstest.sh" into your working directory:
1640005477156.png

You can use REFRESH green icon (right next to).
So, when everything is OK, then you will see the file "upstest.sh" within 'opt' directory.
6. in the terminal window type:
Bash:
chmod +x /opt/upstest.sh
to allow executable permissions for the file.
Done. Exit the terminal

Define cyclic check of the battery status in DSM
In DSM Control panel / Task Scheduler:
Create / Scheduled task / User-defined script
General tab:
Task: name of the Task ----up to you
User: root
Enabled
1640005935195.png


Schedule tab:
use these values from screenshot
1640006045090.png


Task settings tab:
Run command/User-defined script type (use the chosen path to the script):
Bash:
bash /opt/upstest.sh

1640006441246.png


Done. Use OK, then just check if the Task is ENABLED, select it and use RUN:
1640006592456.png


Now you can open a beer or two and call me to celebrate this task! 🍻

With this 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 wants shutdown of charged UPS) :cool:

Last recommendation:
- when something is wrong or just for a check, you can find ERROR LOG within:
/var/log/bash_err.log
- right click, then 'Open with Default Text Editor'
- then Ctrl+F upstest.sh to find related error

1640007335860.png
 

Attachments

  • upstest.zip
    634 bytes · Views: 30
  • 1640005376827.png
    1640005376827.png
    8.8 KB · Views: 18

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.

Similar threads

Looks like I'm having a similar problem with an RS3618XS 6 x 14TB Ironwolf pro drives and keeps randomly...
Replies
3
Views
3,709
  • Solved
Thanks for this thread. The warning: "All services will be stopped during the operation and will resume...
Replies
3
Views
3,136
the original post has been updated about how to shutdown the Client side also :coffee: 1616434288 you...
Replies
12
Views
5,874
  • Question
Thanks Rusty. Appreciate the help and your knowledge. :)
Replies
7
Views
1,022
Ok I may have fixed it. Select push service Far right on phone setting has pull-down to select which rule...
Replies
1
Views
704
  • Question
OK, I'm now seeing something I recognize. There was no reason to start with the /var/services/...
Replies
5
Views
2,203

Welcome to SynoForum.com!

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

Registration is free, easy and fast!

Back
Top