Add more API examples
This commit is contained in:
parent
9205491af8
commit
ff5c9fe224
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
* Created by cmiles on 9/21/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var express = require('express');
|
||||||
|
var router = express.Router();
|
||||||
|
|
||||||
|
router.get('/', function(req, res, next) {
|
||||||
|
return_data = {
|
||||||
|
"cpu_utilization": cpu_utilization,
|
||||||
|
"leases_per_second": current_leases_per_second,
|
||||||
|
"leases_per_minute": leases_per_minute,
|
||||||
|
"host_name": host_name
|
||||||
|
};
|
||||||
|
|
||||||
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.send(JSON.stringify(return_data));
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
3
app.js
3
app.js
|
@ -52,6 +52,7 @@ app.use('/api/get_subnet_details/', require('./api/get_subnet_details'));
|
||||||
app.use('/api/get_vendor_count/', require('./api/get_vendor_count'));
|
app.use('/api/get_vendor_count/', require('./api/get_vendor_count'));
|
||||||
app.use('/api/get_mac_oui_count_by_vendor/', require('./api/get_mac_oui_count_by_vendor'));
|
app.use('/api/get_mac_oui_count_by_vendor/', require('./api/get_mac_oui_count_by_vendor'));
|
||||||
app.use('/api/get_dhcp_requests/', require('./api/get_dhcp_requests'));
|
app.use('/api/get_dhcp_requests/', require('./api/get_dhcp_requests'));
|
||||||
|
app.use('/api/get_server_info/', require('./api/get_server_info'));
|
||||||
|
|
||||||
app.set('view engine', 'html');
|
app.set('view engine', 'html');
|
||||||
|
|
||||||
|
@ -94,7 +95,7 @@ options.interval = 1000;
|
||||||
|
|
||||||
debug_watch_lease_parse_stream = 0;
|
debug_watch_lease_parse_stream = 0;
|
||||||
|
|
||||||
host_name = execSync("cat /etc/hostname").toString();
|
host_name = execSync("cat /etc/hostname").toString().replace("\n", "");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ingest OUI Database
|
* Ingest OUI Database
|
||||||
|
|
|
@ -6,21 +6,12 @@ function api_example(example) {
|
||||||
var start_time = new Date().getTime();
|
var start_time = new Date().getTime();
|
||||||
|
|
||||||
switch(example) {
|
switch(example) {
|
||||||
case "get_active_leases":
|
|
||||||
$("#get_active_leases").html(loader_html);
|
|
||||||
$.getJSON( "/api/get_active_leases", function( data ) {
|
|
||||||
var request_time = (new Date().getTime() - start_time) / 1000;
|
|
||||||
$("#get_active_leases").html('Server Response Time: ' + request_time + 'ms <pre style="margin-top:20px">' + JSON.stringify(data, null, 2) + '</pre>');
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "get_subnet_details":
|
|
||||||
$("#get_subnet_details").html(loader_html);
|
|
||||||
$.getJSON( "/api/get_subnet_details", function( data ) {
|
|
||||||
var request_time = (new Date().getTime() - start_time) / 1000;
|
|
||||||
$("#get_subnet_details").html('Server Response Time: ' + request_time + 'ms <pre style="margin-top:20px">' + JSON.stringify(data, null, 2) + '</pre>');
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
|
$("#" + example).html(loader_html);
|
||||||
|
$.getJSON( "/api/" + example, function( data ) {
|
||||||
|
var request_time = (new Date().getTime() - start_time) / 1000;
|
||||||
|
$("#" + example).html('Server Response Time: ' + request_time + 'ms <pre style="margin-top:20px">' + JSON.stringify(data, null, 2) + '</pre>');
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,69 +1,225 @@
|
||||||
<!-- Get Active Leases -->
|
<!-- Get Active Leases -->
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
<div class="row clearfix">
|
||||||
<div class="card">
|
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||||
<div class="header">
|
<div class="card">
|
||||||
<h2>
|
<div class="header">
|
||||||
GET: Active Leases
|
<h2>
|
||||||
</h2>
|
GET: Active Leases Data
|
||||||
</div>
|
</h2>
|
||||||
<div class="body">
|
|
||||||
<label>Call</label>
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="form-line">
|
|
||||||
<input disabled type="input" class="form-control" value="/api/get_active_leases" autocomplete="off">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<label>URL Example</label>
|
<div class="body">
|
||||||
<div class="form-group">
|
<label>Call</label>
|
||||||
<div class="form-line">
|
<div class="form-group">
|
||||||
<input disabled type="input" class="form-control api_url" value="/api/get_active_leases" autocomplete="off">
|
<div class="form-line">
|
||||||
|
<input disabled type="input" class="form-control" value="/api/get_active_leases" autocomplete="off">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<label>URL Example</label>
|
||||||
<label>Test</label>
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<div class="form-line">
|
||||||
<div>
|
<input disabled type="input" class="form-control api_url" value="/api/get_active_leases" autocomplete="off">
|
||||||
<button type="button" onclick="api_example('get_active_leases')" class="btn btn-default waves-effect">Try It!</button>
|
</div>
|
||||||
<button type="button" onclick="raw_api('/api/get_active_leases')" class="btn btn-default waves-effect">Raw</button>
|
</div>
|
||||||
<button type="button" onclick="clear_api('get_active_leases')" class="btn btn-default waves-effect">Clear</button>
|
<label>Test</label>
|
||||||
<div id="get_active_leases" style="margin-top:20px"></div>
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button type="button" onclick="api_example('get_active_leases')" class="btn btn-default waves-effect">Try It!</button>
|
||||||
|
<button type="button" onclick="raw_api('/api/get_active_leases')" class="btn btn-default waves-effect">Raw</button>
|
||||||
|
<button type="button" onclick="clear_api('get_active_leases')" class="btn btn-default waves-effect">Clear</button>
|
||||||
|
<div id="get_active_leases" style="margin-top:20px"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Get Subnet Details -->
|
<!-- Get Subnet Details -->
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
<div class="row clearfix">
|
||||||
<div class="card">
|
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||||
<div class="header">
|
<div class="card">
|
||||||
<h2>
|
<div class="header">
|
||||||
GET: Subnet Details
|
<h2>
|
||||||
</h2>
|
GET: Subnet Details
|
||||||
</div>
|
</h2>
|
||||||
<div class="body">
|
|
||||||
<label>Call</label>
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="form-line">
|
|
||||||
<input disabled type="input" class="form-control" value="/api/get_subnet_details" autocomplete="off">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<label>URL Example</label>
|
<div class="body">
|
||||||
<div class="form-group">
|
<label>Call</label>
|
||||||
<div class="form-line">
|
<div class="form-group">
|
||||||
<input disabled type="input" class="form-control api_url" value="/api/get_subnet_details" autocomplete="off">
|
<div class="form-line">
|
||||||
|
<input disabled type="input" class="form-control" value="/api/get_subnet_details" autocomplete="off">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<label>URL Example</label>
|
||||||
<label>Test</label>
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<div class="form-line">
|
||||||
<div>
|
<input disabled type="input" class="form-control api_url" value="/api/get_subnet_details" autocomplete="off">
|
||||||
<button type="button" onclick="api_example('get_subnet_details')" class="btn btn-default waves-effect">Try It!</button>
|
</div>
|
||||||
<button type="button" onclick="raw_api('/api/get_subnet_details')" class="btn btn-default waves-effect">Raw</button>
|
</div>
|
||||||
<button type="button" onclick="clear_api('get_subnet_details')" class="btn btn-default waves-effect">Clear</button>
|
<label>Test</label>
|
||||||
<div id="get_subnet_details" style="margin-top:20px"></div>
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button type="button" onclick="api_example('get_subnet_details')" class="btn btn-default waves-effect">Try It!</button>
|
||||||
|
<button type="button" onclick="raw_api('/api/get_subnet_details')" class="btn btn-default waves-effect">Raw</button>
|
||||||
|
<button type="button" onclick="clear_api('get_subnet_details')" class="btn btn-default waves-effect">Clear</button>
|
||||||
|
<div id="get_subnet_details" style="margin-top:20px"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="block-header">
|
||||||
|
<h2>Statistics Data</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- GET: Server Info -->
|
||||||
|
<div class="row clearfix">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="header">
|
||||||
|
<h2>
|
||||||
|
GET: Basic Server Info
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div class="body">
|
||||||
|
<label>Call</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-line">
|
||||||
|
<input disabled type="input" class="form-control" value="/api/get_server_info" autocomplete="off">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label>URL Example</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-line">
|
||||||
|
<input disabled type="input" class="form-control api_url" value="/api/get_server_info" autocomplete="off">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label>Test</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button type="button" onclick="api_example('get_server_info')" class="btn btn-default waves-effect">Try It!</button>
|
||||||
|
<button type="button" onclick="raw_api('/api/get_server_info')" class="btn btn-default waves-effect">Raw</button>
|
||||||
|
<button type="button" onclick="clear_api('get_server_info')" class="btn btn-default waves-effect">Clear</button>
|
||||||
|
<div id="get_server_info" style="margin-top:20px"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- GET: Vendor Count -->
|
||||||
|
<div class="row clearfix">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="header">
|
||||||
|
<h2>
|
||||||
|
GET: Device Count by Vendor
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div class="body">
|
||||||
|
<label>Call</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-line">
|
||||||
|
<input disabled type="input" class="form-control" value="/api/get_vendor_count" autocomplete="off">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label>URL Example</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-line">
|
||||||
|
<input disabled type="input" class="form-control api_url" value="/api/get_vendor_count" autocomplete="off">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label>Test</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button type="button" onclick="api_example('get_vendor_count')" class="btn btn-default waves-effect">Try It!</button>
|
||||||
|
<button type="button" onclick="raw_api('/api/get_vendor_count')" class="btn btn-default waves-effect">Raw</button>
|
||||||
|
<button type="button" onclick="clear_api('get_vendor_count')" class="btn btn-default waves-effect">Clear</button>
|
||||||
|
<div id="get_vendor_count" style="margin-top:20px"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- GET: OUI Count by Vendor -->
|
||||||
|
<div class="row clearfix">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="header">
|
||||||
|
<h2>
|
||||||
|
GET: OUI Count by Vendor
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div class="body">
|
||||||
|
<label>Call</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-line">
|
||||||
|
<input disabled type="input" class="form-control" value="/api/get_mac_oui_count_by_vendor" autocomplete="off">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label>URL Example</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-line">
|
||||||
|
<input disabled type="input" class="form-control api_url" value="/api/get_mac_oui_count_by_vendor" autocomplete="off">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label>Test</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button type="button" onclick="api_example('get_mac_oui_count_by_vendor')" class="btn btn-default waves-effect">Try It!</button>
|
||||||
|
<button type="button" onclick="raw_api('/api/get_mac_oui_count_by_vendor')" class="btn btn-default waves-effect">Raw</button>
|
||||||
|
<button type="button" onclick="clear_api('get_mac_oui_count_by_vendor')" class="btn btn-default waves-effect">Clear</button>
|
||||||
|
<div id="get_mac_oui_count_by_vendor" style="margin-top:20px"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- GET: Excessive DHCP Requests -->
|
||||||
|
<div class="row clearfix">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="header">
|
||||||
|
<h2>
|
||||||
|
GET: Excessive DHCP Requests
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div class="body">
|
||||||
|
<label>Call</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-line">
|
||||||
|
<input disabled type="input" class="form-control" value="/api/get_dhcp_requests" autocomplete="off">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label>URL Example</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-line">
|
||||||
|
<input disabled type="input" class="form-control api_url" value="/api/get_dhcp_requests" autocomplete="off">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label>Test</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button type="button" onclick="api_example('get_dhcp_requests')" class="btn btn-default waves-effect">Try It!</button>
|
||||||
|
<button type="button" onclick="raw_api('/api/get_dhcp_requests')" class="btn btn-default waves-effect">Raw</button>
|
||||||
|
<button type="button" onclick="clear_api('get_dhcp_requests')" class="btn btn-default waves-effect">Clear</button>
|
||||||
|
<div id="get_dhcp_requests" style="margin-top:20px"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue