[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r15030 - in gauger: . web web/css
From: |
gnunet |
Subject: |
[GNUnet-SVN] r15030 - in gauger: . web web/css |
Date: |
Tue, 19 Apr 2011 19:07:13 +0200 |
Author: bartpolot
Date: 2011-04-19 19:07:13 +0200 (Tue, 19 Apr 2011)
New Revision: 15030
Added:
gauger/web/
gauger/web/ajax.php
gauger/web/css/
gauger/web/explore.php
gauger/web/images/
gauger/web/index.php
gauger/web/js/
gauger/web/params.php
gauger/web/plot.php
gauger/web/template.php
gauger/web/template_graph.php
gauger/web/template_host.php
gauger/web/template_menu.php
gauger/web/template_welcome.php
Removed:
gauger/ajax.php
gauger/css/
gauger/explore.php
gauger/images/
gauger/index.php
gauger/js/
gauger/params.php
gauger/plot.php
gauger/template.php
gauger/template_graph.php
gauger/template_host.php
gauger/template_menu.php
gauger/template_welcome.php
gauger/web/css/images/
gauger/web/css/smoothness/
gauger/web/css/style.css
Log:
Grouped all web related files in own subdirectory
Deleted: gauger/ajax.php
===================================================================
--- gauger/ajax.php 2011-04-19 14:41:56 UTC (rev 15029)
+++ gauger/ajax.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -1,54 +0,0 @@
-<?php
-/** ajax.php
-
- This file is part of gauger.
- Copyright 2011 Bartlomiej Polot
-
- gauger is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- gauger 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with gauger. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-include "params.php"; // Manage all parameters given by the user
-include "explore.php"; // Gather all existing hosts and counters
-init_params();
-explore();
-
-$persist = get_param('persist') == 'true';
-foreach ($range_parameters as $param_name) {
- $prev = array_key_exists($param_name, $_SESSION);
- if ($prev) $bck = $_SESSION[$param_name];
- $$param_name = get_param($param_name, '', $persist, false);
- if($$param_name === '') continue;
- if(!is_numeric($$param_name) && $persist) {
- if($prev) {
- $_SESSION[$param_name] = $bck;
- } else {
- $_SESSION[$param_name] = '';
- }
- $_SESSION[$param_name."_a"] = 1;
- $$param_name = '*';
- } else if($persist) {
- $_SESSION[$param_name."_a"] = 0;
- }
-}
-$req = get_param('req');
-if($req) {
- $reqa = Array();
- foreach(explode(',', $req) as $param) {
- $reqa[$param] = get_session($param, '');
- }
- die(json_encode($reqa));
-} else {
- die('OK');
-}
Deleted: gauger/explore.php
===================================================================
--- gauger/explore.php 2011-04-19 14:41:56 UTC (rev 15029)
+++ gauger/explore.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -1,132 +0,0 @@
-<?php
-/** explore.php
-
- This file is part of gauger.
- Copyright 2011 Bartlomiej Polot
-
- gauger is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- gauger 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with gauger. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-$CONF = parse_ini_file('gauger.conf');
-$DATADIR = array_key_exists('data', $CONF) && $CONF["data"] ? $CONF['data'] :
'data/';
-$PAGELENGTH = array_key_exists('page_length', $CONF) && $CONF['page_lenght'] ?
$CONF['page_lenght'] : 5;
-if ($DATADIR[strlen($DATADIR)-1] != '/') $DATADIR .= '/';
-$hosts = array();
-$metrics = array();
-$metrics_c = array();
-
-function get_counter_name($s) {
- $s = str_replace('-SLASH-', '/', $s);
- if(($b = strpos($s, ':::')) !== FALSE)
- $b += 3;
- else
- $b = 0;
- if(($e = strpos($s, '___')) === FALSE)
- return substr($s, $b);
- return substr($s, $b, $e-$b);
-}
-
-function get_counter_unit($s) {
- $s = str_replace('-SLASH-', '/', $s);
- if(($b = strpos($s, '___')) !== FALSE)
- return substr($s, $b+3);
- else
- return "";
-}
-
-function get_counter_category($s) {
- $s = str_replace('-SLASH-', '/', $s);
- if(($b = strpos($s, ':::')) !== FALSE)
- return substr($s, 0, $b);
- else
- return "";
-}
-
-function get_range_global() {
- global $DATADIR;
- $f = fopen($DATADIR.'global_range.dat', 'r');
- $buffer = fgets($f, 512);
- fclose($f);
- return explode(' ', $buffer);
-}
-
-function get_range($host, $counter) {
- global $DATADIR;
- if(empty($host) || empty($counter)) return get_range_global();
- $f = @fopen("$DATADIR$host/$counter.dat", 'r');
- if ($f === false) return get_range_global();
- $b = false;
- while (($buffer = fgets($f, 512)) !== false) {
- if($b === false) {$b = explode(' ', $buffer); $b = $b[0]; }
- $e = $buffer;
- }
- fclose($f);
- $e = explode(' ', $e);
- $e = $e[0];
- return Array($b, $e);
-}
-
-function get_local_maximum($h, $g, $s, $e) {
- global $DATADIR;
- $lm = false;
- $f = @fopen("$DATADIR$h/$g.dat", 'r');
- if ($f === false) return 1;
- while (($buffer = fgets($f, 512)) !== false) {
- $l = explode(' ', $buffer);
- if($l[0] >= $s && $l[0] <= $e) {
- if($lm === false || $l[1] > $lm) $lm = $l[1];
- }
- }
- fclose($f);
- return $lm ? $lm : 1;
-}
-
-function explore() {
- global $DATADIR;
- global $hosts;
- global $metrics;
- global $metrics_c;
- global $q;
- $d = dir($DATADIR);
- while (false !== ($entry = $d->read())) {
- if (is_dir($DATADIR.$entry) && !($entry[0] == ".")) {
- $hosts[$entry] = array();
- $d2 = dir($DATADIR.$entry);
- while (false !== ($counter = $d2->read())) {
- // Do not include files containing dots or tildes or
incomplete files
- if (($q === "" || strpos($counter, $q) !== false) &&
- preg_match("/(\.|~)/", $counter) === 0 &&
- is_file("$DATADIR$entry/$counter.dat")) {
- $hosts[$entry][] = $counter;
- $metrics[$counter] = get_counter_name($counter);
- $metrics_c[get_counter_category($counter)][$counter] =
get_counter_name($counter);
- }
- }
- }
- }
-
- ksort($hosts);
- foreach ($hosts as $host => $a) {
- sort(&$hosts[$host]);
- }
- foreach ($metrics_c as $id => $a) {
- ksort(&$metrics_c[$id]);
- }
- ksort(&$metrics_c);
- if (array_key_exists('', $metrics_c)) {
- $others = array_shift($metrics_c);
- $metrics_c[''] = $others;
- }
- $d->close();
-}
Deleted: gauger/index.php
===================================================================
--- gauger/index.php 2011-04-19 14:41:56 UTC (rev 15029)
+++ gauger/index.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -1,25 +0,0 @@
-<?php
-/** index.php
-
- This file is part of gauger.
- Copyright 2011 Bartlomiej Polot
-
- gauger is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- gauger 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with gauger. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-include "params.php"; // Manage all parameters given by the user
-include "explore.php"; // Gather all existing hosts and counters
-init_params();
-explore();
-include "template.php"; // Display info
\ No newline at end of file
Deleted: gauger/params.php
===================================================================
--- gauger/params.php 2011-04-19 14:41:56 UTC (rev 15029)
+++ gauger/params.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -1,93 +0,0 @@
-<?php
-/** params.php
-
- This file is part of gauger.
- Copyright 2011 Bartlomiej Polot
-
- gauger is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- gauger 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with gauger. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-$range_parameters = Array('x_max', 'x_min',
- 'y_max', 'y_min',
- 'png_x_size', 'png_y_size');
-$mode_host = FALSE;
-$mode_graph = FALSE;
-$current = "";
-$currentg = "";
-
-function get_param($name, $default = '', $persist = FALSE, $usesession = TRUE)
{
- if (array_key_exists($name, $_REQUEST)) {
- $ret = $_REQUEST[$name];
- if($persist) {
- $_SESSION[$name] = $ret;
- }
- } else if ($usesession && array_key_exists($name, $_SESSION)) {
- $ret = $_SESSION[$name];
- } else {
- $ret = $default;
- }
- return $ret;
-}
-
-function get_param_escsh($name, $default = '', $persist = FALSE, $sess = TRUE)
{
- return escapeshellcmd(get_param($name, $default, $persist, $sess));
-}
-
-function get_session($name, $default = '') {
- if (array_key_exists($name, $_SESSION) && $_SESSION[$name] !== '') {
- return $_SESSION[$name];
- } else {
- return $default;
- }
-}
-
-function init_params() {
- global $mode_host;
- global $mode_graph;
- global $current;
- global $currentg;
- global $q;
- global $range_parameters;
-
- session_start();
-
- if (get_param('logout')) {
- session_unset();
- header("Location: " . preg_replace("/\?.*/", "",
$_SERVER["REQUEST_URI"]));
- die();
- }
-
- if ($current = get_param('host')) {
- $mode_host = TRUE;
- }
-
- if ($currentg = get_param('graph')) {
- $mode_graph = TRUE;
- }
-
- if (get_session('xrange_min') === '') {
- $r = get_range('','');
- $_SESSION['xrange_min'] = $r[0];
- $_SESSION['xrange_max'] = $r[1];
- $_SESSION['y_min'] = 0;
- foreach ($range_parameters as $param_name) {
- $_SESSION[$param_name.'_a'] = 1;
- }
- $_SESSION['png_x_size'] = 640;
- $_SESSION['png_y_size'] = 480;
- }
-
- $q = get_param('q', '');
-}
Deleted: gauger/plot.php
===================================================================
--- gauger/plot.php 2011-04-19 14:41:56 UTC (rev 15029)
+++ gauger/plot.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -1,232 +0,0 @@
-<?php
-/** plot.php
-
- This file is part of gauger.
- Copyright 2011 Bartlomiej Polot
-
- gauger is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- gauger 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with gauger. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-/** Function build_gnuplot_file
- * @param $cmd: header, terminal size and plot range
- * @param $rangecmd: xtics range description
- * @param $plotcmd: data description
- * @return: gnuplot file with inline data
- */
-function build_gnuplot_file($cmd, $rangecmd, $plotcmd) {
- $files = explode(",", $plotcmd);
- $paths = array();
- foreach ($files as $i => $file) {
- $paths[$i] = stripslashes(preg_replace('/[^"]*"([^"]+).*/', '\1',
$file));
- $files[$i] = preg_replace('/"[^"]+/', '"-', $file, 1);
- }
- $plotcmd = implode(",", $files);
- header('Content-Type: text/plain');
- header('Content-Disposition: attachment; filename=source.gp');
- echo str_replace("; ", ";\n", $cmd) . "\n";
- echo "$plotcmd;\n";
- foreach($paths as $path) {
- readfile($path);
- echo "e\n";
- }
- die();
-}
-
-/** Function build_gnuplot_command
- * @param $cmd: header, terminal size and plot range
- * @param $rangecmd: xtics range description
- * @param $plotcmd: data description
- * @return: gnuplot file with inline data
- */
-function build_gnuplot_command($cmd, $rangecmd, $plotcmd) {
- return "echo '$cmd $rangecmd $plotcmd' | gnuplot";
-}
-
-/** Function plot
- * @param h: host name
- * @param g: graph name
- * @return: stream representing a png graph
- */
-function plot($g, $h) {
- global $hosts;
- global $DATADIR;
-
- $cmd = 'set terminal png font "Arial,12";';
- $cmd .= ' set grid;';
- //$cmd .= ' set yrange[0:];';
- $cmd .= ' set key below;';
- $cmd .= ' set style lines 1 lt rgb "#A0A0A0" lw 2;';
- $cmd .= ' set style lines 2 lt rgb "#404040" lw 1 pt 1;';
- $cmd .= ' set style lines 3 lt rgb "green" lw 2;';
- $cmd .= ' set style lines 4 lt rgb "red" lw 2;';
- $cmd .= ' set style lines 5 lt rgb "blue" lw 2;';
- $cmd .= ' set style lines 6 lt rgb "cyan" lw 2;';
- $cmd .= ' set style lines 7 lt rgb "violet" lw 2;';
- $cmd .= ' set style lines 8 lt rgb "orange" lw 2;';
- $cmd .= ' set style increment user;';
-
- $cmd .= ' set terminal png size ';
- $cmd .= get_session('png_x_size', '640') . ',';
- $cmd .= get_session('png_y_size', '480') . ';';
-
- $norm = get_param('norm', '') == 'true';
- if(!empty($g)) {
- $cmd .= ' set ylabel "' . ($norm ? 'percentage' :
get_counter_unit($g[0])) . '";';
- }
-
- foreach (Array('x_max', 'x_min', 'y_max', 'y_min') as $param_name) {
- $$param_name = get_param_escsh($param_name, '', false);
- $explicit = get_param_escsh($param_name, '', false, false);
- if(!is_numeric($$param_name) ||
- (get_session($param_name.'_a') == 1 && !$explicit))
- $$param_name = '*';
- }
- $cmd .= " set xrange [$x_min:$x_max];";
- $cmd .= " set yrange [$y_min:$y_max];";
-
- $ch = count($h);
- if($ch == 0){
- $h = array_keys($hosts);
- }
- $cg = count($g);
- if($cg == 1) {
- $cmd .= ' set title "' . get_counter_name($g[0]) . '";';
- }
-
- if($x_min != '*') {
- $range_start = $x_min;
- } else {
- $range_start = get_param_escsh('xrange_max');
- }
- if($x_max != '*') {
- $range_end = $x_max;
- } else {
- $range_end = get_param_escsh('xrange_min');
- }
-
- $plotcmd = ' plot';
- $c = 0;
- if($x_min == '*' || $x_max == '*') {
- foreach($h as $host) {
- $counters = $hosts[$host];
- if($cg == 0) $g = $counters;
- foreach($g as $graph) {
- if(array_search($graph, $counters) === FALSE) continue;
- $r = get_range($host, $graph);
- if($x_min == '*') {
- $range_start = min($range_start, $r[0]);
- }
- if($x_max == '*') {
- $range_end = max($range_end, $r[1]);
- }
- }
- }
- }
- $left_unit = null;
- $right_unit = null;
- foreach($h as $host) {
- $counters = $hosts[$host];
- if($cg == 0) $g = $counters;
- foreach($g as $graph) {
- if(array_search($graph, $counters) === FALSE) continue;
- $unit = get_counter_unit($graph);
- if($left_unit === null) {
- $left_unit = $unit;
- }
- if($left_unit != $unit && $right_unit === null) {
- $right_unit = $unit;
- $cmd .= " set y2label \"$unit\"; set ytics nomirror; set
y2tics;";
- }
- if($left_unit != $unit && $right_unit != $unit) {
- header('Location: images/toomanyunits.png');
- die();
- }
- $counter = get_counter_name($graph);
- if($c) $plotcmd .= ',';
- $plotcmd .= escapeshellcmd(" \"$DATADIR$host/$graph.dat\"");
- if($norm) {
- $metric_max = (int)get_local_maximum($host, $graph,
$range_start, $range_end);
- $plotcmd .= " using 1:($2*100/$metric_max)";
- }
- $plotcmd .= " title \"";
- if($ch != 1) $plotcmd .= $host;
- if($ch != 1 && $cg != 1) $plotcmd .= " - ";
- if($cg != 1) {
- $plotcmd .= $counter;
- if($unit == $right_unit) $plotcmd .= " ($unit)";
- }
- $plotcmd .= "\"";
- $plotcmd .= " with lines lw 2";
- if($unit == $right_unit) $plotcmd .= ' axes x1y2';
- if($ch == 1 && $cg == 1) {
- $plotcmd .= ', ';
- $plotcmd .= escapeshellcmd(" \"$DATADIR$host/$graph.dat\"");
- $plotcmd .= " notitle with yerrorbars lw 1";
- if($unit == $right_unit) $plotcmd .= ' axes x1y2';
- }
- $c++;
- }
- }
- $size = get_param_escsh('png_x_size');
- $gap = $range_end - $range_start;
- $deadspace = $right_unit === null ? 150 : 220;
- $interval = ceil($gap/(abs($size-$deadspace)/50));
- if($interval > $gap) $interval = $gap;
- if($interval == 0) $interval = 1;
- $rangecmd = " set xtics $range_start,$interval,$range_end;";
-
- if(!$c) {
- header('Location: images/nodata.png');
- die();
- }
-
- if(get_param('raw_cmd') == 'true') {
- build_gnuplot_file($cmd, $rangecmd, $plotcmd);
- } else {
- $cmd = build_gnuplot_command($cmd, $rangecmd, $plotcmd);
- $out = shell_exec($cmd);
- }
-
- return $out;
-}
-
-include "params.php";
-include "explore.php";
-init_params();
-explore();
-
-if ($h = get_param('h')) {
- $h = explode(',', $h);
-} else {
- $h = array();
-}
-
-if ($g = get_param('g')) {
- $g = explode(',', $g);
-} else {
- $g = array();
-}
-
-$out = plot($g, $h);
-if($out) {
- header('Content-type: image/png');
- header("Cache-Control: no-cache, must-revalidate");
- header("Pragma: no-cache");
- header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
- die($out);
-} else {
- header('Location: images/nodata.png');
- die();
-}
Deleted: gauger/template.php
===================================================================
--- gauger/template.php 2011-04-19 14:41:56 UTC (rev 15029)
+++ gauger/template.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -1,582 +0,0 @@
-<?php
-/** template.php
-
- This file is part of gauger.
- Copyright 2011 Bartlomiej Polot
-
- gauger is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- gauger 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with gauger. If not, see <http://www.gnu.org/licenses/>.
-
-*/?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<html lang="en">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>Gauger [<?php echo isset($current) && $current ? $current :
get_counter_name($currentg) ?>]</title>
-
- <link href="css/smoothness/jquery-ui-1.8.9.custom.css"
rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
- <script type="text/javascript"
src="js/jquery-ui-1.8.9.custom.min.js"></script>
- <script type="text/javascript" src="js/jCookie.js"></script>
-
- <link rel="shortcut icon" href="images/favicon.png" />
- <link href="css/style.css" type="text/css" rel="stylesheet">
-
-
- <script type="text/javascript">
-
- var inst_search;
- var last_search = "";
- var field_search;
- var search_prompt = "Search...";
-
- $(document).ready(function() {
- $( ".slider-range" ).slider({
- range: true,
- min: <?php echo get_session('xrange_min', '0') ?>,
- max: <?php echo get_session('xrange_max', '100') ?>,
- values: [ <?php echo get_session('x_min',
get_session('xrange_min', '0')) ?> , <?php echo get_session('x_max',
get_session('xrange_max', '100')) ?> ],
- slide: function( event, ui ) {
- if(this.id == "default_range_slider") {
- $(".input_min").val(ui.values[0]);
- $(".input_max").val(ui.values[1]);
- if($(this).slider('values', 0) !=
ui.values[0]) {
- $( ".auto_min" ).attr('checked', false);
- }
- if($(this).slider('values', 1) !=
ui.values[1]) {
- $( ".auto_max" ).attr('checked', false);
- }
- $( ".slider-range" ).each(function(){
- $(this).slider('values', 0, ui.values[0]);
- $(this).slider('values', 1, ui.values[1]);
- });
- } else {
-
$(this).parents("tr").find(".input_min").val(ui.values[0]);
-
$(this).parents("tr").find(".input_max").val(ui.values[1]);
- if($(this).slider('values', 0) !=
ui.values[0]) {
- $(this).parents("tr").find( ".auto_min"
).attr('checked', false);
- }
- if($(this).slider('values', 1) !=
ui.values[1]) {
- $(this).parents("tr").find( ".auto_max"
).attr('checked', false);
- }
- }
- },
- stop: function( event, ui ) {
- if(this.id == "default_range_slider") {
- min =
$(this).parents(".slider_control").find(".auto_min").attr('checked') ? "auto" :
$(this).slider('values', 0);
- max =
$(this).parents(".slider_control").find(".auto_max").attr('checked') ? "auto" :
$(this).slider('values', 1);
- $.get("ajax.php", {
- x_min: min,
- x_max: max,
- persist: "true"
- }, function(data) {
- $( ".plot" ).each(function() {
- this.src =
this.src.replace(/&x_m(ax|in)=[^&]+/g, '')+"&reload=1";
- });
- }
- );
- } else {
- min =
$(this).parents("tr").find(".auto_min").attr('checked') ? "auto" :
$(this).slider('values', 0);
- max =
$(this).parents("tr").find(".auto_max").attr('checked') ? "auto" :
$(this).slider('values', 1);
-
$(this).parents("tr").find(".plot").each(function(){
- this.src =
this.src.replace(/&x_m(ax|in)=[^&]+/g, '')+"&x_min="+min+"&x_max="+max;
- });
- }
- }
- });
- $( ".input_min" ).change(function( event ) {
- var newmin = this.value;
- if(this.id == "default_input_min") {
- $( ".auto_min" ).attr('checked', false);
- $( ".slider-range" ).each(function(){
- $(this).slider('values', 0, newmin);
- });
- $( ".input_min" ).val(newmin);
- max =
$(this).parents(".slider_control").find(".auto_max").attr('checked') ?
- "auto" :
-
$(this).parents(".slider_control").find(".slider-range").slider('values', 1);
- $.get("ajax.php", {
- x_min: newmin,
- x_max: max,
- persist: "true"
- }, function(data) {
- $( ".plot" ).each(function() {
- this.src =
this.src.replace(/&x_m(ax|in)=[^&]+/g, '')+"&reload=1";
- });
- }
- );
- } else {
- $(this).parents("tr").find( ".auto_min"
).attr('checked', false);
- $(this).parents("tr").find( ".slider-range"
).slider('values', 0, newmin);
- max =
$(this).parents(".tr").find(".auto_max").attr('checked') ?
- "auto" :
-
$(this).parents(".tr").find(".slider-range").slider('values', 1);
- $(this).parents("tr").find(".plot").each(function(){
- this.src = this.src.replace(/&x_m(ax|in)=[^&]+/g,
'')+"&x_min="+newmin+"&x_max="+max;
- });
- }
- });
- $( ".input_max" ).change(function( event ) {
- var newmax = this.value;
- if(this.id == "default_input_max") {
- $( ".auto_max" ).attr('checked', false);
- $( ".slider-range" ).each(function(){
- $(this).slider('values', 1, newmax);
- });
- $( ".input_max" ).val(newmax);
- min =
$(this).parents(".slider_control").find(".auto_min").attr('checked') ?
- "auto" :
-
$(this).parents(".slider_control").find(".slider-range").slider('values', 0);
- $.get("ajax.php", {
- x_min: min,
- x_max: newmax,
- persist: "true"
- }, function(data) {
- $( ".plot" ).each(function() {
- this.src =
this.src.replace(/&x_m(ax|in)=[^&]+/g, '')+"&reload=1";
- });
- }
- );
- } else {
- $(this).parents("tr").find( ".auto_max"
).attr('checked', false);
- $(this).parents("tr").find( ".slider-range"
).slider('values', 1, newmax);
- min =
$(this).parents(".tr").find(".auto_min").attr('checked') ?
- "auto" :
-
$(this).parents(".tr").find(".slider-range").slider('values', 0);
- $(this).parents("tr").find(".plot").each(function(){
- this.src = this.src.replace(/&x_m(ax|in)=[^&]+/g,
'')+"&x_min="+min+"&x_max="+newmax;
- });
- }
- });
- $( ".auto_min" ).click(function(){
- var chk = this.checked;
- if($(this).parents("#default_range_control").length > 0) {
- $( ".auto_min" ).attr('checked', chk);
- min = chk ? "auto" :
$(this).parents(".slider_control").find(".slider-range").slider('values', 0);
- $( ".plot" ).each(function() {
- this.src = this.src.replace(/&x_min=[^&]+/g,
'')+"&x_min="+min;
- });
- $.get("ajax.php", {
- x_min: min,
- persist: "true"
- });
- if(!chk) {
- $( ".slider-range" ).each(function(){
- $(this).slider('values', 0, min);
- });
- $( ".input_min" ).val(min);
- }
- } else {
- min = chk ? "auto" :
$(this).parents("tr").find(".slider-range").slider('values', 0);
- $(this).parents("tr").find(".plot").each(function(){
- this.src = this.src.replace(/&x_min=[^&]+/g,
'')+"&x_min="+min;
- });
- }
- });
- $( ".auto_max" ).click(function(){
- var chk = this.checked;
- if($(this).parents("#default_range_control").length > 0) {
- $( ".auto_max" ).attr('checked', chk);
- max = chk ? "auto" :
$(this).parents(".slider_control").find(".slider-range").slider('values', 1);
- $( ".plot" ).each(function() {
- this.src = this.src.replace(/&x_max=[^&]+/g,
'')+"&x_max="+max;
- });
- $.get("ajax.php", {
- x_max: max,
- persist: "true"
- });
- if(!chk) {
- $( ".slider-range" ).each(function(){
- $(this).slider('values', 1, max);
- });
- $( ".input_max" ).val(max);
- }
- } else {
- max = chk ? "auto" :
$(this).parents("tr").find(".slider-range").slider('values', 1);
- $(this).parents("tr").find(".plot").each(function(){
- this.src = this.src.replace(/&x_max=[^&]+/g,
'')+"&x_max="+max;
- });
- }
- });
- $( ".auto_y" ).click(function(){
- var chk = this.checked;
- min = chk ? "auto" :
$("#change_origin_slider").slider('value');
- $.get("ajax.php", {
- y_min: min,
- persist: "true"
- }, function(data) {
- $( ".plot" ).each(function(){
- this.src = this.src.replace(/&y_min=[^&]+/g,
'')+"&reload=1";
- });
- });
- });
- $( "#change_origin_slider" ).slider({
- min: <?php echo get_session('yrange_min', '0') ?>,
- max: <?php echo get_session('yrange_max', '100') ?>,
- value: <?php echo get_session('y_min', '0') ?>,
- slide: function( event, ui ) {
-
$(this).parents(".slider_control").find(".input_max").val(ui.value);
-
$(this).parents(".slider_control").find(".auto_y").attr("checked", false);
- },
- change: function( event, ui ) {
-
$(this).parents(".slider_control").find(".input_max").val(ui.value);
- $.get("ajax.php", {
- y_min: ui.value,
- persist: "true"
- }, function(data) {
- $( ".plot" ).each(function(){
- this.src =
this.src.replace(/&y_m(ax|in)=[^&]+/g, '')+"&reload=1";
- });
- }
- );
- }
- });
- $(
"#change_origin_control").find('.input_max').change(function(){
-
$(this).parents(".slider_control").find(".auto_y").attr("checked", false);
- $("#change_origin_slider").slider('value', this.value);
- });
- $( "#change_size_x_slider" ).slider({
- min: 0,
- max: 2000,
- value: <?php echo get_session('png_x_size', '640') ?>,
- slide: function( event, ui ) {
- $("#left-range-x-input").val(ui.value);
- },
- change: function( event, ui ) {
- $.get("ajax.php", {
- png_x_size: ui.value,
- persist: "true"
- }, function(data) {
- $( ".plot" ).each(function(){
- this.src = this.src+"&reload=1";
- });
- $( "td" ).attr('width', ui.value);
- }
- );
- }
- });
- $( "#left-range-x-input").change(function(){
- $("#change_size_x_slider").slider('value', this.value);
- });
- $( "#change_size_y_slider" ).slider({
- min: 0,
- max: 2000,
- value: <?php echo get_session('png_y_size', '480') ?>,
- slide: function( event, ui ) {
- $("#right-range-y-input").val(ui.value);
- },
- change: function( event, ui ) {
- $.get("ajax.php", {
- png_y_size: ui.value,
- persist: "true"
- }, function(data) {
- $( ".plot" ).each(function(){
- this.src = this.src+"&reload=1";
- });
- $( "td" ).attr('height', ui.value);
- }
- );
- }
- });
- $( "#right-range-y-input").change(function(){
- $("#change_size_y_slider").slider('value', this.value);
- });
- $( "#default_range" ).click(function() {
- var was = $( "#default_range_control" ).css("display");
- $( ".slider_control" ).hide();
- if(was == "none")
- $( "#default_range_control" ).show();
- });
- $( "#change_origin" ).click(function() {
- var was = $( "#change_origin_control" ).css("display");
- $( ".slider_control" ).hide();
- if(was == "none")
- $( "#change_origin_control" ).show();
- });
- $( "#change_size" ).click(function() {
- var was = $( "#change_size_control" ).css("display");
- $( ".slider_control" ).hide();
- if(was == "none")
- $( "#change_size_control" ).show();
- });
- $( "#norm" ).click(function () {
- c = this;
- $(this).parents("tr").find(".plot").each(function(){
- //alert(this.src.replace(/&norm=[^&]+/g,
'')+"&norm="+c.checked);
- this.src = this.src.replace(/&norm=[^&]+/g,
'')+"&norm="+c.checked;
- });
- });
- $( ".metric_category_header" ).click(function () {
- ul = $(this).parents(".metric").find("ul");
- ul.toggle();
- if(ul.is(':visible')) {
- $(this).find("img").attr("src", "images/contract.png");
- $.cookie(":::"+ul.attr("id"), "visible");
- } else {
- $(this).find("img").attr("src", "images/expand.png");
- $.cookie(":::"+ul.attr("id"), "hidden");
- }
- });
- $( ".instant_search" ).focus(function(){
- if(this.value==search_prompt){
- this.value="";
- }
- field_search = this;
- inst_search = setInterval(monitor_search, 200);
- monitor_search();
- });
- $( ".instant_search" ).blur(function(){
- if(this.value==""){
- this.value=search_prompt;
- }
- clearInterval(inst_search);
- });
- $( ".instant_search" ).each(function(){
- value = $.cookie(this.id);
- if(value && value != search_prompt){
- this.value = value;
- field_search = this;
- monitor_search();
- } else {
- last_search = " ";
- field_search = this;
- monitor_search();
- this.value = search_prompt;
- $.cookie(this.id, null);
- }
- });
- $("#metrics ul").each(function(){
- if($.cookie(":::"+this.id) == "hidden") {
- $(this).toggle()
- $(this).parents(".metric").find("img").attr("src",
"images/expand.png");
- }
- });
- $(".plot-all-hosts").click(function(){
- $(this).parents("ul").find(".plot-host").attr('checked',
true);
- $(this).parents("tr").find(".plot").each(function() {
- this.src = this.src.replace(/&h=[^&]+/g, '');
- });
- });
- $(".plot-no-hosts").click(function(){
- $(this).parents("ul").find(".plot-host").attr('checked',
false);
- });
- $(".plot-host").click(function(){
- var hosts = "";
- var sep = "";
- var links =
$(".plot-host:checked").parents("li").find("a").get().reverse();
- for(i in links) {
- host = "" + links[i];
- hosts += sep + host.replace(/.*host=([^&]+).*/g, "$1");
- sep = ",";
- }
- $(this).parents("tr").find(".plot").each(function() {
- this.src = this.src.replace(/&h=[^&]+/g,
'')+"&h="+hosts;
- });
- });
- $(".add-metric").click(function(){
- x =
$(this).parents(".control-column").find(".select-metric").val();
- added =
$(this).parents(".control-column").find(".added-metric").parents("li").find("a").get();
- for(i in added) {
- a = "" + added[i];
- a = a.replace(/.*graph=([^&]+).*/g, "$1");
- a = a.replace(/%20/g, " ");
- if (x == a) {
- return;
- }
- }
-
$(this).parents(".control-column").find(".added-metrics").append(
- '<li>\
- <input type="checkbox" checked="checked"
class="added-metric" onclick="rescan_added_hosts(this)">\
- <a href="index.php?graph=' + x + '" title="[' +
get_category(x) + '] ' + get_name(x) + '">' + get_name(x) + '</a>\
- </li>'
- );
- u0 =
get_unit($(this).parents("tr").find("option.same-unit-metric").val());
- if(get_unit(x) != u0) {
-
$(this).parents("tr").find("option:not(.same-unit-metric)").each(function() {
- if(get_unit(this.value) == get_unit(x)) {
- $(this).addClass('second-unit-metric');
- } else {
- $(this).addClass('incompatible-unit-metric');
- }
- });
- }
- $(this).parents("tr").find("option[value=" + x +
"]").remove();
- $(this).parents("tr").find(".plot").each(function() {
- this.src = this.src.replace(/(g=[^&]+)/g, '$1,'+x);
- });
- });
- });
-
- function rescan_added_hosts(that) {
- var graphs = "";
- var sep = "";
- var x = null;
- var x0 = null;
- var links =
$(that).parents("ul").find(".added-metric:checked").parents("li").find("a").get().reverse();
- for(i in links) {
- graph = "" + links[i];
- graph = graph.replace(/.*graph=([^&]+).*/g, "$1");
- graphs += sep + graph;
- if(x == null) {
- if(i == 0) {
- x0 = graph;
- } else {
- if(get_unit(graph) != get_unit(x0)) {
- x = graph;
- }
- }
- }
- sep = ",";
- }
-
$(that).parents("tr").find("option:not(.same-unit-metric)").each(function() {
- if(x != null) {
- if(get_unit(this.value) == get_unit(x)) {
-
$(this).removeClass('incompatible-unit-metric').addClass('second-unit-metric');
- } else {
-
$(this).removeClass('second-unit-metric').addClass('incompatible-unit-metric');
- }
- } else {
- $(this).removeClass('second-unit-metric');
- $(this).removeClass('incompatible-unit-metric');
- }
- });
- $(that).parents("tr").find(".plot").each(function() {
- this.src = this.src.replace(/&g=[^&]+/g, '')+"&g="+graphs;
- });
- }
-
- function get_command(element) {
- var url = $(element).parents("tr").find("img").attr("src");
- document.location = url + "&raw_cmd=true";
- }
-
- function monitor_search() {
- text = $( field_search ).val();
- if(text == last_search) return;
- if(text == search_prompt) text = '';
- last_search = text;
- $.cookie(field_search.id, text);
- if(!$.browser.msie) { /* SORRY, BUT IE IS *SLOW* WITH JQUERY */
- uls = $("#metrics ul:visible"); /* Nasty hack: */
- uls.hide(); /* 500x speedup on old Chrome
versions */
- if(text == "") {
- $( field_search
).parents(".search_realm").find(".search_item").show();
- } else {
- $( field_search
).parents(".search_realm").find(".search_item[id*="+text+"]").show();
- $( field_search
).parents(".search_realm").find(".search_item:not([id*="+text+"])").hide();
- }
- uls.show();
- } else { /* IE SPECIFIC ALGORITHM (x10 speedup on IE) */
- $( field_search
).parents(".search_realm").find(".search_item").each(function(){
- if(this.id.indexOf(text) == -1){
- $(this).hide();
- } else {
- $(this).show();
- }
- });
- }
- }
-
- function debug(param) {
- $( "#debug" ).html($( "#debug" ).html() + param + ' ');
- }
-
- function reset_session() {
- $.cookie('instant_search_hosts', null);
- $.cookie('instant_search_metrics', null);
- document.location = '?logout=1';
- }
-
- function get_category(s) {
- return s.replace(/:::.*/g, '');
- }
-
- function get_name(s) {
- s = s.replace(/.*:::/g, '');
- return s.replace(/___.*/g, '');
- }
-
- function get_unit(s) {
- return s.replace(/.*___/g, '');
- }
-
- </script>
-
- </head>
- <body>
- <div Id="debug"></div>
- <div class="header">
- <?php include "template_menu.php" ?>
- <a href="index.php" class="name"><img src="images/l.png" /></a>
- <p><a href="index.php" class="name">Gauger, performance recording
tool</a></p>
- </div>
- <div class="header-shadow"></div>
- <div class="container">
- <div class="menu">
- <div id="hosts" class="search_realm">
- <h2>Hosts</h2>
- <input id="instant_search_hosts" class="instant_search"></input>
- <ul>
- <?php foreach ($hosts as $host => $counters): ?>
- <li id="<?php echo $host ?>" class="search_item">
- <a href="?host=<?php echo $host ?>">
- <?php echo $host ?>
- </a>
- </li>
- <?php endforeach; ?>
- </ul>
- </div>
- <div id="metrics" class="search_realm">
- <h2>Metrics</h2>
- <input id="instant_search_metrics" class="instant_search"></input>
- <?php foreach ($metrics_c as $category => $counters): ?>
- <div class="metric">
- <div class="metric_category_header">
- <?php echo $category ? $category : 'Others' ?>
- <img class="expand_arrow" src="images/contract.png"></img>
- </div>
- <ul id="<?php echo $category ? $category : 'Others' ?>">
- <?php foreach ($counters as $link => $name): ?>
- <li id="<?php echo $name ?>" class="search_item"><a
href="?graph=<?php echo $link ?>">
- <?php echo $name . (get_counter_unit($link) ? ' (' .
get_counter_unit($link) . ')' : '') ?>
- </a></li>
- <?php endforeach; ?>
- </ul>
- </div>
- <?php endforeach; ?>
- </div>
- </div>
- <div class="content">
- <?php if($mode_host == 1): ?>
- <?php include "template_host.php" ?>
- <?php elseif($mode_graph == 1): ?>
- <?php include "template_graph.php" ?>
- <?php else: ?>
- <?php include "template_welcome.php" ?>
- <?php endif; ?>
- </div>
- <div style="clear:both"></div>
- </div>
- <div class="footer-shadow"></div>
- <div id="footer">
- <p>Copyright 2011 Bartlomiej Polot (address@hidden)</p>
- <p>This software is distributed under the <a target="_blank"
href="http://www.gnu.org/licenses/agpl.html">GNU AGPL</a></p>
- <p>
- <a target="_blank" href="https://gnunet.org/svn/gauger">gauger
version 0.0.4alpha</a> |
- <a target="_blank"
href="https://gnunet.org/gauger/index.php">Project Main Page</a> |
- <a target="_blank" href="https://gnunet.org/svn/gauger">SVN
repository</a>
- </p>
- </div>
- </body>
-</html>
Deleted: gauger/template_graph.php
===================================================================
--- gauger/template_graph.php 2011-04-19 14:41:56 UTC (rev 15029)
+++ gauger/template_graph.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -1,76 +0,0 @@
-<?php
-/** template_graph.php
-
- This file is part of gauger.
- Copyright 2011 Bartlomiej Polot
-
- gauger is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- gauger 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with gauger. If not, see <http://www.gnu.org/licenses/>.
-
-*/?>
-<h1>SHOWING GRAPH: <?php echo get_counter_name($currentg) ?></h1>
-<?php if (array_key_exists($currentg, $metrics)): ?>
-<table>
- <tr>
- <th class="control-column">Controls</th>
- <th>Graph</th>
- </tr>
- <tr>
- <th class="control-column">
- Range
- <br/>
- <div class="side_slider_control">
- <div class="slider-range" id="other_slider" ></div>
- <div class="left-range">
- <input class="input_min" value="<?php echo
get_session('x_min', get_session('xrange_min', '0')) ?>"></input>
- </div>
- <div class="right-range">
- <input class="input_max" value="<?php echo
get_session('x_max', get_session('xrange_max', '0')) ?>"></input>
- </div>
- <div class="auto_range">
- <input class="auto_min" type="checkbox" <?php
if(get_session('x_min_a')) echo 'checked="checked"'?>/>
- Auto
- <input class="auto_max" type="checkbox" <?php
if(get_session('x_max_a')) echo 'checked="checked"'?>/>
- </div>
- </div>
- <hr/>
- <span>Normalize<input type="checkbox" id="norm"/></span>
- <hr/>
- <a href="#" onclick="get_command(this); return false;" >Get
Source</a>
- <hr/>
- <ul>
- <?php foreach ($hosts as $host => $counters): ?>
- <?php if(array_search($currentg, $counters) !== FALSE): ?>
- <li>
- <input type="checkbox" class="plot-host" checked="true"/>
- <a href="?host=<?php echo $host ?>" title="<?php echo
$host ?>">
- <?php echo (strlen($host) > 10) ?
substr($host,0,8).'...' : $host ?>
- </a>
- <br />
- </li>
- <?php endif; ?>
- <?php endforeach; ?>
- <li>
- <input type="button" class="plot-all-hosts" value="All"/>
- <input type="button" class="plot-no-hosts" value="None"/>
- </li>
- </ul>
- </th>
- <td height="<?php echo get_session('png_y_size')+2 ?>" width="<?php
echo get_session('png_x_size')+2 ?>">
- <img class="plot" src="plot.php?g=<?php echo $currentg ?>"
alt="loading..."/>
- </td>
- </tr>
-</table>
-<?php else: ?>
-<h1>The graph "<?php echo $currentg ?>" is not present in any host.</h1>
-<?php endif; ?>
Deleted: gauger/template_host.php
===================================================================
--- gauger/template_host.php 2011-04-19 14:41:56 UTC (rev 15029)
+++ gauger/template_host.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -1,131 +0,0 @@
-<?php
-/** template_host.php
-
- This file is part of gauger.
- Copyright 2011 Bartlomiej Polot
-
- gauger is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- gauger 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with gauger. If not, see <http://www.gnu.org/licenses/>.
-
-*/?>
-<?php if (isset($hosts[$current])): ?>
- <div class="title">
- <h1>SHOWING HOST: <?php echo $current ?></h1>
- <form action="index.php" method="get" id="search_host">
- <input name="host" value="<?php echo $current ?>"
class="hidden_input"/>
- <input name="q" value="<?php echo $q ?>"/>
- <input type="submit" value="Search">
- </form>
- </div>
- <?php if (!empty($hosts[$current])): ?>
- <?php $p = get_param('page', 1); $maxp =
ceil(count($hosts[$current])/$PAGELENGTH) ?>
- <p class="pager">
- <?php if ($p >= 4): ?>
- <a href="index.php?host=<?php echo $current ?>&q=<?php echo $q
?>&page=1">1</a><?php if ($p > 4) echo " .. " ?>
- <?php endif; ?>
- <?php for ($l = $p - 2; $l <= $p+2; $l++): ?>
- <?php if($l >= 1 && $l <= $maxp): ?>
- <?php if($l == $p) echo "[" ?>
- <a href="index.php?host=<?php echo $current ?>&q=<?php echo $q
?>&page=<?php echo $l ?>"><?php echo $l ?></a>
- <?php if($l == $p) echo "]" ?>
- <?php endif; ?>
- <?php endfor; ?>
- <?php if ($p <= $maxp - 3): ?>
- <?php if ($p < $maxp - 3) echo " .. " ?><a href="index.php?host=<?php
echo $current ?>&q=<?php echo $q ?>&page=<?php echo $maxp ?>"><?php
echo $maxp ?></a>
- <?php endif; ?>
- </p>
- <table>
- <tr>
- <th class="control-column">Controls</th>
- <th>Graph</th>
- </tr>
- <?php for ($i = 0; $i < $PAGELENGTH && ($p-1)*$PAGELENGTH+$i <
count($hosts[$current]); $i++): ?>
- <?php $counter = $hosts[$current][($p-1)*$PAGELENGTH+$i] ?>
- <tr>
- <th class="control-column">
- Range
- <br/>
- <div class="side_slider_control">
- <div class="slider-range" id="other_slider" ></div>
- <div class="left-range">
- <input class="input_min" value="<?php echo
get_session('x_min', get_session('xrange_min', '0')) ?>"></input>
- </div>
- <div class="right-range">
- <input class="input_max" value="<?php echo
get_session('x_max', get_session('xrange_max', '0')) ?>"></input>
- </div>
- <div class="auto_range">
- <input class="auto_min" type="checkbox" <?php
if(get_session('x_min_a')) echo 'checked="checked"'?>/>
- Auto
- <input class="auto_max" type="checkbox" <?php
if(get_session('x_max_a')) echo 'checked="checked"'?>/>
- </div>
- </div>
- <hr/>
- <a href="#" onclick="get_command(this); return false;" >Get
Source</a>
- <hr/>
- <ul class="added-metrics">
- <li>
- <input type="checkbox" checked="checked"
class="added-metric" disabled>
- <a href="?graph=<?php echo $counter ?>" title="<?php
echo '['.get_counter_category($counter).'] '. get_counter_name($counter)?>">
- <?php echo get_counter_name($counter) ?>
- </a>
- </li>
- </ul>
- <hr/>
- Compare with:
- <select class="select-metric">
- <?php foreach ($hosts[$current] as $graph): ?>
- <?php if($graph != $counter): ?>
- <option value="<?php echo $graph?>"
- <?php if(get_counter_unit($graph) ==
get_counter_unit($counter)): ?>
- <?php echo ' class="same-unit-metric"' ?>
- <?php endif; ?>
- >
- <?php echo get_counter_name($graph) ?>
- </option>
- <?php endif; ?>
- <?php endforeach; ?>
- </select><br/>
- <input type="button" value="Add" class="add-metric"></input>
- <br/>
- <p class="same-unit-metric">Main unit</p>
- <p class="second-unit-metric">Secondary unit</p>
- <p class="incompatible-unit-metric">Incompatible</p>
- </th>
- <td height="<?php echo get_session('png_y_size')+2 ?>"
width="<?php echo get_session('png_x_size')+2 ?>"><img class="plot"
src="plot.php?h=<?php echo "$current&g=$counter" ?>" alt="loading..."/></td>
- </tr>
- <?php endfor; ?>
- </table>
- <p class="pager">
- <?php if ($p >= 4): ?>
- <a href="index.php?host=<?php echo $current ?>&q=<?php echo $q
?>&page=1">1</a><?php if ($p > 4) echo ".." ?>
- <?php endif; ?>
- <?php for ($l = $p - 2; $l <= $p+2; $l++): ?>
- <?php if($l >= 1 && $l <= $maxp): ?>
- <?php if($l == $p) echo "[" ?>
- <a href="index.php?host=<?php echo $current ?>&q=<?php echo $q
?>&page=<?php echo $l ?>"><?php echo $l ?></a>
- <?php if($l == $p) echo "]" ?>
- <?php endif; ?>
- <?php endfor; ?>
- <?php if ($p <= $maxp - 3): ?>
- <?php if ($p < $maxp - 3) echo ".." ?><a href="index.php?host=<?php
echo $current ?>&q=<?php echo $q ?>&page=<?php echo $maxp ?>"><?php
echo $maxp ?></a>
- <?php endif; ?>
- </p>
- <?php else: ?>
- <h1>The host "<?php echo $current ?>" has no counters</h1>
- <?php endif; ?>
-<?php else: ?>
- <h1>Oops!</h1>
- <p>The host you are looking for doesn't seem to exist. Please select a
host from the menu on the left.</p>
- <p>If you reached this page from a link within the application, an error
must have occurred.
- Please be so kind and send a report to the maintainer.</p>
-<?php endif; ?>
Deleted: gauger/template_menu.php
===================================================================
--- gauger/template_menu.php 2011-04-19 14:41:56 UTC (rev 15029)
+++ gauger/template_menu.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -1,56 +0,0 @@
-<?php
-/** template_menu.php
-
- This file is part of gauger.
- Copyright 2011 Bartlomiej Polot
-
- gauger is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- gauger 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with gauger. If not, see <http://www.gnu.org/licenses/>.
-
-*/?>
- <div class="advanced_menu">
- <a href="#" id="default_range" >Default Range</a>
- <div class="slider_control" id="default_range_control">
- <div class="slider-range" id="default_range_slider"></div>
- <div class="left-range">
- <input id="default_input_min" class="input_min"
value="<?php echo get_session('x_min', get_session('xrange_min', '0'))
?>"></input>
- </div>
- <div class="right-range">
- <input id="default_input_max" class="input_max"
value="<?php echo get_session('x_max', get_session('xrange_max', '0'))
?>"></input>
- </div>
- <div class="auto_range">
- <input class="auto_min" type="checkbox" <?php
if(get_session('x_min_a')) echo 'checked="checked"'?>/>
- Auto
- <input class="auto_max" type="checkbox" <?php
if(get_session('x_max_a')) echo 'checked="checked"'?>/>
- </div>
- </div> |
- <a href="#" id="change_origin" >Change Origin</a>
- <div class="slider_control" id="change_origin_control">
- <div class="slider" id="change_origin_slider"></div>
- <div class="auto_range">
- <input class="auto_y" type="checkbox" <?php
if(get_session('y_min_a')) echo 'checked="checked"'?>/>
- Auto
- <input class="input_max" value="<?php echo
get_session('y_min', '0') ?>"></input>
- </div>
- </div> |
- <a href="#" id="change_size" >Change Size</a>
- <div class="slider_control" id="change_size_control">
- <div class="slider-container"><div class="slider"
id="change_size_x_slider"></div></div>
- <div id="left-range-x">X</div>
- <input id="left-range-x-input" value="<?php echo
get_session('png_x_size', '640') ?>"></input>
- <div id="right-range-y">Y</div>
- <input id="right-range-y-input" value="<?php echo
get_session('png_y_size', '480') ?>"></input>
- <div class="slider" id="change_size_y_slider"></div>
- </div> |
- <a href="#" onclick="reset_session(); return false;">Reset
Session</a>
- </div>
Deleted: gauger/template_welcome.php
===================================================================
--- gauger/template_welcome.php 2011-04-19 14:41:56 UTC (rev 15029)
+++ gauger/template_welcome.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -1,49 +0,0 @@
-<?php
-/** template_welcome.php
-
- This file is part of gauger.
- Copyright 2011 Bartlomiej Polot
-
- gauger is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- gauger 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with gauger. If not, see <http://www.gnu.org/licenses/>.
-
-*/?>
-<h1>Welcome to Gauger</h1>
-
-<p>We have data from <b>r<?php echo get_session('xrange_min') ?></b> to
<b>r<?php echo get_session('xrange_max') ?></b>.
-
-<p>If you click on a host from the <b>Hosts</b> menu on the left, you will see
all the metrics for that particular host.</p>
-
-<p>If you to compare all hosts given a metric, click on the corresponding
metric in the <b>Metrics</b> section.</p>
-
-<h2>Options</h2>
-In the upper right corner you have the options menu. It's possible to adjust
the following parameters:
-
-<h3>Default Range</h3>
-<p>Changing this setting will affect <b>all</b> the graphs that are displayed.
The start of the plotted range can be adjusted by
-moving the left handle of the slider. Similiarly, the end of the plotted range
can be set dragging the right handle.</p>
-
-<p>By default the graphs are plotted in automatic mode, i.e, only the region
that contains data is plotted.
-This can be turned off by unchecking the <i>Auto</i> checkbox for either side
of the graph or by adjusting either side of the slider.
-Checking the <i>Auto</i> checkbox sets the that side of the range to automatic
detection, but does not affect the range selected by the slider.</p>
-
-<h3>Change Origin</h3>
-By default all data is plotted in a scale from 0 to the highest value in the
range. This option allows to change where to set the origin
-of axis <i>y</i>.
-
-<h3>Change Size</h3>
-To better adapt the graphs to the size of the screen, it is possible change
the size of each plot. The default plot size is
-640 pixels wide and 480 pixels high, but these values can be changed using the
sliders.
-
-<h3>Reset Session</h3>
-Clicking on this opition resets all changes done to the previous options,
effectively starting a new session.
Copied: gauger/web/ajax.php (from rev 15002, gauger/ajax.php)
===================================================================
--- gauger/web/ajax.php (rev 0)
+++ gauger/web/ajax.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -0,0 +1,54 @@
+<?php
+/** ajax.php
+
+ This file is part of gauger.
+ Copyright 2011 Bartlomiej Polot
+
+ gauger is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ gauger 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with gauger. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+include "params.php"; // Manage all parameters given by the user
+include "explore.php"; // Gather all existing hosts and counters
+init_params();
+explore();
+
+$persist = get_param('persist') == 'true';
+foreach ($range_parameters as $param_name) {
+ $prev = array_key_exists($param_name, $_SESSION);
+ if ($prev) $bck = $_SESSION[$param_name];
+ $$param_name = get_param($param_name, '', $persist, false);
+ if($$param_name === '') continue;
+ if(!is_numeric($$param_name) && $persist) {
+ if($prev) {
+ $_SESSION[$param_name] = $bck;
+ } else {
+ $_SESSION[$param_name] = '';
+ }
+ $_SESSION[$param_name."_a"] = 1;
+ $$param_name = '*';
+ } else if($persist) {
+ $_SESSION[$param_name."_a"] = 0;
+ }
+}
+$req = get_param('req');
+if($req) {
+ $reqa = Array();
+ foreach(explode(',', $req) as $param) {
+ $reqa[$param] = get_session($param, '');
+ }
+ die(json_encode($reqa));
+} else {
+ die('OK');
+}
Deleted: gauger/web/css/style.css
===================================================================
--- gauger/css/style.css 2011-04-19 14:41:56 UTC (rev 15029)
+++ gauger/web/css/style.css 2011-04-19 17:07:13 UTC (rev 15030)
@@ -1,392 +0,0 @@
-/** syles.css
-
- This file is part of gauger.
- Copyright 2011 Bartlomiej Polot
-
- gauger is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- gauger 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with gauger. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-body {
- font-size: 75%;
- font-family: 'Helvetica','Verdana','Arial','sans serif';
- background-color: #D3D3D3;
- color: #404040;
- margin: 0px;
-}
-
-h1 {
- font-size: 140%;
-}
-
-h2 {
- font-size: 120%;
- margin-bottom: 5px;
-}
-
-h3 {
- font-size: 110%;
-}
-
-table {
- border: 2px;
- border-style: solid;
- border-color: #D3D3D3;
-}
-
-tr {
- padding: 0px;
-}
-
-th {
- background-color: #D3D3D3;
- padding: 2px;
- font-weight: normal;
-}
-
-th.control-column {
- width: 100px;
- min-width: 100px;
-}
-
-td {
- background-color: white;
- border: 1px;
- border-style: solid;
- border-color: #D3D3D3;
- text-align: center;
- padding: 0px;
-}
-
-img {
- margin: 0px;
- padding: 0px;
- border: none;
-}
-
-div {
- margin: 0px;
- padding: 0px;
- border: none;
-}
-
-a:link {
- color: #404040;
- text-decoration: none;
-}
-
-a:visited {
- color: #404040;
- text-decoration: none;
-}
-
-a:hover {
- color: #808080;
- text-decoration: none;
-}
-
-.header {
- margin: 0px;
- padding-top: 5px;
-}
-
-.header img {
- margin: 4px 10px 4px 10px;
- float: left;
- border: none;
-}
-
-.header p {
- font-size: 20px;
- font-weight: bold;
- margin: 10px 0 0 0;
-}
-
-.header-shadow {
- height: 50px;
- background-image: url("images/h.png");
- clear: both;
-}
-
-.container {
- background-color: white;
- padding: 10px;
-}
-
-.menu {
- float: left;
- width: 135px;
- margin-right: 5px;
-}
-
-.menu a {
- display: block;
- border-bottom: solid 1px #D3D3D3;
-}
-
-/*.menu a:hover {
- background: #D3D3D3;
-}*/
-
-.instant_search {
- width: 133px;
- height: 14px;
- border: solid 1px #D3D3D3;
- font-size: 90%;
-}
-
-#instant_search_metrics {
- margin-bottom: 5px;
-}
-
-#search_host {
- float: right;
-}
-
-.hidden_input {
- display: none;
-}
-
-.search_item {
- display: none;
-}
-
-.metric_category_header {
- background: #D3D3D3;
- padding: 1px 1px 1px 5px;
- font-size: 120%;
- cursor: pointer;
-}
-
-.metric_category_header:hover {
- background: #E0E0E0;
-}
-
-.menu ul {
- padding-left: 6px;
- margin: 0px;
- list-style-type: none;
-}
-
-.menu li {
- padding: 2px 0px 2px 0px;
- font-size: 90%;
-}
-
-.menu .expand_arrow {
- float: right;
- margin-right: 4px;
-}
-
-.content {
- margin: 10px;
- margin-left: 145px;
-}
-
-.advanced_menu {
- float: right;
- margin: 5px;
-}
-
-.slider_control {
- display: none;
- padding: 3px 3px 3px 3px;
- margin-top: 5px;
- border: 1px black solid;
- text-align: center;
- font-size: 80%;
- width: 100px;
- background-color: white;
-}
-
-.side_slider_control {
- padding: 3px 3px 3px 3px;
- margin-top: 5px;
- text-align: center;
- font-size: 80%;
-}
-
-#default_range_control {
- position: absolute;
- margin-left: 0px;
-}
-
-#change_origin_control {
- position: absolute;
- margin-left: 98px;
-}
-
-#change_size_control {
- position: absolute;
- margin-left: 200px;
-}
-
-.left-range {
- float: left;
- text-align: left;
-}
-
-.right-range {
- float: right;
- text-align: right;
-}
-
-#left-range-x {
- float: left;
- padding: 1px 4px 1px 2px;
- margin-bottom: 4px;
- background-color: #D3D3D3;
- height: 14px;
-}
-
-#left-range-x-input {
- width: 30px;
- height: 14px;
- border: none;
- font-size: 90%;
- background-color: #D3D3D3;
- color: #000;
- float: left;
-}
-
-#right-range-y {
- float: right;
- padding: 1px 2px 1px 4px;
- margin-bottom: 4px;
- height: 14px;
-}
-
-#right-range-y-input {
- width: 30px;
- height: 14px;
- border: none;
- font-size: 90%;
- float: right;
- background-color: #FFF;
- color: #000;
- text-align: right;
-
-}
-
-.slider-container {
- background-color: #D3D3D3;
- padding: 1px;
-}
-
-.slider-range {
- margin: 5px;
- width: 90%;
-}
-
-.slider {
- margin: 5px;
- width: 90%;
- clear: both;
-}
-
-.ui-slider .ui-slider-handle {
- width: 8px;
-}
-
-.auto_range {
- clear: both;
-}
-
-.auto_range input {
- margin: 0px;
-}
-
-.auto_min {
- float: left;
-}
-
-.input_min {
- width: 40px;
- border: none;
- font-size: 90%;
-}
-
-.auto_max {
- float: right;
-}
-
-.input_max {
- width: 40px;
- border: none;
- font-size: 90%;
- text-align: right;
-}
-
-#norm {
- position: relative;
- top: 2px;
-}
-
-.control-column ul {
- padding-left: 6px;
- margin: 0px;
- list-style-type: none;
- text-align: left;
- font-size: 90%;
-}
-
-.control-column input {
- border: 0px;
- background: white;
-}
-
-.control-column p {
- margin: 2px;
-}
-
-.select-metric {
- width: 95px;
- font-size: 90%;
- margin: 5px 0px 5px 0px;
-}
-
-.add-metric {
- width: 95px;
- margin-bottom: 5px;
-}
-
-.same-unit-metric {
- background: #0F0;
- color: #000;
-}
-
-.second-unit-metric {
- background: #9F0;
- color: #000;
-}
-
-.incompatible-unit-metric {
- background: #F00;
- color: #000;
-}
-
-.footer-shadow {
- height: 50px;
- background-image: url("images/f.png");
- clear: both;
-}
-
-#footer {
- text-align: right;
- padding: 3px;
-}
-
-#footer p {
- margin: 1px;
-}
Copied: gauger/web/explore.php (from rev 15002, gauger/explore.php)
===================================================================
--- gauger/web/explore.php (rev 0)
+++ gauger/web/explore.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -0,0 +1,132 @@
+<?php
+/** explore.php
+
+ This file is part of gauger.
+ Copyright 2011 Bartlomiej Polot
+
+ gauger is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ gauger 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with gauger. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+$CONF = parse_ini_file('gauger.conf');
+$DATADIR = array_key_exists('data', $CONF) && $CONF["data"] ? $CONF['data'] :
'data/';
+$PAGELENGTH = array_key_exists('page_length', $CONF) && $CONF['page_lenght'] ?
$CONF['page_lenght'] : 5;
+if ($DATADIR[strlen($DATADIR)-1] != '/') $DATADIR .= '/';
+$hosts = array();
+$metrics = array();
+$metrics_c = array();
+
+function get_counter_name($s) {
+ $s = str_replace('-SLASH-', '/', $s);
+ if(($b = strpos($s, ':::')) !== FALSE)
+ $b += 3;
+ else
+ $b = 0;
+ if(($e = strpos($s, '___')) === FALSE)
+ return substr($s, $b);
+ return substr($s, $b, $e-$b);
+}
+
+function get_counter_unit($s) {
+ $s = str_replace('-SLASH-', '/', $s);
+ if(($b = strpos($s, '___')) !== FALSE)
+ return substr($s, $b+3);
+ else
+ return "";
+}
+
+function get_counter_category($s) {
+ $s = str_replace('-SLASH-', '/', $s);
+ if(($b = strpos($s, ':::')) !== FALSE)
+ return substr($s, 0, $b);
+ else
+ return "";
+}
+
+function get_range_global() {
+ global $DATADIR;
+ $f = fopen($DATADIR.'global_range.dat', 'r');
+ $buffer = fgets($f, 512);
+ fclose($f);
+ return explode(' ', $buffer);
+}
+
+function get_range($host, $counter) {
+ global $DATADIR;
+ if(empty($host) || empty($counter)) return get_range_global();
+ $f = @fopen("$DATADIR$host/$counter.dat", 'r');
+ if ($f === false) return get_range_global();
+ $b = false;
+ while (($buffer = fgets($f, 512)) !== false) {
+ if($b === false) {$b = explode(' ', $buffer); $b = $b[0]; }
+ $e = $buffer;
+ }
+ fclose($f);
+ $e = explode(' ', $e);
+ $e = $e[0];
+ return Array($b, $e);
+}
+
+function get_local_maximum($h, $g, $s, $e) {
+ global $DATADIR;
+ $lm = false;
+ $f = @fopen("$DATADIR$h/$g.dat", 'r');
+ if ($f === false) return 1;
+ while (($buffer = fgets($f, 512)) !== false) {
+ $l = explode(' ', $buffer);
+ if($l[0] >= $s && $l[0] <= $e) {
+ if($lm === false || $l[1] > $lm) $lm = $l[1];
+ }
+ }
+ fclose($f);
+ return $lm ? $lm : 1;
+}
+
+function explore() {
+ global $DATADIR;
+ global $hosts;
+ global $metrics;
+ global $metrics_c;
+ global $q;
+ $d = dir($DATADIR);
+ while (false !== ($entry = $d->read())) {
+ if (is_dir($DATADIR.$entry) && !($entry[0] == ".")) {
+ $hosts[$entry] = array();
+ $d2 = dir($DATADIR.$entry);
+ while (false !== ($counter = $d2->read())) {
+ // Do not include files containing dots or tildes or
incomplete files
+ if (($q === "" || strpos($counter, $q) !== false) &&
+ preg_match("/(\.|~)/", $counter) === 0 &&
+ is_file("$DATADIR$entry/$counter.dat")) {
+ $hosts[$entry][] = $counter;
+ $metrics[$counter] = get_counter_name($counter);
+ $metrics_c[get_counter_category($counter)][$counter] =
get_counter_name($counter);
+ }
+ }
+ }
+ }
+
+ ksort($hosts);
+ foreach ($hosts as $host => $a) {
+ sort(&$hosts[$host]);
+ }
+ foreach ($metrics_c as $id => $a) {
+ ksort(&$metrics_c[$id]);
+ }
+ ksort(&$metrics_c);
+ if (array_key_exists('', $metrics_c)) {
+ $others = array_shift($metrics_c);
+ $metrics_c[''] = $others;
+ }
+ $d->close();
+}
Copied: gauger/web/index.php (from rev 15002, gauger/index.php)
===================================================================
--- gauger/web/index.php (rev 0)
+++ gauger/web/index.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -0,0 +1,25 @@
+<?php
+/** index.php
+
+ This file is part of gauger.
+ Copyright 2011 Bartlomiej Polot
+
+ gauger is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ gauger 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with gauger. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+include "params.php"; // Manage all parameters given by the user
+include "explore.php"; // Gather all existing hosts and counters
+init_params();
+explore();
+include "template.php"; // Display info
\ No newline at end of file
Copied: gauger/web/params.php (from rev 15002, gauger/params.php)
===================================================================
--- gauger/web/params.php (rev 0)
+++ gauger/web/params.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -0,0 +1,93 @@
+<?php
+/** params.php
+
+ This file is part of gauger.
+ Copyright 2011 Bartlomiej Polot
+
+ gauger is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ gauger 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with gauger. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+$range_parameters = Array('x_max', 'x_min',
+ 'y_max', 'y_min',
+ 'png_x_size', 'png_y_size');
+$mode_host = FALSE;
+$mode_graph = FALSE;
+$current = "";
+$currentg = "";
+
+function get_param($name, $default = '', $persist = FALSE, $usesession = TRUE)
{
+ if (array_key_exists($name, $_REQUEST)) {
+ $ret = $_REQUEST[$name];
+ if($persist) {
+ $_SESSION[$name] = $ret;
+ }
+ } else if ($usesession && array_key_exists($name, $_SESSION)) {
+ $ret = $_SESSION[$name];
+ } else {
+ $ret = $default;
+ }
+ return $ret;
+}
+
+function get_param_escsh($name, $default = '', $persist = FALSE, $sess = TRUE)
{
+ return escapeshellcmd(get_param($name, $default, $persist, $sess));
+}
+
+function get_session($name, $default = '') {
+ if (array_key_exists($name, $_SESSION) && $_SESSION[$name] !== '') {
+ return $_SESSION[$name];
+ } else {
+ return $default;
+ }
+}
+
+function init_params() {
+ global $mode_host;
+ global $mode_graph;
+ global $current;
+ global $currentg;
+ global $q;
+ global $range_parameters;
+
+ session_start();
+
+ if (get_param('logout')) {
+ session_unset();
+ header("Location: " . preg_replace("/\?.*/", "",
$_SERVER["REQUEST_URI"]));
+ die();
+ }
+
+ if ($current = get_param('host')) {
+ $mode_host = TRUE;
+ }
+
+ if ($currentg = get_param('graph')) {
+ $mode_graph = TRUE;
+ }
+
+ if (get_session('xrange_min') === '') {
+ $r = get_range('','');
+ $_SESSION['xrange_min'] = $r[0];
+ $_SESSION['xrange_max'] = $r[1];
+ $_SESSION['y_min'] = 0;
+ foreach ($range_parameters as $param_name) {
+ $_SESSION[$param_name.'_a'] = 1;
+ }
+ $_SESSION['png_x_size'] = 640;
+ $_SESSION['png_y_size'] = 480;
+ }
+
+ $q = get_param('q', '');
+}
Copied: gauger/web/plot.php (from rev 15002, gauger/plot.php)
===================================================================
--- gauger/web/plot.php (rev 0)
+++ gauger/web/plot.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -0,0 +1,232 @@
+<?php
+/** plot.php
+
+ This file is part of gauger.
+ Copyright 2011 Bartlomiej Polot
+
+ gauger is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ gauger 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with gauger. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+/** Function build_gnuplot_file
+ * @param $cmd: header, terminal size and plot range
+ * @param $rangecmd: xtics range description
+ * @param $plotcmd: data description
+ * @return: gnuplot file with inline data
+ */
+function build_gnuplot_file($cmd, $rangecmd, $plotcmd) {
+ $files = explode(",", $plotcmd);
+ $paths = array();
+ foreach ($files as $i => $file) {
+ $paths[$i] = stripslashes(preg_replace('/[^"]*"([^"]+).*/', '\1',
$file));
+ $files[$i] = preg_replace('/"[^"]+/', '"-', $file, 1);
+ }
+ $plotcmd = implode(",", $files);
+ header('Content-Type: text/plain');
+ header('Content-Disposition: attachment; filename=source.gp');
+ echo str_replace("; ", ";\n", $cmd) . "\n";
+ echo "$plotcmd;\n";
+ foreach($paths as $path) {
+ readfile($path);
+ echo "e\n";
+ }
+ die();
+}
+
+/** Function build_gnuplot_command
+ * @param $cmd: header, terminal size and plot range
+ * @param $rangecmd: xtics range description
+ * @param $plotcmd: data description
+ * @return: gnuplot file with inline data
+ */
+function build_gnuplot_command($cmd, $rangecmd, $plotcmd) {
+ return "echo '$cmd $rangecmd $plotcmd' | gnuplot";
+}
+
+/** Function plot
+ * @param h: host name
+ * @param g: graph name
+ * @return: stream representing a png graph
+ */
+function plot($g, $h) {
+ global $hosts;
+ global $DATADIR;
+
+ $cmd = 'set terminal png font "Arial,12";';
+ $cmd .= ' set grid;';
+ //$cmd .= ' set yrange[0:];';
+ $cmd .= ' set key below;';
+ $cmd .= ' set style lines 1 lt rgb "#A0A0A0" lw 2;';
+ $cmd .= ' set style lines 2 lt rgb "#404040" lw 1 pt 1;';
+ $cmd .= ' set style lines 3 lt rgb "green" lw 2;';
+ $cmd .= ' set style lines 4 lt rgb "red" lw 2;';
+ $cmd .= ' set style lines 5 lt rgb "blue" lw 2;';
+ $cmd .= ' set style lines 6 lt rgb "cyan" lw 2;';
+ $cmd .= ' set style lines 7 lt rgb "violet" lw 2;';
+ $cmd .= ' set style lines 8 lt rgb "orange" lw 2;';
+ $cmd .= ' set style increment user;';
+
+ $cmd .= ' set terminal png size ';
+ $cmd .= get_session('png_x_size', '640') . ',';
+ $cmd .= get_session('png_y_size', '480') . ';';
+
+ $norm = get_param('norm', '') == 'true';
+ if(!empty($g)) {
+ $cmd .= ' set ylabel "' . ($norm ? 'percentage' :
get_counter_unit($g[0])) . '";';
+ }
+
+ foreach (Array('x_max', 'x_min', 'y_max', 'y_min') as $param_name) {
+ $$param_name = get_param_escsh($param_name, '', false);
+ $explicit = get_param_escsh($param_name, '', false, false);
+ if(!is_numeric($$param_name) ||
+ (get_session($param_name.'_a') == 1 && !$explicit))
+ $$param_name = '*';
+ }
+ $cmd .= " set xrange [$x_min:$x_max];";
+ $cmd .= " set yrange [$y_min:$y_max];";
+
+ $ch = count($h);
+ if($ch == 0){
+ $h = array_keys($hosts);
+ }
+ $cg = count($g);
+ if($cg == 1) {
+ $cmd .= ' set title "' . get_counter_name($g[0]) . '";';
+ }
+
+ if($x_min != '*') {
+ $range_start = $x_min;
+ } else {
+ $range_start = get_param_escsh('xrange_max');
+ }
+ if($x_max != '*') {
+ $range_end = $x_max;
+ } else {
+ $range_end = get_param_escsh('xrange_min');
+ }
+
+ $plotcmd = ' plot';
+ $c = 0;
+ if($x_min == '*' || $x_max == '*') {
+ foreach($h as $host) {
+ $counters = $hosts[$host];
+ if($cg == 0) $g = $counters;
+ foreach($g as $graph) {
+ if(array_search($graph, $counters) === FALSE) continue;
+ $r = get_range($host, $graph);
+ if($x_min == '*') {
+ $range_start = min($range_start, $r[0]);
+ }
+ if($x_max == '*') {
+ $range_end = max($range_end, $r[1]);
+ }
+ }
+ }
+ }
+ $left_unit = null;
+ $right_unit = null;
+ foreach($h as $host) {
+ $counters = $hosts[$host];
+ if($cg == 0) $g = $counters;
+ foreach($g as $graph) {
+ if(array_search($graph, $counters) === FALSE) continue;
+ $unit = get_counter_unit($graph);
+ if($left_unit === null) {
+ $left_unit = $unit;
+ }
+ if($left_unit != $unit && $right_unit === null) {
+ $right_unit = $unit;
+ $cmd .= " set y2label \"$unit\"; set ytics nomirror; set
y2tics;";
+ }
+ if($left_unit != $unit && $right_unit != $unit) {
+ header('Location: images/toomanyunits.png');
+ die();
+ }
+ $counter = get_counter_name($graph);
+ if($c) $plotcmd .= ',';
+ $plotcmd .= escapeshellcmd(" \"$DATADIR$host/$graph.dat\"");
+ if($norm) {
+ $metric_max = (int)get_local_maximum($host, $graph,
$range_start, $range_end);
+ $plotcmd .= " using 1:($2*100/$metric_max)";
+ }
+ $plotcmd .= " title \"";
+ if($ch != 1) $plotcmd .= $host;
+ if($ch != 1 && $cg != 1) $plotcmd .= " - ";
+ if($cg != 1) {
+ $plotcmd .= $counter;
+ if($unit == $right_unit) $plotcmd .= " ($unit)";
+ }
+ $plotcmd .= "\"";
+ $plotcmd .= " with lines lw 2";
+ if($unit == $right_unit) $plotcmd .= ' axes x1y2';
+ if($ch == 1 && $cg == 1) {
+ $plotcmd .= ', ';
+ $plotcmd .= escapeshellcmd(" \"$DATADIR$host/$graph.dat\"");
+ $plotcmd .= " notitle with yerrorbars lw 1";
+ if($unit == $right_unit) $plotcmd .= ' axes x1y2';
+ }
+ $c++;
+ }
+ }
+ $size = get_param_escsh('png_x_size');
+ $gap = $range_end - $range_start;
+ $deadspace = $right_unit === null ? 150 : 220;
+ $interval = ceil($gap/(abs($size-$deadspace)/50));
+ if($interval > $gap) $interval = $gap;
+ if($interval == 0) $interval = 1;
+ $rangecmd = " set xtics $range_start,$interval,$range_end;";
+
+ if(!$c) {
+ header('Location: images/nodata.png');
+ die();
+ }
+
+ if(get_param('raw_cmd') == 'true') {
+ build_gnuplot_file($cmd, $rangecmd, $plotcmd);
+ } else {
+ $cmd = build_gnuplot_command($cmd, $rangecmd, $plotcmd);
+ $out = shell_exec($cmd);
+ }
+
+ return $out;
+}
+
+include "params.php";
+include "explore.php";
+init_params();
+explore();
+
+if ($h = get_param('h')) {
+ $h = explode(',', $h);
+} else {
+ $h = array();
+}
+
+if ($g = get_param('g')) {
+ $g = explode(',', $g);
+} else {
+ $g = array();
+}
+
+$out = plot($g, $h);
+if($out) {
+ header('Content-type: image/png');
+ header("Cache-Control: no-cache, must-revalidate");
+ header("Pragma: no-cache");
+ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
+ die($out);
+} else {
+ header('Location: images/nodata.png');
+ die();
+}
Copied: gauger/web/template.php (from rev 15003, gauger/template.php)
===================================================================
--- gauger/web/template.php (rev 0)
+++ gauger/web/template.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -0,0 +1,582 @@
+<?php
+/** template.php
+
+ This file is part of gauger.
+ Copyright 2011 Bartlomiej Polot
+
+ gauger is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ gauger 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with gauger. If not, see <http://www.gnu.org/licenses/>.
+
+*/?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <title>Gauger [<?php echo isset($current) && $current ? $current :
get_counter_name($currentg) ?>]</title>
+
+ <link href="css/smoothness/jquery-ui-1.8.9.custom.css"
rel="stylesheet" type="text/css"/>
+ <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
+ <script type="text/javascript"
src="js/jquery-ui-1.8.9.custom.min.js"></script>
+ <script type="text/javascript" src="js/jCookie.js"></script>
+
+ <link rel="shortcut icon" href="images/favicon.png" />
+ <link href="css/style.css" type="text/css" rel="stylesheet">
+
+
+ <script type="text/javascript">
+
+ var inst_search;
+ var last_search = "";
+ var field_search;
+ var search_prompt = "Search...";
+
+ $(document).ready(function() {
+ $( ".slider-range" ).slider({
+ range: true,
+ min: <?php echo get_session('xrange_min', '0') ?>,
+ max: <?php echo get_session('xrange_max', '100') ?>,
+ values: [ <?php echo get_session('x_min',
get_session('xrange_min', '0')) ?> , <?php echo get_session('x_max',
get_session('xrange_max', '100')) ?> ],
+ slide: function( event, ui ) {
+ if(this.id == "default_range_slider") {
+ $(".input_min").val(ui.values[0]);
+ $(".input_max").val(ui.values[1]);
+ if($(this).slider('values', 0) !=
ui.values[0]) {
+ $( ".auto_min" ).attr('checked', false);
+ }
+ if($(this).slider('values', 1) !=
ui.values[1]) {
+ $( ".auto_max" ).attr('checked', false);
+ }
+ $( ".slider-range" ).each(function(){
+ $(this).slider('values', 0, ui.values[0]);
+ $(this).slider('values', 1, ui.values[1]);
+ });
+ } else {
+
$(this).parents("tr").find(".input_min").val(ui.values[0]);
+
$(this).parents("tr").find(".input_max").val(ui.values[1]);
+ if($(this).slider('values', 0) !=
ui.values[0]) {
+ $(this).parents("tr").find( ".auto_min"
).attr('checked', false);
+ }
+ if($(this).slider('values', 1) !=
ui.values[1]) {
+ $(this).parents("tr").find( ".auto_max"
).attr('checked', false);
+ }
+ }
+ },
+ stop: function( event, ui ) {
+ if(this.id == "default_range_slider") {
+ min =
$(this).parents(".slider_control").find(".auto_min").attr('checked') ? "auto" :
$(this).slider('values', 0);
+ max =
$(this).parents(".slider_control").find(".auto_max").attr('checked') ? "auto" :
$(this).slider('values', 1);
+ $.get("ajax.php", {
+ x_min: min,
+ x_max: max,
+ persist: "true"
+ }, function(data) {
+ $( ".plot" ).each(function() {
+ this.src =
this.src.replace(/&x_m(ax|in)=[^&]+/g, '')+"&reload=1";
+ });
+ }
+ );
+ } else {
+ min =
$(this).parents("tr").find(".auto_min").attr('checked') ? "auto" :
$(this).slider('values', 0);
+ max =
$(this).parents("tr").find(".auto_max").attr('checked') ? "auto" :
$(this).slider('values', 1);
+
$(this).parents("tr").find(".plot").each(function(){
+ this.src =
this.src.replace(/&x_m(ax|in)=[^&]+/g, '')+"&x_min="+min+"&x_max="+max;
+ });
+ }
+ }
+ });
+ $( ".input_min" ).change(function( event ) {
+ var newmin = this.value;
+ if(this.id == "default_input_min") {
+ $( ".auto_min" ).attr('checked', false);
+ $( ".slider-range" ).each(function(){
+ $(this).slider('values', 0, newmin);
+ });
+ $( ".input_min" ).val(newmin);
+ max =
$(this).parents(".slider_control").find(".auto_max").attr('checked') ?
+ "auto" :
+
$(this).parents(".slider_control").find(".slider-range").slider('values', 1);
+ $.get("ajax.php", {
+ x_min: newmin,
+ x_max: max,
+ persist: "true"
+ }, function(data) {
+ $( ".plot" ).each(function() {
+ this.src =
this.src.replace(/&x_m(ax|in)=[^&]+/g, '')+"&reload=1";
+ });
+ }
+ );
+ } else {
+ $(this).parents("tr").find( ".auto_min"
).attr('checked', false);
+ $(this).parents("tr").find( ".slider-range"
).slider('values', 0, newmin);
+ max =
$(this).parents(".tr").find(".auto_max").attr('checked') ?
+ "auto" :
+
$(this).parents(".tr").find(".slider-range").slider('values', 1);
+ $(this).parents("tr").find(".plot").each(function(){
+ this.src = this.src.replace(/&x_m(ax|in)=[^&]+/g,
'')+"&x_min="+newmin+"&x_max="+max;
+ });
+ }
+ });
+ $( ".input_max" ).change(function( event ) {
+ var newmax = this.value;
+ if(this.id == "default_input_max") {
+ $( ".auto_max" ).attr('checked', false);
+ $( ".slider-range" ).each(function(){
+ $(this).slider('values', 1, newmax);
+ });
+ $( ".input_max" ).val(newmax);
+ min =
$(this).parents(".slider_control").find(".auto_min").attr('checked') ?
+ "auto" :
+
$(this).parents(".slider_control").find(".slider-range").slider('values', 0);
+ $.get("ajax.php", {
+ x_min: min,
+ x_max: newmax,
+ persist: "true"
+ }, function(data) {
+ $( ".plot" ).each(function() {
+ this.src =
this.src.replace(/&x_m(ax|in)=[^&]+/g, '')+"&reload=1";
+ });
+ }
+ );
+ } else {
+ $(this).parents("tr").find( ".auto_max"
).attr('checked', false);
+ $(this).parents("tr").find( ".slider-range"
).slider('values', 1, newmax);
+ min =
$(this).parents(".tr").find(".auto_min").attr('checked') ?
+ "auto" :
+
$(this).parents(".tr").find(".slider-range").slider('values', 0);
+ $(this).parents("tr").find(".plot").each(function(){
+ this.src = this.src.replace(/&x_m(ax|in)=[^&]+/g,
'')+"&x_min="+min+"&x_max="+newmax;
+ });
+ }
+ });
+ $( ".auto_min" ).click(function(){
+ var chk = this.checked;
+ if($(this).parents("#default_range_control").length > 0) {
+ $( ".auto_min" ).attr('checked', chk);
+ min = chk ? "auto" :
$(this).parents(".slider_control").find(".slider-range").slider('values', 0);
+ $( ".plot" ).each(function() {
+ this.src = this.src.replace(/&x_min=[^&]+/g,
'')+"&x_min="+min;
+ });
+ $.get("ajax.php", {
+ x_min: min,
+ persist: "true"
+ });
+ if(!chk) {
+ $( ".slider-range" ).each(function(){
+ $(this).slider('values', 0, min);
+ });
+ $( ".input_min" ).val(min);
+ }
+ } else {
+ min = chk ? "auto" :
$(this).parents("tr").find(".slider-range").slider('values', 0);
+ $(this).parents("tr").find(".plot").each(function(){
+ this.src = this.src.replace(/&x_min=[^&]+/g,
'')+"&x_min="+min;
+ });
+ }
+ });
+ $( ".auto_max" ).click(function(){
+ var chk = this.checked;
+ if($(this).parents("#default_range_control").length > 0) {
+ $( ".auto_max" ).attr('checked', chk);
+ max = chk ? "auto" :
$(this).parents(".slider_control").find(".slider-range").slider('values', 1);
+ $( ".plot" ).each(function() {
+ this.src = this.src.replace(/&x_max=[^&]+/g,
'')+"&x_max="+max;
+ });
+ $.get("ajax.php", {
+ x_max: max,
+ persist: "true"
+ });
+ if(!chk) {
+ $( ".slider-range" ).each(function(){
+ $(this).slider('values', 1, max);
+ });
+ $( ".input_max" ).val(max);
+ }
+ } else {
+ max = chk ? "auto" :
$(this).parents("tr").find(".slider-range").slider('values', 1);
+ $(this).parents("tr").find(".plot").each(function(){
+ this.src = this.src.replace(/&x_max=[^&]+/g,
'')+"&x_max="+max;
+ });
+ }
+ });
+ $( ".auto_y" ).click(function(){
+ var chk = this.checked;
+ min = chk ? "auto" :
$("#change_origin_slider").slider('value');
+ $.get("ajax.php", {
+ y_min: min,
+ persist: "true"
+ }, function(data) {
+ $( ".plot" ).each(function(){
+ this.src = this.src.replace(/&y_min=[^&]+/g,
'')+"&reload=1";
+ });
+ });
+ });
+ $( "#change_origin_slider" ).slider({
+ min: <?php echo get_session('yrange_min', '0') ?>,
+ max: <?php echo get_session('yrange_max', '100') ?>,
+ value: <?php echo get_session('y_min', '0') ?>,
+ slide: function( event, ui ) {
+
$(this).parents(".slider_control").find(".input_max").val(ui.value);
+
$(this).parents(".slider_control").find(".auto_y").attr("checked", false);
+ },
+ change: function( event, ui ) {
+
$(this).parents(".slider_control").find(".input_max").val(ui.value);
+ $.get("ajax.php", {
+ y_min: ui.value,
+ persist: "true"
+ }, function(data) {
+ $( ".plot" ).each(function(){
+ this.src =
this.src.replace(/&y_m(ax|in)=[^&]+/g, '')+"&reload=1";
+ });
+ }
+ );
+ }
+ });
+ $(
"#change_origin_control").find('.input_max').change(function(){
+
$(this).parents(".slider_control").find(".auto_y").attr("checked", false);
+ $("#change_origin_slider").slider('value', this.value);
+ });
+ $( "#change_size_x_slider" ).slider({
+ min: 0,
+ max: 2000,
+ value: <?php echo get_session('png_x_size', '640') ?>,
+ slide: function( event, ui ) {
+ $("#left-range-x-input").val(ui.value);
+ },
+ change: function( event, ui ) {
+ $.get("ajax.php", {
+ png_x_size: ui.value,
+ persist: "true"
+ }, function(data) {
+ $( ".plot" ).each(function(){
+ this.src = this.src+"&reload=1";
+ });
+ $( "td" ).attr('width', ui.value);
+ }
+ );
+ }
+ });
+ $( "#left-range-x-input").change(function(){
+ $("#change_size_x_slider").slider('value', this.value);
+ });
+ $( "#change_size_y_slider" ).slider({
+ min: 0,
+ max: 2000,
+ value: <?php echo get_session('png_y_size', '480') ?>,
+ slide: function( event, ui ) {
+ $("#right-range-y-input").val(ui.value);
+ },
+ change: function( event, ui ) {
+ $.get("ajax.php", {
+ png_y_size: ui.value,
+ persist: "true"
+ }, function(data) {
+ $( ".plot" ).each(function(){
+ this.src = this.src+"&reload=1";
+ });
+ $( "td" ).attr('height', ui.value);
+ }
+ );
+ }
+ });
+ $( "#right-range-y-input").change(function(){
+ $("#change_size_y_slider").slider('value', this.value);
+ });
+ $( "#default_range" ).click(function() {
+ var was = $( "#default_range_control" ).css("display");
+ $( ".slider_control" ).hide();
+ if(was == "none")
+ $( "#default_range_control" ).show();
+ });
+ $( "#change_origin" ).click(function() {
+ var was = $( "#change_origin_control" ).css("display");
+ $( ".slider_control" ).hide();
+ if(was == "none")
+ $( "#change_origin_control" ).show();
+ });
+ $( "#change_size" ).click(function() {
+ var was = $( "#change_size_control" ).css("display");
+ $( ".slider_control" ).hide();
+ if(was == "none")
+ $( "#change_size_control" ).show();
+ });
+ $( "#norm" ).click(function () {
+ c = this;
+ $(this).parents("tr").find(".plot").each(function(){
+ //alert(this.src.replace(/&norm=[^&]+/g,
'')+"&norm="+c.checked);
+ this.src = this.src.replace(/&norm=[^&]+/g,
'')+"&norm="+c.checked;
+ });
+ });
+ $( ".metric_category_header" ).click(function () {
+ ul = $(this).parents(".metric").find("ul");
+ ul.toggle();
+ if(ul.is(':visible')) {
+ $(this).find("img").attr("src", "images/contract.png");
+ $.cookie(":::"+ul.attr("id"), "visible");
+ } else {
+ $(this).find("img").attr("src", "images/expand.png");
+ $.cookie(":::"+ul.attr("id"), "hidden");
+ }
+ });
+ $( ".instant_search" ).focus(function(){
+ if(this.value==search_prompt){
+ this.value="";
+ }
+ field_search = this;
+ inst_search = setInterval(monitor_search, 200);
+ monitor_search();
+ });
+ $( ".instant_search" ).blur(function(){
+ if(this.value==""){
+ this.value=search_prompt;
+ }
+ clearInterval(inst_search);
+ });
+ $( ".instant_search" ).each(function(){
+ value = $.cookie(this.id);
+ if(value && value != search_prompt){
+ this.value = value;
+ field_search = this;
+ monitor_search();
+ } else {
+ last_search = " ";
+ field_search = this;
+ monitor_search();
+ this.value = search_prompt;
+ $.cookie(this.id, null);
+ }
+ });
+ $("#metrics ul").each(function(){
+ if($.cookie(":::"+this.id) == "hidden") {
+ $(this).toggle()
+ $(this).parents(".metric").find("img").attr("src",
"images/expand.png");
+ }
+ });
+ $(".plot-all-hosts").click(function(){
+ $(this).parents("ul").find(".plot-host").attr('checked',
true);
+ $(this).parents("tr").find(".plot").each(function() {
+ this.src = this.src.replace(/&h=[^&]+/g, '');
+ });
+ });
+ $(".plot-no-hosts").click(function(){
+ $(this).parents("ul").find(".plot-host").attr('checked',
false);
+ });
+ $(".plot-host").click(function(){
+ var hosts = "";
+ var sep = "";
+ var links =
$(".plot-host:checked").parents("li").find("a").get().reverse();
+ for(i in links) {
+ host = "" + links[i];
+ hosts += sep + host.replace(/.*host=([^&]+).*/g, "$1");
+ sep = ",";
+ }
+ $(this).parents("tr").find(".plot").each(function() {
+ this.src = this.src.replace(/&h=[^&]+/g,
'')+"&h="+hosts;
+ });
+ });
+ $(".add-metric").click(function(){
+ x =
$(this).parents(".control-column").find(".select-metric").val();
+ added =
$(this).parents(".control-column").find(".added-metric").parents("li").find("a").get();
+ for(i in added) {
+ a = "" + added[i];
+ a = a.replace(/.*graph=([^&]+).*/g, "$1");
+ a = a.replace(/%20/g, " ");
+ if (x == a) {
+ return;
+ }
+ }
+
$(this).parents(".control-column").find(".added-metrics").append(
+ '<li>\
+ <input type="checkbox" checked="checked"
class="added-metric" onclick="rescan_added_hosts(this)">\
+ <a href="index.php?graph=' + x + '" title="[' +
get_category(x) + '] ' + get_name(x) + '">' + get_name(x) + '</a>\
+ </li>'
+ );
+ u0 =
get_unit($(this).parents("tr").find("option.same-unit-metric").val());
+ if(get_unit(x) != u0) {
+
$(this).parents("tr").find("option:not(.same-unit-metric)").each(function() {
+ if(get_unit(this.value) == get_unit(x)) {
+ $(this).addClass('second-unit-metric');
+ } else {
+ $(this).addClass('incompatible-unit-metric');
+ }
+ });
+ }
+ $(this).parents("tr").find("option[value=" + x +
"]").remove();
+ $(this).parents("tr").find(".plot").each(function() {
+ this.src = this.src.replace(/(g=[^&]+)/g, '$1,'+x);
+ });
+ });
+ });
+
+ function rescan_added_hosts(that) {
+ var graphs = "";
+ var sep = "";
+ var x = null;
+ var x0 = null;
+ var links =
$(that).parents("ul").find(".added-metric:checked").parents("li").find("a").get().reverse();
+ for(i in links) {
+ graph = "" + links[i];
+ graph = graph.replace(/.*graph=([^&]+).*/g, "$1");
+ graphs += sep + graph;
+ if(x == null) {
+ if(i == 0) {
+ x0 = graph;
+ } else {
+ if(get_unit(graph) != get_unit(x0)) {
+ x = graph;
+ }
+ }
+ }
+ sep = ",";
+ }
+
$(that).parents("tr").find("option:not(.same-unit-metric)").each(function() {
+ if(x != null) {
+ if(get_unit(this.value) == get_unit(x)) {
+
$(this).removeClass('incompatible-unit-metric').addClass('second-unit-metric');
+ } else {
+
$(this).removeClass('second-unit-metric').addClass('incompatible-unit-metric');
+ }
+ } else {
+ $(this).removeClass('second-unit-metric');
+ $(this).removeClass('incompatible-unit-metric');
+ }
+ });
+ $(that).parents("tr").find(".plot").each(function() {
+ this.src = this.src.replace(/&g=[^&]+/g, '')+"&g="+graphs;
+ });
+ }
+
+ function get_command(element) {
+ var url = $(element).parents("tr").find("img").attr("src");
+ document.location = url + "&raw_cmd=true";
+ }
+
+ function monitor_search() {
+ text = $( field_search ).val();
+ if(text == last_search) return;
+ if(text == search_prompt) text = '';
+ last_search = text;
+ $.cookie(field_search.id, text);
+ if(!$.browser.msie) { /* SORRY, BUT IE IS *SLOW* WITH JQUERY */
+ uls = $("#metrics ul:visible"); /* Nasty hack: */
+ uls.hide(); /* 500x speedup on old Chrome
versions */
+ if(text == "") {
+ $( field_search
).parents(".search_realm").find(".search_item").show();
+ } else {
+ $( field_search
).parents(".search_realm").find(".search_item[id*="+text+"]").show();
+ $( field_search
).parents(".search_realm").find(".search_item:not([id*="+text+"])").hide();
+ }
+ uls.show();
+ } else { /* IE SPECIFIC ALGORITHM (x10 speedup on IE) */
+ $( field_search
).parents(".search_realm").find(".search_item").each(function(){
+ if(this.id.indexOf(text) == -1){
+ $(this).hide();
+ } else {
+ $(this).show();
+ }
+ });
+ }
+ }
+
+ function debug(param) {
+ $( "#debug" ).html($( "#debug" ).html() + param + ' ');
+ }
+
+ function reset_session() {
+ $.cookie('instant_search_hosts', null);
+ $.cookie('instant_search_metrics', null);
+ document.location = '?logout=1';
+ }
+
+ function get_category(s) {
+ return s.replace(/:::.*/g, '');
+ }
+
+ function get_name(s) {
+ s = s.replace(/.*:::/g, '');
+ return s.replace(/___.*/g, '');
+ }
+
+ function get_unit(s) {
+ return s.replace(/.*___/g, '');
+ }
+
+ </script>
+
+ </head>
+ <body>
+ <div Id="debug"></div>
+ <div class="header">
+ <?php include "template_menu.php" ?>
+ <a href="index.php" class="name"><img src="images/l.png" /></a>
+ <p><a href="index.php" class="name">Gauger, performance recording
tool</a></p>
+ </div>
+ <div class="header-shadow"></div>
+ <div class="container">
+ <div class="menu">
+ <div id="hosts" class="search_realm">
+ <h2>Hosts</h2>
+ <input id="instant_search_hosts" class="instant_search"></input>
+ <ul>
+ <?php foreach ($hosts as $host => $counters): ?>
+ <li id="<?php echo $host ?>" class="search_item">
+ <a href="?host=<?php echo $host ?>">
+ <?php echo $host ?>
+ </a>
+ </li>
+ <?php endforeach; ?>
+ </ul>
+ </div>
+ <div id="metrics" class="search_realm">
+ <h2>Metrics</h2>
+ <input id="instant_search_metrics" class="instant_search"></input>
+ <?php foreach ($metrics_c as $category => $counters): ?>
+ <div class="metric">
+ <div class="metric_category_header">
+ <?php echo $category ? $category : 'Others' ?>
+ <img class="expand_arrow" src="images/contract.png"></img>
+ </div>
+ <ul id="<?php echo $category ? $category : 'Others' ?>">
+ <?php foreach ($counters as $link => $name): ?>
+ <li id="<?php echo $name ?>" class="search_item"><a
href="?graph=<?php echo $link ?>">
+ <?php echo $name . (get_counter_unit($link) ? ' (' .
get_counter_unit($link) . ')' : '') ?>
+ </a></li>
+ <?php endforeach; ?>
+ </ul>
+ </div>
+ <?php endforeach; ?>
+ </div>
+ </div>
+ <div class="content">
+ <?php if($mode_host == 1): ?>
+ <?php include "template_host.php" ?>
+ <?php elseif($mode_graph == 1): ?>
+ <?php include "template_graph.php" ?>
+ <?php else: ?>
+ <?php include "template_welcome.php" ?>
+ <?php endif; ?>
+ </div>
+ <div style="clear:both"></div>
+ </div>
+ <div class="footer-shadow"></div>
+ <div id="footer">
+ <p>Copyright 2011 Bartlomiej Polot (address@hidden)</p>
+ <p>This software is distributed under the <a target="_blank"
href="http://www.gnu.org/licenses/agpl.html">GNU AGPL</a></p>
+ <p>
+ <a target="_blank" href="https://gnunet.org/svn/gauger">gauger
version 0.0.4alpha</a> |
+ <a target="_blank"
href="https://gnunet.org/gauger/index.php">Project Main Page</a> |
+ <a target="_blank" href="https://gnunet.org/svn/gauger">SVN
repository</a>
+ </p>
+ </div>
+ </body>
+</html>
Copied: gauger/web/template_graph.php (from rev 15002,
gauger/template_graph.php)
===================================================================
--- gauger/web/template_graph.php (rev 0)
+++ gauger/web/template_graph.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -0,0 +1,76 @@
+<?php
+/** template_graph.php
+
+ This file is part of gauger.
+ Copyright 2011 Bartlomiej Polot
+
+ gauger is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ gauger 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with gauger. If not, see <http://www.gnu.org/licenses/>.
+
+*/?>
+<h1>SHOWING GRAPH: <?php echo get_counter_name($currentg) ?></h1>
+<?php if (array_key_exists($currentg, $metrics)): ?>
+<table>
+ <tr>
+ <th class="control-column">Controls</th>
+ <th>Graph</th>
+ </tr>
+ <tr>
+ <th class="control-column">
+ Range
+ <br/>
+ <div class="side_slider_control">
+ <div class="slider-range" id="other_slider" ></div>
+ <div class="left-range">
+ <input class="input_min" value="<?php echo
get_session('x_min', get_session('xrange_min', '0')) ?>"></input>
+ </div>
+ <div class="right-range">
+ <input class="input_max" value="<?php echo
get_session('x_max', get_session('xrange_max', '0')) ?>"></input>
+ </div>
+ <div class="auto_range">
+ <input class="auto_min" type="checkbox" <?php
if(get_session('x_min_a')) echo 'checked="checked"'?>/>
+ Auto
+ <input class="auto_max" type="checkbox" <?php
if(get_session('x_max_a')) echo 'checked="checked"'?>/>
+ </div>
+ </div>
+ <hr/>
+ <span>Normalize<input type="checkbox" id="norm"/></span>
+ <hr/>
+ <a href="#" onclick="get_command(this); return false;" >Get
Source</a>
+ <hr/>
+ <ul>
+ <?php foreach ($hosts as $host => $counters): ?>
+ <?php if(array_search($currentg, $counters) !== FALSE): ?>
+ <li>
+ <input type="checkbox" class="plot-host" checked="true"/>
+ <a href="?host=<?php echo $host ?>" title="<?php echo
$host ?>">
+ <?php echo (strlen($host) > 10) ?
substr($host,0,8).'...' : $host ?>
+ </a>
+ <br />
+ </li>
+ <?php endif; ?>
+ <?php endforeach; ?>
+ <li>
+ <input type="button" class="plot-all-hosts" value="All"/>
+ <input type="button" class="plot-no-hosts" value="None"/>
+ </li>
+ </ul>
+ </th>
+ <td height="<?php echo get_session('png_y_size')+2 ?>" width="<?php
echo get_session('png_x_size')+2 ?>">
+ <img class="plot" src="plot.php?g=<?php echo $currentg ?>"
alt="loading..."/>
+ </td>
+ </tr>
+</table>
+<?php else: ?>
+<h1>The graph "<?php echo $currentg ?>" is not present in any host.</h1>
+<?php endif; ?>
Copied: gauger/web/template_host.php (from rev 15004, gauger/template_host.php)
===================================================================
--- gauger/web/template_host.php (rev 0)
+++ gauger/web/template_host.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -0,0 +1,132 @@
+<?php
+/** template_host.php
+
+ This file is part of gauger.
+ Copyright 2011 Bartlomiej Polot
+
+ gauger is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ gauger 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with gauger. If not, see <http://www.gnu.org/licenses/>.
+
+*/?>
+<?php if (isset($hosts[$current])): ?>
+ <div class="title">
+ <h1>SHOWING HOST: <?php echo $current ?></h1>
+ <form action="index.php" method="get" id="search_host">
+ <input name="host" value="<?php echo $current ?>"
class="hidden_input"/>
+ <input name="q" value="<?php echo $q ?>"/>
+ <input type="submit" value="Search">
+ </form>
+ </div>
+ <?php if (!empty($hosts[$current])): ?>
+ <?php $p = get_param('page', 1); $maxp =
ceil(count($hosts[$current])/$PAGELENGTH) ?>
+ <p class="pager">
+ <?php if ($p >= 4): ?>
+ <a href="index.php?host=<?php echo $current ?>&q=<?php echo $q
?>&page=1">1</a><?php if ($p > 4) echo " .. " ?>
+ <?php endif; ?>
+ <?php for ($l = $p - 2; $l <= $p+2; $l++): ?>
+ <?php if($l >= 1 && $l <= $maxp): ?>
+ <?php if($l == $p) echo "[" ?>
+ <a href="index.php?host=<?php echo $current ?>&q=<?php echo $q
?>&page=<?php echo $l ?>"><?php echo $l ?></a>
+ <?php if($l == $p) echo "]" ?>
+ <?php endif; ?>
+ <?php endfor; ?>
+ <?php if ($p <= $maxp - 3): ?>
+ <?php if ($p < $maxp - 3) echo " .. " ?><a href="index.php?host=<?php
echo $current ?>&q=<?php echo $q ?>&page=<?php echo $maxp ?>"><?php
echo $maxp ?></a>
+ <?php endif; ?>
+ </p>
+ <table>
+ <tr>
+ <th class="control-column">Controls</th>
+ <th>Graph</th>
+ </tr>
+ <?php for ($i = 0; $i < $PAGELENGTH && ($p-1)*$PAGELENGTH+$i <
count($hosts[$current]); $i++): ?>
+ <?php $counter = $hosts[$current][($p-1)*$PAGELENGTH+$i] ?>
+ <tr>
+ <th class="control-column">
+ Range
+ <br/>
+ <div class="side_slider_control">
+ <div class="slider-range" id="other_slider" ></div>
+ <div class="left-range">
+ <input class="input_min" value="<?php echo
get_session('x_min', get_session('xrange_min', '0')) ?>"></input>
+ </div>
+ <div class="right-range">
+ <input class="input_max" value="<?php echo
get_session('x_max', get_session('xrange_max', '0')) ?>"></input>
+ </div>
+ <div class="auto_range">
+ <input class="auto_min" type="checkbox" <?php
if(get_session('x_min_a')) echo 'checked="checked"'?>/>
+ Auto
+ <input class="auto_max" type="checkbox" <?php
if(get_session('x_max_a')) echo 'checked="checked"'?>/>
+ </div>
+ </div>
+ <hr/>
+ <a href="#" onclick="get_command(this); return false;" >Get
Source</a>
+ <hr/>
+ <ul class="added-metrics">
+ <li>
+ <input type="checkbox" checked="checked"
class="added-metric" disabled>
+ <a href="?graph=<?php echo $counter ?>" title="<?php
echo '['.get_counter_category($counter).'] '. get_counter_name($counter)?>">
+ <?php echo get_counter_name($counter) ?>
+ </a>
+ </li>
+ </ul>
+ <hr/>
+ Compare with:
+ <select class="select-metric">
+ <?php foreach ($hosts[$current] as $graph): ?>
+ <?php if($graph != $counter): ?>
+ <option value="<?php echo $graph?>"
+ <?php if(get_counter_unit($graph) ==
get_counter_unit($counter)): ?>
+ <?php echo ' class="same-unit-metric"' ?>
+ <?php endif; ?>
+ >
+ <?php echo get_counter_name($graph) ?>
+ </option>
+ <?php endif; ?>
+ <?php endforeach; ?>
+ </select><br/>
+ <input type="button" value="Add" class="add-metric"></input>
+ <br/>
+ <a href='#'>What do these colors mean?</a>
+ <p class="same-unit-metric">Main unit</p>
+ <p class="second-unit-metric">Secondary unit</p>
+ <p class="incompatible-unit-metric">Incompatible</p>
+ </th>
+ <td height="<?php echo get_session('png_y_size')+2 ?>"
width="<?php echo get_session('png_x_size')+2 ?>"><img class="plot"
src="plot.php?h=<?php echo "$current&g=$counter" ?>" alt="loading..."/></td>
+ </tr>
+ <?php endfor; ?>
+ </table>
+ <p class="pager">
+ <?php if ($p >= 4): ?>
+ <a href="index.php?host=<?php echo $current ?>&q=<?php echo $q
?>&page=1">1</a><?php if ($p > 4) echo ".." ?>
+ <?php endif; ?>
+ <?php for ($l = $p - 2; $l <= $p+2; $l++): ?>
+ <?php if($l >= 1 && $l <= $maxp): ?>
+ <?php if($l == $p) echo "[" ?>
+ <a href="index.php?host=<?php echo $current ?>&q=<?php echo $q
?>&page=<?php echo $l ?>"><?php echo $l ?></a>
+ <?php if($l == $p) echo "]" ?>
+ <?php endif; ?>
+ <?php endfor; ?>
+ <?php if ($p <= $maxp - 3): ?>
+ <?php if ($p < $maxp - 3) echo ".." ?><a href="index.php?host=<?php
echo $current ?>&q=<?php echo $q ?>&page=<?php echo $maxp ?>"><?php
echo $maxp ?></a>
+ <?php endif; ?>
+ </p>
+ <?php else: ?>
+ <h1>The host "<?php echo $current ?>" has no counters</h1>
+ <?php endif; ?>
+<?php else: ?>
+ <h1>Oops!</h1>
+ <p>The host you are looking for doesn't seem to exist. Please select a
host from the menu on the left.</p>
+ <p>If you reached this page from a link within the application, an error
must have occurred.
+ Please be so kind and send a report to the maintainer.</p>
+<?php endif; ?>
Copied: gauger/web/template_menu.php (from rev 15002, gauger/template_menu.php)
===================================================================
--- gauger/web/template_menu.php (rev 0)
+++ gauger/web/template_menu.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -0,0 +1,56 @@
+<?php
+/** template_menu.php
+
+ This file is part of gauger.
+ Copyright 2011 Bartlomiej Polot
+
+ gauger is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ gauger 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with gauger. If not, see <http://www.gnu.org/licenses/>.
+
+*/?>
+ <div class="advanced_menu">
+ <a href="#" id="default_range" >Default Range</a>
+ <div class="slider_control" id="default_range_control">
+ <div class="slider-range" id="default_range_slider"></div>
+ <div class="left-range">
+ <input id="default_input_min" class="input_min"
value="<?php echo get_session('x_min', get_session('xrange_min', '0'))
?>"></input>
+ </div>
+ <div class="right-range">
+ <input id="default_input_max" class="input_max"
value="<?php echo get_session('x_max', get_session('xrange_max', '0'))
?>"></input>
+ </div>
+ <div class="auto_range">
+ <input class="auto_min" type="checkbox" <?php
if(get_session('x_min_a')) echo 'checked="checked"'?>/>
+ Auto
+ <input class="auto_max" type="checkbox" <?php
if(get_session('x_max_a')) echo 'checked="checked"'?>/>
+ </div>
+ </div> |
+ <a href="#" id="change_origin" >Change Origin</a>
+ <div class="slider_control" id="change_origin_control">
+ <div class="slider" id="change_origin_slider"></div>
+ <div class="auto_range">
+ <input class="auto_y" type="checkbox" <?php
if(get_session('y_min_a')) echo 'checked="checked"'?>/>
+ Auto
+ <input class="input_max" value="<?php echo
get_session('y_min', '0') ?>"></input>
+ </div>
+ </div> |
+ <a href="#" id="change_size" >Change Size</a>
+ <div class="slider_control" id="change_size_control">
+ <div class="slider-container"><div class="slider"
id="change_size_x_slider"></div></div>
+ <div id="left-range-x">X</div>
+ <input id="left-range-x-input" value="<?php echo
get_session('png_x_size', '640') ?>"></input>
+ <div id="right-range-y">Y</div>
+ <input id="right-range-y-input" value="<?php echo
get_session('png_y_size', '480') ?>"></input>
+ <div class="slider" id="change_size_y_slider"></div>
+ </div> |
+ <a href="#" onclick="reset_session(); return false;">Reset
Session</a>
+ </div>
Copied: gauger/web/template_welcome.php (from rev 15002,
gauger/template_welcome.php)
===================================================================
--- gauger/web/template_welcome.php (rev 0)
+++ gauger/web/template_welcome.php 2011-04-19 17:07:13 UTC (rev 15030)
@@ -0,0 +1,49 @@
+<?php
+/** template_welcome.php
+
+ This file is part of gauger.
+ Copyright 2011 Bartlomiej Polot
+
+ gauger is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ gauger 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with gauger. If not, see <http://www.gnu.org/licenses/>.
+
+*/?>
+<h1>Welcome to Gauger</h1>
+
+<p>We have data from <b>r<?php echo get_session('xrange_min') ?></b> to
<b>r<?php echo get_session('xrange_max') ?></b>.
+
+<p>If you click on a host from the <b>Hosts</b> menu on the left, you will see
all the metrics for that particular host.</p>
+
+<p>If you to compare all hosts given a metric, click on the corresponding
metric in the <b>Metrics</b> section.</p>
+
+<h2>Options</h2>
+In the upper right corner you have the options menu. It's possible to adjust
the following parameters:
+
+<h3>Default Range</h3>
+<p>Changing this setting will affect <b>all</b> the graphs that are displayed.
The start of the plotted range can be adjusted by
+moving the left handle of the slider. Similiarly, the end of the plotted range
can be set dragging the right handle.</p>
+
+<p>By default the graphs are plotted in automatic mode, i.e, only the region
that contains data is plotted.
+This can be turned off by unchecking the <i>Auto</i> checkbox for either side
of the graph or by adjusting either side of the slider.
+Checking the <i>Auto</i> checkbox sets the that side of the range to automatic
detection, but does not affect the range selected by the slider.</p>
+
+<h3>Change Origin</h3>
+By default all data is plotted in a scale from 0 to the highest value in the
range. This option allows to change where to set the origin
+of axis <i>y</i>.
+
+<h3>Change Size</h3>
+To better adapt the graphs to the size of the screen, it is possible change
the size of each plot. The default plot size is
+640 pixels wide and 480 pixels high, but these values can be changed using the
sliders.
+
+<h3>Reset Session</h3>
+Clicking on this opition resets all changes done to the previous options,
effectively starting a new session.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r15030 - in gauger: . web web/css,
gnunet <=