ildm6 update
This commit is contained in:
parent
246cc85640
commit
2d94b19349
@ -3,7 +3,7 @@
|
||||
|
||||
// file positionen
|
||||
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
|
||||
define('RRDSRV', "10.10.254.100");
|
||||
@ -148,7 +148,7 @@ class BaseTables {
|
||||
Cmd::ebtables("-t filter -A FORWARD -i {$tunnel['device']} -j tap_block");
|
||||
Cmd::ebtables("-t filter -I tap_block 1 -o {$tunnel['device']} -j DROP");
|
||||
}
|
||||
|
||||
|
||||
// ansonsten alles in den tunnel packen
|
||||
foreach ($tunnels as $tunnel)
|
||||
Cmd::ebtables("-t filter -A FORWARD -o {$tunnel['device']} -j ACCEPT");
|
||||
@ -173,7 +173,7 @@ class ForwardTables {
|
||||
$address = Cmd::ip("-4 addr show dev ${file}");
|
||||
if (count($address))
|
||||
continue;
|
||||
|
||||
|
||||
Cmd::ifconfig("{$file} down");
|
||||
Cmd::vconfig("rem {$file}");
|
||||
}
|
||||
@ -637,7 +637,7 @@ class Stats {
|
||||
}
|
||||
|
||||
function get_masters($masters) {
|
||||
$lines_from = Cmd::ebtables('-t nat -L hlswmaster --Lc');
|
||||
$lines_from = Cmd::ebtables('-t nat -L hlswmaster --Lc');
|
||||
$lines_to = Cmd::ebtables('-t filter -L hlswmaster --Lc');
|
||||
|
||||
$result = array();
|
||||
@ -645,7 +645,7 @@ class Stats {
|
||||
foreach ($lines_from as $line) {
|
||||
if (strpos($line, $hlsw['ip'])) {
|
||||
$parts = explode(' ', $line);
|
||||
$from = $parts[14];
|
||||
$from = $parts[13];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -653,7 +653,7 @@ class Stats {
|
||||
foreach ($lines_to as $line) {
|
||||
if (strpos($line, $hlsw['dev'])) {
|
||||
$parts = explode(' ', $line);
|
||||
$to = $parts[12];
|
||||
$to = $parts[11];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,9 @@ define('DB_USER', 'bridge');
|
||||
define('DB_PASS', 'bridge');
|
||||
define('DB_NAME', 'bridge');
|
||||
|
||||
define('RRDTOOL', '/usr/bin/rrdtool');
|
||||
define('RRDPATH', '/var/lib/rrd');
|
||||
|
||||
function __autoload($classname)
|
||||
{
|
||||
$filename = $classname.'.class.php';
|
||||
|
45
web/include/Graphs.class.php
Normal file
45
web/include/Graphs.class.php
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -7,6 +7,7 @@ class Hlsw {
|
||||
public $flags;
|
||||
public $ip = "0.0.0.0";
|
||||
public $name;
|
||||
public $rrdpath;
|
||||
|
||||
private function fromRow($row) {
|
||||
$retval = new Hlsw();
|
||||
@ -17,6 +18,7 @@ class Hlsw {
|
||||
$retval->flags = (int)$row['flags'];
|
||||
$retval->ip = (string)$row['ip'];
|
||||
$retval->name = (string)$row['name'];
|
||||
$retval->rrdpath = (string)$row['rrdpath'];
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
@ -30,9 +32,13 @@ class Hlsw {
|
||||
|
||||
function load($id) {
|
||||
$dbh = Database::getInstance();
|
||||
$sql = "SELECT id, vlanid, flags, INET_NTOA(ip) AS ip, name
|
||||
FROM hlsw
|
||||
WHERE id = '{$id}'";
|
||||
$sql = "SELECT h.id, h.vlanid, h.flags, INET_NTOA(h.ip) AS ip, h.name,
|
||||
CONCAT('bridge-', b.id, '/hlsw-', h.id, '.rrd') AS rrdpath
|
||||
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);
|
||||
return self::fromRow($dbh->fetch_assoc());
|
||||
@ -66,9 +72,13 @@ class Hlsw {
|
||||
function getAll() {
|
||||
$dbh = Database::getInstance();
|
||||
|
||||
$sql = "SELECT id, vlanid, flags, INET_NTOA(ip) AS ip, name
|
||||
FROM hlsw
|
||||
ORDER BY ip";
|
||||
$sql = "SELECT h.id, h.vlanid, h.flags, INET_NTOA(h.ip) AS ip, h.name,
|
||||
CONCAT('bridge-', b.id, '/hlsw-', h.id, '.rrd') AS rrdpath
|
||||
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);
|
||||
|
||||
$retval = array();
|
||||
|
@ -6,6 +6,7 @@ class Trunk {
|
||||
public $bridgeid;
|
||||
public $flags;
|
||||
public $name;
|
||||
public $fullname;
|
||||
|
||||
private function fromRow($row) {
|
||||
$retval = new Trunk();
|
||||
@ -15,6 +16,7 @@ class Trunk {
|
||||
$retval->bridgeid = (int)$row['bridgeid'];
|
||||
$retval->flags = (int)$row['flags'];
|
||||
$retval->name = (string)$row['name'];
|
||||
$retval->fullname = (string)$row['fullname'];
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
@ -27,9 +29,11 @@ class Trunk {
|
||||
|
||||
function load($id) {
|
||||
$dbh = Database::getInstance();
|
||||
$sql = "SELECT id, bridgeid, flags, name
|
||||
FROM trunk
|
||||
WHERE id = '{$id}'";
|
||||
$sql = "SELECT t.id, t.bridgeid, t.flags, t.name,
|
||||
CONCAT(b.name, ': ', t.name) AS fullname
|
||||
FROM trunk t, bridge b
|
||||
WHERE id = '{$id}'
|
||||
AND b.id = t.bridgeid";
|
||||
|
||||
$dbh->query($sql);
|
||||
return self::fromRow($dbh->fetch_assoc());
|
||||
@ -67,11 +71,12 @@ class Trunk {
|
||||
function getAll($bridgeid = false) {
|
||||
$dbh = Database::getInstance();
|
||||
|
||||
$sql = "SELECT id, bridgeid, flags, name
|
||||
FROM trunk
|
||||
".($bridgeid ? "WHERE bridgeid = '{$bridgeid}'" : "")."
|
||||
ORDER BY name";
|
||||
|
||||
$sql = "SELECT t.id, t.bridgeid, t.flags, t.name,
|
||||
CONCAT(b.name, ': ', t.name) AS fullname
|
||||
FROM trunk t, bridge b
|
||||
WHERE ".($bridgeid ? "bridgeid = '{$bridgeid}'" : "1")."
|
||||
AND b.id = t.bridgeid
|
||||
ORDER BY b.name, t.name";
|
||||
$dbh->query($sql);
|
||||
|
||||
$retval = array();
|
||||
|
@ -8,6 +8,8 @@ class Vlan {
|
||||
public $vlannum;
|
||||
public $bandwidth;
|
||||
public $mac = "00:00:00:00:00:00";
|
||||
public $rrdpath;
|
||||
public $fullname;
|
||||
|
||||
private function fromRow($row) {
|
||||
$retval = new Vlan();
|
||||
@ -19,6 +21,8 @@ class Vlan {
|
||||
$retval->vlannum = (int)$row['vlannum'];
|
||||
$retval->bandwidth = (int)$row['bandwidth'];
|
||||
$retval->mac = (string)$row['mac'];
|
||||
$retval->rrdpath = (string)$row['rrdpath'];
|
||||
$retval->fullname = (string)$row['fullname'];
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
@ -33,9 +37,19 @@ class Vlan {
|
||||
|
||||
function load($id) {
|
||||
$dbh = Database::getInstance();
|
||||
$sql = "SELECT id, trunkid, flags, vlannum, bandwidth, mac
|
||||
FROM vlan
|
||||
WHERE id = '{$id}'";
|
||||
$sql = "SELECT v.id, v.trunkid, v.flags, v.vlannum, v.bandwidth, v.mac,
|
||||
IF (v.vlannum = 1,
|
||||
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);
|
||||
return self::fromRow($dbh->fetch_assoc());
|
||||
@ -69,10 +83,14 @@ class Vlan {
|
||||
function getAll($trunkid = false) {
|
||||
$dbh = Database::getInstance();
|
||||
|
||||
$sql = "SELECT id, trunkid, flags, vlannum, bandwidth, mac
|
||||
FROM vlan
|
||||
".($trunkid ? "WHERE trunkid = '{$trunkid}'" : "")."
|
||||
ORDER BY vlannum";
|
||||
$sql = "SELECT v.id, v.trunkid, v.flags, v.vlannum, v.bandwidth, v.mac,
|
||||
CONCAT('bridge-', b.id, '/vlan-', t.name, '.', v.vlannum, '.rrd') as rrdpath,
|
||||
CONCAT(t.name, '.', v.vlannum) as fullname
|
||||
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);
|
||||
|
||||
$retval = array();
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
<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>
|
||||
<br><br>
|
||||
|
@ -22,25 +22,27 @@
|
||||
<a {if $smarty.server.PHP_SELF == 'hlsw.php'}class="sel"{/if} href="hlsw.php">HLSW Master</a>
|
||||
</span><br>
|
||||
<br>
|
||||
{*
|
||||
<span class="navgroup">Statistics:</span><br>
|
||||
{*
|
||||
<span class="navlink">=>
|
||||
<a {if $smarty.server.PHP_SELF == 'stat_device.php'}class="sel"{/if} href="stat_device.php">Bridges</a>
|
||||
</span><br>
|
||||
<span class="navlink">=>
|
||||
<a {if $smarty.server.PHP_SELF == 'stat_tunnel.php'}class="sel"{/if} href="stat_tunnel.php">Bridge Tunnels</a>
|
||||
</span><br>
|
||||
*}
|
||||
<span class="navlink">=>
|
||||
<a {if $smarty.server.PHP_SELF == 'stat_vlan.php'}class="sel"{/if} href="stat_vlan.php">Bridge VLANs</a>
|
||||
</span><br>
|
||||
{*
|
||||
<span class="navlink">=>
|
||||
<a {if $smarty.server.PHP_SELF == 'stat_forward.php'}class="sel"{/if} href="stat_forward.php">Forwarding Ports</a>
|
||||
</span><br>
|
||||
*}
|
||||
<span class="navlink">=>
|
||||
<a {if $smarty.server.PHP_SELF == 'stat_hlsw.php'}class="sel"{/if} href="stat_hlsw.php">HLSW Server</a>
|
||||
</span><br>
|
||||
<br>
|
||||
*}
|
||||
<br><br><br>
|
||||
</td>
|
||||
<td class="fillborder" height="100%" valign="top">
|
||||
|
15
web/smarty/templates/stat_hlsw.tpl
Normal file
15
web/smarty/templates/stat_hlsw.tpl
Normal 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>
|
26
web/smarty/templates/stat_vlan.tpl
Normal file
26
web/smarty/templates/stat_vlan.tpl
Normal 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>
|
||||
|
||||
<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
35
web/stat_hlsw.php
Normal 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
48
web/stat_vlan.php
Normal 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');
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user