コード例 #1
0
ファイル: billing.php プロジェクト: kyrisu/observernms
function getRates($bill_id, $datefrom, $dateto)
{
    $mq_text = "SELECT count(delta) FROM bill_data ";
    $mq_text = $mq_text . " WHERE bill_id = {$bill_id}";
    $mq_text = $mq_text . " AND timestamp > {$datefrom} AND timestamp <= {$dateto}";
    $m_query = mysql_query($mq_text);
    $measurements = mysql_result($m_query, 0);
    $measurement_95th = round($measurements / 100 * 95) - 1;
    $q_95_text = "SELECT delta FROM bill_data  WHERE bill_id = {$bill_id}";
    $q_95_text = $q_95_text . " AND timestamp > {$datefrom} AND timestamp <= {$dateto} ORDER BY delta ASC";
    $q_95th = mysql_query($q_95_text);
    $m_95th = mysql_result($q_95th, $measurement_95th);
    $mt_q = mysql_query("SELECT SUM(delta) FROM bill_data WHERE bill_id = '{$bill_id}' AND timestamp > '{$datefrom}' AND timestamp <= '{$dateto}'");
    $mtot = mysql_result($mt_q, 0);
    $data['rate_95th_in'] = get95thIn($bill_id, $datefrom, $dateto);
    $data['rate_95th_out'] = get95thOut($bill_id, $datefrom, $dateto);
    if ($data['rate_95th_out'] > $data['rate_95th_in']) {
        $data['rate_95th'] = $data['rate_95th_out'];
        $data['dir_95th'] = 'out';
    } else {
        $data['rate_95th'] = $data['rate_95th_in'];
        $data['dir_95th'] = 'in';
    }
    $data['total_data'] = round($mtot / 1000 / 1000, 2);
    $data['rate_average'] = round($mtot / $measurements / 1000 / 300 * 8, 2);
    return $data;
}
コード例 #2
0
ファイル: billing.php プロジェクト: Tatermen/librenms
function getRates($bill_id, $datefrom, $dateto)
{
    $data = array();
    $mq_text = 'SELECT count(delta) FROM bill_data ';
    $mq_text .= " WHERE bill_id = '" . mres($bill_id) . "'";
    $mq_text .= " AND timestamp > '" . mres($datefrom) . "' AND timestamp <= '" . mres($dateto) . "'";
    $measurements = dbFetchCell($mq_sql);
    $measurement_95th = round($measurements / 100 * 95) - 1;
    $q_95_sql = "SELECT delta FROM bill_data  WHERE bill_id = '" . mres($bill_id) . "'";
    $q_95_sql .= " AND timestamp > '" . mres($datefrom) . "' AND timestamp <= '" . mres($dateto) . "' ORDER BY delta ASC";
    $a_95th = dbFetchColumn($q_95_sql);
    $m_95th = $a_95th[$measurement_95th];
    $sum_data = getSum($bill_id, $datefrom, $dateto);
    $mtot = $sum_data['total'];
    $mtot_in = $sum_data['inbound'];
    $mtot_out = $sum_data['outbound'];
    $ptot = $sum_data['period'];
    $data['rate_95th_in'] = get95thIn($bill_id, $datefrom, $dateto);
    $data['rate_95th_out'] = get95thOut($bill_id, $datefrom, $dateto);
    if ($data['rate_95th_out'] > $data['rate_95th_in']) {
        $data['rate_95th'] = $data['rate_95th_out'];
        $data['dir_95th'] = 'out';
    } else {
        $data['rate_95th'] = $data['rate_95th_in'];
        $data['dir_95th'] = 'in';
    }
    $data['total_data'] = $mtot;
    $data['total_data_in'] = $mtot_in;
    $data['total_data_out'] = $mtot_out;
    $data['rate_average'] = $mtot / $ptot * 8;
    $data['rate_average_in'] = $mtot_in / $ptot * 8;
    $data['rate_average_out'] = $mtot_out / $ptot * 8;
    // print_r($data);
    return $data;
}