Koozali.org: home of the SME Server

Nut and serial cable config

John Crisp

Nut and serial cable config
« on: November 14, 2003, 12:56:50 AM »
I have an old, but serviceable Best Patriot dumb UPS that I want to run at here at home. I have a 6.0b3 server.

I have tested it with the INT 51 cable on a W2K workstation and everything workls as it should.

I am having a devil of a job trying to find anything concise about reconfiguring nut to work. I have read just about every post on UPS, NUT and anything else I can find here, and all (the little that there is) of the manuals  at the nut site, along with trawling though anything else I can find online.

I am stuck on trying to set the right configuration options.

I know that I need the following config in ups.conf :

[UPS]

driver = genericups
port = /dev/ttyS0
upstype = 6

I added a property to db configuration nut called Options and set it to 6

I enabled nut, and have had a bit of a hack at the templates and can generate the above with the following custom ups.conf template :

{
    my $model = $nut{Model} || "hidups";
    my $device = $nut{Device} || "/var/lib/ups/hiddev0";
    my $upstype = $nut{Options};        ####Added this line
    $OUT .= "[UPS]\n";
    $OUT .= "\tdriver = $model\n";
    $OUT .= "\tport = $device\n";
    $OUT .= "\tupstype = $upstype\n";    ####Added this line
}

First question is about the ||hidups and ||/var.lib/ups/hiddev0 - dooes this mean 'default to these settings in the absence of another setting ?


However, I know that this isn't all there is too it as it kept reporting that
the line was stale. Having had another recce, I tried the following on the command line too see what would happen:

/sbin/genericups -x upstype=6 /dev/ttyS0

and got the followjng failure :

Network UPS Tools - Generic UPS driver 0.60 (1.2.0)
UPS type: Best Patriot (INT51 cable)
This program is currently running as nutups (UID 420)
/dev/ttyS0 is owned by user root (UID 0), mode 0660
Change the port name, or fix the permissions or ownership of /dev/ttyS0 and try again.
Unable to open /dev/ttyS0: Permission denied

This would be the correct config for my UPS.

I then had a bit more of a hunt round and found /etc/sysconfig/ups

As the original property I had in ups.conf and db configuration was called upstype, I discover that here it is called Options. So I changed  the ups.conf fragment and the configuration entry to read Options and now I have two files that look vaguley as I would expect. But when I start the service it shows

Poll UPS [localhost] failed - Data stale

But then if I stop the ups service I get the following :

Stopping UPS: UPS
Can't open /var/lib/ups/genericups-ttyS0.pid: No such file or directory

So I guess the root of the problem is that UPS doesn't seem to be able to grab the ttyS0 and hence can't tell what's on the other end of it.

Couple of other things I noticed whilst writing  - man ups.conf doesn't mention about having a upstype, but I am sure I read it somewhere around - possibly regarding the genericups driver.

I have also tried a nolock option in the file and get the following :

Starting upsd: Network UPS Tools upsd 1.2.0
Can't bind to socket: Address already in use
                                                           [ FAILED ]


Hmm. Nothing else connected to either port. Presumably it's a permissions thing, but well beyond me,

If I remove no lock and the upstrype from the ups.conf file I get a file called upsd.pid with a pid appear in the /var/lib/ups

So that's as far as I have got and I'm stuck well and truly, and know that but for a couple of bits of code I would be away.

Anyway, if anyone can tell me what I have done right or wrong, where to go next etc I would be grateful. After 3 nights of this my brain is totally frazzed. Just wish there was a bit more documentation around about implemetation/configuration of this on my server.

B. Rgds
John


Epilogue - just for fun I chmoded ttyS0 from 660 to 666. And away it went - connected up and running. Still get a complaint about the genericups-ttyS0.pid - no such file or directory.

I guess that there must be a more secure way of doing this so what have I missed, and what about the pid file ?

Aaaahhhhh. A pid file has now appeared and all seems well on this front. So. What about the permissions ? Is this a securtiy risk ? Why does it happen, and how do I stop it ?

Ray Mitchell

Re: Nut and serial cable config
« Reply #1 on: November 14, 2003, 02:35:13 AM »
Can't help with NUT, but you could always try powstatd.
It's fully configurable for your cable and UPS
See the e-smith.org HOWTO site for a powstatd UPS HOWTO

Regs
Ray

Michael Doerner

Re: Nut and serial cable config
« Reply #2 on: November 14, 2003, 12:57:21 PM »
John,

there are a few things where I might be able to contribute although I am not an expert on the nut/ups setup ....

The quietness around nut is a bit strange I feel. It looks excellent from it's features and it's flexibility for various brands and models but not many users seem to use it with serial monitoring cables.

I played here at some stage with a 525VA (cheap) UPS called Powercom and have it working with some BUTs...

Rather than permissions 666, I changed the owner for the serial port (/dev/ttyS1 here) to be "nutups" which solved the access rights problem.

My /etc/sysconfig/ups at the moment:
DEVICE=/dev/ttyS1
MODEL=powercom
OPTIONS=
SERVER=yes
and /etc/ups/ups.conf is this:
[Powercom]
        driver = powercom
        port = /dev/ttyS1
        linevoltage = 230
        manufacturer = PCM
#       modelname = KIN-525AP
#       serialnumber = 10209107
#       subtype = KP525AP

Current problem: it's filling up the messages log file with messages like this (every minute!):
Nov 14 22:52:01 tux1 upsd[527]: Connection from 127.0.0.1
Nov 14 22:52:01 tux1 upsd[527]: Client on 127.0.0.1 logged out
Nov 14 22:53:00 tux1 upsd[527]: Connection from 127.0.0.1
Nov 14 22:53:00 tux1 upsd[527]: Client on 127.0.0.1 logged out

I don't know where to suppress these.

Hope that gives you some new ideas, please let me know.

Regards,
Michael Doerner

John Crisp

Re: Nut and serial cable config
« Reply #3 on: November 14, 2003, 04:45:23 PM »
Ray, thanks for the advice. It just seems a shame to have to install more software when there is already something there already that can do the job. A bit more documentation on the various e-smith config options for nut would be a major benefit.

Michael,

How did you setup your configuration ? Through the esmith config or just manually hacking the files ?

Regarding the loggin on/off I think that this is the ups monitor - config files is /etc/ups/upsmon.conf. It has a setting for as follows :

MONITOR localhost 1 monuser mypassword slave

I guess that it checks every minute for the current status. But why you get a log every minute is beyond me. What version of SME are you using ? Mine is 6.0b3

I just wonder if it's how you set up your configuration. If you did it manually I wonder if something has been missed.

Let me know. I would also love any comments from Mitel about changing the nut settings.

Best regards,

John

Ray Mitchell

Re: Nut and serial cable config
« Reply #4 on: November 15, 2003, 02:48:45 AM »
John

My suggestion to use powstatd was based on your comments:

> After 3 nights of this my brain is totally frazzed.

Powstatd should be installed and fully configured in about an hour, not 3 nights and still counting !

> It just seems a shame to have to install more software when there is already something there already that can do the job. A bit more documentation on the various e-smith config options for nut would be a major benefit.

Powstatd is very easy to instal and has a good HOWTO that fully explains all the configuration steps for any UPS brand/model and cable type and suits your "dumb" UPS, unlike NUT which needs to be worked out by the end user from available information which you have found less than satisfactory.
I do believe the information is available at the nut web site, but you still have to "work it all out".
The details for powstatd are at
http://www.e-smith.org/docs/howto/contrib/powstatdUPSHOWTOv5.5v5.6.txt

Regs
Ray