mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
git-svn-id: http://www.observium.org/svn/observer/trunk@371 61d68cd4-352d-0410-923a-c4978735b2b8
42 lines
1.4 KiB
PHP
Executable File
42 lines
1.4 KiB
PHP
Executable File
#!/usr/local/bin/php
|
|
<?php
|
|
|
|
include("config.php");
|
|
include("includes/functions.php");
|
|
|
|
$mac_accounting_query = mysql_query("SELECT * FROM `mac_accounting` as A, `interfaces` AS I, `devices` AS D where A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.status = '1'");
|
|
while ($acc = mysql_fetch_array($mac_accounting_query)) {
|
|
|
|
echo("Polling :" . $acc['peer_ip']. " " . $acc['ifDescr']. " " . $acc['hostname'] . "\n");
|
|
|
|
$snmp_cmd = $config['snmpget'] . " -O Uqnv -" . $acc['snmpver'] . " -c " . $acc['community'] . " " . $acc['hostname'];
|
|
$snmp_cmd .= " " . $acc['in_oid'] . " " . $acc['out_oid'];
|
|
|
|
$snmp_output = trim(`$snmp_cmd`);
|
|
|
|
list($in,$out) = explode("\n", $snmp_output);
|
|
|
|
$acc_rrd = $config['rrd_dir'] . "/" . $acc['hostname'] . "/mac-accounting";
|
|
if(!is_dir($acc_rrd)) { mkdir($acc_rrd); echo("Created directory : $acc_rrd\n"); }
|
|
$rrdfile = $acc_rrd . "/" . $acc['ifIndex'] . "-" . $acc['peer_ip'] . ".rrd";
|
|
|
|
if(!is_file($rrdfile)) {
|
|
$woo = shell_exec($config['rrdtool'] ." create $rrdfile \
|
|
DS:IN:COUNTER:600:0:12500000000 \
|
|
DS:OUT:COUNTER:600:0:12500000000 \
|
|
RRA:AVERAGE:0.5:1:600 \
|
|
RRA:AVERAGE:0.5:6:700 \
|
|
RRA:AVERAGE:0.5:24:775 \
|
|
RRA:AVERAGE:0.5:288:797 \
|
|
RRA:MAX:0.5:1:600 \
|
|
RRA:MAX:0.5:6:700 \
|
|
RRA:MAX:0.5:24:775 \
|
|
RRA:MAX:0.5:288:797");
|
|
}
|
|
|
|
$woo = "N:$in:$out";
|
|
$ret = rrdtool_update("$rrdfile", $woo);
|
|
|
|
}
|
|
?>
|