mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added support for Oxidized versioning
This commit is contained in:
40
doc/Extensions/Oxidized.md
Normal file
40
doc/Extensions/Oxidized.md
Normal file
@@ -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'
|
||||||
|
```
|
||||||
@@ -94,26 +94,76 @@ if ($_SESSION['userlevel'] >= '7') {
|
|||||||
}
|
}
|
||||||
else if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) {
|
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);
|
$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 ($config['oxidized']['features']['versioning'] === true && isset($_POST['config'])) {
|
||||||
if ($text == 'node not found') {
|
list($oid,$date,$version) = explode('|',mres($_POST['config']));
|
||||||
$text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['os'].'/'.$device['hostname']);
|
$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 '<br />
|
echo '<br />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-4">
|
';
|
||||||
<div class="panel panel-primary">
|
|
||||||
<div class="panel-heading">Sync status: <strong>'.$node_info['last']['status'].'</strong></div>
|
if (is_array($node_info)) {
|
||||||
<ul class="list-group">
|
echo '
|
||||||
<li class="list-group-item"><strong>Node:</strong> '.$node_info['name'].'</strong></li>
|
<div class="col-sm-4">
|
||||||
<li class="list-group-item"><strong>IP:</strong> '.$node_info['ip'].'</strong></li>
|
<div class="panel panel-primary">
|
||||||
<li class="list-group-item"><strong>Model:</strong> '.$node_info['model'].'</strong></li>
|
<div class="panel-heading">Sync status: <strong>'.$node_info['last']['status'].'</strong></div>
|
||||||
<li class="list-group-item"><strong>Last Sync:</strong> '.$node_info['last']['end'].'</strong></li>
|
<ul class="list-group">
|
||||||
</ul>
|
<li class="list-group-item"><strong>Node:</strong> '.$node_info['name'].'</strong></li>
|
||||||
</div>
|
<li class="list-group-item"><strong>IP:</strong> '.$node_info['ip'].'</strong></li>
|
||||||
</div>
|
<li class="list-group-item"><strong>Model:</strong> '.$node_info['model'].'</strong></li>
|
||||||
</div>';
|
<li class="list-group-item"><strong>Last Sync:</strong> '.$node_info['last']['end'].'</strong></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($config_versions)) {
|
||||||
|
echo '
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<form class="form-horizontal" action="" method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="config" class="col-sm-2 control-label">Config version</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<select id="config" name="config" class="form-control">
|
||||||
|
<option value="">Select version</option>
|
||||||
|
';
|
||||||
|
|
||||||
|
$config_total = count($config_versions);
|
||||||
|
foreach ($config_versions as $version) {
|
||||||
|
echo '<option value="'.$version['oid'].'|'.$version['date'].'|'.$config_total.'">'.$config_total.' :: '.$version['date'].' - '.$version['message'].'</option>';
|
||||||
|
$config_total--;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-6">
|
||||||
|
<button type="submit" class="btn btn-primary btn-sm">Show version</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
|
|||||||
Reference in New Issue
Block a user