mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
08a1b75ea240b3c99cff4751a2bc74100b006af6
InfluxDB PHP SDK
Send metrics to InfluxDB.
$client = new \InfluxDB\Client();
$client->setAdapter(new \InfluxDB\Adapter\UdpAdapter());
$client->mark("search", [
"query" => "php"
]);
Install it
Just use composer
php composer.phar require corley/influxdb-sdk:*
Or place it in your require section
{
"require": {
// ...
"corley/influxdb-sdk": "*"
}
}
Send data using HTTP json API
Actually we using Guzzle as HTTP client
$influx->mark("tcp.test", ["mark" => "element"]);
Prepare lib dependencies
Use your DiC or Service Locator in order to provide a configured client
<?php
use InfluxDB\Client;
use InfluxDB\Options;
use InfluxDB\Adapter\GuzzleAdapter;
use GuzzleHttp\Client as GuzzleHttpClient;
$options = new Options();
$options->setHost("analytics.mine.domain.tld");
$options->setPort(8086);
$options->setUsername("root");
$options->setPassword("root");
$guzzleHttp = new GuzzleHttpClient();
$adapter = new GuzzleAdapter($guzzleHttp, $options);
$adapter->setDatabase("mine");
$influx = new Client();
$influx->setAdapter($adapter);
$influx->mark("tcp.test", ["mark" => "element"]);
Languages
PHP
85.1%
JavaScript
6.6%
Blade
4.3%
CSS
1.8%
Python
1.1%
Other
1%