[Nut-upsuser] Master privileges unavailable on UPS, no access :(

Jonathan Dion dion.jonathan at gmail.com
Thu Aug 17 06:47:06 UTC 2006


Hello Martin,

Sorry not to have answered before, but I was sleeping ^_^
To stay in the mailing list, either choose "answer to all" when you
answer me (I think all mail software have this possibility), or add
nut-upsuser at lists.alioth.debian.org as a recipient of your mail

I copy your mails :

--first mail

I beg your pardon, mister, but  I do not know how to reply to all. I
just communicate with you from my private email, because I couldn't
figure out how to communicate via tha mail list :(. If you explain to
me what to do so that everyone else sees our communication, I will be
glad to carry it out :)
So long as I understand you, in order to achieve system shutdown at a
power failure, I have to cahange the configuration like that:

  NOTIFYCMD /usr/local/ups/bin/notifyme
  NOTIFYMSG ONLINE "UPS %s is getting line power"
  NOTIFYMSG ONBATT "Someone pulled the plug on %s"
  NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC

  The file notifyme should contain:
   echo "The system is shutting down";
    telinit 0;
Will it work? What do you think?
I want to set the power control like this, because I am not sure that
the ups I am using fits this driver. That is why I wish to test it: I
want to see if the system will go down whenever I unplug the UPS.
Besides, because of the fact that I am not sure I am using the right
driver, I do not know whether the real UPS state of low battery will
be recognized as such by the software. And I do not feel like
experimenting with the low battery status. So I will be content if my
PC goes down whenever there is a power failure. Once I achieve that, I
will see how to achieve better performance. Probably I will again need
your help. If you suggest me some way to simulate the "on battery" and
the " low battery" and test the system behaviour, would be best :)

-- second mail

So, let me now tell you what I achieved so far:
I modified upsmon.conf like that:

  RUN_AS_USER root
  MONITOR Inform at localhost 1 root password master
  MINSUPPLIES 1
  SHUTDOWNCMD "/sbin/shutdown -h now"
  NOTIFYCMD /usr/local/ups/bin/notifyme
  POLLFREQ 5
  POLLFREQALERT 5
  HOSTSYNC 0
  DEADTIME 15
  POWERDOWNFLAG /etc/killpower
  NOTIFYMSG ONLINE "UPS %s is getting line power"
  NOTIFYMSG ONBATT "Someone pulled the plug on %s"
  NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
  RBWARNTIME 43200
  NOCOMMWARNTIME 300
  FINALDELAY 0

  The file notifyme is executable and contains:
  echo "The system is shutting down" > /home/marto/opit
  /sbin/telinit 0

The upsd.users file is:
[root]
               password = 98221026
               allowfrom = localhost
               upsmon master
               actions = SET
               instcmds = ALL

With this configuration, whenever I diconnect the UPS from the mains,
the system shutsdown normally. I would be glad if there is some way of
tellin g the ups itself to power off, after the PC shuts down, but
only in case that ups.status has turned "OB BOOST", i.e. only in cas
there has been power failure. What I have so far achieved suffices me
for now, but things can always get better.
Concisely, I have two questions:
1. How to make the UPS power off after the PC powers off in case of
power failure. Of course when there is no power failure, but I issue
shutdown command to the system, the UPS must not power off.
2. I would be glad if you suggest me how to improve my configuration
files: ups.conf, upsd.conf, upsd.users and upsmon.conf. They work ok
now, but I am sure something can be embettered :)

Thank you very much indeed for your responsiveness.

-- third mail

On 8/16/06, Martin Ivanov <tramni at abv.bg> wrote:
> Hello again!
> Here is how I further modified the executable file notifyme, so that upsmon does almost everything that I wish for:
> echo `date` >> /root/upsLog
> echo "  No power, shutting down the system!" >> /root/upsLog
> sleep 30
> control=`/usr/local/ups/bin/upsc Inform at localhost ups.status`
> if [ $control != OL ]
> then
>  /sbin/telinit 0
> fi
>
> So if power returns within 30 sec, the system will not go to   shutdown :). If power does not return, then the system goes to runlevel 0. The UPS goes on buzzing, but it can go on buzzing like that for quite a lot time before the battery gets damaged, because the PC is off and the power consumption from the UPS battery is minimal, am I not right? I am not quite sure whether I need to make the UPS itself go down in case of power failure, because if it does not go down, it has the chance to get charged when power returns. Do you think I am right? What would you recommend to me?
>
> -----------------------------------------------------------------
> http://ide.li/ - портал за българите по света. Статии, новини, форуми, снимки, информация.
>

So... ok, I give you my pardon ;-)

Nice, I see you achieve what you wanted.
But you know, if the driver you use is able to see the change of state
when your UPS is disconnected, I'm pretty sure it also is able to see
the low battery flag. As I see, the driver already know when to
display OL, OB and BOOSt status, so it probably know too when to
display LB status

Can you send us the result of the execution of "upsc
Inform at localhost". If all the information is here and seem correct,
the driver probably manage your UPS just fine.

If you want to test it without any risk, connect your PC directly to
the main, without using your UPS for power supply, but plug your UPS
to the PC normally. Run the driver, upsd and upsmon normally. The
problem is that you'll need to have something alimented by the UPS so
its battery charge dicrease. An old PC could be good.
Disconnect the UPs from main and wait. The PC should poweroff as soon
as the UPS reach lowbattery.

You should really not be confident on your UPS to only let it
30seconds on battery before shutting down the PC XD
Your method work of course but has a little problem : the case where
two very short power outage hapen the second 30 seconds after the
first.

For shutting down the UPS, I see that Peter already replied to you on
this. It is always better to poweroff the UPS if it is lowbattery and
no more needed because the computer is off.

To improve your configuration files... nothing to add in ups.conf,
nothing neither in upsd.users. your upsmon.conf file seem nice.
Perhaps you should try not to run upsmon as root, but it could be a
problem. I know upsmon start as root then duplicate itself to run with
RUN_AS_USER user (if this user is not root). The root upsmon is then
only here to launch the shutdown command in case it is needed.
In this case, your NOTIFYCMD would'nt be launch as root and could not
have the right to shutdown the system.

But if you are not paranoiac about security, there is no need to do that.

oh, and in the line :
MONITOR Inform at localhost 1 root password master

password must be changed to be the password of [root] NUT user
(98221026 in your case)


Cheer,

Jonathan Dion


More information about the Nut-upsuser mailing list