Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOW-TO: UPS MGE Protection Center 500
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
wickwire
n00b
n00b


Joined: 13 Dec 2003
Posts: 71

PostPosted: Sat Feb 26, 2005 8:58 pm    Post subject: HOW-TO: UPS MGE Protection Center 500 Reply with quote

I've recently come in need of an UPS for my gentoo box, did some researching and found out that APC has a fairly decent support under linux - however, I also came across this baby:

http://www.mgeups.com/products/pdt230/smallups/pcenter/index.htm

And the number of power sockets, battery uptime and explicit linux support caught my attention.

So I bought it, and here's a little howto I think will come in handy for everyone else out there with it, trying to make it work properly (I've checked the forums and all I could find was a thread in spanish, so I've decided to create this how-to)

First off, kernel settings:
I'm using Gentoo Dev Sources 2.6.10-gentoo-r6 and these are the kernel settings I believe to be relevant in this case:

Code:
Device Drivers  --->
             USB support  ---><*> Support for Host-side USB
   [*]   USB device filesystem
  <*> EHCI HCD (USB 2.0) support
  <*> OHCI HCD support
  <*> UHCI HCD (most Intel and VIA) support
  <*> USB Human Interface Device (full HID) support
   [*]   HID input layer support
   [*]   /dev/hiddev raw HID device support


(I'm a bit of a n00b so maybe I've got extra stuff turned on, I'm using UDEV as well)

This UPS connects to the PC via USB port only, and dmesg states this upon connection to the PC:

Code:
usbcore: registered new driver hiddev
usbhid: probe of 2-2:1.0 failed with error -5


However, it still works.

Now, according to http://opensource.mgeups.com/ups.htm, the MGE Protection Center uses the newhidups driver and the most recent version of NUT (http://www.networkupstools.org/) in portage at the time of writing was www-apps/nut-2.0.1_pre4 which I believe doesn't have this newhidups driver, I installed it and the driver wasn't there, so I downloaded the source code for www-apps/nut-2.0.1 to /usr/portage/distfiles/ from the NUT homepage and created my own ebuild copying the /usr/portage/www-apps/nut/ directory to /usr/local/portage/, deleting all the ebuilds except one, all metadata, manifests, renaming the ebuild to nut-2.0.1.ebuild then running

Code:
ebuild nut-2.0.1.ebuild digest


and NUT 2.0.1 emerged just fine, so I moved on to the configuration part:

NOTE:

kdvgent wrote:

Quote:
Downloading the nut source and building your own e-build is not necessary. I unmasked the latest nut version (nut-2.0.1_pre4) and did
Code:
Code:
NUT_DRIVERS="newhidups" emerge www-apps/nut


There are three files to mess around with, and a possible forth upsd.conf, upsmon.conf, upsd.users, ups.conf, all in the /etc/nut/ directory:

upsd.conf -->didn't change a thing

upsd.users --> didn't change a thing

ups.conf

Code:
[mge]   
        driver = newhidups
        port = auto
        desc = "MGE Protection Center"


upsmon.conf

Code:
RUN_AS_USER root --> tried with "nutmon" but the notices to all users and notifyme script didn't work, decided to risk it with root...
MONITOR mge@localhost 1 <user> <pass> master
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
NOTIFYCMD /usr/local/bin/notifyme
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
NOTIFYMSG ONLINE "UPS %s is getting line power"
NOTIFYMSG ONBATT "Someone pulled the plug on %s"
NOTIFYMSG LOWBATT "Battery is CRITICAL!"
NOTIFYMSG FSD "UPS is going down"
NOTIFYMSG COMMOK "UPS is responding properly"
NOTIFYMSG COMMBAD "UPS not responding"
NOTIFYMSG SHUTDOWN "The system will shutdown NOW"
NOTIFYMSG REPLBATT "Hurry up and change batteries!"
NOTIFYFLAG ONLINE EXEC+SYSLOG+WALL
NOTIFYFLAG ONBATT EXEC+SYSLOG+WALL
NOTIFYFLAG LOWBATT EXEC+SYSLOG+WALL
NOTIFYFLAG FSD EXEC+SYSLOG+WALL
NOTIFYFLAG COMMOK EXEC+SYSLOG
NOTIFYFLAG COMMBAD EXEC+SYSLOG
NOTIFYFLAG SHUTDOWN EXEC+SYSLOG+WALL
NOTIFYFLAG REPLBATT EXEC+SYSLOG+WALL
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 2


I then changed the battery.battery.low parameter on the UPS to 20% (there will be a prompt for the value),
as root

Code:
grin linux # upsrw -s battery.charge.low -u <user> -p <pass> mge@localhost


this way the battery will assume critical state when reaching 20% of its battery uptime - and then the system shuts down accordingly.

/etc/init.d/upsd start
/etc.init.d/upsmon start

rc-update add upsd default
rc-update add upsmon default

I'm thinking that my logic behind this is ok... First I though of a way to, upon power failure, the system ignite a delayed shutdown - if the power returned before the delay, the UPS notified the system and the shutdown sequence would be aborted.
I then realised that it would be simpler to just use the critical parameter on the UPS: power is out, if it comes back before then, fine, the system never knew what went on and the power is back, the UPS recovers, if not, as the critical battery limit is reached, the system is notified and immediate shutdown takes place.

knutclient seems to be a very nice UPS client, allows to alter rw parameters such as the critical battery level however I've decided to use ups-monitor which only shows the state of the ups - it's more "gnomish", knutclient is KDE all the way.

So far I've been using the UPS just fine, sometimes I see a notice regarding loss of communication with the UPS but right after that I get another one informing that communication has been re-established, so I think things are under control...

I hope this helps setting things up, feel free to improve the How-to with tips and comments, my main reason in doing it was so that everyone else in doubt about UPS support would find this one to work under linux, as I've read in the forums that USB connection for this model might be tricky... well, it works! :)

Also, forgot to mention, the UPS load is at 34% - one hdd, one DVD-writer, a 450W Be Quiet! PSU, Asus A7N8X Deluxe + AMD Athlon XP 2000+, 512MB DDR.

EDIT:

If set, WALL outputs the NOTIFYMSG to a running console I think, but I've set things up so that when something happens and a NOTIFYMSG is to come out, it gets mailed to a given user instead - with EXEC and the NOTIFYCMD.

I used sendmail and Thunderbird. Set up an email account with movemail in Thunderbird for the user in question, then go to upsmon.conf and set the NOTIFYCMD /usr/local/bin/notifyme (or whatever you want to call it), create the notifyme file (or the name you chose) under /usr/local/bin similar to this and chmod it to executable:

Code:

#! /bin/bash
(echo Subject: MGE Protection Center ; echo "$*"  )| sendmail -F"mge@localhost" grin@grin.gr.org


when a NOTIFYMSG shows up, if it has the EXEC set, an email is generated with the Subject and given msg and then sent to grin@grin.gr.org, with sender mge@localhost.


Last edited by wickwire on Sun Aug 28, 2005 9:11 pm; edited 2 times in total
Back to top
View user's profile Send private message
kdvgent
Guru
Guru


Joined: 29 Sep 2004
Posts: 328
Location: Belgium

PostPosted: Sun Mar 27, 2005 6:33 pm    Post subject: Additional information Reply with quote

Your HOWTO has been a great help. Thanks. Some remarks, questions:

Downloading the nut source and building your own e-build is not necessary. I unmasked the latest nut version (nut-2.0.1_pre4) and did
Code:
NUT_DRIVERS="newhidups" emerge www-apps/nut

For the configuration of the various files, I did follow the instructions in the NUT documentation (where it is explained how to define a specific user and group so that root is not needed): http://eu1.networkupstools.org/doc/2.0.1/INSTALL.html.

Remaining problems, questions:
  1. I get regularly "data stale" messages although, as explained in the nut FAQ, I allready put MAXAGE to 30 in upsd.conf.
  2. I am using enlightenment (E17) as windows manager. In order to be able to run certain applications, I have parts of KDE and GNOME installed - but it happens to be more KDE than GNOME. Hence, I installed knutclient to monitor the UPS instead of ups-monitor (that would require to install almost all gnome packages). Strange enough, knutclient needs arts (although there is no dependency in the e-build). But having installed arts (that I do not use), everything works fine.
  3. I tried to install the gkrellm plug-in (gkrellmbups) but, in order to work with NUT, during the build one must run ./configure with the --enable-nut option. I do not know how to pass this option via the emerge command.
Hope this helps.
Back to top
View user's profile Send private message
wickwire
n00b
n00b


Joined: 13 Dec 2003
Posts: 71

PostPosted: Mon Apr 04, 2005 9:21 am    Post subject: Reply with quote

Hi there, thanks for the comments, I'll get right on correcting the How-To - I also get "data stale" messages and somehow my ups won't last the 30min or so advertised, what I mean is, it seems to be "set" at 15min top - I still haven't had the time to mess around with it and figure out if there's some option in there that I might be missing... as for the gkrellm plugin I haven't tried it yet, I'll do so whenever possible - not quite sure on how to perform the ./configure part as well, but maybe there's something you can alter on the ebuild itself and move it to /usr/local/portage...

Later! :)
Back to top
View user's profile Send private message
lpx
Apprentice
Apprentice


Joined: 03 Mar 2005
Posts: 205
Location: Braga, Portugal

PostPosted: Mon Apr 11, 2005 8:48 pm    Post subject: Reply with quote

Hi,

I bought a UPS too and everything is fine until i reach the battery low point.

The systems starts to shutdown and the ups is imnediatly shuted down.

I cant understand what's happening because the halt script located in /etc/init.d seems to be just fine!

Can someone help me in understanding what's happening?

Cheers,
_________________
Imaginando o futuro
Imagining the future
Back to top
View user's profile Send private message
wickwire
n00b
n00b


Joined: 13 Dec 2003
Posts: 71

PostPosted: Fri May 27, 2005 2:18 am    Post subject: Reply with quote

Well, I guess that if afterwards you boot the system and the filesystem shows as having been cleanly unmounted... you're safe.

Unless I misunderstood your situation, if after new boot the filesystem indicates NOT having been cleanly umounted, I'm thinking the following: you set the shutdown signal too close to battery lower limit, and the shutdown sequence is taking more time than the power still left on the UPS upon shutdown signal being sent.
Hence the "crash", if so - battery is at, say, 1min of "dying", signal is sent, system starts shutting down, shutdown sequence itself lasts more than a minute... battery dies and the computer loses power before shutdown sequence completes.

Hope this helps... (and sorry for the late reply)
Back to top
View user's profile Send private message
bobbix
Apprentice
Apprentice


Joined: 04 Dec 2004
Posts: 173

PostPosted: Fri Jul 01, 2005 6:58 pm    Post subject: Reply with quote

Just to say that you need libusb to be able to compile the newhid driver.

Bobbix
Back to top
View user's profile Send private message
kamikaze04
Guru
Guru


Joined: 28 Mar 2004
Posts: 366
Location: Valencia-Spain

PostPosted: Mon Dec 05, 2005 12:39 pm    Post subject: Reply with quote

Yeah, i was having problems trying to emerge nut, but emergin libusb solved them...

Quote:

Just to say that you need libusb to be able to compile the newhid driver.


Thanks bobbix[/code]
_________________
Todo lo que quisiste saber sobre google en: www.noticiasgoogle.es
Back to top
View user's profile Send private message
phsdv
Guru
Guru


Joined: 13 Mar 2005
Posts: 372
Location: Europe

PostPosted: Wed May 17, 2006 7:38 am    Post subject: Reply with quote

kdvgent wrote:
3. I tried to install the gkrellm plug-in (gkrellmbups) but, in order to work with NUT, during the build one must run ./configure with the --enable-nut option. I do not know how to pass this option via the emerge command.
[/list]
I enhanced the ebuild. It was not that difficult. Below the diff beteen the local ebuild and the one in portage. I will file a bug report to get this into portage. [edit]bug filed[/edit]
Code:
$ diff gkrellmbups-2.0.2.ebuild /usr/portage/x11-plugins/gkrellmbups/gkrellmbups-2.0.2.ebuild
5c5
< IUSE="nut"
---
> IUSE=""
23c23
<       econf `use_enable nut` || die "configure failed"
---
>       econf || die
Now I need to get the plugin configured, because up to now it does not show me much... (only empty graphs).
Back to top
View user's profile Send private message
kdvgent
Guru
Guru


Joined: 29 Sep 2004
Posts: 328
Location: Belgium

PostPosted: Mon Jul 03, 2006 7:32 pm    Post subject: Problem with packages more recent than nut-2.0.0 Reply with quote

Anybody experiencing the same problem?

When I use a version of sys-power/nut more recent than version 2.0.0, the software always looses, after a while, contact with the UPC. With version 2.0.0, my computer can run forever without problems.

All suggestions welcome.
Back to top
View user's profile Send private message
phsdv
Guru
Guru


Joined: 13 Mar 2005
Posts: 372
Location: Europe

PostPosted: Tue Jul 04, 2006 5:28 am    Post subject: Reply with quote

Quote:
sys-power/nut more recent than version 2.0.0, the software always looses, after a while, contact with the UPC
yes very similar here. I was running nut 2.0.3-r1 and that did break often. I just dowgraded to 2.0.0 and that seems to work better, but time will tell.
Back to top
View user's profile Send private message
arlequin
l33t
l33t


Joined: 16 Nov 2002
Posts: 707
Location: grep $USER /etc/passwd | cut -d':' -f6

PostPosted: Mon Aug 14, 2006 4:16 pm    Post subject: Reply with quote

Tip : if you get in trouble with kernel 2.6.17+, unmask sys-power/nut-2.0.4. In /etc/portage/package.keywords :
Code:
dev-libs/libusb ~x86
sys-power/nut ~x86

_________________
J'vous dis ciao !
Au fait, ciao ça veut dire bye en anglais.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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