Jump to content

UPS script for shutting down Unraid host (v6) + vm´s


luca2

Recommended Posts

Hi,

I posted some stuff related here: http://lime-technology.com/forum/index.php?topic=34994.msg352040#msg352040

I am rethinking the option to try to install my Powershield (Riello) software directly in Unraid or in my win8.1 vm. I already installed the windows package -called UPSMON- in my w8.1 vm and it turns off my vm, but did not try to also shutdown the host since probably it will not do a clean shutdown.

I guess a clean powerdown can be achieved from my main win8.1 vm, but I need to create a script for that. I am actually using "Powerdown Package (2.13)" plugin in my Unraid.

Maybe I could copy part of this script to the UPSMON "Jobs Tab" and create the desired script. Actually I should create a copy of the same script for the different situations ie low battery, output ups overload, ups overtemperature, ups baterry bad, etc.)

What do you think?

Other route is to follow this step http://www.ecopowersupplies.com/filedata/0000/0299/riello-ups-software-upsmon-manual.pdf ... page 38.

http://www.riello-ups.de/de/Download/PowerShield3/Linux-andere and install the linux package. Since I am not a linux expert, and also don´t know what linux version Unraid is, this is more complex for me, but hey, I did manage to make unraid/KVM work and now is my main rig....maybe this could be also the way to go since Iwill not loose so much time creating all those scripts.

Any ideas for any of both routes are welcome.

 

 

Link to comment

I have the APCUPS and Powerdown script installed on unRAID and if my power goes out my win 8.1 VM successfully shuts down without being killed. If your  win 8.1 VM is not shutting down then I would bet the XML config needs to be altered. Do you have a linux VM running at all? If so you could test to make sure that it gets the signal to shutdown properly.

Link to comment

I have the APCUPS and Powerdown script installed on unRAID and if my power goes out my win 8.1 VM successfully shuts down without being killed. If your  win 8.1 VM is not shutting down then I would bet the XML config needs to be altered. Do you have a linux VM running at all? If so you could test to make sure that it gets the signal to shutdown properly.

He is using a UPS that is not supported by apcupsd, so all signalling and control has to happen from within the Windows 8.1 vm that can see and control the UPS, which makes it a little tricky, since the controlling VM must shut down properly and still signal unraid to shut down after it's done.
Link to comment

He is using a UPS that is not supported by apcupsd, so all signalling and control has to happen from within the Windows 8.1 vm that can see and control the UPS, which makes it a little tricky, since the controlling VM must shut down properly and still signal unraid to shut down after it's done.

Right. Is there not any way to send the powerdown command to unraid before my vm is shutdown?

Link to comment

Hi,

 

This is the link for the english manual: http://www.ups-technet.com/AreaFTP/Manuals/0MNU106NPB-GB%20%28Manuale%20software%20UPSmon%20GB%29.pdf.

 

If you go to page 50 you will read how easy it is to trigger a job:

2.5 Job configuration
The jobs configuration menu is used to define the jobs that will be executed when an event of the UPS occurs. It is possible to configure multiple jobs for a particular event. It is possible to execute an external command defined by the user. Using the jobs configuration menu it is possible to launch an external editing program to write a user defined shutdown script. The user defined shutdown script is executed
before the normal system shutdown. This can be used for specific commands, which will be executed before the shutdown, for example, stop the web server, close some special application or shutdown database server. The name of this script is ups_shut.scr for the UNIX system.
...
For each event, it is possible to set an action from the list below:
1. Log event (L)
2. Execute file (E)
3. Local message (O)
4. Broadcast message (B)
5. System shutdown (S)
6. Email (E)
7. SMS (M)
...
2. Execute file (E): If selected the Upsagent will execute a specified command file when a selected condition occurs. Recommendation: Always use the full path name for the file. 

 

All this belong to the second route/option, so it must be installed in unraid (linux). Which version would you suggest to install in Unraid -if you think it is possible/recommended at all-?...

 

PowerShield3 for Linux (not red hat)
PowerShield3 v.5.3 (Build: 000) für Linux Debian x86 kernel 2.2, 2.4 2.6
PowerShield3 v.5.3 (Build: 000) für Linux Debian x86_64 kernel 2.6
PowerShield3 v.5.3 (Build: 000) für Linux Debian AMD64 kernel 2.6
PowerShield3 v.5.3 (Build: 000) für Linux Gentoo x86 kernel 2.6
PowerShield3 v.5.3 (Build: 000) für Linux Slackware x86 kernel 12.x, 13.x
PowerShield3 v.5.3 (Build: 000) für Linux Ubuntu x86_64 kernel 2.6
PowerShield3 v.5.3 (Build: 000) für Linux Ubuntu AMD64 kernel 2.6

 

Link to comment

Aren't we using a 64bit Slackware kernel, which unfortunately doesn't seem to appear there.

 

Yes on V6.  Not V5.

 

Sorry, you're right, I assumed as luca2 was using a VM that he's be using one of the 6 betas, but I don't know whether he is or not.  Come to think of it, I don't even know if virtualisation is possible in V5? 

