From d48aa2789ccb21a3de760e4b4b406f375c74b2e7 Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 18 Dec 2015 11:15:56 +0000 Subject: [PATCH] More influx changes --- includes/influxdb.inc.php | 55 +++++++++++++++++++++------------------ poller.php | 5 +++- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/includes/influxdb.inc.php b/includes/influxdb.inc.php index dfe63f6f3..7e3a9ee7f 100644 --- a/includes/influxdb.inc.php +++ b/includes/influxdb.inc.php @@ -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 diff --git a/poller.php b/poller.php index 1bad4c390..b5eccb35e 100755 --- a/poller.php +++ b/poller.php @@ -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);