mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added API to feed into Oxidized
This commit is contained in:
@ -17,6 +17,7 @@
|
|||||||
- [`get_graph_by_port_hostname`](#api-route-9)
|
- [`get_graph_by_port_hostname`](#api-route-9)
|
||||||
- [`list_devices`](#api-route-10)
|
- [`list_devices`](#api-route-10)
|
||||||
- [`add_device`](#api-route-11)
|
- [`add_device`](#api-route-11)
|
||||||
|
- [`list_oxidized`](#api-route-21)
|
||||||
- [`routing`](#api-routing)
|
- [`routing`](#api-routing)
|
||||||
- [`list_bgp`](#api-route-1)
|
- [`list_bgp`](#api-route-1)
|
||||||
- [`switching`](#api-switching)
|
- [`switching`](#api-switching)
|
||||||
@ -395,6 +396,36 @@ Output:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### <a name="api-route-21">Function: `list_oxidized`</a> [`top`](#top)
|
||||||
|
|
||||||
|
List devices for use with Oxidized.
|
||||||
|
|
||||||
|
Route: /api/v0/oxidized
|
||||||
|
|
||||||
|
Input (JSON):
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
```curl
|
||||||
|
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/oxidized
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```text
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"hostname": "localhost",
|
||||||
|
"os": "linux"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hostname": "otherserver",
|
||||||
|
"os": "linux"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
## <a name="api-routing">`Routing`</a> [`top`](#top)
|
## <a name="api-routing">`Routing`</a> [`top`](#top)
|
||||||
|
|
||||||
### <a name="api-route-1">Function: `list_bgp`</a> [`top`](#top)
|
### <a name="api-route-1">Function: `list_bgp`</a> [`top`](#top)
|
||||||
|
@ -29,6 +29,7 @@ $app->setName('api');
|
|||||||
$app->group('/api', function() use ($app) {
|
$app->group('/api', function() use ($app) {
|
||||||
$app->group('/v0', function() use ($app) {
|
$app->group('/v0', function() use ($app) {
|
||||||
$app->get('/bgp', 'authToken', 'list_bgp')->name('list_bgp');//api/v0/bgp
|
$app->get('/bgp', 'authToken', 'list_bgp')->name('list_bgp');//api/v0/bgp
|
||||||
|
$app->get('/oxidized', 'authToken', 'list_oxidized')->name('list_oxidized');
|
||||||
$app->group('/devices', function() use ($app) {
|
$app->group('/devices', function() use ($app) {
|
||||||
$app->delete('/:hostname', 'authToken', 'del_device')->name('del_device');//api/v0/devices/$hostname
|
$app->delete('/:hostname', 'authToken', 'del_device')->name('del_device');//api/v0/devices/$hostname
|
||||||
$app->get('/:hostname', 'authToken', 'get_device')->name('get_device');//api/v0/devices/$hostname
|
$app->get('/:hostname', 'authToken', 'get_device')->name('get_device');//api/v0/devices/$hostname
|
||||||
|
@ -699,3 +699,17 @@ function get_inventory() {
|
|||||||
$app->response->headers->set('Content-Type', 'application/json');
|
$app->response->headers->set('Content-Type', 'application/json');
|
||||||
echo _json_encode($output);
|
echo _json_encode($output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function list_oxidized() {
|
||||||
|
// return details of a single device
|
||||||
|
$app = \Slim\Slim::getInstance();
|
||||||
|
$app->response->headers->set('Content-Type', 'application/json');
|
||||||
|
|
||||||
|
$devices = array();
|
||||||
|
foreach (dbFetchRows("SELECT hostname,os FROM `devices` WHERE `status`='1'") as $device) {
|
||||||
|
$devices[] = $device;
|
||||||
|
}
|
||||||
|
$app->response->headers->set('Content-Type', 'application/json');
|
||||||
|
echo _json_encode($devices);
|
||||||
|
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user