--- etc/95.php.orig 2003-09-24 20:40:57 UTC +++ etc/95.php @@ -1,41 +1,37 @@ \n\n\n"; + print "\n\n\n"; /* Connect to RTG MySQL Database */ - $dbc=@mysql_connect ($host, $user, $pass) or - $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or + $dbc=@mysqli_connect ($host, $user, $pass, $db) or die ("MySQL Connection Failed, Check Configuration."); - mysql_select_db($db,$dbc); - if ($PHP_SELF == "") { + if (!isset($PHP_SELF) || ($PHP_SELF == "")) { $PHP_SELF = "95.php"; - $customer = $_GET['customer']; - $syear = $_GET['syear']; - $eyear = $_GET['eyear']; - $smonth = $_GET['smonth']; - $emonth = $_GET['emonth']; - $sday = $_GET['sday']; - $eday = $_GET['eday']; - $shour = $_GET['shour']; - $ehour = $_GET['ehour']; - $smin = $_GET['smin']; - $emin = $_GET['emin']; - $debug = $_GET['debug']; + $customer = isset($_GET['customer'])?$_GET['customer']:""; + $syear = isset($_GET['syear'])?$_GET['syear']:""; + $eyear = isset($_GET['eyear'])?$_GET['eyear']:""; + $smonth = isset($_GET['smonth'])?$_GET['smonth']:""; + $emonth = isset($_GET['emonth'])?$_GET['emonth']:""; + $sday = isset($_GET['sday'])?$_GET['sday']:""; + $eday = isset($_GET['eday'])?$_GET['eday']:""; + $shour = isset($_GET['shour'])?$_GET['shour']:""; + $ehour = isset($_GET['ehour'])?$_GET['ehour']:""; + $smin = isset($_GET['smin'])?$_GET['smin']:""; + $emin = isset($_GET['emin'])?$_GET['emin']:""; + $debug = isset($_GET['debug'])?$_GET['debug']:""; } - print "RTG: "; - if ($customer) print "$customer\n"; + print "<title>RTG: "; + if ($customer != "") print "$customer\n"; ?> - - - - - - -

+ + + +[RTG Home Page] +

counter; $sample_secs = $selectRow->unixtime; $total += $counter; @@ -83,132 +79,136 @@ function int_stats($statement, $dbc) { } ?> -


-Report: 95th percentile
+
+Report: 95th percentile
\n"; - if (($bt || $smonth)) { - $dbc=@mysql_connect ($host, $user, $pass) or - $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or die ("MySQL Connection Failed, Check Configuration."); - mysql_select_db($db,$dbc); + echo "
\n"; + if (($bt != "") || ($smonth != "")) { + $dbc=@mysqli_connect ($host, $user, $pass, $db) or + die ("MySQL Connection Failed, Check Configuration."); /* Format into GNU date syntax */ if ($bt == "") { $bt = strtotime("$syear-$smonth-$sday $shour:$smin:00"); $et = strtotime("$eyear-$emonth-$eday $ehour:$emin:59"); } - echo "Customer: $customer
\n"; + echo "Customer: $customer
\n"; print strftime("Period: %m/%d/%Y %H:%M - ", $bt); print strftime("%m/%d/%Y %H:%M

