Koozali.org: home of the SME Server

Obsolete Releases => SME 7.x Contribs => Topic started by: NoTo on July 16, 2008, 09:47:53 PM

Title: Live UPS monitoring, Sysmon?
Post by: NoTo on July 16, 2008, 09:47:53 PM
Hi all,

Been looking through and searching on this but can't find anything that really helps, so hopefully some kind soul will give me a pointer.

On SME 7.3 I am using a APC UPS with USB cable for monitoring. I followed the HowTo to set it up and it works fine, I even get an email if it goes to battery.

What I'd really like though is an easy way to monitor it's status, battery level, that it's all working fine etc, and preferably without going to the command line.

So far I have added the Sysmon contrib which is fabulous. It has a link for UPS1 on the upper menu, but clicking on it reveals no information at all, no graph etc, just the Hourly, Weekly, Monthly etc link.

Is that contrib capable of displaying my UPS info with a little tinkering, or does anyopne have a suggestion at all?

Very many thanks,
Graham
Title: Re: Live UPS monitoring, Sysmon?
Post by: byte on July 16, 2008, 09:48:17 PM
Moving this topic to the SME 7.x contribs forum, it is more appropriate there. Thanks!
Title: Re: Live UPS monitoring, Sysmon?
Post by: okepc on July 17, 2008, 09:34:28 AM
I have installed the systemmonitor from mastersleepy in combination with apcupsd and i get graphs about main and output voltage , runtime , temperature , battery voltage.

From what i understand is that mastersleepy's improved code is goin to merge into sysmon but i don't know if ups statistics from apcupsd work in sysmon.

Dirk 
Title: Re: Live UPS monitoring, Sysmon?
Post by: cactus on July 17, 2008, 01:59:17 PM
I have installed the systemmonitor from mastersleepy in combination with apcupsd and i get graphs about main and output voltage , runtime , temperature , battery voltage.

From what i understand is that mastersleepy's improved code is goin to merge into sysmon but i don't know if ups statistics from apcupsd work in sysmon.

Dirk 
AFAIK the UPS code should also be working in the default one, the code is not MasterSleepy's. Judging from the source it determines the device from the configuration file and uses /usr/bin/upsc to query the ups data. This should be part of the nut or nut-client package, do you have nut installed? You can test with
Code: [Select]
rpm -q nut nut-clientAbove should output the package and version number if installed.
Title: Re: Live UPS monitoring, Sysmon?
Post by: NoTo on July 17, 2008, 02:05:38 PM
Code: [Select]
rpm -q nut nut-clientAbove should output the package and version number if installed.
Hi Cactus,
The above command gives this information:
Code: [Select]
nut-2.2.0-3.3.el4
nut-client-2.2.0-3.3.el4

Graham
Title: Re: Live UPS monitoring, Sysmon?
Post by: okepc on July 17, 2008, 03:15:45 PM
It's only working if you install and configure apcupsd, without it you won't get any graphs concerning the ups.
Title: Re: Live UPS monitoring, Sysmon?
Post by: okepc on July 17, 2008, 03:17:53 PM
But maybe i have an old version and nut support has been added later.....
Title: Re: Live UPS monitoring, Sysmon?
Post by: cactus on July 17, 2008, 04:02:36 PM
It's only working if you install and configure apcupsd, without it you won't get any graphs concerning the ups.
I wonder what makes you think that as the relevant code seems not to indicate such:

Code: [Select]
            my $cnt=0;
            if ( $upsstatus eq 'enabled') {
                my @upses = `cat /etc/ups/ups.conf | sed -ne 's/\\[\\(.*\\)\\]/\\1/p'`;
                foreach(@upses) {
                    chomp;
                    my $upsname="$_\@localhost";
                    $cnt++;
                    my @upsdata = `/usr/bin/upsc $upsname 2> /dev/null`;
                    foreach(@upsdata) {
                        if(/^([a-z])[^.]+\.(voltage|load|charge|runtime|temperature|humidity)\s*:\s*([0-9,.]+)/) {
                            my $element = "$1_$2";
                            $datahash->{ups}->{$cnt}->{$element}=$3;
                            if($element=~/time/i) { $datahash->{ups}->{$cnt}->{$element} /= 60; }
                        }
                    }
                }
            }

Graham,

what is the output of the following commands:
Code: [Select]
db configuration getprop nut statusand
Code: [Select]
cat /etc/ups/ups.conf | sed -ne 's/\\[\\(.*\\)\\]/\\1/p'
Title: Re: Live UPS monitoring, Sysmon?
Post by: NoTo on July 17, 2008, 06:10:17 PM
Cactus,

db configuration getprop nut status
Code: [Select]
enabled
cat /etc/ups/ups.conf | sed -ne 's/\\[\\(.*\\)\\]/\\1/p'
Code: [Select]
no output, just returns to the prompt
Much obliged for your interest :-)

Graham
Title: Re: Live UPS monitoring, Sysmon?
Post by: cactus on July 17, 2008, 08:06:28 PM
db configuration getprop nut status
Code: [Select]
enabled
That means nut is enabled and the system is aware that a UPS should be queried for data.

