* - current maintainer * 2001 Gonthar * - developed scr_ipfm-0.1 * * scr_ipfm generates graphical statistics from ipfm logs. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * USA. * * $Id: yearly-graph.php,v 1.2 2003/11/08 00:56:54 gibas Exp $ */ $sum_in = 0; $sum_out = 0; $sum_total = 0; $in = 0; $out = 0; $total = 0; //default values of variables. secure_sort(); secure_flag(); $ar_years = create_ar_years(); $ar_months = create_ar_months(); $ar_days = create_ar_days(); secure_year(); $filename = "$ipfm_log_dir" . "ipfm-global-" . $_GET['year']; $header = "Statistics for year " . $_GET['year']; html_make_header_en($auto_refresh, $header, $version); echo "
"; html_make_links_year("yearlygraph"); echo "
"; html_make_links("yearly"); check_dir_exists($ipfm_log_dir); check_file_exists("$filename" . "-" . end($ar_months) . "-" . end($ar_days) . ".log", "year"); //sets global variables: $*_style, $s and $*_flag set_style_flag_s(); //$_GET['flag'] = invert_flag($_GET['flag']); $ar_results = array(); $ar_results_all = array(); $ar_hosts = array(); $string = ""; for ($l = 0; $l < count($ar_months); $l++) { $_GET['month'] = $ar_months[$l]; $ar_months = create_ar_months(); $ar_days = create_ar_days(); for ($k = 0; $k < count($ar_days); $k++) { $filename = "$ipfm_log_dir" . "/" . "ipfm-global-$_GET[year]-$ar_months[$l]-$ar_days[$k]" . ".log"; $datas = file($filename); for($i=0; $i < count($datas); $i++) { if(preg_match("/^# /", $datas[$i])) { if(strstr("$datas[$i]", " IPFM")) { //interface, time, version ipfm... $string = split(" ", $datas[$i]); //dirty hack - for old versions ipfm. if($string[6] == "every") { $string[9] = $string[7]; $string[13] = $string[11]; } } } else { if(strlen($datas[$i]) != 0) { $elements = preg_split("/\s+/", $datas[$i]); $host = $elements[0]; $in = $elements[1]; $out = $elements[2]; $total = $elements[3]; if(!in_array($host, $ar_hosts)) { array_push($ar_hosts, "$host"); } if (array_key_exists($host, $ar_results)) { $ar_results[$host][0] = $host; $ar_results[$host][1] += $in; $ar_results[$host][2] += $out; $ar_results[$host][3] += $total; } else { $ar_results[$host][0] = $host; $ar_results[$host][1] = $in; $ar_results[$host][2] = $out; $ar_results[$host][3] = $total; } } $sum_in += $in; $sum_out += $out; $sum_total += $total; } } } } foreach ($ar_hosts as $host) { $line = $ar_results[$host][0] . " " . $ar_results[$host][1] . " " . $ar_results[$host][2] . " " . $ar_results[$host][3]; array_push($ar_results_all, $line); } //if($_GET['flag'] == "ASC") { // $datas = sortbycol($ar_results_all, $s, SORT_ASC); //} //else { $datas = sortbycol($ar_results_all, $s, SORT_DESC); //} echo "
"; for($i=0; $i < count($datas); $i++) { if(strlen($datas[$i]) != 0) { $elements = preg_split("/\s+/", $datas[$i]); $host = $elements[0]; $total = $elements[$s]; if (!isset($scale)) { $scale = calc_scale($datas[$i], $s); } $total_scaled = round($total) / round($scale); //background color // $style = set_table_bg_style($elements[$s]); html_graph_horizon($host, $total, round($total_scaled)); } } echo "
"; html_make_empty_table(); html_make_version_table($string[1], $string[3], $string[9], $string[13], $version); ?>