Gentoo Wiki ArchivesGentoo Wiki




Alot of the information in this document can be applied to most UPS models, but for the purposes of consistency a Liebert PowerSure Personal XT installation is specifically described throughout.

I recently bought a Liebert PowerSure Personal XT UPS and got it working how I wanted after quite a bit of poking about. The reason that I purchased this particular UPS, rather than any other, was price! It's cheap as chips! The UPS comes supplied with its own software that is designed to work on Linux and Windows. However, in order for you to install it and get it working on Linux, it requires that you have a window system installed; hardly ideal for a Linux server. Enter NUT...

I initially tried to get the UPS working using the serial connection, but could not find a suitable NUT driver. After building a custom Contact Closure cable for it and finding again that there was no suitable NUT driver, I finally got it working with the USB connection.

I wrote this document so that other people can avoid going through the process of installing the supplied software and finding it's not ideal, building cables that you don't need, trying different settings you will never use, not having graphical output, setting up notify commands that don't work...and so on. If you need to discuss this document with me, you can contact me at irc://


Install the NUT package:

Code: Install NUT
emerge sys-power/nut

For some bizarre reason, the ebuild for NUT does not put our nut user in the tty group (or allow permission any other way) so that it can send messages to our terminals. We need to fix this, if we want to receive a WALL when specific UPS events occur.

Code: Add nut user to tty group
usermod -aG tty nut

NUT configuration


Now we need to set our UPS up in the ups conf file. We will use a USB HID driver, as the serial cable provided does not work with any of the NUT drivers. I also tried building a contact closure cable for it, which didn't work too well either. If you haven't already, you will need to add USB and HID support to your kernel. I'll assume you know how to do this, as kernel configuration is beyond the scope of this document.

Code: /etc/nut/ups.conf
echo 'user = nut
        driver = hidups
        port = /dev/usb/hiddev0
        HidDevPrefix = /dev/usb/hiddev' >> /etc/nut/ups.conf

User access

You can control access to upsd via ACL's in /etc/nut/upsd.conf. The ebuild/default settings were fine for my liking, but you should take a look at this file and decide what access you want to allow/reject.

We will need to setup a nut user in the upsd users file. We need this user entry for upsmon, it should not be confused with the system nut user. The password you set here will be the same password that we use in the upsmon conf file, in the next step.

Code: /etc/nut/upsd.users
echo '[nut]
       password  = <Password_Goes_Here>
       allowfrom = localhost
       actions = SET
       instcmds = ALL
       upsmon master' >> /etc/nut/upsd.users


Next, we tell upsmon to monitor our UPS.

Code: /etc/nut/upsmon.conf
echo 'MONITOR liebert@localhost 1 nut <Password_Goes_Here> master' >> /etc/nut/upsmon.conf

We can use upsmon to notify us when specific UPS events occur. If we want upsmon to email us when these events happen, we need to create a small script to do so. You should change my@email.address and nut@gentoo.server to your liking.

Code: /usr/local/bin/ups_notify
echo '#!/bin/bash
NOTIFYTYPE=$(upsc liebert@localhost ups.status)
case "$NOTIFYTYPE" in OL) NOTIFYTYPE="On-line";; OB) NOTIFYTYPE="On Battery";; LB) NOTIFYTYPE="Low Battery";; FSD) NOTIFYTYPE="Forced Shutdown"; esac
echo "To: my@email.address
From: nut@gentoo.server
Subject: UPS Status ($NOTIFYTYPE)

