Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Help with nut (upsmon)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
mhodak
Veteran
Veteran


Joined: 15 Nov 2003
Posts: 1218

PostPosted: Tue May 06, 2014 7:15 pm    Post subject: Help with nut (upsmon) Reply with quote

I am not able to get upsmon going correctly with nut. I can see UPS status fine, i.e. upsc gives the info, but calling shutdown sequence is a problem. Part of it is that I do not understand how should things work and why do I need additional users (nut and another one for monitoring).

Here is what I have in /etc/nut/upsd.users:
Code:
[upsmonuser]
                password  = my_p4ss
                upsmon master


That seems OK to me, but I am not sure if the user "upsmonuser" should be a UNIX system user (in which case it should be created) or if it is just a fake user for nut. I have not created the user, maybe that is the problem.

Next, here is /etc/nut/upsmon.conf
Code:
MONITOR myups 1 upsmonuser my_p4ss master
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/nut/killpower
NOTIFYFLAG ONBATT      SYSLOG+WALL
 NOTIFYFLAG LOWBATT     SYSLOG+WALL
 NOTIFYFLAG FSD SYSLOG+WALL
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5

I added "MONITOR myups 1 upsmonuser my_p4ss master" and three NOTIFYFLAG messages, the rest was default.

AFAIK, this should be correct for setting up upsmon. But when I cut power to my UPS, there is no message in terminals, although /var/log/messages says "wall: user nut broadcasted 1 lines (22 chars)", but nothing appears in any terminal. I would like to test shutdown, but by default nut waits until battery becomes low, which is stupid for testing. Waiting for 1 minute after ups loses power should be much better, but I do not see a good way to set it up.

So, basically, how do I know that upsmon is working? Do I need to create an extra user for that? And ho to easily test that the whole setup works?

Overall, I am pretty frustrated with nut. I understand what it tries to do, but even after reading its manual I do not understand how it works.

Thank you for your help.
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6219
Location: Dallas area

PostPosted: Tue May 06, 2014 7:41 pm    Post subject: Reply with quote

You would probably need to add /etc/init.d/nut.powerfail to the default to have it shutdown on power fail.

I've seen a message in my terminal when I had power blink for a moment, but I had a term open at the time.
Otherwise it won't open a terminal to tell you about it, as far as I know. (wall should write to ALL console/terms)

I do keep a daily log of the ups using usplog (I think it talks to upsmon, but that's a guess), the log zeroed at midnight.
Do a "man upsmon" for further info.

And yes the documentation leaves a lot to be desired. ;)
_________________
UM780, 6.12 zen kernel, gcc 13, openrc, wayland
Back to top
View user's profile Send private message
mhodak
Veteran
Veteran


Joined: 15 Nov 2003
Posts: 1218

PostPosted: Tue May 06, 2014 7:48 pm    Post subject: Reply with quote

Actually, I have tried adding /etc/init.d/nut.powerfail to default startup, but it would shutdown the machine, which was quite unpleasant :). Had to use chroot to remove it from startup.
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6219
Location: Dallas area

PostPosted: Tue May 06, 2014 8:08 pm    Post subject: Reply with quote

From the /etc/init.d/nut.powerfail
Quote:
if [ -f /etc/killpower -o -f /etc/nut/killpower ]; then


It should only trigger a shutdown if either of those two files are present
(gentoo should be using /etc/nut/killpower)
_________________
UM780, 6.12 zen kernel, gcc 13, openrc, wayland
Back to top
View user's profile Send private message
mhodak
Veteran
Veteran


Joined: 15 Nov 2003
Posts: 1218

PostPosted: Tue May 06, 2014 11:58 pm    Post subject: Reply with quote

It looks like that according to the script, but when I start the service (I have just tested that), it kills my machine and none of the files are present. Actually, it is not a clean shutdown, machine stays powered up but it is not responsive. Maybe there is something wrong with the script or it should not be started automatically, that is nut will call it when power is off.
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6219
Location: Dallas area

PostPosted: Wed May 07, 2014 12:20 am    Post subject: Reply with quote

Code:
    if [ -f /etc/killpower -o -f /etc/nut/killpower ]; then
        UPS_CTL=/sbin/upsdrvctl
        UPS_POWERDOWN="${UPS_CTL} shutdown"
    elif [ -f /etc/apcupsd/powerfail ]; then
        UPS_CTL=/sbin/apcupsd
        UPS_POWERDOWN="${UPS_CTL} --killpower"
    else
        ewarn "UPS powerfail script scheduled, but no poweroff commands found."
        return 0
    fi


It should only take one of three paths, shutdown, apcupsd (if running apc ups) or simply tell you that no poweroff script was found.

But you may be correct that it shouldn't be autostarted, I don't have it that way, but haven't had a long running power failure to see what happens.
_________________
UM780, 6.12 zen kernel, gcc 13, openrc, wayland
Back to top
View user's profile Send private message
mhodak
Veteran
Veteran


Joined: 15 Nov 2003
Posts: 1218

PostPosted: Wed May 07, 2014 6:23 am    Post subject: Reply with quote

Not sure why it kills my machine, but according to bug #266804 (when the script was added), it is meant to run as a part of shutdown to turn off UPS.

Back to upsmon. How do you handle user there, is it an actual system user or just something that exists within upsmon?
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6219
Location: Dallas area

PostPosted: Wed May 07, 2014 9:45 am    Post subject: Reply with quote

As far as I know the user in upsd.user is some name you decide to use.
The name I picked isn't a user on my system.

You should be seeing messages in any terminal that is open (X) or any one of the console terms.
Edit to add: It does use "wall" which is part of sysvinit, if using systemd then I don't know if cmd is available.


As far as testing, the UPS itself may have a test option, where it sends a signal to the operating system.
_________________
UM780, 6.12 zen kernel, gcc 13, openrc, wayland
Back to top
View user's profile Send private message
AndCycle
n00b
n00b


Joined: 05 Jun 2004
Posts: 19

PostPosted: Fri Jan 08, 2016 12:16 pm    Post subject: Reply with quote

I know this is outdated reply, but this thread is high in google ranking,

here is the correct answer,

nut.powerfail should be in "shutdown" level, not "default",


Code:
rc-update add nut.powerfail shutdown

Code:
        nut.powerfail |              shutdown
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum