diff --git a/includes/billing.php b/includes/billing.php index 89856ca79..8dcf6f038 100644 --- a/includes/billing.php +++ b/includes/billing.php @@ -18,7 +18,7 @@ function getDates($dayofmonth) $date_from = $year . $month . $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 = str_replace("-","",$date_to); } @@ -35,7 +35,7 @@ function getDates($dayofmonth) $date_from = $newyear . $newmonth . $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 = 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; $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)) { $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; @@ -121,12 +122,12 @@ function get95thin($bill_id,$datefrom,$dateto) $measurements = mysql_result($m_query,0); $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_95th = mysql_query($q_95_text); $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) @@ -137,12 +138,12 @@ function get95thout($bill_id,$datefrom,$dateto) $measurements = mysql_result($m_query,0); $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_95th = mysql_query($q_95_text); $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) @@ -189,4 +190,4 @@ function getTotal($bill_id,$datefrom,$dateto) $dayofmonth = date("j"); //FIXME is this used anywhere? -?> \ No newline at end of file +?> diff --git a/includes/static-config.php b/includes/static-config.php index fab48b500..b0d71106b 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -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]['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"; $config['os'][$os]['text'] = "Dell PowerConnect"; $config['os'][$os]['ifname'] = 1; diff --git a/poll-billing.php b/poll-billing.php index a5443e458..c4b407606 100644 --- a/poll-billing.php +++ b/poll-billing.php @@ -40,10 +40,8 @@ function CollectData($bill_id) 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_out_measurement = trim(getValue($host, $port_data['community'], $port_data['snmpver'], $port, $port_data['ifIndex'], "Out")); - - echo("$port_in_measurement and $port_out_measurement \n"); + $port_in_measurement = getValue($host, $port, $port_data['ifIndex'], "In"); + $port_out_measurement = getValue($host, $port, $port_data['ifIndex'], "Out"); $now = mysql_result(mysql_query("SELECT NOW()"), 0); @@ -120,4 +118,4 @@ function CollectData($bill_id) if ($argv[1]) { CollectData($argv[1]); } -?> \ No newline at end of file +?>