Link to comment

Just reread your posts Luca,

 

If you've got it installed on your Win8 VM and it's working and shutting down your VM, then assuming you run your VM constantly whilst your UnRAID host is on then why don't you just setup a script within the Win8 VM to send a powerdown command to your UnRAID host via SSH.

 

That would bypass any need to use the Linux configuration of your UPS.

 

 

Link to comment

Just reread your posts Luca,

 

If you've got it installed on your Win8 VM and it's working and shutting down your VM, then assuming you run your VM constantly whilst your UnRAID host is on then why don't you just setup a script within the Win8 VM to send a powerdown command to your UnRAID host via SSH.

 

That would bypass any need to use the Linux configuration of your UPS.

 

Hi, thx for your time and suggestion. I agree that what you propose is a good way to do it (since Unraid 6b is slackware x64 .. so the linux route would not be posible).

 

Could you let me know how should the script look like (to send the powerdown command). It should do these two steps:

-stop array (un-mount shares) and then

-shutdown array.

Link to comment

I haven't tested this at all, but I think where I'd start is:

 

On Your Windows VM

 

1.  Download plink from here onto your Windows VM and place it in wherever you want it to stay I would suggest

 

C:\Windows\System32

 

2.  Create a file called plink.bat on your windows machine (Use Notepad++) containing:

 

C:\Windows\System32\plink.exe [email protected] -m C:\UPS_Shutdown.sh

 

might as well put it in C:\

 

3.  Create a file called UPS_Shutdown.sh (again using Notepadd++) on your Windows box and copy it to

 

C:\

 

In that file I would put

 

powerdown

 

On Your Unraid Box

 

4.  Install the powerdown plugin from dlandon & Weebotech

 

https://github.com/dlandon/unraid-snap/raw/master/powerdown-x86_64.plg

 

(That's the V6 Plugin - I'm assuming you are on V6 as you have a VM.)

 

Back To Your Windows Box & UPS Program

 

5.  Finally get your UPS to execute the file plink.bat in the event of a power cut with

C:\plink.bat

 

Refer to page 35 of the user manual you posted.

 

Like I said, I haven't tested any of this as I have an APC UPS, but I think it will work, might need a bit of tweaking, and I'm afraid I can't try it myself at the moment as I'm in the middle of 2 x 4TB preclears!

 

Once that's finished I'm happy to try it out and see, so let me know if you have any problems.

 

I'm sure some Unraid guru will come along and check the above at some point and offer some advice and tweaking.  ;)

Link to comment
  • 3 months later...

Hi,

Finally I did the testing. I simulated a scheduled shutdown via my ups software.

What happens is the wm where all the files are located (.bat, plink, etc) is shutdown via the scheduled task, but the array is not affected.

Let me know how to check manually that this command is executed:

C:\Windows\System32\plink.exe [email protected] -m C:\UPS_Shutdown.sh

I mean how can I check that I can reach my array (host) with this command?

Rgds.

Link to comment

Hi,

Finally I did the testing. I simulated a scheduled shutdown via my ups software.

What happens is the wm where all the files are located (.bat, plink, etc) is shutdown via the scheduled task, but the array is not affected.

Let me know how to check manually that this command is executed:

C:\Windows\System32\plink.exe [email protected] -m C:\UPS_Shutdown.sh

I mean how can I check that I can reach my array (host) with this command?

Rgds.

Powerdown will make entries in the syslog. Note the time you send the command and check for syslog entries with that timestamp.
Link to comment
  • 1 month later...

Thought I'd just reply to this to help anyone out in the future.

 

I have a HTPC running 24/7 and unraid 5 running on a HP N54L. I have a powershield (australian brand) UPS that doesn't use the APC communication methodology. Seems to be compatible with NUT, but no easy way to run that on unraid 5 by the look - or V6 yet either.

 

So I followed CHBMB's directions, and works successfully with unraid V5. I had to use a different plink command link, and had to install SSH and SSL package on unraid (and then establish user security). Using plink with the telnet connection didn't seem to send the correct command. Somethng about the commands in the telnet shell using plink aren't sent correctly?

 

so my plink command was as follows:

C:\Windows\System32\plink.exe -ssh root_user@IP_OF_SERVER -pw userpassword -m C:\PATH\UPS_Shutdown.sh

 

and it worked perfectly. in my case, the UPS management software is Netguard (looks like an UPSilion 2000 copy/rebrand)

 

 

Link to comment
  • 4 weeks later...

I had to use a different plink command link, and had to install SSH and SSL package on unraid (and then establish user security).

Great news! I gave up before due to my limited programming/linux knowledge and time for investigating. Sorry for that CHBMB!

Just wondering how you did tinstall SSH and SSL? Could anyone post a link or explain how to do it?

Also, just wanted to add macester did it work with NUT (not shure yet which version of unraid he has):

http://lime-technology.com/forum/index.php?topic=41424.0

Rgds.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...