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

Add "Force Discovery" toggle to edit device page

    XMLWordPrintable

Details

    • New Feature
    • Resolution: Fixed
    • Minor
    • None
    • Professional Edition
    • Web Interface

    Description

      There is an existing database field `force_discovery` in the `devices` table that will force a device to be rediscovered along with `new` devices the next time it's run (usually CRONed at 5min intervals).  I tested this small change which adds a toggle for this field to the "Edit Device" page, and seems to work as expected:

      # diff -u0 device.inc.php.original device.inc.php
      --- device.inc.php.original     2024-05-15 17:34:00.989936494 +1000
      +++ device.inc.php      2024-05-15 17:57:16.073886657 +1000
      @@ -90 +90 @@
      -        foreach (['purpose', 'ignore', 'disabled', 'poller_id'] as $param) {
      +        foreach (['purpose', 'ignore', 'disabled', 'poller_id', 'force_discovery'] as $param) {
      @@ -115 +115,4 @@
      -            $update_message = "Device record updated.";
      +            if ((bool)$vars['force_discovery'] != (bool)$device['force_discovery']) {
      +                log_event('Device forced discovery ' . ((bool)$vars['force_discovery'] ? 'enabled' : 'disabled') . ': ' . $device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
      +            }
      +           $update_message = "Device record updated.";
      @@ -240 +243,10 @@
      -$form['row'][8]['submit']   = [
      +$form['row'][8]['force_discovery'] = [
      +  'type'        => 'toggle',
      +  'view'        => 'toggle',
      +  'palette'     => 'red',
      +  'name'        => 'Force Discovery',
      +  //'fieldset'    => 'edit',
      +  'placeholder' => 'Force the device to be rediscovered in the next 5 mins.',
      +  'readonly'    => $readonly,
      +  'value'       => $device['force_discovery']];
      +$form['row'][9]['submit']

      This appears visually like this:

      Is it possible for this, or something functionally equivalent, to be merged, as it's a pain to maintain this out of sync with the main repo and the diff seems relatively safe/trivial to me.

      Best regards,

      Matt Clancy

      Attachments

        Activity

          People

            adama Adam Armstrong
            mcslc Matthew Clancy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: