This is an old revision of the document!


NUT (Network UPS Tool)

Instruction for installation of Network UPS Tools (NUT) on fun_plug v 0.5. These instructions are based on information found at the Network UPS Tool website (http://networkupstools.org/doc/2.2.0/INSTALL.html).

Getting Started

What's Needed

A DNS323 with Fun_Plug 0.5 installed.

A functional telnet connection.

Successful installation of NUT requires three packages from fonz's website (http://www.inreto.de/dns323/fun-plug/0.5/packages/). They are;

  • libusb-0.1.12-1.tgz;
  • neon-0.25.5-1.tgz and;
  • nut-2.2.2-2.tgz

How To Get The Packages

For this example the three packages will be saved to the /mnt/HD_a2/packages directory. Change to this directory by issuing the following command at a telnet prompt;

cd /mnt/HD_a2/packages

Use rsync to obtain the three packages and store them in the /mnt/HD_a2/packages directory on your DNS323. Obtain the files by issuing the following commands;

rsync -av inreto.de::dns323/fun-plug/0.5/packages/neon-0.25.5-1.tgz .
rsync -av inreto.de::dns323/fun-plug/0.5/packages/libusb-0.1.12-1.tgz .
rsync -av inreto.de::dns323/fun-plug/0.5/packages/nut-2.2.2-2.tgz .

How To Install The Packages

The packages can be installed from the /mnt/HD_a2/packages directory using the following commands;

funpkg -i neon-0.25.5-1.tgz
funpkg -i libusb-0.1.12-1.tgz
funpkg -i nut-2.2.2-2.tgz

Prepare the Environment

Once the packages are downloaded and installed the NUT environment will need to be configured before you'll be able to access and control your UPS. Or should I say your UPS will be able to control your DNS323! Instruction found at the Network UPS Tool website (http://networkupstools.org/doc/2.2.0/INSTALL.html) advised creation of a Group and a user named nutmon. Creating such allows one to establish a higher level of security on configuration files.

Create User Group

For the purposes of this exercise a group named nutwill be added. At the prompt enter the following command;

groupadd nut

Create User

For the purposes of this exercise a user named nutmon will be created and added to the group named nut. The user is created and added to the existing group by entering the following command;

adduser -s /bin/false -G nut -H nutmon

The system will respond with:

Changing password for ups
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.

Selected a password for nutmon then enter it at the New password: and again at the Re-enter new password: prompts.

Configure and Start NUT Driver

Create ups.conf File

During NUT installation sample configuration files were copied to the /ffp/etc directory. These files are identifiable by their .sample suffix. During this step of the configuration process a ups.conf file will be created from the ups.conf.sample file. This is achieved by copying the sample ups configuration file to the /ffp/etc directory. The command to do so follows;

cp /ffp/etc/ups.conf.sample /ffp/etc/ups.conf

Add Driver Configuration Detail

Prior to modifying the ups.conf file you'll need to determine which driver is used with your specific UPS. A UPS hardware compatibility list is located on the Network UPS Tools website. Review this list to determine which driver is required for your specific application. Please note these instructions pertain specifically to USB connected UPS.

Use your favourite editor (I use Notepad++) to open the ups.conf file, enter and subsequently save your specific settings.

An APC Back-UPS RS 900 is connected to the USB port on my DNS323. Settings for this device would be;

[APC_UPS]
	driver = usbhid-ups
	port = USB
	desc = "Back-UPS RS 900"

Driver Startup

Start the NUT driver. This is accomplished by issuing the following command;

upsdrvctl start

Make sure the driver doesn't report any errors. It should show a few details about the hardware and then enter the background. You should get back to the command prompt a few seconds later. For reference, a successful start of the usbhid-ups driver looks like this:

Network UPS Tools - UPS driver controller 2.2.2
Network UPS Tools: 0.29 USB communication driver - core 0.33 (2.2.2)
Using subdriver: APC HID 0.92

If the driver doesn't start cleanly, make sure you have picked the right one for your hardware. You might need to try other drivers by changing the “driver=” value in ups.conf file.

Be sure to check the driver's man page to see if it needs any extra settings in ups.conf to detect your hardware.

If it says “can't bind /var/state/ups/…” or similar, then your state path probably isn't writable by the driver. Check the permissions and mode on that directory.

Configure and Start Network Server

Configure Host Access List

Create upsd.conf File

During this step of the configuration process a upsd.conf file will be created from the upsd.conf.sample file. This is achieved by copying the sample upsd configuration file to the /ffp/etc directory. The command to do so follows;

cp /ffp/etc/upsd.conf.sample /ffp/etc/upsd.conf

Configuring Specific Host Settings

Configuring a specific host requires modification of the upsd.conf file. For example, to add a host named DNS323 on IP 192.168.1.50 the following lines need to be added to the upsd.conf file;

ACL DNS323 192.168.1.50/32
ACCEPT DNS323

Use your favourite editor to open the upsd.conf file, enter and subsequently save your specific settings.

Configuration User Access List

Create upsd.users File

During this step of the configuration process a upsd.users file will be created from the upsd.users.sample file. This is achieved by copying the sample upsd configuration file to the /ffp/etc directory. The command to do so follows;

cp /ffp/etc/upsd.users.sample /ffp/etc/upsd.users

Configuring an Administrative User

Use your favourite editor to open the upsd.users file, enter and subsequently save your specific settings.

[nutmon]
	password = NUTMonPW
	allowfrom = localhost
	actions = SET
	instcmds = ALL

While we're at it let's create an entry for monitoring tool.

[monuser]
	password = MonUserPW
	allowfrom = DNS323
	upsmon master

Network Server Startup

Start the network server. This is accomplished by issuing the following command;

upsd

The Network Server can be stopped by issuing an upsd -c stop command.

UPS and Server Status Check

Make sure that the UPS is providing good status data by issuing the following command;

upsc APC_UPS@localhost ups.status

If all is okay then OL (On-line) should appear after the upsc command is issued. If the unit running is On-Battery you would see OB and if charging you would see OC.

The upsc command is also used to look at all status that is being monitored. Look at all of the status data by issuing the following command;

upsc APC_UPS@localhost

What happens now depends on the kind of UPS and driver you have. In the list that follows is sample data from an APC Back-UPS RS 900.

battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 50
battery.date: 2001/09/25
battery.mfr.date: 2008/06/05
battery.runtime: 2025
battery.runtime.low: 120
battery.temperature: 3022999999999998800
battery.type: PbAc
battery.voltage: 27.8
battery.voltage.nominal: 24.0
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.version: 2.2.2
driver.version.data: APC HID 0.92
driver.version.internal: 0.33
input.voltage: 122.0
input.voltage.nominal: 120
output.voltage: 120.0
output.voltage.nominal: 120.0
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.firmware: 9.o2 .D
ups.firmware.aux: o2
ups.load:22999999999999994
ups.mfr: American Power Conversion
ups.mfr.date: 2007/10/24
ups.model: Back-UPS RS 900
ups.productid: 0002
ups.serial: 5B0743U08220
ups.status: OL
ups.test.result: No test initiated
ups.timer.reboot: 0
ups.timer.shutdown: -1
ups.vendorid: 051d

Configure and Start Monitor

Create upsmon.conf File

During this step of the configuration process a upsmon.conf file will be created from the upsmon.conf.sample file. This is achieved by copying the sample upsmon configuration file to the /ffp/etc directory. The command to do so follows;

cp /ffp/etc/upsmon.conf.sample /ffp/etc/upsmon.conf

Configure a RUN_AS_USER

Use your favourite editor to open the upsmon.conf file and edit the line (30) that reads;

# RUN_AS_USER nutmon

Remove the # sign thus changing the line to read;

RUN_AS_USER nutmon

Configure a MONITOR User

With the the upsmon.conf file still open in your editor add the following at line 85;

MONITOR APC_UPS@DNS323 1 monuser MonUserPW master

Note: MonUserPW is the password that was established when monuser was added to the upsd.users file. If you used a different password, which you should, be sure to replace MonUserPW with the password that you set in the upsd.users file.

Configure upsd to recognize upsmon.

First create an ACL in upsd.conf for the host that will be running upsmon. Then use it in an ACCEPT line to allow that host to monitor the UPS. This will let upsmon connect to upsd.

Assuming a host called DNS323_NAS with the IP address of 192.168.1.50, the additional configuration items would look like this:

ACL mybox 192.168.1.50/32
ACCEPT DNS323_NAS

Start the upsmon monitor.

# /ffp/sbin/upsmon

Increase File and Directory Security

Many of NUT's configuration files contain sensitive data; user names and passwords. To guard against inappropriate access of this information restricting access to users belonging to the nut group is recommended. This is achieved through the following commands;

chown root:nut /ffp/etc/ups.conf /ffp/etc/upsd.conf /ffp/etc/upsd.users /ffp/etc/upsmon.conf
chmod 0640 /ffp/etc/ups.conf /ffp/etc/upsd.conf /ffp/etc/upsd.users /ffp/etc/upsmon.conf

It will also be necessary to change ownership of /ffp/var/state/ups directory. This is achieved through the following commands;

chown root:nut /ffp/var/state/ups
chmod 0770 /ffp/var/state/ups

Preserving Passwords

Each time the DNS323 is booted key files are copied from NVRAM to the /etc directory. When this occurs information pertaining to those Groups and Users added as shown above will be lost. Loss can be prevented by writing group and user information to NVRAM using the store-passwd.sh script.

store-passwd.sh

—– Installing WinNUT —–

Create a user for WinNUT Monitoring Tool

adduser -s /bin/false -G nut -H winnmonuser

The system will respond with:

Changing password for winnmonuser
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.

Selected a password for ups then enter it at the New password: and Re-enter new password: prompts.


Navigation

Personal Tools