feature: Oxidized basic config search (#5333)

This commit is contained in:
Søren Rosiak
2017-01-09 21:09:02 +02:00
committed by Neil Lathwood
parent b3f6218359
commit 92aab1608d
4 changed files with 112 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2017 Søren Friis Rosiak <sorenrosiak@gmail.com>
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
header('Content-type: application/json');
$status = 'error';
$message = 'unknown error';
$parameters = clean($_POST['search_in_conf_textbox']);
if (isset($parameters)) {
$status = 'ok';
$message = 'Queried';
$output = clean(search_oxidized_config($parameters));
} else {
$status = 'error';
$message = 'ERROR: Could not query';
}
echo _json_encode(array(
'status' => $status,
'message' => $message,
'search_in_conf_textbox' => $parameters,
'output' => $output
));

View File

@@ -1362,3 +1362,23 @@ function get_rules_from_json()
global $config;
return json_decode(file_get_contents($config['install_dir'] . '/misc/alert_rules.json'), true);
}
function search_oxidized_config($search_in_conf_textbox)
{
global $config;
$oxidized_search_url = $config['oxidized']['url'] . '/nodes/conf_search?format=json';
$postdata = http_build_query(
array(
'search_in_conf_textbox' => $search_in_conf_textbox,
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
return json_decode(file_get_contents($oxidized_search_url, false, $context), true);
}

View File

@@ -89,6 +89,12 @@ if ($config['title_image']) {
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-wrench fa-fw fa-lg" aria-hidden="true"></i> Tools</a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="<?php echo(generate_url(array('page'=>'ripenccapi'))); ?>"><i class="fa fa-arrow-circle-up fa-fw fa-lg" aria-hidden="true"></i> RIPE NCC API</a></li>
<?php
if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) {
echo '<li><a href="'.generate_url(array('page'=>'oxidized')).'"><i class="fa fa-arrow-circle-up fa-fw fa-lg" aria-hidden="true"></i> Oxidized</a></li>';
}
?>
</ul>
</li>
<li role="presentation" class="divider"></li>