Ad Widget

Collapse

Zabbix 7.4.4 error in CGraphHelper widget

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DyingMuppet
    Junior Member
    • Nov 2023
    • 4

    #1

    Zabbix 7.4.4 error in CGraphHelper widget

    Hey Guys,

    When I just updated my Ubuntu server with Zabbix 7.4.3 to Zabbix 7.4.4 I found an error on the CGraphHelper widget as below.

    • Undefined array key "key_" [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\SvgGraph\Actions\WidgetView->doAction() → Widgets\SvgGraph\Includes\CSvgGraphHelper::get() → CGraphHelper::calculateMetricsDelay() → CGraphHelper::getItemMaxDelay() in include/classes/helpers/CGraphHelper.php:306]
    • preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\SvgGraph\Actions\WidgetView->doAction() → Widgets\SvgGraph\Includes\CSvgGraphHelper::get() → CGraphHelper::calculateMetricsDelay() → CGraphHelper::getItemMaxDelay() → preg_match() in include/classes/helpers/CGraphHelper.php:306]
    • Undefined array key "key_" [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\SvgGraph\Actions\WidgetView->doAction() → Widgets\SvgGraph\Includes\CSvgGraphHelper::get() → CGraphHelper::calculateMetricsDelay() → CGraphHelper::getItemMaxDelay() in include/classes/helpers/CGraphHelper.php:306]
    • preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\SvgGraph\Actions\WidgetView->doAction() → Widgets\SvgGraph\Includes\CSvgGraphHelper::get() → CGraphHelper::calculateMetricsDelay() → CGraphHelper::getItemMaxDelay() → preg_match() in include/classes/helpers/CGraphHelper.php:306]
    With a little help from GPT I changed the code of CGraphHelper.php between lines 305 and 306.

    From:
    Code:
    /**
             * Returns the maximum item update interval based on the values of the "type" and "delay" fields.
             * Returns NULL if the item type does not support an update interval or if an error occurred during calculation.
             *
             * @param array  $item
             *
             * @return int|float|null
             */
            private static function getItemMaxDelay(array $item): int|float|null {
                    if (($item['type'] == ITEM_TYPE_ZABBIX_ACTIVE && preg_match('/^(event)?log(rt)?\[/', $item['key_']))​
    To:

    Code:
     /**
             * Returns the maximum item update interval based on the values of the "type" and "delay" fields.
             * Returns NULL if the item type does not support an update interval or if an error occurred during calculation.
             *
             * @param array  $item
             *
             * @return int|float|null
             */
            private static function getItemMaxDelay(array $item): int|float|null {
                    // Guard against empty or missing key_
                     if (!isset($item['key_']) || $item['key_'] === null || $item['key_'] === '') {
                         return 0; // of: continue; afhankelijk van de loop/verwachte semantics
                         }
    
                         // cast extra definition:
                         $subject = (string)$item['key_'];
    
    
                    if (($item['type'] == ITEM_TYPE_ZABBIX_ACTIVE && preg_match('/^(event)?log(rt)?\[/', $subject, $m))​
    This cleared the error for me on the webpage.
    Hope this gives you enough feedback for a new minor version of the CGraphHelper.php

    Regards!
  • tjh
    Junior Member
    • May 2021
    • 16

    #2
    Thanks, I'm seeing this error too. Have you logged a Zabbix bug report? If so can you link to it?
    Kind Regards!

    Comment

    • sancho
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Mar 2015
      • 295

      #3
      Hello, I have created a ticket on the Zabbix support system regarding the error and have informed them of your temporary solution.

      Thank you very much DyingMuppet


      Comment

      • DyingMuppet
        Junior Member
        • Nov 2023
        • 4

        #4
        Thanks guys, I didn't have the time to report it as a bug yet, so thank you a lot sancho

        Comment

        • sancho
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Mar 2015
          • 295

          #5
          Hi,

          After the update to 7.4.5 it seems that they had problems and have not added the fix for this bug and now with this version the problem is reproduced but the DyingMuppet solution does not work, here they have put another solution that should be the one they were going to upload:

          Source: https://support.zabbix.com/browse/ZBX-27153

          Fix: https://git.zabbix.com/projects/ZBX/...raphHelper.php

          Comment

          • cfrancis
            Junior Member
            • Jun 2019
            • 17

            #6
            The error reappears when updating to 7.4.5; the same solution applies.

            Comment

            • JuergenM
              Junior Member
              • Dec 2024
              • 6

              #7
              New versions supplied

              Comment

              Working...