コード例 #1
0
ファイル: sess.php プロジェクト: ut0mt8/phpflow
<?php

$sql = "select ip_src, ip_dst, port_src, port_dst, country_ip_dst, ";
$sql .= $asq . " asq, asn.as_name, ";
$sql .= "sum(bytes)*8*" . $sampling_rate . "/" . $interval . " traffic, ";
$sql .= "sum(packets)*" . $sampling_rate . "/" . $interval . " pps ";
$sql .= "from " . $table . ",asn ";
$sql .= "where " . $asq . "=as_number ";
if ($if != "") {
    $sql .= "and tag = " . $if . " ";
}
if ($cust != "") {
    $sql .= "and tag2 = " . $cust . " ";
}
$sql .= "and stamp_inserted between '" . $stamp_min . "' and '" . $stamp_max . "' ";
$sql .= "group by ip_src, ip_dst, port_src, port_dst order by sum(bytes) desc limit " . $entry_limit;
$result = do_query($sql);
$rows = array();
while ($row = mysqli_fetch_array($result)) {
    array_push($rows, $row);
}
/* clean formating */
foreach ($rows as $key => $row) {
    $traffic = formatUnit($row['traffic']);
    $pps = formatUnit($row['pps']);
    $rows[$key]['traffic'] = $traffic;
    $rows[$key]['pps'] = $pps;
}
$tpl = $twig->loadTemplate('sess.tmpl');
echo $tpl->render(array('rows' => $rows, 'direction' => $direction));
コード例 #2
0
ファイル: asn.php プロジェクト: ut0mt8/phpflow
$sql .= "sum(bytes)*8*" . $sampling_rate . "/" . $interval . " traffic, ";
$sql .= "sum(packets)*" . $sampling_rate . "/" . $interval . " pps ";
$sql .= "from " . $table . ",asn ";
$sql .= "where " . $asq . "=as_number ";
if ($if != "") {
    $sql .= "and tag = " . $if . " ";
}
if ($cust != "") {
    $sql .= "and tag2 = " . $cust . " ";
}
$sql .= "and stamp_inserted between '" . $stamp_min . "' and '" . $stamp_max . "' ";
$sql .= "group by " . $asq . " order by sum(bytes) desc limit " . $entry_limit;
$result = do_query($sql);
$total_traffic = 0;
$total_pps = 0;
$rows = array();
while ($row = mysqli_fetch_array($result)) {
    array_push($rows, $row);
    $total_traffic += $row['traffic'];
    $total_pps += $row['pps'];
}
/* clean formating */
foreach ($rows as $key => $row) {
    $traffic = formatUnit($row['traffic']);
    $pps = formatUnit($row['pps']);
    $rows[$key]['traffic'] = $traffic;
    $rows[$key]['pps'] = $pps;
}
$tpl = $twig->loadTemplate('asn.tmpl');
echo $tpl->render(array('rows' => $rows, 'direction' => $direction, 'total_traffic' => formatUnit($total_traffic), 'total_pps' => formatUnit($total_pps)));
コード例 #3
0
ファイル: talk.php プロジェクト: ut0mt8/phpflow
<?php

if ($direction == "out") {
    $ips1 = "ip_src";
    $ips2 = "ip_dst";
} else {
    $ips1 = "ip_dst";
    $ips2 = "ip_src";
}
$sql = "select " . $ips1 . " ipa, ";
$sql .= "sum(bytes)*8*" . $sampling_rate . "/" . $interval . " traffic ";
$sql .= "from " . $table . " ";
$sql .= "where stamp_inserted between '" . $stamp_min . "' and '" . $stamp_max . "' ";
if ($cust != "") {
    $sql .= "and tag2 = " . $cust . " ";
}
$sql .= "group by ipa order by sum(bytes) desc limit " . $entry_limit;
$result = do_query($sql);
$rows = array();
while ($row = mysqli_fetch_array($result)) {
    array_push($rows, $row);
}
/* search for reverse and clean formating */
foreach ($rows as $key => $row) {
    $hostname = gethostbyaddr($row['ipa']);
    $traffic = formatUnit($row['traffic']);
    $rows[$key]['name'] = $hostname;
    $rows[$key]['traffic'] = $traffic;
}
$tpl = $twig->loadTemplate('talk.tmpl');
echo $tpl->render(array('rows' => $rows, 'direction' => $direction));