mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
some initial code
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
// Author: Paul Gear <librenms@libertysys.com.au>
|
||||
// License: GPLv3
|
||||
//
|
||||
require_once '../../includes/print-interface.inc.php';
|
||||
include_once '../../includes/print-interface.inc.php';
|
||||
|
||||
echo 'ARP Discovery: ';
|
||||
|
||||
|
||||
@@ -509,6 +509,25 @@ foreach ($ports as $port) {
|
||||
$this_port['ifOutMulticastPkts'],
|
||||
);
|
||||
|
||||
$measurement = 'port';
|
||||
$tags = array('ifIndex' => $this_port['ifIndex']);
|
||||
$fields = array('ifInOctets' => $this_port['ifInOctets'],
|
||||
'ifOutOctets' => $this_port['ifOutOctets'],
|
||||
'ifInErrors' => $this_port['ifInErrors'],
|
||||
'ifOutErrors' => $this_port['ifOutErrors'],
|
||||
'ifInUcastPkts' => $this_port['ifInUcastPkts'],
|
||||
'ifOutUcastPkts' => $this_port['ifOutUcastPkts'],
|
||||
'ifInNUcastPkts' => $this_port['ifInNUcastPkts'],
|
||||
'ifOutNUcastPkts' => $this_port['ifOutNUcastPkts'],
|
||||
'ifInDiscards' => $this_port['ifInDiscards'],
|
||||
'ifOutDiscards' => $this_port['ifOutDiscards'],
|
||||
'ifInUnknownProtos' => $this_port['ifInUnknownProtos'],
|
||||
'ifInBroadcastPkts' => $this_port['ifInBroadcastPkts'],
|
||||
'ifOutBroadcastPkts' => $this_port['ifOutBroadcastPkts'],
|
||||
'ifInMulticastPkts' => $this_port['ifInMulticastPkts'],
|
||||
'ifOutMulticastPkts' => $this_port['ifOutMulticastPkts']
|
||||
);
|
||||
influx_update($device,$measurement,$tags,$fields);
|
||||
rrdtool_update("$rrdfile", $this_port['rrd_update']);
|
||||
// End Update IF-MIB
|
||||
// Update PAgP
|
||||
|
||||
@@ -253,6 +253,8 @@ function rrdtool_update($filename, $options) {
|
||||
$options = implode(':', $values);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return rrdtool('update', $filename, $options);
|
||||
|
||||
}
|
||||
@@ -301,3 +303,27 @@ function rrdtool_escape($string, $maxlength=null){
|
||||
return $result.' ';
|
||||
|
||||
}
|
||||
|
||||
function influx_update($device,$measurement,$tags=array(),$fields) {
|
||||
$tmp_tags = array();
|
||||
$tmp_fields = array();
|
||||
foreach ($tags as $k => $v) {
|
||||
$tmp_tags[] = "$k=$v";
|
||||
}
|
||||
foreach ($fields as $k => $v) {
|
||||
$tmp_fields[] = "$k=$v";
|
||||
}
|
||||
|
||||
$tags = implode(',', $tmp_tags);
|
||||
$fields = implode(',', $tmp_fields);
|
||||
|
||||
$influx_url = 'http://localhost:8086/write?db=librenms';
|
||||
|
||||
$ch = curl_init($influx_url);
|
||||
$post = "$measurement,host=".$device['hostname'].",$tags $fields";
|
||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
$response = curl_exec($ch);
|
||||
echo "YEAH $response END\n";
|
||||
d_echo($response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user