$(upsc liebert@localhost ups.mfr) $(upsc liebert@localhost ups.model) \
($(upsc liebert@localhost V$(upsc liebert@localhost driver.version) $(upsc liebert@localhost driver.parameter.port))
Load: $(upsc liebert@localhost ups.load)% of full load
Charge: $(upsc liebert@localhost battery.charge)% of full capacity
Runtime: $(upsc liebert@localhost battery.runtime) seconds total runtime" | sendmail my@email.address' > /usr/local/bin/ups_notify

And we need to allow our nut user to execute our notify script.

Code: /usr/local/bin/ups_notify
chown nut:nut /usr/local/bin/ups_notify &&
chmod 750 /usr/local/bin/ups_notify

Upsmon needs to know that it should use our notify script.

Code: /etc/nut/upsmon.conf
sed -i 's#^\(\# NOTIFYCMD /usr/local/ups/bin/notifyme\)$#\1\nNOTIFYCMD /usr/local/bin/ups_notify#' /etc/nut/upsmon.conf

Also, upsmon needs to know which events should cause it to run the notify script. In this code snippet I have set it to notify us on *all* events, with output to the syslog, terminals and our notify script.

Code: /etc/nut/upsmon.conf
sed -i "s/^\(# If you use IGNORE, don't use any other flags on the same line\.\)$/\1\n\


We need to edit the NUT udev rule to setup the device node for our UPS.

Code: /etc/udev/rules.d/70-nut-usbups.rules
sed -i 's/^\(# udev rules for the NUT USB drivers\)$/\1\n\
# LIEBERT - usbhid-ups\n\
SYSFS{idVendor}=="06da", SYSFS{idProduct}=="ffff", MODE="664", GROUP="nut"/' /etc/udev/rules.d/70-nut-usbups.rules
Warning: If your UPS was already connected by USB cable, you will need to unplug the USB cable and plug it back in.

Web monitoring


If you have a web server installed, you might want to add the cgi scripts to it.

Code: /var/www/localhost/cgi-bin
ln /usr/share/nut/upsset.cgi /var/www/localhost/cgi-bin/upsset.cgi &&
ln /usr/share/nut/upsstats.cgi /var/www/localhost/cgi-bin/upsstats.cgi &&
ln /usr/share/nut/upsimage.cgi /var/www/localhost/cgi-bin/upsimage.cgi &&
chmod 755 /var/www/localhost/cgi-bin/upsimage.cgi /var/www/localhost/cgi-bin/upsstats.cgi /var/www/localhost/cgi-bin/upsset.cgi &&
sed -i 's/^### \(I_HAVE_SECURED_MY_CGI_DIRECTORY\)$/\1/' /etc/nut/upsset.conf &&
echo 'MONITOR liebert@localhost "Local UPS"' >> /etc/nut/hosts.conf
Warning: If you have not secured your cgi directory, you should do so now. Refer to the documentation of your web server for instructions on how to do this.


Alternatively you might want to add some graphs to your MRTG. If so, I'll assume you have MRTG working and used the default paths for everything. First we need to make configuration files for the information we want to monitor. I couldn't see much point in monitoring anything other than the load and battery charge, so here is the configuration files I use for those.

Code: /etc/mrtg/ups-charge.cnf
echo 'WorkDir: /var/www/localhost/htdocs/mrtg  
Target[]: `/etc/mrtg/`
RouterUptime[]: public@
MaxBytes[]: 100        
Title[]: UPS Charge                  
PageTop[]: <H1>UPS Charge %</H1>
Unscaled[]: ymwd             
ShortLegend[]: %     
YLegend[]: UPS Charge
Legend1[]: UPS Charge %
LegendI[]: UPS Charge
Options[]: growright,unknaszero,gauge,nopercent' > /etc/mrtg/
Code: /etc/mrtg/ups-load.cnf
echo 'WorkDir: /var/www/localhost/htdocs/mrtg
Target[]: `/etc/mrtg/`
RouterUptime[]: public@
MaxBytes[]: 100
Title[]: UPS load
PageTop[]: <H1>UPS Load %</H1>
Unscaled[]: ymwd
ShortLegend[]: %
YLegend[]: UPS Load
Legend1[]: UPS Load %
LegendI[]: UPS Load
Options[]: growright,unknaszero,gauge,nopercent' > /etc/mrtg/ups-load.cnf

We will also need a script for each target, to output the information in a format that is suitable for MRTG.

Code: /etc/mrtg/
echo '#!/bin/sh
Var=$(upsc liebert@localhost battery.charge)
echo $Var$'\n'$Var' > /etc/mrtg/
Code: /etc/mrtg/
echo '#!/bin/sh
Var=$(upsc liebert@localhost ups.load)
echo $Var$'\n'$Var' > /etc/mrtg/

The scripts need to be executable.

Code: /etc/mrtg/*.sh
chmod +x /etc/mrtg/ /etc/mrtg/

As always, we need to add cronjobs for each target. I'll assume you maintain your cronjobs for MRTG in a cron dir and use run-parts in your crontab for root.

Code: /etc/cron.mrtg/ups-charge
echo '#!/bin/sh
/usr/bin/mrtg /etc/mrtg/ups-charge.cfg' > /etc/cron.mrtg/ups-charge
Code: /etc/cron.mrtg/ups-load
echo '#!/bin/sh
/usr/bin/mrtg /etc/mrtg/ups-load.cfg ' > /etc/cron.mrtg/ups-load

The cronjobs need to be executable.

Code: /etc/cron.mrtg
chmod +x /etc/cron.mrtg/ups-charge /etc/cron.mrtg/ups-load

We should run the cronjobs three times each, to initialise the logs. Ignore any warnings you see.

Code: /etc/cron.mrtg
/etc/cron.mrtg/ups-charge && /etc/cron.mrtg/ups-charge && /etc/cron.mrtg/ups-charge &&
/etc/cron.mrtg/ups-load && /etc/cron.mrtg/ups-load && /etc/cron.mrtg/ups-load

Now you just need to remake your main index; I shan't include code here for doing that, as it will most likely not include other things you are monitoring, or will try and create things that you are not monitoring. `man indexmaker` if you get stuck.


We need to start our driver, upsd and upsmon. We also need them to run when our box is booted.

Code: /etc/init.d
/etc/init.d/upsdrv start &&
/etc/init.d/upsd start &&
/etc/init.d/upsmon start &&
rc-update add upsdrv default &&
rc-update add upsd default &&
rc-update add upsmon default

Final note

That's it your UPS should be configured. You should check the output of `upsc liebert@localhost` and check that you have meaningful output and no errors. Once you have done that you should back up EVERYTHING that is important before killing the power to the UPS as a final test.

Retrieved from ""

Last modified: Sun, 31 Aug 2008 18:41:00 +1000 Hits: 6,479

Created by, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.