ildm6 update

This commit is contained in:
Olaf Rempel 2006-12-22 00:06:05 +01:00
parent 246cc85640
commit 2d94b19349
12 changed files with 237 additions and 30 deletions

View File

@ -3,7 +3,7 @@
// file positionen // file positionen
define('NEWFILE', 'http://10.10.254.100/bridge/config.php?bridgeid=22'); define('NEWFILE', 'http://10.10.254.100/bridge/config.php?bridgeid=22');
define('OLDFILE', '/etc/bridge/.config.old'); define('OLDFILE', '/var/www/bridge/.config.old');
// rrdsrv on 5001/tcp // rrdsrv on 5001/tcp
define('RRDSRV', "10.10.254.100"); define('RRDSRV', "10.10.254.100");
@ -645,7 +645,7 @@ class Stats {
foreach ($lines_from as $line) { foreach ($lines_from as $line) {
if (strpos($line, $hlsw['ip'])) { if (strpos($line, $hlsw['ip'])) {
$parts = explode(' ', $line); $parts = explode(' ', $line);
$from = $parts[14]; $from = $parts[13];
break; break;
} }
} }
@ -653,7 +653,7 @@ class Stats {
foreach ($lines_to as $line) { foreach ($lines_to as $line) {
if (strpos($line, $hlsw['dev'])) { if (strpos($line, $hlsw['dev'])) {
$parts = explode(' ', $line); $parts = explode(' ', $line);
$to = $parts[12]; $to = $parts[11];
break; break;
} }
} }

View File

@ -7,6 +7,9 @@ define('DB_USER', 'bridge');
define('DB_PASS', 'bridge'); define('DB_PASS', 'bridge');
define('DB_NAME', 'bridge'); define('DB_NAME', 'bridge');
define('RRDTOOL', '/usr/bin/rrdtool');
define('RRDPATH', '/var/lib/rrd');
function __autoload($classname) function __autoload($classname)
{ {
$filename = $classname.'.class.php'; $filename = $classname.'.class.php';

View File

@ -0,0 +1,45 @@
<?php
class Graphs {
private function show($title, $view, $param) {
header('Content-type: image/x-png');
passthru(RRDTOOL." graph - --imgformat PNG --start -{$view} --end -10 --title \"{$title}\" --rigid {$param}");
}
public function hlsw($rrdpath, $title, $view, $height, $width) {
$rrdfile = RRDPATH.'/'.$rrdpath;
$cmd = "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"bytes\" ".
"DEF:a={$rrdfile}:from:AVERAGE ".
"DEF:b={$rrdfile}:to:AVERAGE ".
'CDEF:bb=b,-1,* '.
'AREA:a#008000:"from hlsw" GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n" '.
'HRULE:0#ff0000: '.
'AREA:bb#000080:"to hlsw" GPRINT:b:LAST:"Current\:%8.0lf" GPRINT:b:AVERAGE:"Average\:%8.0lf" GPRINT:b:MAX:"Maximum\:%8.0lf\n" '.
'';
self::show($title, $view, $cmd);
}
public function vlan($rrdpath, $title, $view, $height, $width) {
$rrdfile = RRDPATH.'/'.$rrdpath;
$cmd = "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"bytes\" ".
"DEF:a={$rrdfile}:loop:AVERAGE ".
"DEF:b={$rrdfile}:arp:AVERAGE ".
"DEF:c={$rrdfile}:nonip:AVERAGE ".
"DEF:d={$rrdfile}:block:AVERAGE ".
"DEF:e={$rrdfile}:fwd:AVERAGE ".
"DEF:f={$rrdfile}:out:AVERAGE ".
'AREA:a#FF0000:"loop " GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n" '.
'STACK:b#EA8F00:"arp " GPRINT:b:LAST:"Current\:%8.0lf" GPRINT:b:AVERAGE:"Average\:%8.0lf" GPRINT:b:MAX:"Maximum\:%8.0lf\n" '.
'STACK:c#FFFF00:"nonip " GPRINT:c:LAST:"Current\:%8.0lf" GPRINT:c:AVERAGE:"Average\:%8.0lf" GPRINT:c:MAX:"Maximum\:%8.0lf\n" '.
'STACK:d#0000FF:"blocked " GPRINT:d:LAST:"Current\:%8.0lf" GPRINT:d:AVERAGE:"Average\:%8.0lf" GPRINT:d:MAX:"Maximum\:%8.0lf\n" '.
'STACK:e#00CF00:"forwarded" GPRINT:e:LAST:"Current\:%8.0lf" GPRINT:e:AVERAGE:"Average\:%8.0lf" GPRINT:e:MAX:"Maximum\:%8.0lf\n" '.
'';
self::show($title, $view, $cmd);
}
}
?>

View File

@ -7,6 +7,7 @@ class Hlsw {
public $flags; public $flags;
public $ip = "0.0.0.0"; public $ip = "0.0.0.0";
public $name; public $name;
public $rrdpath;
private function fromRow($row) { private function fromRow($row) {
$retval = new Hlsw(); $retval = new Hlsw();
@ -17,6 +18,7 @@ class Hlsw {
$retval->flags = (int)$row['flags']; $retval->flags = (int)$row['flags'];
$retval->ip = (string)$row['ip']; $retval->ip = (string)$row['ip'];
$retval->name = (string)$row['name']; $retval->name = (string)$row['name'];
$retval->rrdpath = (string)$row['rrdpath'];
} }
return $retval; return $retval;
} }
@ -30,9 +32,13 @@ class Hlsw {
function load($id) { function load($id) {
$dbh = Database::getInstance(); $dbh = Database::getInstance();
$sql = "SELECT id, vlanid, flags, INET_NTOA(ip) AS ip, name $sql = "SELECT h.id, h.vlanid, h.flags, INET_NTOA(h.ip) AS ip, h.name,
FROM hlsw CONCAT('bridge-', b.id, '/hlsw-', h.id, '.rrd') AS rrdpath
WHERE id = '{$id}'"; FROM hlsw h, vlan v, trunk t, bridge b
WHERE h.id = '{$id}'
AND v.id = h.vlanid
AND t.id = v.trunkid
AND b.id = t.bridgeid";
$dbh->query($sql); $dbh->query($sql);
return self::fromRow($dbh->fetch_assoc()); return self::fromRow($dbh->fetch_assoc());
@ -66,9 +72,13 @@ class Hlsw {
function getAll() { function getAll() {
$dbh = Database::getInstance(); $dbh = Database::getInstance();
$sql = "SELECT id, vlanid, flags, INET_NTOA(ip) AS ip, name $sql = "SELECT h.id, h.vlanid, h.flags, INET_NTOA(h.ip) AS ip, h.name,
FROM hlsw CONCAT('bridge-', b.id, '/hlsw-', h.id, '.rrd') AS rrdpath
ORDER BY ip"; FROM hlsw h, vlan v, trunk t, bridge b
WHERE v.id = h.vlanid
AND t.id = v.trunkid
AND b.id = t.bridgeid
ORDER BY h.ip";
$dbh->query($sql); $dbh->query($sql);
$retval = array(); $retval = array();

View File

@ -6,6 +6,7 @@ class Trunk {
public $bridgeid; public $bridgeid;
public $flags; public $flags;
public $name; public $name;
public $fullname;
private function fromRow($row) { private function fromRow($row) {
$retval = new Trunk(); $retval = new Trunk();
@ -15,6 +16,7 @@ class Trunk {
$retval->bridgeid = (int)$row['bridgeid']; $retval->bridgeid = (int)$row['bridgeid'];
$retval->flags = (int)$row['flags']; $retval->flags = (int)$row['flags'];
$retval->name = (string)$row['name']; $retval->name = (string)$row['name'];
$retval->fullname = (string)$row['fullname'];
} }
return $retval; return $retval;
} }
@ -27,9 +29,11 @@ class Trunk {
function load($id) { function load($id) {
$dbh = Database::getInstance(); $dbh = Database::getInstance();
$sql = "SELECT id, bridgeid, flags, name $sql = "SELECT t.id, t.bridgeid, t.flags, t.name,
FROM trunk CONCAT(b.name, ': ', t.name) AS fullname
WHERE id = '{$id}'"; FROM trunk t, bridge b
WHERE id = '{$id}'
AND b.id = t.bridgeid";
$dbh->query($sql); $dbh->query($sql);
return self::fromRow($dbh->fetch_assoc()); return self::fromRow($dbh->fetch_assoc());
@ -67,11 +71,12 @@ class Trunk {
function getAll($bridgeid = false) { function getAll($bridgeid = false) {
$dbh = Database::getInstance(); $dbh = Database::getInstance();
$sql = "SELECT id, bridgeid, flags, name $sql = "SELECT t.id, t.bridgeid, t.flags, t.name,
FROM trunk CONCAT(b.name, ': ', t.name) AS fullname
".($bridgeid ? "WHERE bridgeid = '{$bridgeid}'" : "")." FROM trunk t, bridge b
ORDER BY name"; WHERE ".($bridgeid ? "bridgeid = '{$bridgeid}'" : "1")."
AND b.id = t.bridgeid
ORDER BY b.name, t.name";
$dbh->query($sql); $dbh->query($sql);
$retval = array(); $retval = array();

View File

@ -8,6 +8,8 @@ class Vlan {
public $vlannum; public $vlannum;
public $bandwidth; public $bandwidth;
public $mac = "00:00:00:00:00:00"; public $mac = "00:00:00:00:00:00";
public $rrdpath;
public $fullname;
private function fromRow($row) { private function fromRow($row) {
$retval = new Vlan(); $retval = new Vlan();
@ -19,6 +21,8 @@ class Vlan {
$retval->vlannum = (int)$row['vlannum']; $retval->vlannum = (int)$row['vlannum'];
$retval->bandwidth = (int)$row['bandwidth']; $retval->bandwidth = (int)$row['bandwidth'];
$retval->mac = (string)$row['mac']; $retval->mac = (string)$row['mac'];
$retval->rrdpath = (string)$row['rrdpath'];
$retval->fullname = (string)$row['fullname'];
} }
return $retval; return $retval;
} }
@ -33,9 +37,19 @@ class Vlan {
function load($id) { function load($id) {
$dbh = Database::getInstance(); $dbh = Database::getInstance();
$sql = "SELECT id, trunkid, flags, vlannum, bandwidth, mac $sql = "SELECT v.id, v.trunkid, v.flags, v.vlannum, v.bandwidth, v.mac,
FROM vlan IF (v.vlannum = 1,
WHERE id = '{$id}'"; CONCAT('bridge-', b.id, '/vlan-', t.name, '.rrd'),
CONCAT('bridge-', b.id, '/vlan-', t.name, '.', v.vlannum, '.rrd')
) AS rrdpath,
IF (v.vlannum = 1,
CONCAT(b.name, ': ', t.name),
CONCAT(b.name, ': ', t.name, '.', v.vlannum)
) AS fullname
FROM vlan v, trunk t, bridge b
WHERE v.id = '{$id}'
AND t.id = v.trunkid
AND b.id = t.bridgeid";
$dbh->query($sql); $dbh->query($sql);
return self::fromRow($dbh->fetch_assoc()); return self::fromRow($dbh->fetch_assoc());
@ -69,10 +83,14 @@ class Vlan {
function getAll($trunkid = false) { function getAll($trunkid = false) {
$dbh = Database::getInstance(); $dbh = Database::getInstance();
$sql = "SELECT id, trunkid, flags, vlannum, bandwidth, mac $sql = "SELECT v.id, v.trunkid, v.flags, v.vlannum, v.bandwidth, v.mac,
FROM vlan CONCAT('bridge-', b.id, '/vlan-', t.name, '.', v.vlannum, '.rrd') as rrdpath,
".($trunkid ? "WHERE trunkid = '{$trunkid}'" : "")." CONCAT(t.name, '.', v.vlannum) as fullname
ORDER BY vlannum"; FROM vlan v, trunk t, bridge b
WHERE ".($trunkid ? "trunkid = '{$trunkid}'" : "1")."
AND t.id = v.trunkid
AND b.id = t.bridgeid
ORDER BY b.name, t.name, v.vlannum";
$dbh->query($sql); $dbh->query($sql);
$retval = array(); $retval = array();

View File

@ -30,7 +30,7 @@
<tr><td colspan="2"><hr></td></tr> <tr><td colspan="2"><hr></td></tr>
<tr><td colspan="2" align="center">[fancy rrdtool stats]</td></tr> <tr><td colspan="2" align="center"><img src="stat_hlsw.php?hlswid={$hlsw->id}&mode=overview"></td></tr>
</table> </table>
<br><br> <br><br>

View File

@ -22,25 +22,27 @@
<a {if $smarty.server.PHP_SELF == 'hlsw.php'}class="sel"{/if} href="hlsw.php">HLSW Master</a> <a {if $smarty.server.PHP_SELF == 'hlsw.php'}class="sel"{/if} href="hlsw.php">HLSW Master</a>
</span><br> </span><br>
<br> <br>
{*
<span class="navgroup">Statistics:</span><br> <span class="navgroup">Statistics:</span><br>
{*
<span class="navlink">=>&nbsp; <span class="navlink">=>&nbsp;
<a {if $smarty.server.PHP_SELF == 'stat_device.php'}class="sel"{/if} href="stat_device.php">Bridges</a> <a {if $smarty.server.PHP_SELF == 'stat_device.php'}class="sel"{/if} href="stat_device.php">Bridges</a>
</span><br> </span><br>
<span class="navlink">=>&nbsp; <span class="navlink">=>&nbsp;
<a {if $smarty.server.PHP_SELF == 'stat_tunnel.php'}class="sel"{/if} href="stat_tunnel.php">Bridge Tunnels</a> <a {if $smarty.server.PHP_SELF == 'stat_tunnel.php'}class="sel"{/if} href="stat_tunnel.php">Bridge Tunnels</a>
</span><br> </span><br>
*}
<span class="navlink">=>&nbsp; <span class="navlink">=>&nbsp;
<a {if $smarty.server.PHP_SELF == 'stat_vlan.php'}class="sel"{/if} href="stat_vlan.php">Bridge VLANs</a> <a {if $smarty.server.PHP_SELF == 'stat_vlan.php'}class="sel"{/if} href="stat_vlan.php">Bridge VLANs</a>
</span><br> </span><br>
{*
<span class="navlink">=>&nbsp; <span class="navlink">=>&nbsp;
<a {if $smarty.server.PHP_SELF == 'stat_forward.php'}class="sel"{/if} href="stat_forward.php">Forwarding Ports</a> <a {if $smarty.server.PHP_SELF == 'stat_forward.php'}class="sel"{/if} href="stat_forward.php">Forwarding Ports</a>
</span><br> </span><br>
*}
<span class="navlink">=>&nbsp; <span class="navlink">=>&nbsp;
<a {if $smarty.server.PHP_SELF == 'stat_hlsw.php'}class="sel"{/if} href="stat_hlsw.php">HLSW Server</a> <a {if $smarty.server.PHP_SELF == 'stat_hlsw.php'}class="sel"{/if} href="stat_hlsw.php">HLSW Server</a>
</span><br> </span><br>
<br> <br>
*}
<br><br><br> <br><br><br>
</td> </td>
<td class="fillborder" height="100%" valign="top"> <td class="fillborder" height="100%" valign="top">

View File

@ -0,0 +1,15 @@
<table cellspacing="10">
<tr><td valign="top">
<select name=view OnChange=document.location.href='{$marty.server.SCRIPT_NAME}?view='+this.value>
{html_options options=$views selected=$view}
</select>
<br><br>
{foreach from=$masters item=hlsw}
<img src="stat_hlsw.php?hlswid={$hlsw->id}&view={$view}">
<br><br>
{/foreach}
</td></tr>
</table>

View File

@ -0,0 +1,26 @@
{debug}
<table cellspacing="10">
<tr><td valign="top">
<select name=view OnChange=document.location.href='{$marty.server.SCRIPT_NAME}?trunkid={$trunkid}&view='+this.value>
{html_options options=$views selected=$view}
</select>
&nbsp;
<select name=trunkid OnChange=document.location.href='{$marty.server.SCRIPT_NAME}?view={$view}&trunkid='+this.value>
{foreach from=$trunks item=trunk}
{if $trunk->id == $trunkid}
<option value="{$trunk->id}" selected="selected">{$trunk->fullname}</option>
{else}
<option value="{$trunk->id}">{$trunk->fullname}</option>
{/if}
{/foreach}
</select>
<br><br>
{foreach from=$vlans item=vlan}
<img src="stat_vlan.php?vlanid={$vlan->id}&view={$view}">
<br><br>
{/foreach}
</td></tr>
</table>

35
web/stat_hlsw.php Normal file
View File

@ -0,0 +1,35 @@
<?php
require_once('include.php');
function show($hlsw) {
$view = Input::getVar('view', INP_GET | INP_INT | INP_DEFAULT, 21600);
$mode = Input::getVar('mode', INP_GET | INP_STRING | INP_DEFAULT, 'normal');
switch ($mode) {
case 'overview':
Graphs::hlsw($hlsw->rrdpath, $hlsw->name, $view, 60, 400);
break;
default:
case 'normal':
Graphs::hlsw($hlsw->rrdpath, $hlsw->name, $view, 120, 800);
break;
}
}
$hlswid = Input::getVar('hlswid', INP_GET | INP_INT | INP_DEFAULT, 0);
if ($hlswid != 0) {
$hlsw = Hlsw::load($hlswid);
show($hlsw);
} else {
$view = Input::getVar('view', INP_GET | INP_INT | INP_DEFAULT, 21600);
$smarty = new MySmarty();
$masters = Hlsw::getAll();
$smarty->assign('masters', $masters);
$smarty->assign('view', $view);
$smarty->assign('views', array(21600 => "6 hours", 86400 => "1 day", 604800 => "1 week"));
$smarty->displaySite('Statistics: HLSW Master Server', 'stat_hlsw.tpl');
}
?>

48
web/stat_vlan.php Normal file
View File

@ -0,0 +1,48 @@
<?php
require_once('include.php');
function show($vlan) {
$view = Input::getVar('view', INP_GET | INP_INT | INP_DEFAULT, 21600);
$mode = Input::getVar('mode', INP_GET | INP_STRING | INP_DEFAULT, 'normal');
switch ($mode) {
case 'overview':
Graphs::vlan($vlan->rrdpath, $vlan->fullname, $view, 60, 400);
break;
default:
case 'normal':
Graphs::vlan($vlan->rrdpath, $vlan->fullname, $view, 120, 800);
break;
}
}
$vlanid = Input::getVar('vlanid', INP_GET | INP_INT | INP_DEFAULT, 0);
if ($vlanid != 0) {
$vlan = Vlan::load($vlanid);
show($vlan);
} else {
$trunkid = Input::getVar('trunkid', INP_GET | INP_INT | INP_DEFAULT, 0);
$view = Input::getVar('view', INP_GET | INP_INT | INP_DEFAULT, 21600);
$trunks = Trunk::getAll();
if ($trunkid == 0) {
foreach ($trunks as $trunk) {
$trunkid = $trunk->id;
break;
}
}
$vlans = Vlan::getAll($trunkid);
$smarty = new MySmarty();
$smarty->assign('vlans', $vlans);
$smarty->assign('trunks', $trunks);
$smarty->assign('view', $view);
$smarty->assign('trunkid', $trunkid);
$smarty->assign('views', array(21600 => "6 hours", 86400 => "1 day", 604800 => "1 week"));
$smarty->displaySite('Statistics: Bridge VLANs', 'stat_vlan.tpl');
}
?>