mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
More influx changes
This commit is contained in:
+29
-26
@@ -44,34 +44,37 @@ function influxdb_connect() {
|
||||
|
||||
function influx_update($device,$measurement,$tags=array(),$fields) {
|
||||
global $influxdb,$config,$console_color;
|
||||
$tmp_fields = array();
|
||||
$tmp_tags['hostname'] = $device['hostname'];
|
||||
foreach ($tags as $k => $v) {
|
||||
$tmp_tags[$k] = $v;
|
||||
}
|
||||
foreach ($fields as $k => $v) {
|
||||
$tmp_fields[$k] = force_influx_data('f',$v);
|
||||
}
|
||||
if ($influxdb !== false) {
|
||||
echo "AHHHH $influxdb\n";
|
||||
$tmp_fields = array();
|
||||
$tmp_tags['hostname'] = $device['hostname'];
|
||||
foreach ($tags as $k => $v) {
|
||||
$tmp_tags[$k] = $v;
|
||||
}
|
||||
foreach ($fields as $k => $v) {
|
||||
$tmp_fields[$k] = force_influx_data('f',$v);
|
||||
}
|
||||
|
||||
d_echo("\nInfluxDB data:\n");
|
||||
d_echo($measurement);
|
||||
d_echo($tmp_tags);
|
||||
d_echo($tmp_fields);
|
||||
d_echo("\nEND\n");
|
||||
d_echo("\nInfluxDB data:\n");
|
||||
d_echo($measurement);
|
||||
d_echo($tmp_tags);
|
||||
d_echo($tmp_fields);
|
||||
d_echo("\nEND\n");
|
||||
|
||||
if ($config['noinfluxdb'] !== true) {
|
||||
$points = array(
|
||||
new InfluxDB\Point(
|
||||
$measurement,
|
||||
null, // the measurement value
|
||||
$tmp_tags,
|
||||
$tmp_fields // optional additional fields
|
||||
)
|
||||
);
|
||||
$result = $influxdb->writePoints($points);
|
||||
}
|
||||
else {
|
||||
print $console_color->convert('[%gInfluxDB Disabled%n] ', false);
|
||||
if ($config['noinfluxdb'] !== true) {
|
||||
$points = array(
|
||||
new InfluxDB\Point(
|
||||
$measurement,
|
||||
null, // the measurement value
|
||||
$tmp_tags,
|
||||
$tmp_fields // optional additional fields
|
||||
)
|
||||
);
|
||||
$result = $influxdb->writePoints($points);
|
||||
}
|
||||
else {
|
||||
print $console_color->convert('[%gInfluxDB Disabled%n] ', false);
|
||||
}//end if
|
||||
}//end if
|
||||
}// end influx_update
|
||||
|
||||
|
||||
+4
-1
@@ -105,9 +105,12 @@ if (isset($options['f'])) {
|
||||
$config['noinfluxdb'] = true;
|
||||
}
|
||||
|
||||
if ($config['noinfluxdb'] !== true) {
|
||||
if ($config['noinfluxdb'] !== true && $config['influxdb']['enable'] === true) {
|
||||
$influxdb = influxdb_connect();
|
||||
}
|
||||
else {
|
||||
$influxdb = false;
|
||||
}
|
||||
|
||||
rrdtool_pipe_open($rrd_process, $rrd_pipes);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user