Home > Ubuntu > How-To: install NUT on Ubuntu 10.10 Maverick Meerkat

How-To: install NUT on Ubuntu 10.10 Maverick Meerkat

Last edited by on 31 March 2011 at 20:30

In this How-to I will explain how to install and configure Network UPS Tools on Ubuntu 10.10 Maverick Meerkat.
I will configure it with my APC BackUPS RS 800.
Install the package

[cce_bash]sudo apt-get install nut[/cce]

Now we need to find out what driver we need to use.
Check it out at the Hardware Compatibility List.
In my case the driver is usbhid-ups.
Edit /etc/nut/ups.conf and add the following

[cce_bash][apc]
driver = usbhid-ups
port = auto[/cce]

Start the driver

[cce_bash]sudo upsdrvctl start[/cce]

but you can get this error

[cce_bash]Network UPS Tools – UPS driver controller 2.4.3
Network UPS Tools – Generic HID driver 0.34 (2.4.3)
USB communication driver 0.31
Can’t chdir to /var/run/nut: No such file or directory
Driver failed to start (exit status=1)[/cce]

Do the following to fix the problem

[cce_bash]sudo mkdir /var/run/nut
sudo chown root:nut /var/run/nut
sudo chmod 770 /var/run/nut[/cce]
sudo mkdir /var/run/nut
chown root:nut /var/run/nut
chmod 770 /var/run/nut

Try again with the command

[cce_bash]sudo upsdrvctl start[/cce]
sudo mkdir /var/run/nut
chown root:nut /var/run/nut
chmod 770 /var/run/nut
Network UPS Tools – UPS driver controller 2.4.3
Network UPS Tools – Generic HID driver 0.34 (2.4.3)
USB communication driver 0.31
Can’t chdir to /var/run/nut: No such file or directory
Driver failed to start (exit status=1)

if it works, you should have an output like this

[cce_bash]Network UPS Tools - UPS driver controller 2.4.3
Network UPS Tools - Generic HID driver 0.34 (2.4.3)
USB communication driver 0.31
Using subdriver: APC HID 0.95[/cce]

Now edit /etc/nut/upsd.conf and add the following lines

[cce_bash]LISTEN 127.0.0.1 3493
LISTEN ::1 3493[/cce]

This way, upsd will only listen to localhost port 3493/tcp.
Start the network data server

[cce_bash]sudo upsd

Network UPS Tools upsd 2.4.3
listening on ::1 port 3493
listening on 127.0.0.1 port 3493
Connected to UPS [apc]: usbhid-ups-apc[/cce]

Check the UPS status

[cce_bash]sudo upsc apc@localhost ups.status

OL[/cce]

OL means your system is running on line power.
Look at all of the status data which is being monitored

[cce_bash]sudo upsc apc@localhost

battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 50
battery.date: 2001/09/25
battery.mfr.date: 2007/03/14
battery.runtime: 641
battery.runtime.low: 120
battery.temperature: 29.2
battery.type: PbAc
battery.voltage: 27.4
battery.voltage.nominal: 24.0
device.mfr: APC
device.model: Back-UPS BR  800
device.serial: QB0711130221
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.version: 2.4.3
driver.version.data: APC HID 0.95
driver.version.internal: 0.34
input.sensitivity: high
input.transfer.reason: input voltage out of range
input.voltage: 232.0
input.voltage.nominal: 230
output.voltage: 230.0
output.voltage.nominal: 230.0
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.firmware: 9.o2 .I
ups.firmware.aux: o2
ups.load: 20.0
ups.mfr: APC
ups.mfr.date: 2007/03/14
ups.model: Back-UPS BR  800
ups.productid: 0002
ups.serial: QB0711130221
ups.status: OL
ups.test.result: No test initiated
ups.timer.reboot: 0
ups.timer.shutdown: -1
ups.vendorid: 051d[/cce]

Now edit /etc/nut/upsd.users and add the following lines

[cce_bash][monuser]
        password = mypass
        actions = SET
        instcmds = ALL
        upsmon master
        # or upsmon slave[/cce]

change the password field with a real password.
Reload upsd

[cce_bash]upsd -c reload[/cce]

Edit /etc/nut/upsmon.conf, create a monitor directive for upsmon

[cce_bash]MONITOR apc@localhost 1 local_mon mypass master[/cce]

Edit /etc/nut/nut.conf and change the mode to Standalone

[cce_bash]MODE=standalone[/cce]

Now you can start NUT with

[cce_bash]sudo service nut start[/cce]
echo “$*” | mailx -s “UPS Notice” test@example.com

 

 

If you want to enable e-mail notifications for UPS events, as suggested by Witwolf, edit again /etc/nut/upsmon.conf and add

[cce_bash]NOTIFYCMD /usr/local/bin/nut-notify.sh

NOTIFYFLAG ONLINE   SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT   SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT  SYSLOG+WALL+EXEC
# NOTIFYFLAG FSD     SYSLOG+WALL
# NOTIFYFLAG COMMOK  SYSLOG+WALL
# NOTIFYFLAG COMMBAD SYSLOG+WALL
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM   SYSLOG+WALL+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC[/cce]

Create the script /usr/local/bin/nut-notify.sh and paste the following

[cce_bash]#!/bin/sh
echo "$@" | mail -s "NUT Notice" test@example.com[/cce]

make it executable

[cce_bash]sudo chmod +x /usr/local/bin/nut-notify.sh[/cce]

 

 

Enjoy :)

 

 

SOURCES:
Network UPS Tools: User Manual – Configuration notes
Witwolf: My new APC Back-UPS Pro 900 arrived!

Categories: Linux, Ubuntu
  1. Kiran
    April 12th, 2012 at 16:32 | #1

    Super! Works like a charm. Thanks for posting. Used it with TrippLite ECO750UPS.

    I did not have to make any other changes except one: I did not have to add the two LISTEN lines since I only have one UPS connected via USB. In fact once I added those lines, the listening part stopped working. So I reversed the changes and restarted.

    Regards.

  2. Pino
    December 3rd, 2012 at 21:53 | #2

    How can I check if the client is properly working ? ..speaks to the server…

  3. Simon Mandy
    December 23rd, 2012 at 20:45 | #3

    when i do sudo upsd, i see below message,Network UPS Tools upsd 2.6.4fopen /var/run/nut/upsd.pid: No such file or directorynot listening on ::1 port 3493listening on 127.0.0.1 port 3493no listening interface available

    But I do have /var/run/nut/  but no upsd.pid. 

    pi@raspisimon /var/run/nut $ ls -latotal 4drwxrwxrwx  2 root nut   80 Dec 24 00:08 .drwxr-xr-x 15 root root 580 Dec 24 00:01 ..srw-rw—-  1 nut  nut    0 Dec 24 00:08 usbhid-ups-apc-rw-r–r–  1 nut  nut    5 Dec 24 00:08 usbhid-ups-apc.pid
    Can you help? 

  4. Jason
    May 15th, 2013 at 01:52 | #4

    I got the following when starting upsdrvctl –
    Network UPS Tools – UPS driver controller 2.4.3
    Network UPS Tools – Generic HID driver 0.34 (2.4.3)
    USB communication driver 0.31
    This TrippLite device (09ae:2010) is not (or perhaps not yet) supported
    by usbhid-ups. Please make sure you have an up-to-date version of NUT. If
    this does not fix the problem, try running the driver with the
    ‘-x productid=2010’ option. Please report your results to the NUT user’s
    mailing list .

    Any suggestions?

  5. Jason
    May 15th, 2013 at 01:53 | #5

    I got the below when starting upsdrvctl – any suggestions?

    Network UPS Tools – UPS driver controller 2.4.3
    Network UPS Tools – Generic HID driver 0.34 (2.4.3)
    USB communication driver 0.31
    This TrippLite device (09ae:2010) is not (or perhaps not yet) supported
    by usbhid-ups. Please make sure you have an up-to-date version of NUT. If
    this does not fix the problem, try running the driver with the
    ‘-x productid=2010’ option. Please report your results to the NUT user’s
    mailing list .

  6. Jason
    May 15th, 2013 at 01:55 | #6

    @Jason
    I am running the TrippLite Smart1000LCD using USB on Ubuntu 10.04 64 bit.

  7. May 15th, 2013 at 15:14 | #7

    In /etc/nut/ups.conf try to add
    productid=2010

    I don’t know if the support for your UPS has been added in recent version of NUT but you could try with updated version of Ubuntu 🙂

  8. August 16th, 2013 at 17:10 | #8

    I quite like reading an article that will make men and
    women think. Also, thank you for permitting me to comment!

  9. Mayra
    September 18th, 2014 at 20:10 | #9

    Hi!

    First of all, I’m sorry if something is not clear, my English is not very good.
    I hope you can help me. I’m trying to configure NUT in Ubuntu 14.04, and everything that you write in your post is working for me until this point:

    Check the UPS status

    sudo upsc apc@localhost ups.status
    OL

    When I try, this is the answer:
    Error: Connection failure: Connection refused

    Do you have any idea what is going on?

    This is the scenary:

    I have a domain in Windows Server, the computers’s gateway is a WatchGuard.

    Also, I have a doubt, Can I use the NUT for monitoring UPS’s with USB connection in a network?

    Really I’ll be so thankful if you have any idea!

    Regards from Mérida, México!

  10. October 18th, 2014 at 04:51 | #10

    Hi Mayra,
    sorry for the delay in the answer.
    The connection refused means that the configuration in
    /etc/nut/upsd.conf
    is not correct. Under LISTEN directive, you have to be sure that you have set the correct network from where you are trying to connect.

  11. Raymond Day
    October 18th, 2016 at 01:06 | #11

    I get “Unknown UPS”

    If I do a LSUSB get:

    Bus 001 Device 008: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS

    This is on a Odroid-u2 can’t get it working.

    Any one else got it working on a Odroid-u2? If so how?

    -Raymond Day

  12. Raymond Day
    October 18th, 2016 at 12:49 | #12

    Have a CyberPower SX650G the User’s Manual says SE450G and SX650G. I guess could use the driver for ether one of them. But looks like Nut don’t have that driver so I can’t use it.

    -Raymond Day

  13. Raymond Day
    October 18th, 2016 at 12:54 | #13

    So I get this:

    root@odroid-u2:~# upsdrvctl start
    Network UPS Tools – UPS driver controller 2.6.4
    Network UPS Tools – Generic HID driver 0.37 (2.6.4)
    USB communication driver 0.31
    Duplicate driver instance detected! Terminating other driver!
    Using subdriver: CyberPower HID 0.3
    root@odroid-u2:~# upsc apc@localhost
    Error: Unknown UPS
    root@odroid-u2:~#

    That’s with this in my /etc/nut/ups.conf

    [serverups]
    driver = usbhid-ups
    port = auto
    desc = “Server UPS”
    # productid = “CP1500 AVR UPS”

    Guess they just don’t have a driver for my CyberPower SX650G. If so I could put it in the driver = part in this /etc/nut/ups.conf file.

    -Raymond Day

  14. Raymond Day
    October 28th, 2016 at 03:00 | #14

    Looked like this works now.

    I put your code in /etc/nut/nut.conf just at the end of that file.

    Then did.

    upsdrvctl start

    upsc serverups

    Got this date back:

    battery.charge: 100
    battery.charge.low: 10
    battery.charge.warning: 20
    battery.mfr.date: CPS
    battery.runtime: 7650
    battery.runtime.low: 300
    battery.type: PbAcid
    battery.voltage: 9.5
    battery.voltage.nominal: 12
    device.mfr: CPS
    device.model: SX650G
    device.type: ups
    driver.name: usbhid-ups
    driver.parameter.pollfreq: 30
    driver.parameter.pollinterval: 2
    driver.parameter.port: auto
    driver.version: 2.6.4
    driver.version.data: CyberPower HID 0.3
    driver.version.internal: 0.37
    input.transfer.high: 0
    input.transfer.low: 0
    input.voltage: 121.0
    input.voltage.nominal: 120
    output.voltage: 121.0
    ups.beeper.status: enabled
    ups.delay.shutdown: 20
    ups.delay.start: 30
    ups.load: 0
    ups.mfr: CPS
    ups.model: SX650G
    ups.productid: 0501
    ups.realpower.nominal: 375
    ups.status: OL
    ups.test.result: No test initiated
    ups.timer.shutdown: -60
    ups.timer.start: 0
    ups.vendorid: 0764

  15. Raymond Day
    October 28th, 2016 at 03:01 | #15

    @Raymond Day

    Opps for got to show the code it’s this:

    ./configure –includedir=/usr/include –mandir=/usr/share/man \
    –infodir=/usr/share/info –sysconfdir=/etc/nut –localstatedir=/var \
    –libexecdir=/usr/lib/nut –srcdir=. –disable-maintainer-mode \
    –disable-dependency-tracking –disable-silent-rules –libdir=/usr/lib/x86_64-linux-gnu \
    –with-ssl –with-nss –with-cgi –with-dev –enable-static \
    –with-statepath=/var/run/nut –with-altpidpath=/var/run/nut \
    –with-drvpath=/lib/nut –with-cgipath=/usr/lib/cgi-bin/nut \
    –with-htmlpath=/usr/share/nut/www –with-pidpath=/var/run/nut \
    –datadir=/usr/share/nut –with-pkgconfig-dir=/usr/lib/aarch64-linux-gnu/pkgconfig \
    –with-user=nut –with-group=nut –with-udev-dir=/lib/udev \
    –with-systemdsystemunitdir=/lib/systemd/system

  1. August 18th, 2012 at 14:34 | #1
  2. October 19th, 2013 at 16:43 | #2