Uploaded image for project: 'Observium'
  1. Observium
  2. OBS-3731

PHP fatal errors at device discovery and alert rebuild

Details

    • Bug
    • Resolution: Fixed
    • Major
    • None
    • Professional Edition
    • Alerting

    Description

      Rebuilding alerts from Web UI fail with errors (see attached screenshot)

      When running "{{discovery.php -h <hostname>" }}the discovery runs but exits with:

      PHP Fatal error: Uncaught Error: Call to undefined function r() in /opt/observium/includes/alerts.inc.php:428
      Stack trace:
      #0 /opt/observium/includes/alerts.inc.php(409): update_alert_table()
      #1 /opt/observium/discovery.php(221): update_alert_tables()
      #2 {main}
      {{ thrown in /opt/observium/includes/alerts.inc.php on line 428}}

       

      Attachments

        Activity

          [OBS-3731] PHP fatal errors at device discovery and alert rebuild

          "To err is human, but for a real disaster you need a computer." 

          I can confirm this issue fixed in r11275.

          Thank you for quick response and fix.

           

           

          nodefield Ilkka Myller added a comment - "To err is human, but for a real disaster you need a computer."  I can confirm this issue fixed in r11275. Thank you for quick response and fix.    

          Yeah, this was me rushing a stable merge to fix another bug, and introducing some errant debugging code. Whoops!

          Should be fixed now.

          adama Adam Armstrong added a comment - Yeah, this was me rushing a stable merge to fix another bug, and introducing some errant debugging code. Whoops! Should be fixed now.

          Getting the same issue after svn update.

          mwilliamsr Mark Williams added a comment - Getting the same issue after svn update.
          nodefield Ilkka Myller added a comment - - edited

          The problematic lines were introduced in revs r11253 -> r11262:

          ------------------------------------------------------------------------
          r11262 | adama | 2021-04-26 03:34:03 +0300 (Mon, 26 Apr 2021) | 2 lines
           
          [STABLE] Merge of r11253 through r11261
           
          ------------------------------------------------------------------------
          r11253 | adama | 2021-04-21 17:19:50 +0300 (Wed, 21 Apr 2021) | 2 lines
           
          [STABLE] Stable merge of r11172 through r11252. 

           

          With diff:

           

          observium:/opt/observium# svn diff -r 11253  includes/alerts.inc.php 
          Index: includes/alerts.inc.php
          ===================================================================
          --- includes/alerts.inc.php	(revision 11253)
          +++ includes/alerts.inc.php	(working copy)
          @@ -424,10 +424,15 @@
              {
           
                 $query = parse_qb_ruleset($alert['entity_type'], safe_json_decode($alert['alert_assoc']));
          +
          +r($query);
          +
                 $data  = dbFetchRows($query);
                 //$error = dbError();
                 $entities = array();
           
          +r($data);
          +
                 $field = $GLOBALS['config']['entities'][$alert['entity_type']]['table_fields']['id'];
           
                 foreach($data as $datum)
          @@ -443,9 +448,10 @@
          
          

           

           

          nodefield Ilkka Myller added a comment - - edited The problematic lines were introduced in revs r11253 -> r11262: ------------------------------------------------------------------------ r11262 | adama | 2021-04-26 03:34:03 +0300 (Mon, 26 Apr 2021) | 2 lines   [STABLE] Merge of r11253 through r11261   ------------------------------------------------------------------------ r11253 | adama | 2021-04-21 17:19:50 +0300 (Wed, 21 Apr 2021) | 2 lines   [STABLE] Stable merge of r11172 through r11252.    With diff:   observium:/opt/observium# svn diff -r 11253   includes/alerts.inc.php  Index: includes/alerts.inc.php =================================================================== --- includes/alerts.inc.php (revision 11253 ) +++ includes/alerts.inc.php (working copy) @@ - 424 , 10 + 424 , 15 @@     {          $query = parse_qb_ruleset($alert[ 'entity_type' ], safe_json_decode($alert[ 'alert_assoc' ])); + +r($query); +        $data  = dbFetchRows($query);        //$error = dbError();        $entities = array();   +r($data); +        $field = $GLOBALS[ 'config' ][ 'entities' ][$alert[ 'entity_type' ]][ 'table_fields' ][ 'id' ];          foreach($data as $datum) @@ - 443 , 9 + 448 , 10 @@    

          There seems to be couple of incorrectly formatted lines (bad code indentation) in alerts.inc.php:

          r($query);
          

          r($data);
          

          Could this be result of a bad code merge?

          My svn status is clean and local repo is in sync with the stable Observium Pro repository

           

           

          function update_alert_table($alert, $silent = TRUE)
          {
           
           
             if (is_numeric($alert)) // We got an alert_test_id, fetch the array.
             {
                $alert = dbFetchRow("SELECT * FROM `alert_tests` WHERE `alert_test_id` = ?", array($alert));
             }
           
           
             if (strlen($alert['alert_assoc']))
             {
           
           
                $query = parse_qb_ruleset($alert['entity_type'], safe_json_decode($alert['alert_assoc']));
           
           
          r($query);
           
           
                $data  = dbFetchRows($query);
                //$error = dbError();
                $entities = array();
           
           
          r($data);
           
           
                $field = $GLOBALS['config']['entities'][$alert['entity_type']]['table_fields']['id'];
           
           
                foreach($data as $datum)
                {
                   $entities[$datum[$field]] = array('entity_id' => $datum[$field], 'device_id' => $datum['device_id']);
                }
           
           
             } else {
                $entities = get_alert_entities_from_assocs($alert);
             }
           
           
           
                $data  = dbFetchRows($query);
                //$error = dbError();
                $entities = array();
           
           
          r($data);
           
           
                $field = $GLOBALS['config']['entities'][$alert['entity_type']]['table_fields']['id'];
           
           
                foreach($data as $datum)
                {
                   $entities[$datum[$field]] = array('entity_id' => $datum[$field], 'device_id' => $datum['device_id']);
                }
           
           
             } else {
                $entities = get_alert_entities_from_assocs($alert);
             }
          
          

           

          nodefield Ilkka Myller added a comment - There seems to be couple of incorrectly formatted lines (bad code indentation) in alerts.inc.php: r($query); r($data); Could this be result of a bad code merge? My svn status is clean and local repo is in sync with the stable Observium Pro repository —     function update_alert_table($alert, $silent = TRUE) {        if (is_numeric($alert)) // We got an alert_test_id, fetch the array.    {       $alert = dbFetchRow( "SELECT * FROM `alert_tests` WHERE `alert_test_id` = ?" , array($alert));    }        if (strlen($alert[ 'alert_assoc' ]))    {           $query = parse_qb_ruleset($alert[ 'entity_type' ], safe_json_decode($alert[ 'alert_assoc' ]));     r($query);           $data  = dbFetchRows($query);       //$error = dbError();       $entities = array();     r($data);           $field = $GLOBALS[ 'config' ][ 'entities' ][$alert[ 'entity_type' ]][ 'table_fields' ][ 'id' ];           foreach($data as $datum)       {          $entities[$datum[$field]] = array( 'entity_id' => $datum[$field], 'device_id' => $datum[ 'device_id' ]);       }        } else {       $entities = get_alert_entities_from_assocs($alert);    }             $data  = dbFetchRows($query);       //$error = dbError();       $entities = array();     r($data);           $field = $GLOBALS[ 'config' ][ 'entities' ][$alert[ 'entity_type' ]][ 'table_fields' ][ 'id' ];           foreach($data as $datum)       {          $entities[$datum[$field]] = array( 'entity_id' => $datum[$field], 'device_id' => $datum[ 'device_id' ]);       }        } else {       $entities = get_alert_entities_from_assocs($alert);    }  

          Issue appears in latest stable:

          Observium Professional 21.4.11262

           

          nodefield Ilkka Myller added a comment - Issue appears in latest stable: Observium Professional 21.4.11262  

          Please make and attach additional information about the device:

          • full snmp dump from device:

            snmpwalk -v2c -c <community>  --hexOutputLength=0 -ObentxU <hostname> .1 > myagent.snmpwalk
            snmpwalk -v2c -c <community>  --hexOutputLength=0 -ObentxU <hostname> .1.3.6.1.4.1 >> myagent.snmpwalk

            If device not support SNMP version 2c, replace -v2c with -v1.

          • If you have problems with discovery or poller processes, please do and attach these debugs:

            ./discovery.php -d -h <device>
            ./poller.php -d -h <device>

          • additionally attach device and/or vendor specific MIB files

          Note, this comment is added automatically.

          bot Observium Bot added a comment - Please make and attach additional information about the device: full snmp dump from device: snmpwalk -v2c -c <community> --hexOutputLength=0 -ObentxU <hostname> .1 > myagent.snmpwalk snmpwalk -v2c -c <community> --hexOutputLength=0 -ObentxU <hostname> .1.3.6.1.4.1 >> myagent.snmpwalk If device not support SNMP version 2c, replace -v2c with -v1. If you have problems with discovery or poller processes, please do and attach these debugs: ./discovery.php -d -h <device> ./poller.php -d -h <device> additionally attach device and/or vendor specific MIB files Note, this comment is added automatically.

          People

            adama Adam Armstrong
            nodefield Ilkka Myller
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: