Ejemplo n.º 1
0
/**
 * @author Stephen "TheCodeAssassin" Hoogendijk
 */
require 'vendor/autoload.php';
// vagrant ip
$host = '192.168.33.10';
function randFloat($min, $max)
{
    $range = $max - $min;
    $num = $min + $range * mt_rand(0, 32767) / 32767;
    $num = round($num, 4);
    return (double) $num;
}
$client = new \InfluxDB\Client($host);
$database = $client->selectDB('test');
if ($database->exists()) {
    $database->drop();
}
$database->create(new \InfluxDB\Database\RetentionPolicy('test', '12w', 1, true));
$start = microtime(true);
$countries = ['nl', 'gb', 'us', 'be', 'th', 'jp', 'nl', 'sa'];
$colors = ['orange', 'black', 'yellow', 'white', 'red', 'purple'];
$points = [];
for ($i = 0; $i < 1000; $i++) {
    $points[] = new \InfluxDB\Point('flags', randFloat(1, 999), ['country' => $countries[array_rand($countries)]], ['color' => $colors[array_rand($colors)]], (int) shell_exec('date +%s%N') + mt_rand(1, 1000));
}
// insert the points
$database->writePoints($points);
$end = microtime(true);
$country = $countries[array_rand($countries)];
Ejemplo n.º 2
0
use Phalcon\Di\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
$di = new FactoryDefault();
/**
 * Sets the view component
 */
$di->setShared('view', function () use($config) {
    $view = new View();
    $view->setViewsDir($config->application->viewsDir);
    return $view;
});
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di->set('url', function () use($config) {
    $url = new UrlResolver();
    $url->setBaseUri($config->application->baseUri);
    return $url;
});
/**
 * Database connection is created based in the parameters defined in the configuration file
 */
$di->set('db', function () use($config) {
    return new DbAdapter($config->database->toArray());
});
$di->set('influxdb', function () use($config) {
    $client = new InfluxDB\Client($config->monitor->influxHost, $config->monitor->influxPort, '', '', false, false, 10);
    $database = $client->selectDB('jolie');
    return $database;
});
$di->set('config', $config, true);
Ejemplo n.º 3
0
 * along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
 */
require_once dirname(__FILE__) . '/../../../core/php/core.inc.php';
include_file('core', 'authentification', 'php');
require_once dirname(__FILE__) . '/../vendor/autoload.php';
if (!isConnect()) {
    include_file('desktop', '404', 'php');
    die;
}
try {
    $host = config::byKey('influxdbHost', 'influxdb', 0);
    $port = config::byKey('influxdbPort', 'influxdb', 0);
    $dbName = config::byKey('influxdbDatabase', 'influxdb', 0);
    log::add('influxdb', 'debug', "Connexion à InfluxDB: host={$host}, port={$port}, base={$dbName}");
    $client = new InfluxDB\Client($host, $port);
    $database = $client->selectDB($dbName);
    if (!$database->exists()) {
        log::add('influxdb', 'error', "La base de données InfluxDB '{$dbName}' n'existe pas");
    }
} catch (Exception $e) {
    log::add('influxdb', 'error', displayExeption($e));
}
?>
<form class="form-horizontal">
    <fieldset>
        <div class="form-group">
            <label class="col-lg-4 control-label">{{Adresse du serveur}}</label>
            <div class="col-lg-2">
                <input class="configKey form-control" data-l1key="influxdbHost" />
            </div>
        </div>