Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Email notifications with apcupsd not sent

    Scheduled Pinned Locked Moved pfSense Packages
    9 Posts 4 Posters 2.0k 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.
    • S
      SteveITS Galactic Empire
      last edited by

      We installed apcupsd a few months ago and it's been fine, reporting the status and so forth. Today we've had two power blips:

      Oct 8 09:26:23 apcupsd 98582 Power is back. UPS running on mains.
      Oct 8 09:26:22 apcupsd 98582 Power failure.
      Oct 8 02:23:16 apcupsd 98582 Power is back. UPS running on mains.
      Oct 8 02:23:15 apcupsd 98582 Power failure.

      It does not appear to have tried to send the email notification? Should it log that? Notifications are set to use "php," are configured in System/Advanced and testing there works. I found a couple of old messages from 4-5 years ago about email notifications in apcupsd not working, but were supposed to be fixed by a pfSense update. Is that still an issue?

      Pre-2.7.2/23.09: Only install packages for your version, or risk breaking it. Select your branch in System/Update/Update Settings.
      When upgrading, allow 10-15 minutes to restart, or more depending on packages and device speed.
      Upvote 👍 helpful posts!

      provelsP G 2 Replies Last reply Reply Quote 0
      • provelsP
        provels @SteveITS
        last edited by provels

        @teamits
        I assume you have configured notifications in System/Advanced/Notifications. When you hit
        c2296e02-e041-454a-bd20-6aa48bd6f2f5-image.png
        It works? Other notifications work?

        @teamits said in Email notifications with apcupsd not sent:

        Notifications are set to use "php,"

        Where is that set?

        Peder

        MAIN - pfSense+ 24.11-RELEASE - Adlink MXE-5401, i7, 16 GB RAM, 64 GB SSD. 500 GB HDD for SyslogNG
        BACKUP - pfSense+ 23.01-RELEASE - Hyper-V Virtual Machine, Gen 1, 2 v-CPUs, 3 GB RAM, 8GB VHDX (Dynamic)

        1 Reply Last reply Reply Quote 0
        • S
          serbus
          last edited by serbus

          Hello!

          Check the output from :

          clog /var/log/system.log | grep -i message
          

          Aside from some noise, you should see most email results, good or bad.

          Keep in mind that pfsense does not run an mta. A local powerfail safe relay running postfix/exim/??? on something like a pi can be helpful if you want queues, retries, etc...

          John

          Lex parsimoniae

          1 Reply Last reply Reply Quote 1
          • S
            SteveITS Galactic Empire
            last edited by SteveITS

            @serbus said in Email notifications with apcupsd not sent:

            clog /var/log/system.log | grep -i message

            I see only my test for today:
            Aug 28 18:00:24 router-building php-cgi: notify_monitor.php: Message sent to support@example.com OK
            Aug 28 18:04:37 router-building php-cgi: notify_monitor.php: Message sent to support@example.com OK
            Oct 8 10:02:48 router-building php-fpm[1991]: /system_advanced_notifications.php: Message sent to support@example.com OK

            So that would imply it didn't bother trying?

            ' Notifications are set to use "php," ' is set in the apcupsd settings. It has a choice of "php" or "SMTP built-in" which is the package's own email settings but there is no test button there.

            "php - In order to receive e-mail notifications through php, you need to configure SMTP Email Notifications on System/Advanced/Notifications section.

            SMTP built-in - A simple SMTP mail client for apcupsd. It does not have smtp authentication of any kind."

            Edit: I have already changed to "SMTP built-in" to try for next time but as I said there is no test button.

            Edit 2: clog /var/log/system.log | grep -i apc output:
            Aug 28 18:04:41 router-building apcupsd[98582]: apcupsd 3.14.14 (31 May 2016) freebsd startup succeeded
            Aug 28 18:04:41 router-building apcupsd[98582]: NIS server startup succeeded
            Oct 8 02:23:15 router-building apcupsd[98582]: Power failure.
            Oct 8 02:23:16 router-building apcupsd[98582]: Power is back. UPS running on mains.
            Oct 8 09:26:22 router-building apcupsd[98582]: Power failure.
            Oct 8 09:26:23 router-building apcupsd[98582]: Power is back. UPS running on mains.
            Oct 8 10:19:19 router-building php-fpm[1991]: /pkg_edit.php: Stopping service apcupsd
            Oct 8 10:19:19 router-building apcupsd[98582]: apcupsd exiting, signal 15
            Oct 8 10:19:20 router-building apcupsd[98582]: apcupsd shutdown succeeded
            Oct 8 10:19:24 router-building php-fpm[1991]: /pkg_edit.php: Starting service apcupsd
            Oct 8 10:19:30 router-building apcupsd[92818]: apcupsd 3.14.14 (31 May 2016) freebsd startup succeeded
            Oct 8 10:19:30 router-building apcupsd[92818]: NIS server startup succeeded

            (10:19 was when I changed to the built in SMTP)

            Pre-2.7.2/23.09: Only install packages for your version, or risk breaking it. Select your branch in System/Update/Update Settings.
            When upgrading, allow 10-15 minutes to restart, or more depending on packages and device speed.
            Upvote 👍 helpful posts!

            1 Reply Last reply Reply Quote 0
            • S
              serbus
              last edited by

              Hello!

              apcupsd ends up calling the standard send_smtp_message from /etc/inc/notices.inc when you select the php option.

              You can check the php path with something like :

              /usr/local/bin/php -f /usr/local/pkg/apcupsd_mail.php "commok"
              

              Also, make sure that apcupsd has correctly generated the email notification scripts for php by trying something like :

              /usr/local/etc/apcupsd/commok
              

              I am not sure why there would be nothing in the system.log

              John

              Lex parsimoniae

              1 Reply Last reply Reply Quote 0
              • S
                SteveITS Galactic Empire
                last edited by

                Hmm, with it set to "built in" I tried both commands, and got two "Communications with UPS restored" emails. I changed the mailer back to "php" and ran them again and got two more emails.

                Pre-2.7.2/23.09: Only install packages for your version, or risk breaking it. Select your branch in System/Update/Update Settings.
                When upgrading, allow 10-15 minutes to restart, or more depending on packages and device speed.
                Upvote 👍 helpful posts!

                1 Reply Last reply Reply Quote 0
                • S
                  serbus
                  last edited by

                  Hello!

                  It sounds like it has the pieces in place to send the emails if it wants to.

                  Check /var/log/apcupsd.events and :

                  clog /var/log/system.log | grep -i apcupsd
                  

                  You could also add a "-d" to the command_args in /usr/local/etc/rc.d/apcupsd and then restart the service to try and squeeze out more debug info about what is going on inside apcupsd.

                  John

                  Lex parsimoniae

                  S 1 Reply Last reply Reply Quote 0
                  • S
                    SteveITS Galactic Empire @serbus
                    last edited by

                    @serbus That's what I posted earlier...

                    Aug 28 18:04:41 router-building apcupsd[98582]: apcupsd 3.14.14 (31 May 2016) freebsd startup succeeded
                    Aug 28 18:04:41 router-building apcupsd[98582]: NIS server startup succeeded
                    Oct 8 02:23:15 router-building apcupsd[98582]: Power failure.
                    Oct 8 02:23:16 router-building apcupsd[98582]: Power is back. UPS running on mains.
                    Oct 8 09:26:22 router-building apcupsd[98582]: Power failure.
                    Oct 8 09:26:23 router-building apcupsd[98582]: Power is back. UPS running on mains.

                    No email attempts. I guess I can wait until the next power blip and see if it works when set to the "built in" SMTP server.

                    Pre-2.7.2/23.09: Only install packages for your version, or risk breaking it. Select your branch in System/Update/Update Settings.
                    When upgrading, allow 10-15 minutes to restart, or more depending on packages and device speed.
                    Upvote 👍 helpful posts!

                    1 Reply Last reply Reply Quote 0
                    • G
                      galentx @SteveITS
                      last edited by

                      @steveits I have been encountering the same issue and finally digested this setting in /usr/local/etc/apcupsd/apcupsd.conf:

                      # The ONBATTERYDELAY is the time in seconds from when a power failure
                      #   is detected until we react to it with an onbattery event.
                      #
                      #   This means that, apccontrol will be called with the powerout argument
                      #   immediately when a power failure is detected.  However, the
                      #   onbattery argument is passed to apccontrol only after the
                      #   ONBATTERYDELAY time.  If you don't want to be annoyed by short
                      #   powerfailures, make sure that apccontrol powerout does nothing
                      #   i.e. comment out the wall.
                      ONBATTERYDELAY 6
                      

                      The onbattery condition is immediately logged to the apcupsd event log and syslog, but the email notification is withheld until the ONBATTERYDELAY has transpired to eliminate unnecessary notifications for brief transients. I see that your outages were only on second long, so they would not have satisfied the default 6-second condition.

                      If you want to be notified of brief outages, you might create a powerout script in /usr/local/etc/apcupsd/ similar to the onbattery script.

                      Galen

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.