mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
fix some billing shit. thanks to fall0ut
git-svn-id: http://www.observium.org/svn/observer/trunk@1954 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+11
-10
@@ -18,7 +18,7 @@ function getDates($dayofmonth)
|
|||||||
|
|
||||||
$date_from = $year . $month . $dayofmonth;
|
$date_from = $year . $month . $dayofmonth;
|
||||||
$date_to = $newyear . $newmonth . $dayofmonth;
|
$date_to = $newyear . $newmonth . $dayofmonth;
|
||||||
$dt_q = mysql_query("SELECT DATE_ADD(DATE_SUB('$date_from', INTERVAL 1 DAY), INTERVAL 1 MONTH);");
|
$dt_q = mysql_query("SELECT DATE_SUB(DATE_ADD('$date_from', INTERVAL 1 MONTH), INTERVAL 1 DAY);");
|
||||||
$date_to = mysql_result($dt_q,0);
|
$date_to = mysql_result($dt_q,0);
|
||||||
$date_to = str_replace("-","",$date_to);
|
$date_to = str_replace("-","",$date_to);
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ function getDates($dayofmonth)
|
|||||||
|
|
||||||
$date_from = $newyear . $newmonth . $dayofmonth;
|
$date_from = $newyear . $newmonth . $dayofmonth;
|
||||||
$date_to = $year . $month . $dayofmonth;
|
$date_to = $year . $month . $dayofmonth;
|
||||||
$dt_q = mysql_query("SELECT DATE_ADD(DATE_SUB('$date_to', INTERVAL 1 MONTH), INTERVAL 1 DAY);");
|
$dt_q = mysql_query("SELECT DATE_SUB(DATE_ADD('$date_to', INTERVAL 1 MONTH, INTERVAL 1 DAY);");
|
||||||
$date_from = mysql_result($dt_q,0);
|
$date_from = mysql_result($dt_q,0);
|
||||||
$date_from = str_replace("-","",$date_from);
|
$date_from = str_replace("-","",$date_from);
|
||||||
}
|
}
|
||||||
@@ -57,17 +57,18 @@ function getDates($dayofmonth)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getValue($host, $community, $snmpver, $port, $id, $inout)
|
function getValue($host, $port, $id, $inout)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$oid = "IF-MIB::ifHC" . $inout . "Octets." . $id;
|
$oid = "IF-MIB::ifHC" . $inout . "Octets." . $id;
|
||||||
$value = shell_exec($config['snmpget'] ." -m IF-MIB -c $community -$snmpver -O qv $host:$port $oid");
|
$device = mysql_fetch_assoc(mysql_query("SELECT * from `devices` WHERE `hostname` = '" . $host . "' LIMIT 1"));
|
||||||
|
$value = snmp_get($device, $oid, "-O qv");
|
||||||
|
|
||||||
if (!is_numeric($value))
|
if (!is_numeric($value))
|
||||||
{
|
{
|
||||||
$oid = "IF-MIB::if" . $inout . "Octets." . $id;
|
$oid = "IF-MIB::if" . $inout . "Octets." . $id;
|
||||||
$value = shell_exec($config['snmpget'] ." -m IF-MIB -c $community -$snmpver -O qv $host:$port $oid");
|
$value = snmp_get($device, $oid, "-Oqv");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
@@ -121,12 +122,12 @@ function get95thin($bill_id,$datefrom,$dateto)
|
|||||||
$measurements = mysql_result($m_query,0);
|
$measurements = mysql_result($m_query,0);
|
||||||
$measurement_95th = round($measurements /100 * 95) - 1;
|
$measurement_95th = round($measurements /100 * 95) - 1;
|
||||||
|
|
||||||
$q_95_text = "SELECT in_delta FROM bill_data WHERE bill_id = $bill_id";
|
$q_95_text = "SELECT (in_delta / period / 1000 * 8) AS rate FROM bill_data WHERE bill_id = $bill_id";
|
||||||
$q_95_text .= " AND timestamp > $datefrom AND timestamp <= $dateto ORDER BY in_delta ASC";
|
$q_95_text .= " AND timestamp > $datefrom AND timestamp <= $dateto ORDER BY in_delta ASC";
|
||||||
$q_95th = mysql_query($q_95_text);
|
$q_95th = mysql_query($q_95_text);
|
||||||
$m_95th = mysql_result($q_95th,$measurement_95th);
|
$m_95th = mysql_result($q_95th,$measurement_95th);
|
||||||
|
|
||||||
return(round($m_95th / 1000 / 300 * 8, 2));
|
return(round($m_95th, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function get95thout($bill_id,$datefrom,$dateto)
|
function get95thout($bill_id,$datefrom,$dateto)
|
||||||
@@ -137,12 +138,12 @@ function get95thout($bill_id,$datefrom,$dateto)
|
|||||||
$measurements = mysql_result($m_query,0);
|
$measurements = mysql_result($m_query,0);
|
||||||
$measurement_95th = round($measurements /100 * 95) - 1;
|
$measurement_95th = round($measurements /100 * 95) - 1;
|
||||||
|
|
||||||
$q_95_text = "SELECT out_delta FROM bill_data WHERE bill_id = $bill_id";
|
$q_95_text = "SELECT (out_delta / period / 1000 * 8) AS rate FROM bill_data WHERE bill_id = $bill_id";
|
||||||
$q_95_text .= " AND timestamp > $datefrom AND timestamp <= $dateto ORDER BY out_delta ASC";
|
$q_95_text .= " AND timestamp > $datefrom AND timestamp <= $dateto ORDER BY out_delta ASC";
|
||||||
$q_95th = mysql_query($q_95_text);
|
$q_95th = mysql_query($q_95_text);
|
||||||
$m_95th = mysql_result($q_95th,$measurement_95th);
|
$m_95th = mysql_result($q_95th,$measurement_95th);
|
||||||
|
|
||||||
return(round($m_95th / 1000 / 300 * 8, 2));
|
return(round($m_95th, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRates($bill_id,$datefrom,$dateto)
|
function getRates($bill_id,$datefrom,$dateto)
|
||||||
@@ -189,4 +190,4 @@ function getTotal($bill_id,$datefrom,$dateto)
|
|||||||
|
|
||||||
$dayofmonth = date("j"); //FIXME is this used anywhere?
|
$dayofmonth = date("j"); //FIXME is this used anywhere?
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -338,6 +338,13 @@ $config['os'][$os]['over'][1]['text'] = "CPU Usage";
|
|||||||
$config['os'][$os]['over'][2]['graph'] = "device_mempools";
|
$config['os'][$os]['over'][2]['graph'] = "device_mempools";
|
||||||
$config['os'][$os]['over'][2]['text'] = "Memory Usage";
|
$config['os'][$os]['over'][2]['text'] = "Memory Usage";
|
||||||
|
|
||||||
|
$os = "proxim";
|
||||||
|
$config['os'][$os]['text'] = "Proxim";
|
||||||
|
$config['os'][$os]['type'] = "network";
|
||||||
|
$config['os'][$os]['icon'] = "proxim";
|
||||||
|
$config['os'][$os]['over'][0]['graph'] = "device_bits";
|
||||||
|
$config['os'][$os]['over'][0]['text'] = "Device Traffic";
|
||||||
|
|
||||||
$os = "powerconnect";
|
$os = "powerconnect";
|
||||||
$config['os'][$os]['text'] = "Dell PowerConnect";
|
$config['os'][$os]['text'] = "Dell PowerConnect";
|
||||||
$config['os'][$os]['ifname'] = 1;
|
$config['os'][$os]['ifname'] = 1;
|
||||||
|
|||||||
+3
-5
@@ -40,10 +40,8 @@ function CollectData($bill_id)
|
|||||||
|
|
||||||
echo("\nPolling ".$port_data['ifDescr']." on ".$port_data['hostname']."\n");
|
echo("\nPolling ".$port_data['ifDescr']." on ".$port_data['hostname']."\n");
|
||||||
|
|
||||||
$port_in_measurement = trim(getValue($host, $port_data['community'], $port_data['snmpver'], $port, $port_data['ifIndex'], "In"));
|
$port_in_measurement = getValue($host, $port, $port_data['ifIndex'], "In");
|
||||||
$port_out_measurement = trim(getValue($host, $port_data['community'], $port_data['snmpver'], $port, $port_data['ifIndex'], "Out"));
|
$port_out_measurement = getValue($host, $port, $port_data['ifIndex'], "Out");
|
||||||
|
|
||||||
echo("$port_in_measurement and $port_out_measurement \n");
|
|
||||||
|
|
||||||
$now = mysql_result(mysql_query("SELECT NOW()"), 0);
|
$now = mysql_result(mysql_query("SELECT NOW()"), 0);
|
||||||
|
|
||||||
@@ -120,4 +118,4 @@ function CollectData($bill_id)
|
|||||||
|
|
||||||
if ($argv[1]) { CollectData($argv[1]); }
|
if ($argv[1]) { CollectData($argv[1]); }
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user