ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Pi as a UPS monitor

    Scheduled Pinned Locked Moved IT Discussion
    raspberry piupsapceatonnut
    114 Posts 8 Posters 35.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JaredBuschJ
      JaredBusch
      last edited by JaredBusch

      Manually executed sudo start upsd and got a driver error. Fixed typo, rebooted, and it is online.

      pi@bna-pwr-pi-01:~ $ tail -f /var/log/syslog
      Feb  2 04:27:24 bna-pwr-pi-01 systemd[1]: Reached target Graphical Interface.
      Feb  2 04:27:24 bna-pwr-pi-01 systemd[1]: Starting Update UTMP about System Runlevel Changes...
      Feb  2 04:27:24 bna-pwr-pi-01 upsmon[737]: Init SSL without certificate database
      Feb  2 04:27:24 bna-pwr-pi-01 systemd[1]: Started Update UTMP about System Runlevel Changes.
      Feb  2 04:27:24 bna-pwr-pi-01 systemd[1]: Startup finished in 2.052s (kernel) + 10.336s (userspace) = 12.389s.
      Feb  2 04:27:24 bna-pwr-pi-01 upsd[733]: User bnaupsmon@::1 logged into UPS [bnajaredrouter]
      Feb  2 04:27:31 bna-pwr-pi-01 dhcpcd[698]: wlan0: no IPv6 Routers available
      Feb  2 04:27:51 bna-pwr-pi-01 systemd[1]: Time has been changed
      Feb  2 04:27:52 bna-pwr-pi-01 upsd[733]: Data for UPS [bnajaredrouter] is stale - check driver
      Feb  2 04:27:52 bna-pwr-pi-01 upsd[733]: UPS [bnajaredrouter] data is no longer stale
      
      pi@bna-pwr-pi-01:~ $ sudo upsc bnajaredrouter
      Init SSL without certificate database
      battery.charge: 100
      battery.charge.low: 10
      battery.charge.warning: 50
      battery.date: 2001/09/25
      battery.mfr.date: 2010/12/15
      battery.runtime: 14100
      battery.runtime.low: 120
      battery.type: PbAc
      battery.voltage: 27.3
      battery.voltage.nominal: 24.0
      device.mfr: American Power Conversion
      device.model: Back-UPS BR1000G
      device.serial: 3B1051X20349  
      device.type: ups
      driver.name: usbhid-ups
      driver.parameter.pollfreq: 30
      driver.parameter.pollinterval: 2
      driver.parameter.port: auto
      driver.version: 2.7.2
      driver.version.data: APC HID 0.95
      driver.version.internal: 0.38
      input.sensitivity: medium
      input.transfer.high: 147
      input.transfer.low: 88
      input.voltage: 126.0
      input.voltage.nominal: 120
      ups.beeper.status: disabled
      ups.delay.shutdown: 20
      ups.firmware: 868.L1 .D
      ups.firmware.aux: L1  
      ups.load: 3
      ups.mfr: American Power Conversion
      ups.mfr.date: 2010/12/15
      ups.model: Back-UPS BR1000G
      ups.productid: 0002
      ups.realpower.nominal: 600
      ups.serial: 3B1051X20349  
      ups.status: OL
      ups.test.result: No test initiated
      ups.timer.reboot: 0
      ups.timer.shutdown: -1
      ups.vendorid: 051d
      pi@bna-pwr-pi-01:~ $ 
      
      1 Reply Last reply Reply Quote 0
      • JaredBuschJ
        JaredBusch
        last edited by

        Unplugged the power and had some good news, some bad.

        The WALL commands spammed me, so I know things fired.

        The syslog though showed an error about permissions for PIPE/LOCK. See the message about failed to connect to parent.

        Feb  2 04:32:33 bna-pwr-pi-01 upsmon[737]: UPS bnajaredrouter@localhost on battery
        Feb  2 04:32:41 bna-pwr-pi-01 upssched[805]: Failed to connect to parent and failed to create parent: No such file or directory
        Feb  2 04:33:03 bna-pwr-pi-01 upsmon[737]: UPS bnajaredrouter@localhost on line power
        Feb  2 04:33:03 bna-pwr-pi-01 upssched[811]: Executing command: ongrid
        Feb  2 04:33:03 bna-pwr-pi-01 upssched-cmd: The UPS is now on grid power.
        

        Time to check the permissions.

        1 Reply Last reply Reply Quote 0
        • JaredBuschJ
          JaredBusch
          last edited by

          Well that would be a problem. Where did the file I made go? I guess the default directory was a bad choice?

          pi@bna-pwr-pi-01:~ $ sudo ls -l /var/run/nut/
          total 12
          -rw-r--r-- 1 nut  nut  4 Feb  2 04:27 upsd.pid
          -rw-r--r-- 1 root root 4 Feb  2 04:27 upsmon.pid
          srw-rw---- 1 nut  nut  0 Feb  2 04:27 usbhid-ups-bnajaredrouter
          -rw-r--r-- 1 nut  nut  4 Feb  2 04:27 usbhid-ups-bnajaredrouter.pid
          pi@bna-pwr-pi-01:~ $ 
          
          JaredBuschJ travisdh1T 2 Replies Last reply Reply Quote 0
          • JaredBuschJ
            JaredBusch
            last edited by JaredBusch

            and there there we go.. changed directory to /etc/nut/upssched for PIPE/LOCK (already corrected instructions above)

            WALL spam...

            Broadcast message from nut@bna-pwr-pi-01 (somewhere) (Thu Feb  2 04:44:19 2017)
                                                                                           
            UPS bnajaredrouter@localhost on battery                                        
                                                                       
            Broadcast message from nut@bna-pwr-pi-01 (somewhere) (Thu Feb  2 04:45:19 2017)
                                                                                           
            UPS bnajaredrouter@localhost on line power                   
            

            and the SYSLOG showing the trigger and the command from the shell script.

            Feb  2 04:43:24 bna-pwr-pi-01 upsmon[917]: Startup successful
            Feb  2 04:43:24 bna-pwr-pi-01 upsmon[918]: Init SSL without certificate database
            Feb  2 04:43:24 bna-pwr-pi-01 systemd[1]: nut-monitor.service: Supervising process 918 which is not our child. We'll most likely not notice when it exits.
            Feb  2 04:43:24 bna-pwr-pi-01 systemd[1]: Started Network UPS Tools - power device monitor and shutdown controller.
            Feb  2 04:43:24 bna-pwr-pi-01 upsd[733]: User bnaupsmon@::1 logged into UPS [bnajaredrouter]
            Feb  2 04:44:19 bna-pwr-pi-01 upsmon[918]: UPS bnajaredrouter@localhost on battery
            Feb  2 04:44:19 bna-pwr-pi-01 upssched[929]: Timer daemon started
            Feb  2 04:44:19 bna-pwr-pi-01 upssched[929]: New timer: onbattwarn (30 seconds)
            Feb  2 04:44:49 bna-pwr-pi-01 upssched[929]: Event: onbattwarn
            Feb  2 04:44:49 bna-pwr-pi-01 upssched-cmd: The UPS has been on battery power for 30 seconds.
            Feb  2 04:45:04 bna-pwr-pi-01 upssched[929]: Timer queue empty, exiting
            Feb  2 04:45:19 bna-pwr-pi-01 upsmon[918]: UPS bnajaredrouter@localhost on line power
            Feb  2 04:45:19 bna-pwr-pi-01 upssched[937]: Executing command: ongrid
            Feb  2 04:45:19 bna-pwr-pi-01 upssched-cmd: The UPS is now on grid power.
            
            1 Reply Last reply Reply Quote 0
            • JaredBuschJ
              JaredBusch
              last edited by JaredBusch

              No able to test email right now because there is no way to send SMTP port 25 from my house. I have a VPN to the colo up, and there is a mail relay running there, but it will not accept from outside its LAN.

              So I will have to set that up later.

              1 Reply Last reply Reply Quote 0
              • JaredBuschJ
                JaredBusch
                last edited by

                I'll rewrite this as an actual how to in the next few days.

                1 Reply Last reply Reply Quote 1
                • JaredBuschJ
                  JaredBusch @JaredBusch
                  last edited by

                  @JaredBusch said in Pi as a UPS monitor:

                  Well that would be a problem. Where did the file I made go? I guess the default directory was a bad choice?

                  pi@bna-pwr-pi-01:~ $ sudo ls -l /var/run/nut/
                  total 12
                  -rw-r--r-- 1 nut  nut  4 Feb  2 04:27 upsd.pid
                  -rw-r--r-- 1 root root 4 Feb  2 04:27 upsmon.pid
                  srw-rw---- 1 nut  nut  0 Feb  2 04:27 usbhid-ups-bnajaredrouter
                  -rw-r--r-- 1 nut  nut  4 Feb  2 04:27 usbhid-ups-bnajaredrouter.pid
                  pi@bna-pwr-pi-01:~ $ 
                  

                  @scottalanmiller what would be the 'proper' place for these files?

                  JaredBuschJ 1 Reply Last reply Reply Quote 0
                  • travisdh1T
                    travisdh1 @JaredBusch
                    last edited by

                    @JaredBusch said in Pi as a UPS monitor:

                    Well that would be a problem. Where did the file I made go? I guess the default directory was a bad choice?

                    pi@bna-pwr-pi-01:~ $ sudo ls -l /var/run/nut/
                    total 12
                    -rw-r--r-- 1 nut  nut  4 Feb  2 04:27 upsd.pid
                    -rw-r--r-- 1 root root 4 Feb  2 04:27 upsmon.pid
                    srw-rw---- 1 nut  nut  0 Feb  2 04:27 usbhid-ups-bnajaredrouter
                    -rw-r--r-- 1 nut  nut  4 Feb  2 04:27 usbhid-ups-bnajaredrouter.pid
                    pi@bna-pwr-pi-01:~ $ 
                    

                    If it's me, that's normally forgetting to add the sudo before my favorite text editor. Anything in /dev or /etc requires root privilege. Besides that, dunno. Nano complains at you saying "read only" when you try to save.... yeah, seen that a few more times than I can count.

                    1 Reply Last reply Reply Quote 0
                    • JaredBuschJ
                      JaredBusch @JaredBusch
                      last edited by

                      @JaredBusch said in Pi as a UPS monitor:

                      @JaredBusch said in Pi as a UPS monitor:

                      Well that would be a problem. Where did the file I made go? I guess the default directory was a bad choice?

                      pi@bna-pwr-pi-01:~ $ sudo ls -l /var/run/nut/
                      total 12
                      -rw-r--r-- 1 nut  nut  4 Feb  2 04:27 upsd.pid
                      -rw-r--r-- 1 root root 4 Feb  2 04:27 upsmon.pid
                      srw-rw---- 1 nut  nut  0 Feb  2 04:27 usbhid-ups-bnajaredrouter
                      -rw-r--r-- 1 nut  nut  4 Feb  2 04:27 usbhid-ups-bnajaredrouter.pid
                      pi@bna-pwr-pi-01:~ $ 
                      

                      @scottalanmiller what would be the 'proper' place for these files?

                      Hey @scottalanmiller you never answered this one. What is 'proper' for this kinda thing.

                      travisdh1T 1 Reply Last reply Reply Quote 0
                      • travisdh1T
                        travisdh1 @JaredBusch
                        last edited by

                        @JaredBusch said in Pi as a UPS monitor:

                        @JaredBusch said in Pi as a UPS monitor:

                        @JaredBusch said in Pi as a UPS monitor:

                        Well that would be a problem. Where did the file I made go? I guess the default directory was a bad choice?

                        pi@bna-pwr-pi-01:~ $ sudo ls -l /var/run/nut/
                        total 12
                        -rw-r--r-- 1 nut  nut  4 Feb  2 04:27 upsd.pid
                        -rw-r--r-- 1 root root 4 Feb  2 04:27 upsmon.pid
                        srw-rw---- 1 nut  nut  0 Feb  2 04:27 usbhid-ups-bnajaredrouter
                        -rw-r--r-- 1 nut  nut  4 Feb  2 04:27 usbhid-ups-bnajaredrouter.pid
                        pi@bna-pwr-pi-01:~ $ 
                        

                        @scottalanmiller what would be the 'proper' place for these files?

                        Hey @scottalanmiller you never answered this one. What is 'proper' for this kinda thing.

                        Should be /etc/nut. The standard is to put config files in /etc. /dev is generally hardware devices.

                        1 Reply Last reply Reply Quote 1
                        • gjacobseG
                          gjacobse
                          last edited by

                          @JaredBusch

                          You could add this little display on your Pi for local status-

                          https://www.adafruit.com/product/3527?utm_source=youtube&utm_medium=videodescrip&utm_campaign=newproducts

                          3527-04.jpg

                          scottalanmillerS travisdh1T 2 Replies Last reply Reply Quote 0
                          • scottalanmillerS
                            scottalanmiller @gjacobse
                            last edited by

                            @gjacobse I like that, it's cute.

                            1 Reply Last reply Reply Quote 0
                            • travisdh1T
                              travisdh1 @gjacobse
                              last edited by

                              @gjacobse Nice find. And only uses 6 pins? I've got a 2.5" display that uses most of the GPIO block 😕

                              gjacobseG 1 Reply Last reply Reply Quote 0
                              • gjacobseG
                                gjacobse @travisdh1
                                last edited by

                                @travisdh1 said in Pi as a UPS monitor:

                                @gjacobse Nice find. And only uses 6 pins? I've got a 2.5" display that uses most of the GPIO block 😕

                                The only thing I might do is see if it was possible to rotate the display part 90deg,.. free up the header area for more - OR make a breakout board for all 20 GPIO with the OlED turned...

                                1 Reply Last reply Reply Quote 0
                                • gjacobseG
                                  gjacobse
                                  last edited by

                                  @JaredBusch

                                  Did you ever get this project finished?

                                  1 Reply Last reply Reply Quote 0
                                  • JaredBuschJ
                                    JaredBusch
                                    last edited by

                                    Aside from alerting, this was working. No, I never circled back to this.

                                    1 Reply Last reply Reply Quote 0
                                    • B
                                      bxdobs
                                      last edited by

                                      Struggling with getting nut to work with an old APC UPS ... lsusb suggests the UPS USB port is connecting to the PI (it lists the device when plugged in) but can't seem to find the right combination of configurations to allow nut to actually monitor the UPS itself.

                                      tried drivers;
                                      usbhid-usb port=auto
                                      genericusb with type; = 1, 2, 9, or 12 (port=serial1)
                                      apcsmart
                                      apcsmart-old
                                      apcupsd-ups

                                      seems that the ups is just not being found

                                      is there some way to manually poke the USB port (sort of like we used to do with uarts with AT commands)?

                                      gjacobseG 1 Reply Last reply Reply Quote 0
                                      • gjacobseG
                                        gjacobse @bxdobs
                                        last edited by

                                        @bxdobs said in Pi as a UPS monitor:

                                        Struggling with getting nut to work with an old APC UPS ... lsusb suggests the UPS USB port is connecting to the PI (it lists the device when plugged in) but can't seem to find the right combination of configurations to allow nut to actually monitor the UPS itself.

                                        tried drivers;
                                        usbhid-usb port=auto
                                        genericusb with type; = 1, 2, 9, or 12 (port=serial1)
                                        apcsmart
                                        apcsmart-old
                                        apcupsd-ups

                                        seems that the ups is just not being found

                                        is there some way to manually poke the USB port (sort of like we used to do with uarts with AT commands)?

                                        I actually just went through this about a month or so ago when I set up Ubuntu Server and a APCups. I'm not at the house to pull what I did,... but I heavily referenced this very thread. Yes - where I don't live in Linux CLI as some do, I had to do some trial and error again. but that's part of (re)learning.

                                        1 Reply Last reply Reply Quote 0
                                        • B
                                          bxdobs
                                          last edited by

                                          Removed the nut installation, config files and did a complete Raspbian upgrade ... Now after reinstalling nut with the bare minimum configuration, it is finally talking to the ups.

                                          Even though I have been technically involved with computer tech going back to the late '70s, this install was certainly not for the faint of heart ... I can understand why people walk away in frustration from this stuff

                                          1 Reply Last reply Reply Quote 0
                                          • travisdh1T
                                            travisdh1
                                            last edited by

                                            2023, and this thread is still the best resource for getting nut/apcupsd running.

                                            1 Reply Last reply Reply Quote 2
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 6 / 6
                                            • First post
                                              Last post