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

Probes table probe_id column needs auto_increment

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Trivial
    • None
    • Professional Edition
    • Web Interface
    • None
    • Observium 19.9.10064 (rolling) with latest updates applied.

    Description

      GUI/PHP code works for first probe created, but then fails on subsequent requests given non-unique probe_id value and AUTO_INCREMENT is not set for column

      Need to set AUTO_INCREMENT on column as below to fix.

       

      MariaDB [observium]> describe probes
      -> ;
      ------------------------------------------------------------------------+

      Field Type Null Key Default Extra

      ------------------------------------------------------------------------+

      probe_id int(11) NO PRI NULL  
      device_id int(11) NO MUL NULL  
      probe_type varchar(64) NO   NULL  
      probe_param text YES   NULL  
      probe_cli varchar(256) YES   NULL  
      probe_status enum('ok','warning','alert','unknown') NO   unknown  
      probe_msg varchar(128) YES   NULL  
      probe_output text YES   NULL  
      probe_changed timestamp YES   NULL  
      probe_checked timestamp YES   NULL  

      ------------------------------------------------------------------------+
      10 rows in set (0.001 sec)

      MariaDB [observium]> INSERT INTO probes SET device_id=5, probe_type='check_fping';
      ERROR 1364 (HY000): Field 'probe_id' doesn't have a default value
      MariaDB [observium]> ALTER TABLE probes MODIFY COLUMN probe_id INT(11) AUTO_INCREMENT;
      Query OK, 1 row affected (0.007 sec)
      Records: 1 Duplicates: 0 Warnings: 0

      MariaDB [observium]> INSERT INTO probes SET device_id=5, probe_type='check_fping';
      Query OK, 1 row affected (0.001 sec)

      MariaDB [observium]> select * from probes;
      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

      probe_id device_id probe_type probe_param probe_cli probe_status probe_msg probe_output probe_changed probe_checked

      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

      1 10 check_ssh NULL NULL ok   SSH OK - OpenSSH_7.4 (protocol 2.0) time=0.024783s;;;0.000000;10.000000 2019-10-01 09:30:02 2019-10-01 09:50:02
      2 5 check_fping NULL NULL unknown NULL NULL NULL NULL

      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      2 rows in set (0.000 sec)

      MariaDB [observium]>

       

      [root@observium update]# grep probes *
      417.sql:CREATE TABLE `probes` ( `probe_id` int(11) NOT NULL, `device_id` int(11) NOT NULL, `probe_type` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `probe_param` text COLLATE utf8_unicode_ci, `probe_cli` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL, `probe_status` enum('ok','warning','alert','unknown') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'unknown', `probe_msg` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL, `probe_output` text COLLATE utf8_unicode_ci, `probe_changed` timestamp NULL DEFAULT NULL, `probe_checked` timestamp NULL DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
      417.sql:ALTER TABLE `probes` ADD PRIMARY KEY (`probe_id`), ADD KEY `device_id` (`device_id`);
      [root@observium update]#

       

      [root@observium observium]# cat ./html/includes/actions/add_probe.inc.php
      <?php

      if ($_SESSION['userlevel'] > 8)

      { if(!is_numeric($vars['form_device_id'])) \{ print_error("Invalid Device"); }

      if( empty($vars['form_probe_type'])) { print_error("Invalid Probe Type"); }

      $insert = array("device_id" => $vars['form_device_id'], 'probe_type' => $vars['form_probe_type']);
      if(!empty($vars['form_probe_cmd'])) { $insert['probe_cmd'] = $vars['form_probe_cmd']; }

      $probe_id = dbInsert($insert, 'probes');

      if($probe_id) { print_message('Probe successfully added'); }
      unset($insert);
      }[root@observium observium]#

       

       

      Attachments

        Activity

          People

            adama Adam Armstrong
            colin.stubbs Colin Stubbs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: