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

Add latitude / longitude to devices API - bug in devices.inc.php preventing

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • Professional Edition
    • API
    • None

    Description

      Device API currently displays [devices][id][location], which is the snmp location. Request to add lat/lon to this, which is already present in sql in observium.devices_locations.latitutde and longitude.

      This table is already left joined in a query in:
      ./html/api/v0/includes/devices.inc.php

      .. but I don't think this is actually doing anything as the location listed is already in the devices table.

      It looks like it's checking for $config['geocoding']['enable'] within the api_get_devices() function, but it's not getting $config passed so it's always a FALSE.

      if config were passed via this line:

      Flight::route('GET /devices', 'api_get_devices');

      it would probably solve this. I'm unfamiliar with Flight::route so It wasn't straightforward to me how to pass this. I tried to change the last part of api_get_devices to api_get_devices($config) but it did not enjoy it.

      Attachments

        Activity

          [OBS-2858] Add latitude / longitude to devices API - bug in devices.inc.php preventing

          It is probably the best way of handling the config, either that or $GLOBALS['config'].

          I think the former is slightly faster though.

          adama Adam Armstrong added a comment - It is probably the best way of handling the config, either that or $GLOBALS ['config'] . I think the former is slightly faster though.
          falz falz added a comment -

          That works beyond php3?

          falz falz added a comment - That works beyond php3?

          Probably just "global $config;" in the function body should suffice.

          adama Adam Armstrong added a comment - Probably just "global $config;" in the function body should suffice.
          falz falz added a comment -

          It appears that one can change these lines:

          Flight::route('GET /devices', api_get_devices($config));
          function api_get_devices($config)

          .. and it does work. it however involves removing single ticks from 'api_get_devices' on the first line, which may break other stuff.

          falz falz added a comment - It appears that one can change these lines: Flight::route('GET /devices', api_get_devices($config)); function api_get_devices($config) .. and it does work. it however involves removing single ticks from 'api_get_devices' on the first line, which may break other stuff.

          People

            adama Adam Armstrong
            falz falz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: