FreeNAS and UPS

Status
Not open for further replies.

Sander Jansen

Explorer
Joined
Dec 26, 2015
Messages
87
hey,

Today i got my UPS (Back-UPS XS 700U) and i got it working with FreeNAS just fine. e-mails and stuff works and i can get status info using: upsc ups@localhost . Now in the guide there is a section for remote monitor. Does anyone know how to set this up so i can use my windows machine to see the ups status?

I'm guessing it's asking a bit much to get the functionality of the official software with power consumption stats and such... but that would be awesome if that info could work as well. But for now... does anyone know how to get my windows machine to work with it as well?
 
Last edited by a moderator:

ethereal

Guru
Joined
Sep 10, 2012
Messages
762
use something like bitvise ssh client. that is what I use. you can save your settings as a profile and automatically login.

you'll need to turn on and setup ssh on FreeNAS and then ssh in from windows - then upsc ups@localhost will give you the information you seek.

i also have a task that runs a script once a week which emails me the information which I want

Time: 2017-06-13 12:50:26
UPS Status: OL
Output Load: 28 %
Output Voltage: 120.0 V
Battery Runtime: 1440 s
Battery Charge: 100 %
 
Last edited by a moderator:

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
hey,

Today i got my UPS (Back-UPS XS 700U) and i got it working with freenas just fine. e-mails and stuff works and i can get status info using: upsc ups@localhost . Now in the guide there is a section for remote monitor. Does anyone know how to set this up so i can use my windows machine to see the ups status?

I'm guessing its asking a bit much to get the functionality of the official software with power consumption stats and sutch... but that would be owsome if that info could work aswell. But for now... does anyone know how to get my windows machine to work with it aswell?
I've written a script that emails you a UPS status report, available on GitHub:

https://github.com/Spearfoot/FreeNAS-scripts/blob/master/ups_report.sh

It's one of my FreeNAS utility scripts, available in the Resources section: "Github repository for FreeNAS scripts, including disk burnin".

I don't know of any way to provision real-time UPS monitoring from Windows.
 

ethereal

Guru
Joined
Sep 10, 2012
Messages
762
I've written a script that emails you a UPS status report, available on GitHub:

https://github.com/Spearfoot/FreeNAS-scripts/blob/master/ups_report.sh

It's one of my FreeNAS utility scripts, available in the Resources section: "Github repository for FreeNAS scripts, including disk burnin".

I don't know of any way to provision real-time UPS monitoring from Windows.


thank you - i know i got it somewhere and i was trying to find out where when you posted. spearfoot's scripts are all incredibly useful.
 

Sander Jansen

Explorer
Joined
Dec 26, 2015
Messages
87
Well that is what im doing now, using SSH to login to my freenas and read stats from there... works for now

That is indeed a nice script... im going to steal that aswell ;)

what im more concerned about is that freenas shuts down at 10% and not the 20% i put in (override.battery.charge.low = 20) or is this the wrong value for freenas to turn off at? I have VMs running (still need to figure out if thy shutdown gracefully at all) and freenas needs about 4 to 5 minutes to shutdown...
 

ethereal

Guru
Joined
Sep 10, 2012
Messages
762
i tested my ups two days ago and it sent me an email when it went on to battery and when it shutdown - my settings is after 30s shutdown.

ONBATT - ups

SHUTDOWN -
 

Sander Jansen

Explorer
Joined
Dec 26, 2015
Messages
87
i read on more posts that the shutdown when on battery works fine but the when on low is a bit fiddely. Mine shutdown aswell but to late so it could not finish shutting down. so i tryed changing the battery.charge.low setting to 20% but that did not do much at all. it still went down to 10% before it started to shutdown
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Well that is what im doing now, using SSH to login to my freenas and read stats from there... works for now

That is indeed a nice script... im going to steal that aswell ;)

what im more concerned about is that freenas shuts down at 10% and not the 20% i put in (override.battery.charge.low = 20) or is this the wrong value for freenas to turn off at? I have VMs running (still need to figure out if thy shutdown gracefully at all) and freenas needs about 4 to 5 minutes to shutdown...
I've gotcha covered! See these two threads in the Resources section for scripts and information on configuring your UPS/FreeNAS/ESXi systems with UPS setup, graceful VM shutdown, etc.:

"Configuring UPS support for single or multiple FreeNAS servers"
"Utility scripts for FreeNAS and VMware ESXi"
 

Sander Jansen

Explorer
Joined
Dec 26, 2015
Messages
87
Well thy use the timer function as well instead of battery low... i guess i should switch over to that then...

Now to see if my VMs will shutdown nicely... i have a Debian VM running with webserver stuff on it. it shuts down pretty fast within 1 minute but is there a command i can use to tell it to shutdown before FreeNAS does? (the links for esxi seem to work for esxi specificaly...)

I found that apcupsd is avalible for debian... now how to set it up with FreeNAS...?
EDIT: it's perhaps not as clean but i could make a script that ssh's into the webserver and shuts it down and then waits for X seconds and then shuts down FreeNAS? and link that script in the ups settings?
 
Last edited by a moderator:

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Well thy use the timer function aswell instead of battery low... i guess i should switch over to that then...

Now to see if my VMs will shutdown nicely... i have a Debian VM running with webserver stuff on it. it shuts down pretty fast within 1 minute but is there a command i can use to tell it to shutdown before freenas does? (the links for esxi seem to work for esxi specificaly...)

I found that apcupsd is avalible for debian... now how to set it up with freenas...?
EDIT: it's perhaps not as clean but i could make a script that ssh's into the webserver and shuts it down and then waits for X seconds and then shuts down freenas? and link that script in the ups settings?
I beg your pardon! You must be using FreeNAS as a hypervisor; I don't know how to gracefully shut down VMs in that scenario.
 

Sander Jansen

Explorer
Joined
Dec 26, 2015
Messages
87
yes, i am using FreeNAS as hypervisor... sorry for not mentioning that before...

well ssh seems to be a option but how can i get a script to login? it asks for a password... now ive fund some things but i need to either install "expact" or use keys... I have tried keys but for some reason i get: Could not open a connection to your authentication agent.... and id rather not install things inside FreeNAS, in case it does not work any more with updates or whatever
 
Last edited by a moderator:

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
yes, i am using freenas as hypervisor... sorry for not mentioning that before...

well ssh seems to be a option but how can i get a script to login? it asks for a password... now ive fund some things but i need to eighter install "expact" or use keys... ive tryed keys but for some reason i get: Could not open a connection to your authentication agent.... and id rather not install things inside freenas, in case it doesnt work anymore with updates or whatever
I use PuTTY to SSH to my FreeNAS boxes. You can configure it with public key cryptography if you don't want to have to enter a password to log on. Here are instructions for setting this up:

https://forums.freenas.org/index.ph...keys-using-putty-and-puttygen-with-ssh.39834/
 

Sander Jansen

Explorer
Joined
Dec 26, 2015
Messages
87
thanks, but i need FreeNAS to login to my debian webserver. this needs to happen from inside a script. basecly what i want to do is make a script that logs into the debian over ssh to tell it to shutdown. then wait for about 1.5 minutes and after that tell freenas to shutdown. all this needs to be in 1 script. then i can tell the ups deamon in FreeNAS to call for that script after set seconds of my ups running on battery.

at least for now that seems the best way to do this... and apart from all the things that dont work ... the easyest option XD

EDIT: i get the key working... seems like everything is working now... just waiting for my ups to recharge so i can actually test it... that is one BIG flaw with this timer function... if power fails again before the battery is fully charged... it wont do much good because the timer will be way to long...
 
Last edited by a moderator:

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
thanks, but i need freenas to login to my debian webserver. this needs to happen from inside a script. basecly what i want to do is make a script that logs into the debian over ssh to tell it to shutdown. then wait for about 1.5 minutes and after that tell freenas to shutdown. all this needs to be in 1 script. then i can tell the ups deamon in freenas to call for that script after set seconds of my ups running on battery.

at least for now that seems the best way to do this... and apart from all the things that dont work ... the easyest option XD

EDIT: i get the key working... but now how do i send commands over ssh from a script.,.. as soon as it logsin it stops teh script untill i logout again (manually)
Basically, you execute a command via SSH like this:
Code:
ssh root@debian-host shutdown -h now

You could use sleep in your FreeNAS script to wait for the Debian VM to halt, like this for example:
Code:
#!/bin/sh

# Shut down the Debian server
ssh root@debian-host shutdown -h now

# Wait 90 seconds for it to shutdown
sleep 90

# Shut down FreeNAS
shutdown -h now
 
Status
Not open for further replies.
Top