mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
0ee83437e3
git-subtree-dir: lib/influxdb-php-sdk git-subtree-mainline:15a338061dgit-subtree-split:1928d59eb9
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
namespace Corley\Benchmarks\InfluxDB;
|
|
|
|
use InfluxDB\Client;
|
|
use InfluxDB\Adapter\GuzzleAdapter;
|
|
use InfluxDB\Adapter\UdpAdapter;
|
|
use Athletic\AthleticEvent;
|
|
use GuzzleHttp\Client as HttpClient;
|
|
use InfluxDB\Options;
|
|
|
|
class AdapterEvent extends AthleticEvent
|
|
{
|
|
private $httpClient;
|
|
private $udpClient;
|
|
|
|
public function setUp()
|
|
{
|
|
$options = new Options();
|
|
$options->setHost("localhost");
|
|
$options->setPort(8086);
|
|
$options->setUsername("root");
|
|
$options->setPassword("root");
|
|
$options->setDatabase("tcp.test");
|
|
|
|
$client = new Client(new GuzzleAdapter(new HttpClient(), $options));
|
|
$client->createDatabase("tcp.test");
|
|
$client->createDatabase("udp.test");
|
|
|
|
$this->httpClient = $client;
|
|
|
|
$opts = new Options();
|
|
$opts->setPort(4444);
|
|
|
|
$client = new Client(new UdpAdapter($opts));
|
|
|
|
$this->udpClient = $client;
|
|
}
|
|
|
|
/**
|
|
* @iterations 1000
|
|
*/
|
|
public function sendDataUsingHttpAdapter()
|
|
{
|
|
$this->httpClient->mark("metric.name", ["key" => "value"]);
|
|
}
|
|
|
|
/**
|
|
* @iterations 1000
|
|
*/
|
|
public function sendDataUsingUdpAdapter()
|
|
{
|
|
$this->udpClient->mark("metric.name", ["key" => "value"]);
|
|
}
|
|
}
|