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

    PHP error APCUPSD widget

    Scheduled Pinned Locked Moved General pfSense Questions
    10 Posts 5 Posters 1.3k 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.
    • M
      Micma_
      last edited by

      Installed apcupsd onto 23.01rc latest 23.01.r.20230208.1414

      ups status is fine:
      Running: apcaccess -h 0.0.0.0:3551

      APC : 001,036,0866
      DATE : 2023-02-09 16:34:39 -0500
      HOSTNAME : pfSense.home.arpa
      VERSION : 3.14.14 (31 May 2016) freebsd
      UPSNAME : Sparky

      However the dashboard widget works fine after installation but then throws an error after an onbatt and online cycle when disconnecting ups from power source:

      PHP Fatal error: Uncaught TypeError: strrpos(): Argument #2 ($needle) must be of type string, array given in /usr/local/www/widgets/widgets/apcupsd.widget.php:130
      Stack trace:
      #0 /usr/local/www/widgets/widgets/apcupsd.widget.php(130): strrpos('ONLINE ', Array)
      #1 /usr/local/www/widgets/widgets/apcupsd.widget.php(339): compose_apc_contents('apcupsd-0')
      #2 {main}
      thrown in /usr/local/www/widgets/widgets/apcupsd.widget.php on line 130

      Line 130 in /usr/local/www/widgets/widgets/apcupsd.widget.php:

      if (($bchrg != null) && (in_array("ONLINE", $statusarray)) && ($bchrg < 100) && (strrpos($statstr, $mainstatarray) === false)) {

      Thanks for any input!

      1 Reply Last reply Reply Quote 0
      • M
        Micma_
        last edited by

        Found an unresolved bug:
        https://redmine.pfsense.org/issues/11898

        1 Reply Last reply Reply Quote 0
        • stephenw10S
          stephenw10 Netgate Administrator
          last edited by

          @micma_ said in PHP error APCUPSD widget:

          https://redmine.pfsense.org/issues/11898

          You should update that bug with your new data since it looks exactly the same even in the new PHP version.

          Steve

          M 1 Reply Last reply Reply Quote 0
          • M
            Micma_ @stephenw10
            last edited by

            @stephenw10

            Don't know what to think of it. This morning the widget is running fine!

            1 Reply Last reply Reply Quote 0
            • stephenw10S
              stephenw10 Netgate Administrator
              last edited by

              Yeah it's not the usual PHP errors we might expect from the version change. There's clearly something variable in play. You should probably note your config for apcupsd and add it to the bug.

              Steve

              1 Reply Last reply Reply Quote 0
              • P
                perka.home
                last edited by perka.home

                @micma_ said in PHP error APCUPSD widget:

                https://redmine.pfsense.org/issues/11898

                Same here, apcupsd widget crashed after update to 23.01

                1 Reply Last reply Reply Quote 0
                • stephenw10S
                  stephenw10 Netgate Administrator
                  last edited by

                  Exactly the same error? Is it repeatable? Update the bug report with your findings if so.

                  J 1 Reply Last reply Reply Quote 0
                  • J
                    jrey @stephenw10
                    last edited by

                    @stephenw10

                    Not saying I know this is related, however I noticed the OP is running on the "default" setting stating
                    Running: apcaccess -h 0.0.0.0:3551

                    where as I am running on the more "focused" setting of
                    Running: apcaccess -h 127.0.0.1:3551

                    per the setting / description here:

                    Screen Shot 2023-02-18 at 9.28.54 AM.png

                    No issue here that I have noticed. But it is also possible this unit hasn't had a transfer to battery in the past couple of days. There has been a system reboot (normal reboot cycle via the diag menu).

                    JR

                    1 Reply Last reply Reply Quote 0
                    • N
                      nicole4pt
                      last edited by

                      I upgraded a few days ago and all was fine.
                      However today as it's very windy, we have been having power fluctuations which has started sending me APC alert email after email... I can't get them to stop without disabling APC.

                      I tried unplugging and replugging the USB connection but that did not do anything.

                      PHP ERROR: Type: 1, File: /usr/local/www/widgets/widgets/apcupsd.widget.php, Line: 130, Message: Uncaught TypeError: strrpos(): Argument #2 ($needle) must be of type string, array given in /usr/local/www/widgets/widgets/apcupsd.widget.php:130
                      Stack trace:
                      #0 /usr/local/www/widgets/widgets/apcupsd.widget.php(130): strrpos('ONLINE ', Array)
                      #1 /usr/local/www/widgets/widgets/apcupsd.widget.php(339): compose_apc_contents('apcupsd-0')
                      #2 {main}
                      thrown @ 2023-02-21 16:43:28

                      Error logging - shows
                      PHP errors
                      PHP ERROR: Type: 1, File: /usr/local/www/widgets/widgets/apcupsd.widget.php, Line: 130, Message: Uncaught TypeError: strrpos(): Argument #2 ($needle) must be of type string, array given in /usr/local/www/widgets/widgets/apcupsd.widget.php:130
                      Stack trace:
                      #0 /usr/local/www/widgets/widgets/apcupsd.widget.php(130): strrpos('ONLINE ', Array)
                      #1 /usr/local/www/widgets/widgets/apcupsd.widget.php(339): compose_apc_contents('apcupsd-0')
                      #2 {main}
                      thrown @ 2023-02-21 16:54:05
                      PHP ERROR: Type: 1, File: /usr/local/www/widgets/widgets/apcupsd.widget.php, Line: 130, Message: Uncaught TypeError: strrpos(): Argument #2 ($needle) must be of type string, array given in /usr/local/www/widgets/widgets/apcupsd.widget.php:130
                      Stack trace:
                      #0 /usr/local/www/widgets/widgets/apcupsd.widget.php(130): strrpos('ONLINE ', Array)
                      #1 /usr/local/www/widgets/widgets/apcupsd.widget.php(339): compose_apc_contents('apcupsd-0')
                      #2 {main}
                      thrown @ 2023-02-21 16:54:15

                      And now the power is out...

                      1 Reply Last reply Reply Quote 0
                      • stephenw10S
                        stephenw10 Netgate Administrator
                        last edited by stephenw10

                        That's the open bug referenced above:
                        https://redmine.pfsense.org/issues/11898

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