[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14393 - gauger
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14393 - gauger |
Date: |
Fri, 11 Feb 2011 18:55:21 +0100 |
Author: bartpolot
Date: 2011-02-11 18:55:21 +0100 (Fri, 11 Feb 2011)
New Revision: 14393
Added:
gauger/header.gp
gauger/params.php
gauger/plot.php
gauger/template_graph.php
gauger/template_host.php
Modified:
gauger/explore.php
gauger/index.php
gauger/plot.gp
gauger/style.css
gauger/template.php
Log:
Added dynamic graph generation, added metric comparison for all hosts
Modified: gauger/explore.php
===================================================================
--- gauger/explore.php 2011-02-11 13:59:03 UTC (rev 14392)
+++ gauger/explore.php 2011-02-11 17:55:21 UTC (rev 14393)
@@ -6,7 +6,7 @@
$hosts[$entry] = array();
$d2 = dir($entry);
while (false !== ($counter = $d2->read())) {
- if (!($counter[0] == ".") && preg_match("/.*\.png/", $counter)) {
+ if (preg_match("/[\.|~]/", $counter) === 0) { // Do not include
files containing dots or tildes
$hosts[$entry][] = $counter;
}
}
Added: gauger/header.gp
===================================================================
--- gauger/header.gp (rev 0)
+++ gauger/header.gp 2011-02-11 17:55:21 UTC (rev 14393)
@@ -0,0 +1,4 @@
+set terminal png;
+set grid;
+set yrange[0:];
+set key below;
Modified: gauger/index.php
===================================================================
--- gauger/index.php 2011-02-11 13:59:03 UTC (rev 14392)
+++ gauger/index.php 2011-02-11 17:55:21 UTC (rev 14393)
@@ -1,21 +1,6 @@
<?php
-session_start();
-if (array_key_exists('host', $_REQUEST)) {
- $_SESSION['host'] = $_REQUEST['host'];
- $current = $_REQUEST['host'];
-} else {
- if (array_key_exists('host', $_SESSION)){
- $current = $_SESSION['host'];
- } else {
- $current = "";
- }
-}
-
-if (array_key_exists('logout', $_REQUEST)) {
- session_unset();
- header("Location: " . preg_replace("/\?.*/", "", $_SERVER["REQUEST_URI"]));
-}
-
-include "explore.php"; // Gather all existing hosts and counters
+//include "plot.php"; // Aux function to generate a plot in real time
+include "params.php"; // Manage all parameters given by the user
+include "explore.php"; // Gather all existing hosts and counters
include "template.php"; // Display info
\ No newline at end of file
Added: gauger/params.php
===================================================================
--- gauger/params.php (rev 0)
+++ gauger/params.php 2011-02-11 17:55:21 UTC (rev 14393)
@@ -0,0 +1,41 @@
+<?php
+
+// TODO: refactor into get_param function
+function get_param($name) {
+
+}
+
+session_start();
+
+if (array_key_exists('logout', $_REQUEST)) {
+ session_unset();
+ header("Location: " . preg_replace("/\?.*/", "", $_SERVER["REQUEST_URI"]));
+ die();
+}
+
+$mode_host = FALSE;
+$mode_graph = FALSE;
+
+if (array_key_exists('host', $_REQUEST)) {
+ $_SESSION['host'] = $_REQUEST['host'];
+ $current = $_REQUEST['host'];
+ $mode_host = TRUE;
+} /*else {
+ if (array_key_exists('host', $_SESSION)) {
+ $current = $_SESSION['host'];
+ } else {
+ $current = "";
+ }
+}*/
+
+if (array_key_exists('graph', $_REQUEST)) {
+ $_SESSION['graph'] = $_REQUEST['graph'];
+ $currentg = $_REQUEST['graph'];
+ $mode_graph = TRUE;
+} /*else {
+ if (array_key_exists('graph', $_SESSION)) {
+ $currentg = $_SESSION['graph'];
+ } else {
+ $currentg = "";
+ }
+}*/
Modified: gauger/plot.gp
===================================================================
--- gauger/plot.gp 2011-02-11 13:59:03 UTC (rev 14392)
+++ gauger/plot.gp 2011-02-11 17:55:21 UTC (rev 14393)
@@ -1,6 +1,5 @@
-set terminal png;
+load "header.gp";
set output "FILENAME.png";
-set grid;
plot \
-"FILENAME.dat" with line title "FILENAME" lw 3 lt rgb "#D3D3D3",\
+"FILENAME.dat" with line title "FILENAME" lw 3 lt rgb "#808080",\
"FILENAME.dat" with yerrorbars notitle lw 1 lt rgb "#404040"
Added: gauger/plot.php
===================================================================
--- gauger/plot.php (rev 0)
+++ gauger/plot.php 2011-02-11 17:55:21 UTC (rev 14393)
@@ -0,0 +1,46 @@
+<?php
+
+/** Function plot
+ * @param h: host name
+ * @param g: graph name
+ * @return: stream representing a png graph
+ */
+function plot($h = '', $g = '') {
+ $cmd = 'load "header.gp";';
+ $cmd .= 'plot';
+ global $hosts;
+
+ if(empty($h)) {
+ if(empty($g)) {
+ return 'ERROR1';
+ }
+ $c = 0;
+ foreach($hosts as $host => $counters) {
+ if(array_search($g, $counters) === FALSE) continue;
+ if($c) $cmd .= ',';
+ $cmd .= " \"$host/$g.dat\" title \"$host\" with lines lw 2";
+ $c++;
+ }
+ if(!$c) return 'ERROR2';
+ } else {
+ $c = 0;
+ foreach($hosts as $host => $counters) {
+ if(array_search($g, $counters) === FALSE) continue;
+ if($c) $cmd .= ',';
+ $cmd .= " \"$host/$g.dat\" title \"$host\" with lines lw 2";
+ $c++;
+ }
+ if(!$c) return 'ERROR3';
+ }
+ $cmd = "echo '$cmd' | gnuplot";
+ $out = shell_exec($cmd);
+
+ return $out;
+}
+
+if (array_key_exists('g', $_REQUEST)) {
+ include "explore.php";
+ header('Content-type: image/png');
+ $out = plot('', $_REQUEST['g']);
+ die($out);
+}
Modified: gauger/style.css
===================================================================
--- gauger/style.css 2011-02-11 13:59:03 UTC (rev 14392)
+++ gauger/style.css 2011-02-11 17:55:21 UTC (rev 14393)
@@ -50,8 +50,7 @@
}
a:hover {
- color: #606060;
- font-weight: bold;
+ color: #808080;
text-decoration: none;
}
Modified: gauger/template.php
===================================================================
--- gauger/template.php 2011-02-11 13:59:03 UTC (rev 14392)
+++ gauger/template.php 2011-02-11 17:55:21 UTC (rev 14393)
@@ -3,12 +3,12 @@
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>Gauger [<?php echo $current ?>]</title>
+ <title>Gauger [<?php echo isset($current) ? $current : $currentg
?>]</title>
<link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="header">
- <div class="advanced_menu">[AVANCED MENUS AND CONTROLS WILL GO
HERE] | <a href="?logout=1">Log out</a></div>
+ <div class="advanced_menu"> TODO: Default Range | Change Origin |
<a href="?logout=1">Log out</a></div>
<img src="l.png" /><p>Gauger, performance recording tool<p>
</div>
<div class="header-shadow"></div>
@@ -28,29 +28,13 @@
</ul>
</div>
<div class="content">
- <?php if (isset($hosts[$current])): ?>
- <h1>SHOWING HOST: <?php echo $current ?></h1>
- <?php if (!empty($hosts[$current])): ?>
- <table>
- <tr>
- <th>Counter</th>
- <th>Graph</th>
- <th>Controls</th>
- </tr>
- <?php foreach ($hosts[$current] as $counter): ?>
- <tr>
- <th><?php echo $counter ?></th>
- <td><img src="<?php echo $current . '/' . $counter ?>"
alt="PNG not found :("/></td>
- <td>TODO<br/>Range<br/>Add counter<br/>Colors</td>
- </tr>
- <?php endforeach; ?>
- </table>
- <?php else: ?>
- <h1>The host "<?php echo $current ?>" has no counters</h1>
- <?php endif; ?>
+ <?php if($mode_host == 1): ?>
+ <?php include "template_host.php" ?>
+ <?php elseif($mode_graph == 1): ?>
+ <?php include "template_graph.php" ?>
<?php else: ?>
- <h1>Please select a host from the hosts menu.</h1>
- <p>Some very useful data / overview will go here</p>
+ <p>Sorry, mode not supported (yet?)</p>
+ <p>Try to select a host from the menu on the left :)</p>
<?php endif; ?>
</div>
<div style="clear:both"></div>
Added: gauger/template_graph.php
===================================================================
--- gauger/template_graph.php (rev 0)
+++ gauger/template_graph.php 2011-02-11 17:55:21 UTC (rev 14393)
@@ -0,0 +1,4 @@
+<h1>SHOWING GRAPH: <?php echo $currentg ?></h1>
+<img src="plot.php?g=<?php echo $currentg ?>" alt="PNG not found :("/>
+<p>TODO: Select hosts | Range | Normalize </p>
+
\ No newline at end of file
Added: gauger/template_host.php
===================================================================
--- gauger/template_host.php (rev 0)
+++ gauger/template_host.php 2011-02-11 17:55:21 UTC (rev 14393)
@@ -0,0 +1,26 @@
+ <?php if (isset($hosts[$current])): ?>
+ <h1>SHOWING HOST: <?php echo $current ?></h1>
+ <?php if (!empty($hosts[$current])): ?>
+ <table>
+ <tr>
+ <th>Counter</th>
+ <th>Graph</th>
+ <th>Controls</th>
+ </tr>
+ <?php foreach ($hosts[$current] as $counter): ?>
+ <tr>
+ <th><?php echo $counter ?></th>
+ <td><img src="<?php echo $current . '/' . $counter .
'.png' ?>" alt="PNG not found :("/></td>
+ <td><a href="?graph=<?php echo $counter
?>">Compare</a><br/>
+ <br/>TODO:<br/>Range<br/>Add
counter<br/>Colors</td>
+ </tr>
+ <?php endforeach; ?>
+ </table>
+ <?php else: ?>
+ <h1>The host "<?php echo $current ?>" has no counters</h1>
+ <?php endif; ?>
+ <?php else: ?>
+ <h1>Please select a host from the hosts menu.</h1>
+ <p>Some very useful data / overview will go here</p>
+ <pre><?php print_r($hosts); echo $current ?></pre>
+ <?php endif; ?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14393 - gauger,
gnunet <=