\n", $et); - $range="dtime>FROM_UNIXTIME($bt) AND dtime<=FROM_UNIXTIME($et)"; + $range="`dtime`>FROM_UNIXTIME(" . mysqli_real_escape_string($dbc, $bt) . + ") AND `dtime`<=FROM_UNIXTIME(" . mysqli_real_escape_string($dbc, $et) . ")"; - $selectQuery="SELECT id, name, description, rid FROM interface WHERE description LIKE \"%$customer%\""; - $selectResult=mysql_query($selectQuery, $dbc); - if (mysql_num_rows($selectResult) <= 0) - print "
No Such Customer Found.
\n"; + $selectQuery="SELECT `id`, `name`, `description`, `rid` FROM `interface` WHERE " . + "`description` LIKE \"%" . mysqli_real_escape_string($dbc, $customer) . "%\""; + $selectResult=mysqli_query($dbc, $selectQuery); + if (mysqli_num_rows($selectResult) <= 0) + print "
No Such Customer Found.
\n"; else { - while ($selectRow=mysql_fetch_object($selectResult)){ + while ($selectRow=mysqli_fetch_object($selectResult)){ $ids[$selectRow->id] = $selectRow->name; $rids[$selectRow->id] = $selectRow->rid; $desc[$selectRow->id] = $selectRow->description; } - echo "\n"; - echo "\n"; - echo "
InterfaceCurrent RateMax Rate95th %\n"; + echo "\n"; + echo "\n"; + echo "\n"; if ($debug) - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; if ($debug) - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; $yellow = 1; foreach($ids as $iid=>$name) { - $selectQuery="SELECT name FROM router WHERE rid=$rids[$iid]"; - $selectResult=mysql_query($selectQuery, $dbc); - $selectRow=mysql_fetch_object($selectResult); + $selectQuery="SELECT `name` FROM `router` WHERE `rid`=$rids[$iid]"; + $selectResult=mysqli_query($dbc, $selectQuery); + $selectRow=mysqli_fetch_object($selectResult); $router = $selectRow->name; if ($yellow) $yellow = 0; else $yellow = 1; - echo ""; - $selectQuery="SELECT counter, UNIX_TIMESTAMP(dtime) as unixtime, dtime from ifInOctets_$rids[$iid] WHERE $range AND id=$iid ORDER BY dtime"; + $selectQuery="SELECT `counter`, UNIX_TIMESTAMP(`dtime`) AS `unixtime`, `dtime` FROM `ifInOctets_$rids[$iid]` WHERE $range AND `id`=$iid ORDER BY `dtime`"; list ($intbytes_in, $maxin, $avgin, $nfin,$insamples,$inignore) = int_stats($selectQuery, $dbc); $bytesin = round($intbytes_in/1000000); - $selectQuery="SELECT counter, UNIX_TIMESTAMP(dtime) as unixtime, dtime from ifOutOctets_$rids[$iid] WHERE $range AND id=$iid ORDER BY dtime"; + $selectQuery="SELECT `counter`, UNIX_TIMESTAMP(`dtime`) AS `unixtime`, `dtime` FROM `ifOutOctets_$rids[$iid]` WHERE $range AND `id`=$iid ORDER BY `dtime`"; list ($intbytes_out, $maxout, $avgout, $nfout,$outsamples,$outignore) = int_stats($selectQuery, $dbc); $bytesout = round($intbytes_in/1000000); - printf("", $avgin/1000000); + printf("", $avgout/1000000); + printf("", $maxin/1000000); + printf("", $maxout/1000000); + printf("", $nfin/1000000); + printf("", $nfout/1000000); if ($debug) { - echo ""; } - if ($yellow) echo "\n"; - else echo "\n"; + echo "\n"; + if ($yellow) echo "\n"; + else echo "\n"; } - echo "
InterfaceCurrent RateMax Rate95th %SamplesIgnore Top\n"; - echo "
NameDescriptionRouterIn (Mbps)Out (Mbps)InOutInOut\n"; + echo "SamplesIgnore Top
NameDescriptionRouterIn (Mbps)Out (Mbps)InOutInOutInOutInOut\n"; - echo "
InOutInOut
$name$desc[$iid]$router"; + echo "$name$desc[$iid]$router%2.2f", $avgin/1000000); - printf("%2.2f", $avgout/1000000); - printf("%2.2f", $maxin/1000000); - printf("%2.2f", $maxout/1000000); - printf("%2.2f", $nfin/1000000); - printf("%2.2f", $nfout/1000000); + printf("%2.2f%2.2f%2.2f%2.2f%2.2f%2.2f$insamples$outsamples$inignore$outignore"; + echo "$insamples$outsamples$inignore$outignore
\n"; + echo "
\n"; } } else { - echo "Customer Name:
\n"; - echo "

\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "
From: \n"; - echo "
\n"; + echo "

\n"; + echo "\n"; + echo "\n"; + echo "\n"; - echo "\n"; + echo "\n"; + echo "
From: / \n"; - echo " / \n"; + echo " / \n"; - echo " / \n"; + echo "\n"; - echo ":\n"; - echo ":\n"; + echo "\n"; + echo "\" />
To: \n"; - echo "To: / \n"; - echo " / \n"; + echo " / \n"; - echo " / \n"; + echo "\n"; - echo ":\n"; - echo ":\n"; + echo "\n"; - echo "
Debug: \n"; - echo "\n"; - echo "
\n"; + echo "\" />

Debug:
\n"; - echo "

"; + echo "

"; } - if ($dbc) mysql_close($dbc); - echo "

\n"; + if ($dbc) mysqli_close($dbc); + echo "\n"; ?> -
-
- +
+
+ RTG Version $VERSION"; + print "RTG Version $VERSION
"; ?> - - + +