mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 02:18:39 +00:00
Support for InfluxDB V2 API (#15861)
* Addition of influxdb-client-php to Composer. * Addtion of InfluxDBv2 support. * Addition of front-end options. * Addition of documentation. * Addition of the acknowledgement of the PHP library used. * Fixed a unneeded bracket. * Addition of a basic datastore test. * StyleCI fixes. * StyleCI fixes. * StyleCI fixes. * Fixed exception class. * Revert accidental change. * Fix to composer lock to not update all packages. * Fix to composer lock to not update all packages, but still include the new Influx lib. * Another attempt at getting Composer to behave the way I think it should work. * Fixed merge-conflict in Composer due to #15869. * Update composer.json * Update composer.lock * Update composer.json * Update composer.lock --------- Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
parent
4975a984b6
commit
c855d6c2fe
@ -47,6 +47,7 @@ class Datastore implements DataStorageInterface
|
||||
'f' => 'influxdb.enable',
|
||||
'p' => 'prometheus.enable',
|
||||
'g' => 'graphite.enable',
|
||||
'2' => 'influxdbv2.enable',
|
||||
];
|
||||
foreach ($opts as $opt => $setting) {
|
||||
if (isset($options[$opt])) {
|
||||
|
175
LibreNMS/Data/Store/InfluxDBv2.php
Normal file
175
LibreNMS/Data/Store/InfluxDBv2.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/**
|
||||
* InfluxDBv2.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @link https://www.librenms.org
|
||||
*
|
||||
* @copyright 2024 Tony Murray
|
||||
* @copyright 2024 Ruben van Komen <https://github.com/walkablenormal>
|
||||
* @author Ruben van Komen <rubenvankomen@gmail.com>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Data\Store;
|
||||
|
||||
use App\Polling\Measure\Measurement;
|
||||
use InfluxDB2\Client;
|
||||
use InfluxDB2\Model\WritePrecision;
|
||||
use InfluxDB2\Point;
|
||||
use LibreNMS\Config;
|
||||
use Log;
|
||||
|
||||
class InfluxDBv2 extends BaseDatastore
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'InfluxDBv2';
|
||||
}
|
||||
|
||||
public static function isEnabled()
|
||||
{
|
||||
return Config::get('influxdbv2.enable', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Datastore-independent function which should be used for all polled metrics.
|
||||
*
|
||||
* RRD Tags:
|
||||
* rrd_def RrdDefinition
|
||||
* rrd_name array|string: the rrd filename, will be processed with rrd_name()
|
||||
* rrd_oldname array|string: old rrd filename to rename, will be processed with rrd_name()
|
||||
* rrd_step int: rrd step, defaults to 300
|
||||
*
|
||||
* @param array $device
|
||||
* @param string $measurement Name of this measurement
|
||||
* @param array $tags tags for the data (or to control rrdtool)
|
||||
* @param array|mixed $fields The data to update in an associative array, the order must be consistent with rrd_def,
|
||||
* single values are allowed and will be paired with $measurement
|
||||
*/
|
||||
public function put($device, $measurement, $tags, $fields)
|
||||
{
|
||||
$stat = Measurement::start('write');
|
||||
$tmp_fields = [];
|
||||
$tmp_tags['hostname'] = $device['hostname'];
|
||||
foreach ($tags as $k => $v) {
|
||||
if (empty($v)) {
|
||||
$v = '_blank_';
|
||||
}
|
||||
$tmp_tags[$k] = $v;
|
||||
}
|
||||
foreach ($fields as $k => $v) {
|
||||
if ($k == 'time') {
|
||||
$k = 'rtime';
|
||||
}
|
||||
|
||||
if (($value = $this->forceType($v)) !== null) {
|
||||
$tmp_fields[$k] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($tmp_fields)) {
|
||||
Log::warning('All fields empty, skipping update', ['orig_fields' => $fields]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Log::debug('InfluxDB data: ', [
|
||||
'measurement' => $measurement,
|
||||
'tags' => $tmp_tags,
|
||||
'fields' => $tmp_fields,
|
||||
]);
|
||||
|
||||
// Get a WriteApi instance from the client
|
||||
$client = self::createFromConfig();
|
||||
$writeApi = $client->createWriteApi();
|
||||
try {
|
||||
// Construct data points using the InfluxDB2\Point class
|
||||
$point = Point::measurement($measurement)
|
||||
->addTag('hostname', $device['hostname'])
|
||||
->time(microtime(true)); // Assuming you want to use the current time
|
||||
|
||||
// Write the data points to the database using the WriteApi instance
|
||||
foreach ($tmp_fields as $field => $value) {
|
||||
$point->addField($field, $value);
|
||||
}
|
||||
|
||||
// Adding tags from $tmpTags array
|
||||
foreach ($tmp_tags as $tag => $value) {
|
||||
$point->addTag($tag, $value);
|
||||
}
|
||||
|
||||
$writeApi->write($point);
|
||||
|
||||
$this->recordStatistic($stat->end());
|
||||
} catch (\InfluxDB2\ApiException $e) {
|
||||
print_r($e);
|
||||
// Handle exceptions
|
||||
} finally {
|
||||
// Close the WriteApi to free resources
|
||||
$writeApi->close();
|
||||
}
|
||||
}
|
||||
|
||||
public static function createFromConfig()
|
||||
{
|
||||
$host = Config::get('influxdbv2.host', 'localhost');
|
||||
$transport = Config::get('influxdbv2.transport', 'http');
|
||||
$port = Config::get('influxdbv2.port', 8086);
|
||||
$bucket = Config::get('influxdbv2.bucket', 'librenms');
|
||||
$organization = Config::get('influxdbv2.organization', '');
|
||||
$allow_redirects = Config::get('influxdbv2.allow_redirects', true);
|
||||
$token = Config::get('influxdbv2.token', '');
|
||||
|
||||
$client = new Client([
|
||||
'url' => $transport . '://' . $host . ':' . $port,
|
||||
'token' => $token,
|
||||
'bucket' => $bucket,
|
||||
'org' => $organization,
|
||||
'precision' => WritePrecision::S,
|
||||
'allow_redirects' => $allow_redirects,
|
||||
'debug' => true,
|
||||
]);
|
||||
|
||||
return $client;
|
||||
}
|
||||
|
||||
private function forceType($data)
|
||||
{
|
||||
/*
|
||||
* It is not trivial to detect if something is a float or an integer, and
|
||||
* therefore may cause breakages on inserts.
|
||||
* Just setting every number to a float gets around this, but may introduce
|
||||
* inefficiencies.
|
||||
*/
|
||||
|
||||
if (is_numeric($data)) {
|
||||
return floatval($data);
|
||||
}
|
||||
|
||||
return $data === 'U' ? null : $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the datastore wants rrdtags to be sent when issuing put()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function wantsRrdTags()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@ -85,6 +85,7 @@ class ModuleTestHelper
|
||||
Config::set('rrd.enable', false);
|
||||
Config::set('hide_rrd_disabled', true);
|
||||
Config::set('influxdb.enable', false);
|
||||
Config::set('influxdbv2.enable', false);
|
||||
Config::set('graphite.enable', false);
|
||||
Config::set('prometheus.enable', false);
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ class DevicePoll extends LnmsCommand
|
||||
if ($this->option('no-data')) {
|
||||
Config::set('rrd.enable', false);
|
||||
Config::set('influxdb.enable', false);
|
||||
Config::set('influxdbv2.enable', false);
|
||||
Config::set('prometheus.enable', false);
|
||||
Config::set('graphite.enable', false);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ class DatastoreServiceProvider extends ServiceProvider
|
||||
protected $stores = [
|
||||
'LibreNMS\Data\Store\Graphite',
|
||||
'LibreNMS\Data\Store\InfluxDB',
|
||||
'LibreNMS\Data\Store\InfluxDBv2',
|
||||
'LibreNMS\Data\Store\OpenTSDB',
|
||||
'LibreNMS\Data\Store\Prometheus',
|
||||
'LibreNMS\Data\Store\Rrd',
|
||||
|
@ -34,6 +34,7 @@
|
||||
"easybook/geshi": "^1.0.8",
|
||||
"ezyang/htmlpurifier": "^4.8",
|
||||
"fico7489/laravel-pivot": "^3.0",
|
||||
"influxdata/influxdb-client-php": "^3.4",
|
||||
"influxdb/influxdb-php": "^1.15",
|
||||
"justinrainbow/json-schema": "^5.2",
|
||||
"laravel-notification-channels/webpush": "^7.1",
|
||||
@ -87,7 +88,10 @@
|
||||
"optimize-autoloader": true,
|
||||
"platform-check": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"php-http/discovery": false
|
||||
}
|
||||
},
|
||||
"extra":
|
||||
{
|
||||
|
577
composer.lock
generated
577
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "58f64a166757fcc5ae4e5b22cfdd5d05",
|
||||
"content-hash": "dd407332d453e562b204848f9044161b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "amenadiel/jpgraph",
|
||||
@ -271,6 +271,72 @@
|
||||
],
|
||||
"time": "2022-04-14T14:58:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "clue/stream-filter",
|
||||
"version": "v1.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/clue/stream-filter.git",
|
||||
"reference": "049509fef80032cb3f051595029ab75b49a3c2f7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/clue/stream-filter/zipball/049509fef80032cb3f051595029ab75b49a3c2f7",
|
||||
"reference": "049509fef80032cb3f051595029ab75b49a3c2f7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Clue\\StreamFilter\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Christian Lück",
|
||||
"email": "christian@clue.engineering"
|
||||
}
|
||||
],
|
||||
"description": "A simple and modern approach to stream filtering in PHP",
|
||||
"homepage": "https://github.com/clue/stream-filter",
|
||||
"keywords": [
|
||||
"bucket brigade",
|
||||
"callback",
|
||||
"filter",
|
||||
"php_user_filter",
|
||||
"stream",
|
||||
"stream_filter_append",
|
||||
"stream_filter_register"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/clue/stream-filter/issues",
|
||||
"source": "https://github.com/clue/stream-filter/tree/v1.7.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://clue.engineering/support",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/clue",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-12-20T15:40:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dapphp/radius",
|
||||
"version": "v3.0.0",
|
||||
@ -1763,6 +1829,56 @@
|
||||
],
|
||||
"time": "2023-12-03T19:50:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "influxdata/influxdb-client-php",
|
||||
"version": "3.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/influxdata/influxdb-client-php.git",
|
||||
"reference": "9db0d74595cbca08d9e2ce59814fc967c1b36531"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/influxdata/influxdb-client-php/zipball/9db0d74595cbca08d9e2ce59814fc967c1b36531",
|
||||
"reference": "9db0d74595cbca08d9e2ce59814fc967c1b36531",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=7.2",
|
||||
"php-http/client-common": "^2.2.1",
|
||||
"php-http/discovery": "^1.9.1",
|
||||
"psr/http-client": "^1.0.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"guzzlehttp/psr7": "^2.0.0",
|
||||
"phpunit/phpunit": "^8.5.27",
|
||||
"squizlabs/php_codesniffer": "~3.7"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"InfluxDB2\\": "src/InfluxDB2"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "InfluxDB (v2+) Client Library for PHP",
|
||||
"homepage": "https://www.github.com/influxdata/influxdb-client-php",
|
||||
"keywords": [
|
||||
"influxdb"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/influxdata/influxdb-client-php/issues",
|
||||
"source": "https://github.com/influxdata/influxdb-client-php/tree/3.4.0"
|
||||
},
|
||||
"time": "2023-07-28T03:48:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "influxdb/influxdb-php",
|
||||
"version": "1.15.2",
|
||||
@ -4356,6 +4472,331 @@
|
||||
],
|
||||
"time": "2024-01-21T17:30:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-http/client-common",
|
||||
"version": "2.7.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-http/client-common.git",
|
||||
"reference": "1e19c059b0e4d5f717bf5d524d616165aeab0612"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-http/client-common/zipball/1e19c059b0e4d5f717bf5d524d616165aeab0612",
|
||||
"reference": "1e19c059b0e4d5f717bf5d524d616165aeab0612",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0",
|
||||
"php-http/httplug": "^2.0",
|
||||
"php-http/message": "^1.6",
|
||||
"psr/http-client": "^1.0",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-message": "^1.0 || ^2.0",
|
||||
"symfony/options-resolver": "~4.0.15 || ~4.1.9 || ^4.2.1 || ^5.0 || ^6.0 || ^7.0",
|
||||
"symfony/polyfill-php80": "^1.17"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/instantiator": "^1.1",
|
||||
"guzzlehttp/psr7": "^1.4",
|
||||
"nyholm/psr7": "^1.2",
|
||||
"phpspec/phpspec": "^5.1 || ^6.3 || ^7.1",
|
||||
"phpspec/prophecy": "^1.10.2",
|
||||
"phpunit/phpunit": "^7.5.20 || ^8.5.33 || ^9.6.7"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-json": "To detect JSON responses with the ContentTypePlugin",
|
||||
"ext-libxml": "To detect XML responses with the ContentTypePlugin",
|
||||
"php-http/cache-plugin": "PSR-6 Cache plugin",
|
||||
"php-http/logger-plugin": "PSR-3 Logger plugin",
|
||||
"php-http/stopwatch-plugin": "Symfony Stopwatch plugin"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Http\\Client\\Common\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Márk Sági-Kazár",
|
||||
"email": "mark.sagikazar@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Common HTTP Client implementations and tools for HTTPlug",
|
||||
"homepage": "http://httplug.io",
|
||||
"keywords": [
|
||||
"client",
|
||||
"common",
|
||||
"http",
|
||||
"httplug"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-http/client-common/issues",
|
||||
"source": "https://github.com/php-http/client-common/tree/2.7.1"
|
||||
},
|
||||
"time": "2023-11-30T10:31:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-http/discovery",
|
||||
"version": "1.19.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-http/discovery.git",
|
||||
"reference": "61e1a1eb69c92741f5896d9e05fb8e9d7e8bb0cb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-http/discovery/zipball/61e1a1eb69c92741f5896d9e05fb8e9d7e8bb0cb",
|
||||
"reference": "61e1a1eb69c92741f5896d9e05fb8e9d7e8bb0cb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.0|^2.0",
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"conflict": {
|
||||
"nyholm/psr7": "<1.0",
|
||||
"zendframework/zend-diactoros": "*"
|
||||
},
|
||||
"provide": {
|
||||
"php-http/async-client-implementation": "*",
|
||||
"php-http/client-implementation": "*",
|
||||
"psr/http-client-implementation": "*",
|
||||
"psr/http-factory-implementation": "*",
|
||||
"psr/http-message-implementation": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "^1.0.2|^2.0",
|
||||
"graham-campbell/phpspec-skip-example-extension": "^5.0",
|
||||
"php-http/httplug": "^1.0 || ^2.0",
|
||||
"php-http/message-factory": "^1.0",
|
||||
"phpspec/phpspec": "^5.1 || ^6.1 || ^7.3",
|
||||
"symfony/phpunit-bridge": "^6.2"
|
||||
},
|
||||
"type": "composer-plugin",
|
||||
"extra": {
|
||||
"class": "Http\\Discovery\\Composer\\Plugin",
|
||||
"plugin-optional": true
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Http\\Discovery\\": "src/"
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"src/Composer/Plugin.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Márk Sági-Kazár",
|
||||
"email": "mark.sagikazar@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations",
|
||||
"homepage": "http://php-http.org",
|
||||
"keywords": [
|
||||
"adapter",
|
||||
"client",
|
||||
"discovery",
|
||||
"factory",
|
||||
"http",
|
||||
"message",
|
||||
"psr17",
|
||||
"psr7"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-http/discovery/issues",
|
||||
"source": "https://github.com/php-http/discovery/tree/1.19.2"
|
||||
},
|
||||
"time": "2023-11-30T16:49:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-http/httplug",
|
||||
"version": "2.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-http/httplug.git",
|
||||
"reference": "625ad742c360c8ac580fcc647a1541d29e257f67"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-http/httplug/zipball/625ad742c360c8ac580fcc647a1541d29e257f67",
|
||||
"reference": "625ad742c360c8ac580fcc647a1541d29e257f67",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0",
|
||||
"php-http/promise": "^1.1",
|
||||
"psr/http-client": "^1.0",
|
||||
"psr/http-message": "^1.0 || ^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friends-of-phpspec/phpspec-code-coverage": "^4.1 || ^5.0 || ^6.0",
|
||||
"phpspec/phpspec": "^5.1 || ^6.0 || ^7.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Http\\Client\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Eric GELOEN",
|
||||
"email": "geloen.eric@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Márk Sági-Kazár",
|
||||
"email": "mark.sagikazar@gmail.com",
|
||||
"homepage": "https://sagikazarmark.hu"
|
||||
}
|
||||
],
|
||||
"description": "HTTPlug, the HTTP client abstraction for PHP",
|
||||
"homepage": "http://httplug.io",
|
||||
"keywords": [
|
||||
"client",
|
||||
"http"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-http/httplug/issues",
|
||||
"source": "https://github.com/php-http/httplug/tree/2.4.0"
|
||||
},
|
||||
"time": "2023-04-14T15:10:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-http/message",
|
||||
"version": "1.16.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-http/message.git",
|
||||
"reference": "47a14338bf4ebd67d317bf1144253d7db4ab55fd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-http/message/zipball/47a14338bf4ebd67d317bf1144253d7db4ab55fd",
|
||||
"reference": "47a14338bf4ebd67d317bf1144253d7db4ab55fd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"clue/stream-filter": "^1.5",
|
||||
"php": "^7.2 || ^8.0",
|
||||
"psr/http-message": "^1.1 || ^2.0"
|
||||
},
|
||||
"provide": {
|
||||
"php-http/message-factory-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ergebnis/composer-normalize": "^2.6",
|
||||
"ext-zlib": "*",
|
||||
"guzzlehttp/psr7": "^1.0 || ^2.0",
|
||||
"laminas/laminas-diactoros": "^2.0 || ^3.0",
|
||||
"php-http/message-factory": "^1.0.2",
|
||||
"phpspec/phpspec": "^5.1 || ^6.3 || ^7.1",
|
||||
"slim/slim": "^3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-zlib": "Used with compressor/decompressor streams",
|
||||
"guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories",
|
||||
"laminas/laminas-diactoros": "Used with Diactoros Factories",
|
||||
"slim/slim": "Used with Slim Framework PSR-7 implementation"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/filters.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Http\\Message\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Márk Sági-Kazár",
|
||||
"email": "mark.sagikazar@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "HTTP Message related tools",
|
||||
"homepage": "http://php-http.org",
|
||||
"keywords": [
|
||||
"http",
|
||||
"message",
|
||||
"psr-7"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-http/message/issues",
|
||||
"source": "https://github.com/php-http/message/tree/1.16.0"
|
||||
},
|
||||
"time": "2023-05-17T06:43:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-http/promise",
|
||||
"version": "1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-http/promise.git",
|
||||
"reference": "2916a606d3b390f4e9e8e2b8dd68581508be0f07"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-http/promise/zipball/2916a606d3b390f4e9e8e2b8dd68581508be0f07",
|
||||
"reference": "2916a606d3b390f4e9e8e2b8dd68581508be0f07",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friends-of-phpspec/phpspec-code-coverage": "^4.3.2 || ^6.3",
|
||||
"phpspec/phpspec": "^5.1.2 || ^6.2 || ^7.4"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Http\\Promise\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Joel Wurtz",
|
||||
"email": "joel.wurtz@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Márk Sági-Kazár",
|
||||
"email": "mark.sagikazar@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Promise used for asynchronous HTTP requests",
|
||||
"homepage": "http://httplug.io",
|
||||
"keywords": [
|
||||
"promise"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-http/promise/issues",
|
||||
"source": "https://github.com/php-http/promise/tree/1.3.0"
|
||||
},
|
||||
"time": "2024-01-04T18:49:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpmailer/phpmailer",
|
||||
"version": "v6.9.1",
|
||||
@ -7125,6 +7566,73 @@
|
||||
],
|
||||
"time": "2024-01-30T08:32:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/options-resolver",
|
||||
"version": "v6.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/options-resolver.git",
|
||||
"reference": "22301f0e7fdeaacc14318928612dee79be99860e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/22301f0e7fdeaacc14318928612dee79be99860e",
|
||||
"reference": "22301f0e7fdeaacc14318928612dee79be99860e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"symfony/deprecation-contracts": "^2.5|^3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\OptionsResolver\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Provides an improved replacement for the array_replace PHP function",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"config",
|
||||
"configuration",
|
||||
"options"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/options-resolver/tree/v6.4.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-08-08T10:16:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
"version": "v1.29.0",
|
||||
@ -13348,73 +13856,6 @@
|
||||
],
|
||||
"time": "2024-01-23T14:51:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/options-resolver",
|
||||
"version": "v6.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/options-resolver.git",
|
||||
"reference": "22301f0e7fdeaacc14318928612dee79be99860e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/22301f0e7fdeaacc14318928612dee79be99860e",
|
||||
"reference": "22301f0e7fdeaacc14318928612dee79be99860e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"symfony/deprecation-contracts": "^2.5|^3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\OptionsResolver\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Provides an improved replacement for the array_replace PHP function",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"config",
|
||||
"configuration",
|
||||
"options"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/options-resolver/tree/v6.4.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-08-08T10:16:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php73",
|
||||
"version": "v1.29.0",
|
||||
|
@ -4,7 +4,7 @@ hide_toc: true
|
||||
|
||||
By default we ship all metrics to RRD files, either directly or via
|
||||
[RRDCached](RRDCached.md). On top of this you can ship metrics to
|
||||
Graphite, InfluxDB, OpenTSDB or Prometheus. At present you can't use
|
||||
Graphite, InfluxDB (v1 or v2 API), OpenTSDB or Prometheus. At present you can't use
|
||||
these backends to display graphs within LibreNMS and will need to use
|
||||
something like [Grafana](https://grafana.com/).
|
||||
|
||||
@ -13,5 +13,6 @@ the other backends then please see the documentation below.
|
||||
|
||||
- [Graphite](metrics/Graphite.md)
|
||||
- [InfluxDB](metrics/InfluxDB.md)
|
||||
- [InfluxDBv2](metrics/InfluxDBv2.md)
|
||||
- [OpenTSDB](metrics/OpenTSDB.md)
|
||||
- [Prometheus](metrics/Prometheus.md)
|
||||
|
46
doc/Extensions/metrics/InfluxDBv2.md
Normal file
46
doc/Extensions/metrics/InfluxDBv2.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Enabling support for InfluxDBv2
|
||||
|
||||
Before we get started it is important that you know and understand
|
||||
that InfluxDBv2 support is currently alpha at best. All it provides is
|
||||
the sending of data to a InfluxDBv2 bucket. Due to the current changes
|
||||
that are constantly being made to InfluxDB itself then we cannot
|
||||
guarantee that your data will be ok so enabling this support is at
|
||||
your own risk!
|
||||
|
||||
It is also important to understand that InfluxDBv2 only supports the
|
||||
InfluxDBv2 API used in InfluxDB version 2.0 or higher. If you are
|
||||
looking to send data to any other version of InfluxDB than you should
|
||||
use the InfluxDB datastore instead.
|
||||
|
||||
## Requirements
|
||||
|
||||
- InfluxDB >= 2.0
|
||||
|
||||
The setup of the above is completely out of scope here and we aren't
|
||||
really able to provide any help with this side of things.
|
||||
|
||||
## What you don't get
|
||||
|
||||
- Support for InfluxDB, we would highly recommend that you
|
||||
have some level of experience with these.
|
||||
|
||||
RRD will continue to function as normal so LibreNMS itself should
|
||||
continue to function as normal.
|
||||
|
||||
## Configuration
|
||||
|
||||
!!! setting "poller/influxdbv2"
|
||||
```bash
|
||||
lnms config:set influxdbv2.enable true
|
||||
lnms config:set influxdbv2.transport http
|
||||
lnms config:set influxdbv2.host '127.0.0.1'
|
||||
lnms config:set influxdbv2.port 8086
|
||||
lnms config:set influxdbv2.bucket 'librenms'
|
||||
lnms config:set influxdbv2.token 'admin'
|
||||
lnms config:set influxdbv2.allow_redirect true
|
||||
lmns config:set influxdbv2.organization 'librenms'
|
||||
```
|
||||
|
||||
The same data stored within rrd will be sent to InfluxDB and
|
||||
recorded. You can then create graphs within Grafana or InfluxDB to display the
|
||||
information you need.
|
@ -35,6 +35,7 @@ We list below what we make use of including the license compliance.
|
||||
- Code for UBNT Devices Mark Gibbons <mgibbons@oemcomp.com> Initial code base submitted via PR721
|
||||
- [Jquery LazyLoad](http://www.appelsiini.net/projects/lazyload): MIT License
|
||||
- [influxdb-php](https://github.com/influxdb/influxdb-php): MIT License
|
||||
- [influxdb-client-php](https://github.com/influxdata/influxdb-client-php): MIT License
|
||||
- [HTML Purifier](http://htmlpurifier.org/): LGPL v2.1
|
||||
- [Symfony Yaml](https://github.com/symfony/yaml): MIT
|
||||
- [PHPMailer](https://github.com/PHPMailer/PHPMailer): LGPL v2.1
|
||||
|
@ -61,6 +61,7 @@ return [
|
||||
'distributed' => ['name' => 'Distributed Poller'],
|
||||
'graphite' => ['name' => 'Datastore: Graphite'],
|
||||
'influxdb' => ['name' => 'Datastore: InfluxDB'],
|
||||
'influxdbv2' => ['name' => 'Datastore: InfluxDBv2'],
|
||||
'opentsdb' => ['name' => 'Datastore: OpenTSDB'],
|
||||
'ping' => ['name' => 'Ping'],
|
||||
'prometheus' => ['name' => 'Datastore: Prometheus'],
|
||||
@ -448,7 +449,7 @@ return [
|
||||
],
|
||||
'auth_ldap_userdn' => [
|
||||
'description' => 'Use full user DN',
|
||||
'help' => "Uses a user's full DN as the value of the member attribute in a group instead of member: username using the prefix and suffix. (it’s member: uid=username,ou=groups,dc=domain,dc=com)",
|
||||
'help' => "Uses a user's full DN as the value of the member attribute in a group instead of member: username using the prefix and suffix. (it's member: uid=username,ou=groups,dc=domain,dc=com)",
|
||||
],
|
||||
'auth_ldap_wildcard_ou' => [
|
||||
'description' => 'Wildcard user OU',
|
||||
@ -934,6 +935,45 @@ return [
|
||||
'help' => 'Verify the SSL certificate is valid and trusted',
|
||||
],
|
||||
],
|
||||
'influxdbv2' => [
|
||||
'bucket' => [
|
||||
'description' => 'Bucket',
|
||||
'help' => 'Name of the InfluxDB Bucket to store metrics',
|
||||
],
|
||||
'enable' => [
|
||||
'description' => 'Enable',
|
||||
'help' => 'Exports metrics to InfluxDB using the InfluxDBv2 API',
|
||||
],
|
||||
'host' => [
|
||||
'description' => 'Server',
|
||||
'help' => 'The IP or hostname of the InfluxDB server to send data to',
|
||||
],
|
||||
'token' => [
|
||||
'description' => 'Token',
|
||||
'help' => 'Token to connect to InfluxDB, if required',
|
||||
],
|
||||
'port' => [
|
||||
'description' => 'Port',
|
||||
'help' => 'The port to use to connect to the InfluxDB server',
|
||||
],
|
||||
'transport' => [
|
||||
'description' => 'Transport',
|
||||
'help' => 'The port to use to connect to the InfluxDB server',
|
||||
'options' => [
|
||||
'http' => 'HTTP',
|
||||
'https' => 'HTTPS',
|
||||
],
|
||||
],
|
||||
'organization' => [
|
||||
'description' => 'Organization',
|
||||
'help' => 'The organization that contains the bucket on the InfluxDB server',
|
||||
],
|
||||
'allow_redirects' => [
|
||||
'description' => 'Allow Redirects',
|
||||
'help' => 'To allow redirect from the InfluxDB server',
|
||||
],
|
||||
|
||||
],
|
||||
'ipmitool' => [
|
||||
'description' => 'Path to ipmtool',
|
||||
],
|
||||
|
@ -4057,6 +4057,68 @@
|
||||
"section": "influxdb",
|
||||
"order": 8
|
||||
},
|
||||
"influxdbv2.enable": {
|
||||
"default": false,
|
||||
"type": "boolean",
|
||||
"group": "poller",
|
||||
"section": "influxdbv2",
|
||||
"order": 0
|
||||
},
|
||||
"influxdbv2.transport": {
|
||||
"default": "http",
|
||||
"type": "select",
|
||||
"options": {
|
||||
"http": "HTTP",
|
||||
"https": "HTTPS"
|
||||
},
|
||||
"group": "poller",
|
||||
"section": "influxdbv2",
|
||||
"order": 1
|
||||
},
|
||||
"influxdbv2.host": {
|
||||
"default": "127.0.0.1",
|
||||
"type": "text",
|
||||
"group": "poller",
|
||||
"section": "influxdbv2",
|
||||
"order": 2,
|
||||
"validate": {
|
||||
"value": "ip_or_hostname"
|
||||
}
|
||||
},
|
||||
"influxdbv2.port": {
|
||||
"default": 8086,
|
||||
"type": "integer",
|
||||
"group": "poller",
|
||||
"section": "influxdbv2",
|
||||
"order": 3
|
||||
},
|
||||
"influxdbv2.bucket": {
|
||||
"default": "librenms",
|
||||
"type": "text",
|
||||
"group": "poller",
|
||||
"section": "influxdbv2",
|
||||
"order": 4
|
||||
},
|
||||
"influxdbv2.organization": {
|
||||
"default": "librenms",
|
||||
"type": "text",
|
||||
"group": "poller",
|
||||
"section": "influxdbv2",
|
||||
"order": 5
|
||||
},
|
||||
"influxdbv2.allow_redirects": {
|
||||
"default": false,
|
||||
"type": "boolean",
|
||||
"group": "poller",
|
||||
"section": "influxdbv2",
|
||||
"order": 6
|
||||
},
|
||||
"influxdbv2.token": {
|
||||
"type": "password",
|
||||
"group": "poller",
|
||||
"section": "influxdbv2",
|
||||
"order": 7
|
||||
},
|
||||
"install_dir": {
|
||||
"type": "directory"
|
||||
},
|
||||
@ -6074,4 +6136,4 @@
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -64,6 +64,7 @@ plugins:
|
||||
'Extensions/Email-Alerting.md': 'Alerting/Transports.md'
|
||||
'Extensions/Graphite.md': 'Extensions/metrics/Graphite.md'
|
||||
'Extensions/InfluxDB.md': 'Extensions/metrics/InfluxDB.md'
|
||||
'Extensions/InfluxDBv2.md': 'Extensions/metrics/InfluxDBv2.md'
|
||||
'Extensions/OpenTSDB.md': 'Extensions/metrics/OpenTSDB.md'
|
||||
'Extensions/Poller-Service.md': 'Extensions/Dispatcher-Service.md'
|
||||
'Extensions/Port-Description-Parser.md': 'Extensions/Interface-Description-Parsing.md'
|
||||
@ -222,6 +223,7 @@ nav:
|
||||
- Intro: Extensions/Metric-Storage.md
|
||||
- Graphite: Extensions/metrics/Graphite.md
|
||||
- InfluxDB: Extensions/metrics/InfluxDB.md
|
||||
- InfluxDBv2: Extensions/metrics/InfluxDBv2.md
|
||||
- OpenTSDB: Extensions/metrics/OpenTSDB.md
|
||||
- Prometheus: Extensions/metrics/Prometheus.md
|
||||
|
||||
|
@ -15,6 +15,7 @@ $options = getopt('dh:e:', ['help']);
|
||||
|
||||
Config::set('rrd.enable', false);
|
||||
Config::set('influxdb.enable', false);
|
||||
Config::set('influxdbv2.enable', false);
|
||||
Config::set('nographite', true);
|
||||
|
||||
function print_help()
|
||||
|
@ -40,6 +40,7 @@ class DatastoreTest extends TestCase
|
||||
Config::forget([
|
||||
'graphite',
|
||||
'influxdb',
|
||||
'influxdbv2',
|
||||
'opentsdb',
|
||||
'prometheus',
|
||||
'rrd',
|
||||
@ -60,18 +61,20 @@ class DatastoreTest extends TestCase
|
||||
Config::set('rrd.enable', false);
|
||||
Config::set('graphite.enable', true);
|
||||
Config::set('influxdb.enable', true);
|
||||
Config::set('influxdbv2.enable', true);
|
||||
Config::set('opentsdb.enable', true);
|
||||
Config::set('prometheus.enable', true);
|
||||
|
||||
$ds = $this->app->make('Datastore');
|
||||
$stores = $ds->getStores();
|
||||
$this->assertCount(4, $stores, 'Incorrect number of default stores enabled');
|
||||
$this->assertCount(5, $stores, 'Incorrect number of default stores enabled');
|
||||
|
||||
$enabled = array_map('get_class', $stores);
|
||||
|
||||
$expected_enabled = [
|
||||
'LibreNMS\Data\Store\Graphite',
|
||||
'LibreNMS\Data\Store\InfluxDB',
|
||||
'LibreNMS\Data\Store\InfluxDBv2',
|
||||
'LibreNMS\Data\Store\OpenTSDB',
|
||||
'LibreNMS\Data\Store\Prometheus',
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user