mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #2455 from Rosiak/issue-2051
Add RIPE NCC API Whois lookup
This commit is contained in:
30
html/includes/forms/query-ripenccapi.inc.php
Normal file
30
html/includes/forms/query-ripenccapi.inc.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2015 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.
|
||||
*/
|
||||
|
||||
$status = 'error';
|
||||
$message = 'unknown error';
|
||||
$parameter = mres($_POST['parameter']);
|
||||
if (isset($parameter)) {
|
||||
$status = 'ok';
|
||||
$message = 'Queried';
|
||||
$output = get_ripe_api_whois_data_json($parameter);
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: Could not query';
|
||||
}
|
||||
die(json_encode(array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
'parameter' => $parameter,
|
||||
'output' => $output
|
||||
)));
|
@@ -1252,3 +1252,9 @@ function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$it
|
||||
}
|
||||
return $output;
|
||||
}//end generate_dynamic_config_panel()
|
||||
|
||||
function get_ripe_api_whois_data_json($ripe_parameter) {
|
||||
$ripe_whois_url = 'https://stat.ripe.net/data/whois/data.json?resource=' . $ripe_parameter;
|
||||
return json_decode(file_get_contents($ripe_whois_url) , true);
|
||||
}//end get_ripe_api_whois_data_json()
|
||||
|
||||
|
@@ -74,6 +74,12 @@ if ($_SESSION['userlevel'] >= '10') {
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'availability-map'))); ?>"><i class="fa fa-arrow-circle-up fa-fw fa-lg"></i> Availability</a></li>
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'map'))); ?>"><i class="fa fa-desktop fa-fw fa-lg"></i> Network</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown-submenu">
|
||||
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-wrench fa-fw fa-lg"></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"></i> RIPE NCC API</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'eventlog'))); ?>"><i class="fa fa-book fa-fw fa-lg"></i> Eventlog</a></li>
|
||||
|
51
html/pages/ripenccapi.inc.php
Normal file
51
html/pages/ripenccapi.inc.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2015 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.
|
||||
*/
|
||||
$pagetitle[] = 'RIPE NCC - API Tools';
|
||||
?>
|
||||
<h3> RIPE NCC API Tools </h3>
|
||||
<hr>
|
||||
<h4> Whois </h4>
|
||||
<form class="form-horizontal" action="" method="post">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="input-parameter" placeholder="IP, ASN etc.">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" name="btn-query" id="btn-query" class="btn btn-primary">Query</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
<br />
|
||||
<div id="ripe-output" style="font-family: Courier New; background-color: lightgray;"></div>
|
||||
<br />
|
||||
<script>
|
||||
$("[name='btn-query']").on('click', function(event) {
|
||||
event.preventDefault();
|
||||
var $this = $(this);
|
||||
var parameter = $("#input-parameter").val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax_form.php',
|
||||
data: { type: "query-ripenccapi", parameter: parameter},
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
$('#ripe-output').empty();
|
||||
if (data.output.data.records) {
|
||||
$.each(data.output.data.records[0], function (row,value) {
|
||||
$('#ripe-output').append(value['key'] + ' = ' + value['value'] +'<br />');
|
||||
});
|
||||
}
|
||||
},
|
||||
error:function(){
|
||||
toastr.error('Error');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
Reference in New Issue
Block a user