more updates

This commit is contained in:
laf
2015-08-13 13:11:58 +00:00
parent d13985644e
commit dc05958a12
2 changed files with 7 additions and 2 deletions

View File

@@ -74,6 +74,11 @@ if (is_numeric($uptime)) {
rrdtool_create($uptime_rrd, 'DS:uptime:GAUGE:600:0:U '.$config['rrd_rra']);
}
$measurement = 'uptime';
echo "BOOM " . sprintf("%.1f",$uptime) . " YAH\n";
$fields = array('uptime' => $uptime);
influx_update($device,$measurement,$tags,$fields);
rrdtool_update($uptime_rrd, 'N:'.$uptime);
$graphs['uptime'] = true;

View File

@@ -305,8 +305,8 @@ function rrdtool_escape($string, $maxlength=null){
}
function influx_update($device,$measurement,$tags=array(),$fields) {
$tmp_tags = array();
$tmp_fields = array();
$tmp_tags[] = "host=".$device['hostname'];
foreach ($tags as $k => $v) {
$tmp_tags[] = "$k=$v";
}
@@ -320,7 +320,7 @@ function influx_update($device,$measurement,$tags=array(),$fields) {
$influx_url = 'http://localhost:8086/write?db=librenms';
$ch = curl_init($influx_url);
$post = "$measurement,host=".$device['hostname'].",$tags $fields";
$post = "$measurement,$tags $fields";
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);