Koozali.org: home of the SME Server

SME 7 - how to enable NUT?

kenironside

SME 7 - how to enable NUT?
« on: January 19, 2006, 01:09:10 PM »
I really would appreciate some help with this. I know NUT is part of SME 7 and I want to use it. I have a full set of working NUT config files (from a previous Debian installation).

How do I enable NUT?

How do I put the required contents into the template system so that the NUT config files get correctly created?

The main problems are that 1) I just don't understand how to create parameters for the custom templates and 2) I don;t know which template expand command does what.

I have searchd for thsi knid of info without much success and the sections in Documentation don't seem to fit with SME 7 and, for my level of expertise, they don't explain the process clearly enough.

So, as a second question - is there a clearer explanation of customising., templates etc?

Thanks, Ken

Offline byte

  • *
  • 2,183
  • +2/-0
SME 7 - how to enable NUT?
« Reply #1 on: January 19, 2006, 11:15:42 PM »
Quote
How do I enable NUT?


this will tell you if it's enabled or not...

db configuration show nut

to enable to...

db configuration setprop nut enabled

IIRC, the above is all you need to set as the files are already there under /etc/ups

HTH
--[byte]--

Have you filled in a Bug Report over @ http://bugs.contribs.org ? Please don't wait to be told this way you help us to help you/others - Thanks!

kenironside

SME 7 - how to enable NUT?
« Reply #2 on: January 20, 2006, 07:45:38 AM »
Hi,

Thanks for this - I'm piecing the puzzle together slowly. The problem is that the nut setup 'out of the box' doesn't work for me - I have serial comms with my UPS and its uses a different driver. I also want to enable a number of workstation monitors on the network.

The templates are parameterised and I need to know how I set up new values for parameters like $DEVICE $MODEL $OPTIONS $SERVER (I think this is already set in /home/e-smith/db/configuration) and $UPDS_OPTIONS.

I just can't seem to find out where these should be entered so that they change the templates and are not overwritten.

Maybe I'm missing something obvious, but I havn't been able to find any up-to-date documentation about customising. If anyone has any ideas, please let me know.

Thanks, Ken

Offline chris burnat

  • *****
  • 1,135
  • +2/-0
    • http://www.burnat.com
SME 7 - how to enable NUT?
« Reply #3 on: January 20, 2006, 08:07:18 AM »
Ken,  If anything doesn't work correctly, please report via the bug tracker - Use the button/links located on the left or go to http://bugs.contribs.org/enter_bug.cgi - you may need to register. Please describe exactly what you have done and exactly what you see in response.  Thank you on behalf of the Devteam, your input is appreciated.
- chris
If it does not work out of the box, please fill in a Bug Report @ Bugzilla (http://bugs.contribs.org)  - check: http://wiki.contribs.org/Bugzilla_Help .  Thanks.

kenironside

SME 7 - how to enable NUT?
« Reply #4 on: January 20, 2006, 03:08:21 PM »
I don't think my problem qualifies as a bug - unless poor dcumentation is a bug!

The problem is that the settings I need for nut to operate with my UPS are different to those that come standard with SME 7 when nut is enabled.  In order to change those settings, I need to understand the template structure and I need to understand how to change the values of existing parameters and how to creat new ones, in a way that will survive an upgrade or template expansion. This is needed for the template expansion as well as the nut startup file - /etc/init.d/ups

The documentation of the Documentation page does not cover this aspect and is also out of date - the SME 7 /home/ and /etc/ structure are different to the documentaion page.

Ideally, I'd like to be able to read a clear explanation of where and how the templetes get their parameters or hook up with someone who will answer a few (probably very simple) questions.

Regards, Ken

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
SME 7 - how to enable NUT?
« Reply #5 on: January 20, 2006, 08:27:36 PM »
Quote from: "kenironside"
I don't think my problem qualifies as a bug - unless poor dcumentation is a bug!


Sure it is.

Quote

The problem is that the settings I need for nut to operate with my UPS are different to those that come standard with SME 7 when nut is enabled.


OK.

Quote

 In order to change those settings, I need to understand the template structure and I need to understand how to change the values of existing parameters and how to creat new ones, in a way that will survive an upgrade or template expansion. This is needed for the template expansion as well as the nut startup file - /etc/init.d/ups


I doubt that you'll need to change the startup file, since it reads its settings from /etc/sysconfig/ups.

Quote

The documentation of the Documentation page does not cover this aspect ...


Did you try "Development"?

Quote

and is also out of date - the SME 7 /home/ and /etc/ structure are different to the documentaion page.


The differences are small and are all documented.

Quote

Ideally, I'd like to be able to read a clear explanation of where and how the templetes get their parameters or hook up with someone who will answer a few (probably very simple) questions.


If you can tell people which documentation you've looked at and which bits aren't clear people will be more able to help you.

If you want to "hook up" with people who know the insides then the devinfo mailing list is a likely place. On-topic technical questions are usually answered quickly there.

kenironside

SME 7 - how to enable NUT?
« Reply #6 on: January 20, 2006, 09:50:51 PM »
Hi Charlie,

Thank you for coming back to me. Maybe I should take this to the devinfo mailing list and I really appreciate any help I can get - I'm not trying to be difficult, but let me explain:

Quote
I doubt that you'll need to change the startup file, since it reads its settings from /etc/sysconfig/ups.


The startup file is /etc/init.d/ups and it uses a number of parameters to establish how to start the ups. Here is the relevant section:

start() {
        if [ "$SERVER" = "yes" ]; then
                # Exit if server = yes and model = NONE (not configured)

                if [ "$MODEL" = "NONE" ]; then
                        exit 0
                fi

                echo -n $"Starting $MODEL: "
                if [ "$MODEL" = "upsdrvctl" ]; then
                        daemon /sbin/upsdrvctl start
                else
                        daemon /sbin/$MODEL $OPTIONS $DEVICE
                fi
                echo

                prog="upsd"
                echo -n $"Starting $prog: "
                daemon /usr/sbin/upsd $UPSD_OPTIONS
                RETVAL=$?
                echo
      else
                echo -n $"Starting UPS monitor (slave): "
                daemon /usr/sbin/upsmon
                echo
        fi

        [ "$RETVAL" = 0 ] && touch /var/lock/subsys/ups
}

The parameter $SERVER is set in /home/e-smith/db/configuration but the other parameters used ($MODEL, $OPTIONS, $DEVICE and $UPSD_OPTIONS) are not set in /home/e-smith/db/configuration. The first three could come, as you said, from /etc/sysconfig/ups but that is created from the files in /etc/e-smith/templates/etc/sysconfig/ups/. For example the DEVICE fragment looks like this:
{
# UPS device - needed if UPS is locally attached
    my $device = $nut{Device} || "/var/lib/ups/hiddev0";
    $OUT .= "DEVICE=$device";
}
If nothing is defined for $nut(Device) then it defaults to the hiddev0 driver which is used for UPS's with a USB connection. I have a serial connection and I need this to pont to the 'Blazer' device. In order to do that I think I need to add this parameter to the /etc/e-smith/db/configuration file. I don't  know how to do that and I haven't found documentation on how to do it.

The same applie (more or less)  to the other parameters mentioned above and I don't know at alll where $UPSD_OPTIONS is initialised.

Quote
Did you try "Development"?


Yes, I have examined all the documentation under Development. Unfortunately, for example, under the link for “How to build a contrib.” the links to what look like useful documents all fail. (e.g. http://www.e-smith.org/docs/papers/templates.html).
This doc was in a section that reads “For a detailed discussion of the e-smith templated configuration system and how to use it to greatest effect, see the paper 23 The e-smith templated configuration system on the e-smith developer website.”

I have also searched the forum archive and the how-to’s and Googled the question quite extensively. I’m sure it is all available somewhere – I just need someone to point the way. Stung by your suggestion that I hadn’t looked as hard as I could, I found two documents on soundforge that go quite a long way to helping. Now I just have a couple of questions to ask to check my understanding.

Quote
The differences are small and are all documented.


OK, I take your point – I was thrown by a reference to /home/e-smith/configuration (missing /db/) in one of them. My apologies if I have caused offence.

Quote
If you can tell people which documentation you've looked at and which bits aren't clear people will be more able to help you.


I have given more detail

Quote
If you want to "hook up" with people who know the insides then the devinfo mailing list is a likely place. On-topic technical questions are usually answered quickly there.


Thanks to you I have now got a clearer picture! Is this where you suggest I go to ask some questions that will confirm (or contradict) my understanding of how add/change configuration parameters?

Thanks, Ken

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
SME 7 - how to enable NUT?
« Reply #7 on: January 20, 2006, 10:41:11 PM »
Quote from: "kenironside"

If nothing is defined for $nut(Device) then it defaults to the hiddev0 driver which is used for UPS's with a USB connection. I have a serial connection and I need this to pont to the 'Blazer' device. In order to do that I think I need to add this parameter to the /etc/e-smith/db/configuration file. I don't  know how to do that and I haven't found documentation on how to do it.


config setprop nut Device xxxx
expand-template /etc/sysconfig/ups

Offline mdo

  • *
  • 355
  • +0/-0
SME 7 - how to enable NUT?
« Reply #8 on: January 21, 2006, 02:46:39 AM »
Ken,

would you post your Debian config files as they are?

I tried various times to use nut with serial connected UPSes w/o success and got lost in the documentation. I would like the chance to look at your config files and learn from there.

Regards,
Michael
...

kenironside

SME 7 - how to enable NUT?
« Reply #9 on: January 21, 2006, 06:17:18 AM »
Hi Michael,

Sure. The local domain is ironside. Make sure the permissions are as per the Installation document on the NUT site.

ups.conf:
[ironsideups]
        driver = blazer
        port = /dev/ttyS0
        desc = "UPS serving Ironside network"

upsd.conf:
ACL all 0.0.0.0/0
ACL localclients 192.168.0.1/24
ACL localhost 127.0.0.1/32

ACCEPT localhost
ACCEPT localclients
REJECT all

upsd.users:
[admin]
        password = xxxxx
        allowfrom = 192.168.0.108 localclients
        actions = SET
        instcmds = ALL

# server
[monmaster]
        password = xxxxx
        allowfrom = 192.168.0.108
        upsmon master

# workstation - greendesk
[mongreen]
        password = xxxxx
        allowfrom = 192.168.0.103
        upsmon slave

# workstation - newdesk
[monnew]
        password = xxxxx
        allowfrom = 192.168.0.106
        upsmon slave

# workstation - frontdesk
[monfront]
        password = xxxxx
        allowfrom = 192.168.0.107
        upsmon slave

# firewall pc
[monfirewall]
        password = xxxxx
        allowfrom = 192.168.0.1
        upsmon slave


upsmon.conf:
MONITOR ironsideups@localhost 1 monmaster xxxxx master
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5

hosts.conf:
MONITOR ironsideups@localhost "UPS serving Ironside network"

The standard nut installation does not use a /etc/sysconfig/ups file (as does SME)

Each workstation has either upsmon (linux) or WinNut (Windows) installed which reads signals from the server and shuts down if the ups goes down.

Regards, Ken

kenironside

SME 7 - how to enable NUT?
« Reply #10 on: January 21, 2006, 06:27:23 AM »
Thanks, Charles,

Quote
config setprop nut Device xxxx
expand-template /etc/sysconfig/ups


OK, one more question: How can I find out where the value of $UPSD_OPTIONS (used in /etc/init.d/ups) is initialised?

If I get this right, I'll write a howto.

Regards, Ken

kenironside

SME 7 - how to enable NUT?
« Reply #11 on: January 21, 2006, 06:58:32 AM »
Thanks, Charles,

Quote
config setprop nut Device xxxx
expand-template /etc/sysconfig/ups


OK, one more question: How can I find out where the value of $UPSD_OPTIONS (used in /etc/init.d/ups) is initialised?

If I get this right, I'll write a howto.

Regards, Ken

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
SME 7 - how to enable NUT?
« Reply #12 on: January 21, 2006, 09:43:14 PM »
Quote from: "kenironside"
Thanks, Charles,


Only my mum and the taxman call me that.

Quote

OK, one more question: How can I find out where the value of $UPSD_OPTIONS (used in /etc/init.d/ups) is initialised?


It's not. If you want it to be, you have to create it in /etc/sysconfig/ups. There's no magic here, really!

kenironside

SME 7 - how to enable NUT?
« Reply #13 on: January 21, 2006, 10:26:04 PM »
Hey Charlie,

I'm not one of those two, so sorry! No offence meant.

It's pretty late here, I'll test tomorrow. Thanks for being patient with a pita.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
SME 7 - how to enable NUT?
« Reply #14 on: January 31, 2006, 10:37:42 PM »
Quote from: "kenironside"

ups.conf:
[ironsideups]
        driver = blazer
        port = /dev/ttyS0
        desc = "UPS serving Ironside network"


This might work, but just for the server configuration:

config setprop nut status enabled Model blazer Device /dev/ttyS0
expand-template /etc/ups/* /etc/sysconfig/ups
/etc/rc.d/init.d/nut restart

If it doesn't work, please open a ticket (with details) in the bug tracker. Permissions on /dev/ttyS0 is something I'm not sure about.

Note that this configuration doesn't include any of your network client configuration. There's no support in the templated files for anything beyond localhost, and we could soon be lost in complexity if we tried to anticipate such things. You can add custom template fragments for the additional configuration you need.