diff --git a/doc/Extensions/Oxidized.md b/doc/Extensions/Oxidized.md new file mode 100644 index 0000000000..5d82dcdf57 --- /dev/null +++ b/doc/Extensions/Oxidized.md @@ -0,0 +1,40 @@ +# Oxidized integration + +You can integrate LibreNMS with [Oxidized](https://github.com/ytti/oxidized-web) in two ways: + +### Config viewing + +This is a straight forward use of Oxidized, it relies on you having a working Oxidized setup which is already taking config snapshots for your devices. +When you have that, you only need the following config to enable the display of device configs within the device page itself: + +```php +$config['oxidized']['enabled'] = TRUE; +$config['oxidized']['url'] = 'http://127.0.0.1:8888'; +``` + +We also support config versioning within Oxidized, this will allow you to see the old configs stored. At present this is waiting on a [PR](https://github.com/ytti/oxidized-web/pull/25) to be merged upstream into Oxidized but you could simply patch your local install in the meantime. + +```php +$config['oxidized']['features']['versioning'] = true; +``` + +### Feeding Oxidized + +Oxidized has support for feeding devices into it via an API call, support for Oxidized has been added to the LibreNMS API. A sample config for Oxidized is provided below. + +You will need to configure default credentials for your devices, LibreNMS doesn't provide login credentials at this time. + +```bash + source: + default: http + debug: false + http: + url: https://librenms/api/v0/oxidized + scheme: https + delimiter: !ruby/regexp /:/ + map: + name: hostname + model: os + headers: + X-Auth-Token: '01582bf94c03104ecb7953dsadsadwed' +``` diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index 9efc95d63a..ac5672d823 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -94,26 +94,76 @@ if ($_SESSION['userlevel'] >= '7') { } else if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) { $node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$device['hostname'].'?format=json'), true); - $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['hostname']); - if ($text == 'node not found') { - $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['os'].'/'.$device['hostname']); + if ($config['oxidized']['features']['versioning'] === true && isset($_POST['config'])) { + list($oid,$date,$version) = explode('|',mres($_POST['config'])); + $text = file_get_contents($config['oxidized']['url'].'/node/version/view?node='.$device['hostname'].'&group=&oid='.$oid.'&date='.urlencode($date).'&num='.$version.'&format=text'); + if ($text == 'node not found') { + $text = file_get_contents($config['oxidized']['url'].'/node/version/view?node='.$device['hostname'].'&group='.$device['os'].'&oid='.$oid.'&date='.urlencode($date).'&num='.$version.'&format=text'); + } + } + else { + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['hostname']); + if ($text == 'node not found') { + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['os'].'/'.$device['hostname']); + } + } + if ($config['oxidized']['features']['versioning'] === true) { + $config_versions = json_decode(file_get_contents($config['oxidized']['url'].'/node/version?node_full='.$device['hostname'].'&format=json'), true); } - if (is_array($node_info)) { + if (is_array($node_info) || is_array($config_versions)) { echo '
-
-
-
Sync status: '.$node_info['last']['status'].'
-
    -
  • Node: '.$node_info['name'].'
  • -
  • IP: '.$node_info['ip'].'
  • -
  • Model: '.$node_info['model'].'
  • -
  • Last Sync: '.$node_info['last']['end'].'
  • -
-
-
-
'; + '; + + if (is_array($node_info)) { + echo ' +
+
+
Sync status: '.$node_info['last']['status'].'
+ +
+
+ '; + } + + if (is_array($config_versions)) { + echo ' +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ '; + } + + echo ''; } else { echo '
';