mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
feature: Add Basic Oxidized Node List (#6017)
* feature: Add Basic Oxidized Node List
This commit is contained in:
committed by
Neil Lathwood
parent
55384ad1b0
commit
db58fea2d2
@@ -1436,3 +1436,39 @@ function set_image_type()
|
|||||||
return header('Content-type: image/png');
|
return header('Content-type: image/png');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_oxidized_nodes_list()
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$context = stream_context_create(array(
|
||||||
|
'http' => array(
|
||||||
|
'header' => "Accept: application/json",
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
$data = json_decode(file_get_contents($config['oxidized']['url'] . '/nodes?format=json', false, $context), true);
|
||||||
|
|
||||||
|
foreach ($data as $object) {
|
||||||
|
$device = device_by_name($object['name']);
|
||||||
|
$fa_color = $object['status'] == 'success' ? 'success' : 'danger';
|
||||||
|
echo "
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
" . generate_device_link($device) . "
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<i class='fa fa-square text-" . $fa_color . "'></i>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
" . $object['time'] . "
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
" . $object['model'] . "
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
" . $object['group'] . "
|
||||||
|
</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -11,22 +11,56 @@
|
|||||||
*/
|
*/
|
||||||
$pagetitle[] = 'Oxidized';
|
$pagetitle[] = 'Oxidized';
|
||||||
?>
|
?>
|
||||||
<h3> Oxidized - Config Search </h3>
|
<div class="col-xs-12">
|
||||||
<hr>
|
<h2>Oxidized</h2>
|
||||||
<form class="form-horizontal" action="" method="post">
|
<div class="panel-heading">
|
||||||
<br />
|
<ul class="nav nav-tabs">
|
||||||
<div class="input-group">
|
<li class="active"><a href="#list" data-toggle="tab">Node List</a></li>
|
||||||
<input type="text" class="form-control" id="input-parameter" placeholder="service password-encryption etc.">
|
<li><a href="#search" data-toggle="tab">Config Search</a></li>
|
||||||
<span class="input-group-btn">
|
</ul>
|
||||||
<button type="submit" name="btn-search" id="btn-search" class="btn btn-primary">Search</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
<div class="panel with-nav-tabs panel-default">
|
||||||
<br />
|
<div class="panel-body">
|
||||||
<div id="search-output" class="alert alert-success" style="display: none;"></div>
|
<div class="tab-content">
|
||||||
<br />
|
<div class="tab-pane fade in active" id="list">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="oxidized-nodes" class="table table-hover table-condensed table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-column-id="hostname" data-order="desc">Hostname</th>
|
||||||
|
<th data-column-id="last_status">Last Status</th>
|
||||||
|
<th data-column-id="last_update">Last Update</th>
|
||||||
|
<th data-column-id="model">Model</th>
|
||||||
|
<th data-column-id="group">Group</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php get_oxidized_nodes_list();?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="tab-pane fade" id="search">
|
||||||
|
<form class="form-horizontal" action="" method="post">
|
||||||
|
<br/>
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" class="form-control" id="input-parameter"
|
||||||
|
placeholder="service password-encryption etc.">
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<button type="submit" name="btn-search" id="btn-search" class="btn btn-primary">Search</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<br/>
|
||||||
|
<div id="search-output" class="alert alert-success" style="display: none;"></div>
|
||||||
|
<br/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$("[name='btn-search']").on('click', function(event) {
|
$("[name='btn-search']").on('click', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var search_in_conf_textbox = $("#input-parameter").val();
|
var search_in_conf_textbox = $("#input-parameter").val();
|
||||||
@@ -38,16 +72,16 @@ $pagetitle[] = 'Oxidized';
|
|||||||
search_in_conf_textbox: search_in_conf_textbox
|
search_in_conf_textbox: search_in_conf_textbox
|
||||||
},
|
},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function (data) {
|
||||||
$('#search-output').empty();
|
$('#search-output').empty();
|
||||||
$("#search-output").show();
|
$("#search-output").show();
|
||||||
if (data.output)
|
if (data.output)
|
||||||
$('#search-output').append('Config appears on the folllowing device(s):<br />');
|
$('#search-output').append('Config appears on the folllowing device(s):<br />');
|
||||||
$.each(data.output, function(row, value) {
|
$.each(data.output, function (row, value) {
|
||||||
$('#search-output').append(value['full_name'] + '<br />');
|
$('#search-output').append(value['full_name'] + '<br />');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function () {
|
||||||
toastr.error('Error');
|
toastr.error('Error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user