cat /etc/ups/ups.conf | sed -ne 's/\\[\\(.*\\)\\]/\\1/p'
Code: [Select]
no output, just returns to the prompt
Than I think there is the cause of the problem... no name for the UPS can be determined and hence no UPS will be queried for data. Can you post the contents of the /etc/ups/ups.conf file?

Much obliged for your interest :-)
You're welcome.
Title: Re: Live UPS monitoring, Sysmon?
Post by: NoTo on July 17, 2008, 08:49:31 PM
Yep, I think I can do that... :-?

/etc/ups/ups.conf

Code: [Select]
#------------------------------------------------------------
#              !!DO NOT MODIFY THIS FILE!!
#
# Manual changes will be lost when this file is regenerated.
#
# Please read the developer's guide, which is available
# at http://www.contribs.org/development/
#
# Copyright (C) 1999-2006 Mitel Networks Corporation
#------------------------------------------------------------
[UPS]
        driver = usbhid-ups
        port = /var/lib/ups/hiddev0


Ooh, I could :shock:
Title: Re: Live UPS monitoring, Sysmon?
Post by: cactus on July 17, 2008, 09:16:35 PM
Yep, I think I can do that... :-?

/etc/ups/ups.conf

Code: [Select]
#------------------------------------------------------------
#              !!DO NOT MODIFY THIS FILE!!
#
# Manual changes will be lost when this file is regenerated.
#
# Please read the developer's guide, which is available
# at http://www.contribs.org/development/
#
# Copyright (C) 1999-2006 Mitel Networks Corporation
#------------------------------------------------------------
[UPS]
        driver = usbhid-ups
        port = /var/lib/ups/hiddev0


Ooh, I could :shock:
Haha, but that is the default contents, I have the same, but I have no UPS, you did reboot after setting the status of nut to enabled like described in the wiki?

What is the make and model of your UPS?

Perhaps Shad, the original author has some ideas...
Title: Re: Live UPS monitoring, Sysmon?
Post by: NoTo on July 17, 2008, 09:26:54 PM
It's an APC Back-UPS CS 500.

Yep, I followed the HowTo to the letter like a good noob should :D which was basically

Code: [Select]
config setprop nut status enabled
signal-event post-upgrade
signal-event reboot

Decided to test the UPS by yanking the power lead out. Server kept running for about half an hour and then sent me an email to say it's shutting down. So I think it functioning perfectly. Will wait and see if Shad can shed any light on the matter. I'm happy that it works at least. At the weekend I'll be making it live and on Monday the SBS2003 box goes on ebay  :-P
Title: Re: Live UPS monitoring, Sysmon?
Post by: cactus on July 17, 2008, 09:55:30 PM
Will wait and see if Shad can shed any light on the matter.
Shad is happy to see and try to help out, but for that he would like you to report this in the bugtracker. If you need help with that... I'll be glad to be of assistance.

I'm happy that it works at least. At the weekend I'll be making it live and on Monday the SBS2003 box goes on ebay  :-P
That is nice indeed.
Title: Re: Live UPS monitoring, Sysmon?
Post by: NoTo on July 17, 2008, 11:15:04 PM
Bug added. Thanks heaps, Cactus. :grin:
Title: Re: Live UPS monitoring, Sysmon?
Post by: cactus on July 17, 2008, 11:15:58 PM
Bug added. Thanks heaps, Cactus. :grin:
Please post a link for future reference.
Title: Re: Live UPS monitoring, Sysmon?
Post by: NoTo on July 17, 2008, 11:43:08 PM
Oops, sorry about that :shock:

http://bugs.contribs.org/show_bug.cgi?id=4449 (http://bugs.contribs.org/show_bug.cgi?id=4449)

Title: Re: Live UPS monitoring, Sysmon?
Post by: okepc on July 18, 2008, 09:47:31 AM
Cactus

later in tha code...

                else
                    {
                    if( -e '/sbin/apcaccess')
                        {
                        $linev = 'U';
                        $loadpct = 'U';
                        $bcharge = 'U';
                        $timeleft = 'U';
                        $outputv = 'U';
                        $itemp = 'U';
                        $battv = 'U';
                        @apcdata = `/sbin/apcaccess status 2> /dev/null`;
                        if ( $debug eq 'debug' )
                    {
                        foreach (@apcdata )
                            {   
                                print 'apcdata : ' . $_;

Quote
if( -e '/sbin/apcaccess')
--> apcupsd

Nut support and apcupsd support.

Dirk
Title: Re: Live UPS monitoring, Sysmon?
Post by: cactus on July 18, 2008, 03:43:11 PM
Cactus

later in tha code...

                else
                    {
                    if( -e '/sbin/apcaccess')
                        {
                        $linev = 'U';
                        $loadpct = 'U';
                        $bcharge = 'U';
                        $timeleft = 'U';
                        $outputv = 'U';
                        $itemp = 'U';
                        $battv = 'U';
                        @apcdata = `/sbin/apcaccess status 2> /dev/null`;
                        if ( $debug eq 'debug' )
                    {
                        foreach (@apcdata )
                            {   
                                print 'apcdata : ' . $_;
 --> apcupsd

Nut support and apcupsd support.

Dirk
Nope that is not in the default contrib (from smecontribs, I believe) I have installed.