mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
adding map drawing and securing some directories
git-svn-id: http://www.observium.org/svn/observer/trunk@352 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
1
html/includes/.htaccess
Normal file
1
html/includes/.htaccess
Normal file
@@ -0,0 +1 @@
|
||||
deny from all
|
98
html/map.php
Executable file
98
html/map.php
Executable file
@@ -0,0 +1,98 @@
|
||||
<?
|
||||
|
||||
include("../config.php");
|
||||
include("../includes/functions.php");
|
||||
|
||||
$device = mysql_fetch_array(mysql_query("SELECT * from devices WHERE device_id = ".$_GET['device'].""));
|
||||
|
||||
if($device && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
||||
|
||||
$map = "digraph G { sep=0.01; size=\"12,5.5\"; pack=100; bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=0;
|
||||
node [ fontname=\"helvetica\", fontstyle=bold, style=filled, color=white, fillcolor=lightgrey, overlap=false;];
|
||||
edge [ bgcolor=white; fontname=\"helvetica\"; fontstyle=bold; arrowhead=dot; arrowtail=dot];
|
||||
graph [bgcolor=transparent;];
|
||||
|
||||
";
|
||||
|
||||
$map .= "\"".$device['hostname']."\" [fontsize=20 fillcolor=\"lightblue\" URL=\"/device/".$device['device_id']."/map/\" shape=box3d]\n";
|
||||
|
||||
|
||||
$sql = "SELECT * from interfaces AS I, links AS L WHERE I.device_id = ".$device['device_id']." AND L.src_if = I.interface_id";
|
||||
$links = mysql_query($sql);
|
||||
while($link = mysql_fetch_array($links)) {
|
||||
|
||||
$src_if = $link['src_if'];
|
||||
$dst_if = $link['dst_if'];
|
||||
|
||||
$i = 0; $done = 0;
|
||||
while ($i < count($linkdone)) {
|
||||
$thislink = "$dst_if $src_if";
|
||||
if ($linkdone[$i] == $thislink) { $done = 1; }
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!$done) {
|
||||
|
||||
$linkdone[] = "$src_if $dst_if";
|
||||
|
||||
if($link['ifSpeed'] >= "10000000000") {
|
||||
$info = "color=lightred style=\"setlinewidth(8)\"";
|
||||
} elseif ($link['ifSpeed'] >= "1000000000") {
|
||||
$info = "color=lightblue style=\"setlinewidth(4)\"";
|
||||
} elseif ($link['ifSpeed'] >= "100000000") {
|
||||
$info = "color=lightgrey style=\"setlinewidth(2)\"";
|
||||
} elseif ($link['ifSpeed'] >= "10000000") {
|
||||
$info = "style=\"setlinewidth(1)\"";
|
||||
} else {
|
||||
$info = "style=\"setlinewidth(1)\"";
|
||||
}
|
||||
|
||||
$src = $device['hostname'];
|
||||
$dst = mysql_result(mysql_query("SELECT `hostname` FROM `devices` AS D, `interfaces` AS I WHERE I.interface_id = '$dst_if' AND D.device_id = I.device_id"),0);
|
||||
$dst_host = mysql_result(mysql_query("SELECT D.device_id FROM `devices` AS D, `interfaces` AS I WHERE I.interface_id = '$dst_if' AND D.device_id = I.device_id"),0);
|
||||
|
||||
|
||||
$sif = makeshortif($link['ifDescr']);
|
||||
$dif = makeshortif(mysql_result(mysql_query("SELECT ifDescr from interfaces WHERE interface_id = '".$dst_if."'"),0));
|
||||
|
||||
$map .= "\"$src$sif\" [label=\"$sif\", fontsize=12, fillcolor=lightblue URL=\"/device/".$device['device_id']."/interface/$src_if/\"]\n";
|
||||
$map .= "\"$src\" -> \"$src$sif\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
|
||||
# $map .= "\"$src$sif\" -> \"$dst$dif\" [weight=1] \n";
|
||||
|
||||
$map .= "\"$dst\" [URL=\"/device/$dst_host/map/\" fontsize=20 shape=box3d]\n";
|
||||
|
||||
if($dst_host == $device['device_id']) {
|
||||
$map .= "\"$dst$dif\" [label=\"$dif\", fontsize=12, fillcolor=lightblue, URL=\"/device/$dst_host/interface/$dst_if/\"]\n";
|
||||
} else {
|
||||
$map .= "\"$dst$dif\" [label=\"$dif\", fontsize=12, fillcolor=lightgray, URL=\"/device/$dst_host/interface/$dst_if/\"]\n";
|
||||
}
|
||||
|
||||
|
||||
$map .= "\"$dst$dif\" -> \"$dst\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
|
||||
$map .= "\"$src$sif\" -> \"$dst$dif\" [weight=1, arrowhead=normal, arrowtail=normal, len=2, $info] \n";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$map .= "
|
||||
};";
|
||||
|
||||
#echo("<pre>$map</pre>");
|
||||
|
||||
$img = shell_exec("echo \"".addslashes($map)."\" | dot -T".$_GET['format']."");
|
||||
if($_GET['format'] == "png") {
|
||||
header("Content-type: image/".$_GET['format']);
|
||||
} elseif ($_GET['format'] == "svg") {
|
||||
header("Content-type: image/svg+xml");
|
||||
$img = str_replace("<a ", "<a target = \"_parent\" ", $img);
|
||||
}
|
||||
echo("$img");
|
||||
|
||||
}
|
||||
|
||||
?>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
if($_GET['logout']) {
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
// convert username and password from _POST or _SESSION
|
||||
if($_SERVER['PHP_AUTH_PW']) {
|
||||
$_SESSION['username']=$_SERVER['PHP_AUTH_USER'];
|
||||
$_SESSION['password']=$_SERVER['PHP_AUTH_PW'];
|
||||
} elseif($_POST){
|
||||
$_SESSION['username']=$_POST["username"];
|
||||
$_SESSION['password']=$_POST["password"];
|
||||
}
|
||||
|
||||
// query for a user/pass match
|
||||
$password = $_SESSION['password'];
|
||||
$encrypted = md5($password);
|
||||
|
||||
$sql = "select username, level from users where username='$_SESSION[username]' and password='$encrypted'";
|
||||
|
||||
$row = mysql_fetch_row(mysql_query($sql));
|
||||
|
||||
$result = $row[0];
|
||||
|
||||
$auth_level = $row[1];
|
||||
|
||||
if ( $_SESSION['username'] != "" && $result == $_SESSION['username'] ) {
|
||||
$auth_user = $result;
|
||||
} else {
|
||||
header('WWW-Authenticate: Basic realm="Vostron Administration"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
echo 'Authentication required.';
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
?>
|
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
echo ("<p class=device-header><a href='?page=device&id=$device[id]'>$device[hostname]</a></p>");
|
||||
if($device[location] != "") { $locationhtml = $device[location]; }
|
||||
|
||||
$type = strtolower($device['os']);
|
||||
if(file_exists("..images/os/$type" . ".gif")){ $image = "<img src='..images/os/$type.gif' align=absmiddle>"; }
|
||||
|
||||
if ($device['os'] == "IOS") {
|
||||
echo ("<p class=box-desc>
|
||||
<div style='float: left; padding: 10px;'>$image</div>
|
||||
$device[hardware] <br /> $device[os] $device[version] <br />
|
||||
$device[features] <br />
|
||||
$locationhtml<br />
|
||||
Up " . formatUptime($device[uptime]) ."</p>");
|
||||
} else {
|
||||
echo ("<p class=box-desc>$image $device[os] $device[version] ($device[features])
|
||||
<br />$locationhtml <br />
|
||||
Up " . formatUptime($device[uptime]) ."</p>");
|
||||
}
|
||||
|
||||
if($_GET['page'] == 'device') {
|
||||
if($_GET['graphs'] == 'yes') {
|
||||
echo("<p class=interface><a href='?page=device&id=$_GET[id]'><img src='images/neu/hide-graphs.png' border=0 align=absmiddle> Hide Graphs</a></p>");
|
||||
} else {
|
||||
echo("<p class=interface><a href='?page=device&id=$_GET[id]&graphs=yes'><img src='images/neu/show-graphs.png' border=0 align=absmiddle> Show Graphs</a></p>");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
$iftype = fixiftype($interface[ifType]);
|
||||
|
||||
echo ("<p class=interface-header>$inf</p>");
|
||||
if($ifalias && $ifalias != "") { echo("<span class=box-desc>$ifalias</span><br />"); }
|
||||
if($iftype && $iftype != "") { echo("<span class=box-desc>$iftype</span> ");
|
||||
if($mac && $mac != "") { echo("<span class=box-desc>$mac</span><br />");
|
||||
} else { echo("<br />"); }
|
||||
}
|
||||
|
||||
if($interface[ifType] != "softwareLoopback") {
|
||||
if($speed == '0') { $speed = "0bps"; }
|
||||
echo("<span class=box-desc>$speed");
|
||||
if($interface[ifDuplex] != unknown) { echo(" / $interface[ifDuplex]-duplex"); }
|
||||
if($interface[ifMtu] && $interface[ifMtu] != "") { echo(" / $interface[ifMtu]MTU</span>"); }
|
||||
echo("</span><br />");
|
||||
}
|
||||
|
||||
echo ("<span class=box-desc><b>$status</b></span> <br />");
|
||||
|
||||
|
||||
?>
|
@@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
$if_id = $interface['id'];
|
||||
$inf = fixifName($interface['if']);
|
||||
$ifIndex = $interface['ifIndex'];
|
||||
$ifclass = ifclass($interface['up'], $interface['up_admin']);
|
||||
$ifname = $interface['name'];
|
||||
if($ifname) {$ifname = $ifname . "</br>";}
|
||||
echo("<tr>
|
||||
<td valign=top width=250>
|
||||
<a class='$ifclass' href='?page=interface&id=$interface[id]'>
|
||||
$i. $inf
|
||||
</a><br /><span class=interface-desc>$ifname</span>");
|
||||
if($ifalias && $ifalias != "") { echo("<span class=interface-desc>$ifalias</span><br />"); }
|
||||
unset ($break);
|
||||
|
||||
$iftype = fixiftype($interface[ifType]);
|
||||
if($show_all) {
|
||||
if($iftype && $iftype != "") { echo("<span class=box-desc>$iftype</span> ");
|
||||
if($mac && $mac != "") { echo("<span class=box-desc>$mac</span><br />");
|
||||
} else { echo("<br />"); }
|
||||
}
|
||||
|
||||
if($interface[ifType] != "softwareLoopback") {
|
||||
if($speed == '0') { $speed = "0bps"; }
|
||||
echo("<span class=box-desc>$speed");
|
||||
if($interface[ifDuplex] != unknown) { echo(" / $interface[ifDuplex]-duplex"); }
|
||||
if($interface[ifMtu] && $interface[ifMtu] != "") { echo(" / $interface[ifMtu]MTU</span>"); }
|
||||
echo("</span><br />");
|
||||
}
|
||||
|
||||
echo ("<span class=box-desc><b>$status</b></span> <br />");
|
||||
}
|
||||
|
||||
$ipdata = mysql_query("SELECT * FROM `ipaddr` WHERE `interface_id` = '$interface[id]'");
|
||||
while($ip = mysql_fetch_Array($ipdata)) {
|
||||
echo("$break <a href=\"javascript:popUp('/whois.php?query=$ip[addr]')\">$ip[addr]/$ip[cidr]</a>");
|
||||
$break = "<br />";
|
||||
}
|
||||
echo("</span></td>");
|
||||
echo("<td valign=top class=interface-desc>");
|
||||
|
||||
if ( strpos($inf, "oopback") === false ) {
|
||||
|
||||
$link_query = mysql_query("select I.if, D.hostname, D.id AS dev_id, I.id from links AS L, interfaces AS I, devices AS D WHERE L.src_if = '$if_id' AND L.dst_if = I.id AND I.host = D.id");
|
||||
while($link = mysql_fetch_array($link_query)) {
|
||||
$link_if = fixifName($link['if']);
|
||||
echo("--> <a href='?page=interface&id=$link[id]'>$link_if</a> on <a href='?page=device&id=$link[dev_id]'>$link[hostname]</a><br />");
|
||||
$br = "<br />";
|
||||
}
|
||||
$adj_sql = "SELECT * FROM networks AS N, interfaces AS I, adjacencies AS A ";
|
||||
$adj_sql = $adj_sql . "WHERE I.id = A.interface_id AND A.network_id = N.id ";
|
||||
$adj_sql = $adj_sql . "AND I.id = '$if_id'";
|
||||
$adj_query = mysql_query("$adj_sql");
|
||||
while($adjs = mysql_fetch_array($adj_query)) {
|
||||
$network_id = $adjs['network_id'];
|
||||
$newsql = "SELECT *, I.id AS iid, D.id AS did FROM adjacencies AS A, networks as N, interfaces as I, devices as D ";
|
||||
$newsql = $newsql . "WHERE N.id = '$network_id' AND A.network_id = N.id AND I.id = A.interface_id AND D.id = I.host ";
|
||||
$newsql = $newsql . "AND D.id != '$device[id]' AND I.if NOT LIKE '%loopback%' GROUP BY D.id ORDER BY D.hostname";
|
||||
$new_query = mysql_query($newsql);
|
||||
while($new = mysql_fetch_array($new_query)) {
|
||||
if ($new['status'] == '0') { $class = "red"; } else { $class = "blue"; }
|
||||
if ($new['ignore'] == '1') {
|
||||
$class = "list-device-ignored";
|
||||
if ($new['status'] == '1') { $class = "green"; }
|
||||
}
|
||||
$this_ifid = $new['iid'];
|
||||
$this_hostid = $new['did'];
|
||||
$this_hostname = $new['hostname'];
|
||||
$this_ifname = fixifName($new['if']);
|
||||
$wq = mysql_query("select count(*) FROM links WHERE dst_if = '$this_ifid' AND src_if = $if_id;");
|
||||
if (@mysql_result($wq, 0) == '0') {
|
||||
echo("$br |- <a href=?page=interface&id=$this_ifid>$this_ifname</a> on <a class=$class href=?page=device&id=$this_hostid>$this_hostname</a>");
|
||||
$br = "<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo("</td></tr>");
|
||||
|
||||
// If we're showing graphs, generate the graph and print the img tags
|
||||
if($_GET[graphs] == 'yes' && is_file("rrd/" . $hostname . ".". $ifIndex . ".rrd")) {
|
||||
$trafgraph = trafgraph ($hostname . ".". $ifIndex . ".rrd", $hostname . ".". $ifIndex . "-traf.png");
|
||||
$trafgraphmonth = trafgraph ($hostname . ".". $ifIndex . ".rrd", $hostname . ".". $ifIndex . "-month-traf.png", "-1m");
|
||||
if($trafgraph !== false) {
|
||||
echo("<tr><td colspan=2><img src='$trafgraph'> <img src='$trafgraphmonth'></td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
echo("<tr height=5><td colspan=2></td></tr>");
|
||||
|
||||
|
||||
?>
|
@@ -1,20 +0,0 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td align=left>
|
||||
<a href='/network/'><img src='images/neu/monitor.png' align=absmiddle border=0> Network</a>
|
||||
</td>
|
||||
<td width=5></td>
|
||||
<td align=left>
|
||||
<a href='/wiki/'><img src='images/neu/edit.png' align=absmiddle border=0> Wiki</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=left>
|
||||
<a href='http://customer.vostron.net/support/staff.cgi'><img src='images/neu/info.png' align=absmiddle border=0> Support</a>
|
||||
</td>
|
||||
<td width=5></td>
|
||||
<td align=left>
|
||||
<a href='/dns/'><img src='images/neu/dns.png' align=absmiddle border=0> DNS Admin</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
1
html/pages/.htaccess
Normal file
1
html/pages/.htaccess
Normal file
@@ -0,0 +1 @@
|
||||
deny from all
|
Reference in New Issue
Block a user