Moving device sub-pages

git-svn-id: http://www.observium.org/svn/observer/trunk@51 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2007-04-04 10:15:07 +00:00
parent 0d678d9e4c
commit 03de99e914
9 changed files with 480 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
<?php
if($device['uptime'] < '86400') { $uptime_colour = $warn_colour_a; }
echo("
<table width=100% cellspacing=0 cellpadding=0>
<tr><td class=tablehead>Operating System</td><td>$device[os] $device[version] ($device[features])</td></tr>
<tr><td class=tablehead>Hardware </td><td>$device[hardware]</td></tr>
<tr><td class=tablehead>Uptime </td><td bgcolor=$uptime_colour>" . formatuptime($device[uptime]) . "</td></tr>
</table>
");
?>

View File

@@ -0,0 +1,85 @@
<?php
if($_SESSION['userlevel'] < '5') {
print_error("Insufficient Privileges");
} else {
if($_POST['editing']) {
if($userlevel > "5") {
include("includes/edit-host.inc");
}
}
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `id` = '$_GET[id]'"));
$descr = $device['purpose'];
if($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
}
if($device['type'] == 'server') { $server_select = "selected"; }
if($device['type'] == 'network') { $network_select = "selected"; }
if($device['type'] == 'firewall') { $firewall_select = "selected"; }
if($device['type'] == 'workstation') { $workstation_select = "selected"; }
if($device['type'] == 'other') { $other_select = "selected"; }
echo("<table cellpadding=0 cellspacing=0><tr><td>
<h4>Edit Device</h4>
<form id='edit' name='edit' method='post' action=''>
<input type=hidden name='editing' value='yes'>
<table width='200' border='0'>
<tr>
<td width='300'><div align='right'>Description</div></td>
<td colspan='3'><textarea name='descr' cols='50'>$descr</textarea></td>
</tr>
<tr>
<td>
Type
</td>
<td>
<select name='type'>
<option value='server' $server_select>Server</option>
<option value='network' $network_select>Network</option>
<option value='firewall' $firewall_select>Firewall</option>
<option value='workstation' $workstation_select>Workstation</option>
<option value='other' $other_select>Other</option>
</select>
</td>
</tr>
<tr>
<td width='300'><div align='right'>Disable</div></td>
<td width='300'><input name='disable' type='checkbox' id='disable' value='1'");
if($device['disabled']) {echo("checked=checked");}
echo("/></td>
<td width='300'><div align='right'>Ignore</div></td>
<td width='300'><input name='ignore' type='checkbox' id='disable' value='1'");
if($device['ignore']) {echo("checked=checked");}
echo("/></td>
</tr>
<tr>
<td width='300'><div align='right'>Apache</div></td>
<td width='300'><label>
<input name='apache' type='checkbox' id='apache' value='1'");
if($device['apache']) {echo("checked=checked");}
echo("/>
</label></td>
</tr>
</table>
<input type='submit' name='Submit' value='Save' />
<label><br />
</label>
</form></td>
<td width=50></td><td>");
echo("</td></tr></table>");
}

View File

@@ -0,0 +1,15 @@
<?
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` WHERE `host` = '$_GET[id]' ORDER BY `datetime` DESC LIMIT 0,250";
$data = mysql_query($query);
echo("<table cellspacing=0 cellpadding=1 width=100%>");
while($entry = mysql_fetch_array($data)) {
include("includes/print-event.inc");
}
echo("</table>");
?>

View File

@@ -0,0 +1,189 @@
<?
$device_query = mysql_query("select * from devices WHERE id = '$_GET[id]'");
while($device = mysql_fetch_array($device_query)) {
$hostname = $device[hostname];
$bg="#ffffff";
echo("<div style='clear: both;'>");
switch ($device['os']) {
case "ProCurve":
echo("<div class=graphhead>Processor Utilisation</div>");
$graph_type = "cpu"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>Memory Usage</div>");
$graph_type = "mem"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>Device Uptime</div>");
$graph_type = "uptime"; include ("includes/print-device-graph.php"); break;
echo("<br />");
break;
case "Windows":
$graph_type = "cpu";
include ("includes/print-device-graph.php");
$memgraph = memgraphWin ($device[hostname] . "-mem.rrd", $device[hostname] . "-mem.png", $day, $now, 335, 100);
$loadgraph = loadgraphWin ($device[hostname] . "-load.rrd", $device[hostname] . "-load.png", $day, $now, 335, 100);
$cpugraphm = cpugraphWin ($device[hostname] . "-cpu.rrd", $device[hostname] . "-cpu-m.png", $month, $now, 335, 100);
$memgraphm = memgraphWin ($device[hostname] . "-mem.rrd", $device[hostname] . "-mem-m.png", $month, $now, 335, 100);
$loadgraphm = loadgraphWin ($device[hostname] . "-load.rrd", $device[hostname] . "-load-m.png", $month, $now, 335, 100);
$usersgraph = usersgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-users.png", $day, $now, 335, 100);
$usersgraphm = usersgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-users-m.png", $month, $now, 335, 100);
$procsgraph = procsgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-procs.png", $day, $now, 335, 100);
$procsgraphm = procsgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-procs-m.png", $month, $now, 335, 100);
break;
case "FreeBSD":
case "NetBSD":
case "Linux":
case "m0n0wall":
case "Voswall":
case "DragonFly":
case "OpenBSD":
case "pfSense":
echo("<div class=graphhead>Processor Utilisation</div>");
$graph_type = "cpu"; include ("includes/print-device-graph.php");
echo("<br />");
if($device[os] == "m0n0wall" || $device[os] == "pfSense" || $device[os] == "Voswall" || $device[monowall]) {
echo("<div class=graphhead>Device Uptime</div>");
$graph_type = "uptime"; include ("includes/print-device-graph.php"); break;
echo("<br />");
}
if($device['os'] != "NetBSD") {
echo("<div class=graphhead>Memory Utilisation</div>");
$graph_type = "mem"; include ("includes/print-device-graph.php");
echo("<br />");
}
if(mysql_result(mysql_query("SELECT count(storage_id) FROM storage WHERE host_id = '$device[id]'"),0)) {
echo("<div class=graphhead>Storage</div>");
$graph_type = "unixfs"; include ("includes/print-device-graph.php");
echo("<br />");
}
if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '$device[id]'"),0)) {
echo("<div class=graphhead>Temperatures</div>");
$graph_type = "temp"; include ("includes/print-device-graph.php");
echo("<br />");
}
echo("<div class=graphhead>IP Statistics</div>");
$graph_type = "ip_graph"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>TCP Statistics</div>");
$graph_type = "tcp_graph"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>UDP Statistics</div>");
$graph_type = "udp_graph"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>ICMP Statistics</div>");
$graph_type = "icmp_graph"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>System Load</div>");
$graph_type = "load"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>Users Logged On</div>");
$graph_type = "users"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>Running Processes</div>");
$graph_type = "procs"; include ("includes/print-device-graph.php");
echo("<br />");
if($device[postfix] == '1') {
echo("<div class=graphhead>Postfix Mail Statistics</div>");
$graph_type = "postfix"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>Postfix Mail Error Statistics</div>");
$graph_type = "postfixerrors"; include ("includes/print-device-graph.php");
echo("<br />");
}
if($device[courier] == '1') {
echo("<div class=graphhead>Postfix Mail Statistics</div>");
$graph_type = "courier"; include ("includes/print-device-graph.php");
echo("<br />");
}
if($device[apache] == '1') {
echo("<div class=graphhead>Apache Hits</div>");
$graph_type = "apachehits"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>Apache Traffic</div>");
$graph_type = "apachebits"; include ("includes/print-device-graph.php");
echo("<br />");
}
echo("<div class=graphhead>Device Uptime</div>");
$graph_type = "uptime"; include ("includes/print-device-graph.php");
echo("<br />");
break;
case "IOS":
echo("<div class=graphhead>CPU Usage</div>");
$graph_type = "cpu"; include ("includes/print-device-graph.php");
echo("<div class=graphhead>Memory Usage</div>");
echo("<br />");
$graph_type = "mem"; include ("includes/print-device-graph.php");
echo("<br />");
if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '$device[id]'"),0)) {
echo("<div class=graphhead>Temperatures</div>");
$graph_type = "temp"; include ("includes/print-device-graph.php");
echo("<br />");
}
echo("<div class=graphhead>IP Statistics</div>");
$graph_type = "ip_graph"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>TCP Statistics</div>");
$graph_type = "tcp_graph"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>UDP Statistics</div>");
$graph_type = "udp_graph"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>ICMP Statistics</div>");
$graph_type = "icmp_graph"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>Uptime</div>");
$graph_type = "uptime"; include ("includes/print-device-graph.php");
break;
case "Snom":
echo("<div class=graphhead>Calls</div>");
$graph_type = "calls"; include ("includes/print-device-graph.php");
}
if($memgraph) {
echo("<img src='$memgraph'> <img src='$memgraphm'>");
}
if($storagegraph) {
echo("$storagegraph");
}
if($loadgraph) {
echo("<img src='$loadgraph'> <img src='$loadgraphm'>");
}
if($tempgraph) {
echo("<img src='$tempgraph'> <img src='$tempgraphm'>");
}
if($mailsgraph) {
echo("<img src='$mailsgraph'> <img src='$mailsgraphm'>");
}
if($mailerrorgraph) {
echo("<img src='$mailerrorgraph'> <img src='$mailerrorgraphm'>");
}
if($couriergraph) {
echo("<img src='$couriergraph'> <img src='$couriergraphm'>");
}
if($ahitsgraph) {
echo("<img src='$ahitsgraph'> <img src='$ahitsgraphm'>");
}
if($abitsgraph) {
echo("<img src='$abitsgraph'> <img src='$abitsgraphm'>");
}
if($usersgraph) {
echo("<img src='$usersgraph'> <img src='$usersgraphm'>");
}
if($procsgraph) {
echo("<img src='$procsgraph'> <img src='$procsgraphm'>");
}
if($uptimegraph) {
echo("<img src='$uptimegraph'> <img src='$uptimegraphm'>");
}
echo("</div>");
}
?>

View File

@@ -0,0 +1,7 @@
<?php
$dographs = 1;
include("pages/device/dev-ifs.inc");
?>

View File

@@ -0,0 +1,13 @@
<?php
$hostname = gethostbyid($_GET[id]);
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "1";
$interface_query = mysql_query("select * from interfaces WHERE host = '$_GET[id]' ORDER BY 'ifIndex'");
while($interface = mysql_fetch_array($interface_query)) {
include("includes/print-interface.inc");
}
echo("</table></div>");
?>

View File

@@ -0,0 +1,118 @@
<?php
$overview = 1;
$id = $_GET[id];
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE id = '$_GET[id]'"));
$interfaces['total'] = mysql_result(mysql_query("SELECT count(id) FROM interfaces WHERE host = '$id'"),0);
$interfaces['up'] = mysql_result(mysql_query("SELECT count(id) FROM interfaces WHERE host = '$id' AND up = 'up'"),0);
$interfaces['down'] = mysql_result(mysql_query("SELECT count(id) FROM interfaces WHERE host = '$id' AND up = 'down' AND up_admin = 'up'"),0);
$interfaces['disabled'] = mysql_result(mysql_query("SELECT count(id) FROM interfaces WHERE host = '$id' AND up_admin = 'down'"),0);
$services['total'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '$id'"),0);
$services['up'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '$id' AND service_status = '1' AND service_ignore ='0'"),0);
$services['down'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '$id' AND service_status = '0' AND service_ignore = '0'"),0);
$services['disabled'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '$id' AND service_ignore = '1'"),0);
if($services['down']) { $services_colour = $warn_colour_a; } else { $services_colour = $list_colour_a; }
if($interfaces['down']) { $interfaces_colour = $warn_colour_a; } else { $interfaces_colour = $list_colour_a; }
echo("
<table width=100% cellspacing=0 cellpadding=0>
<tr><td width=50% valign=top>");
if(file_exists("includes/dev-data-" . strtolower($device[os]) . ".inc")) {
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
echo("<p class=sectionhead>Device Data</p><div style='height: 5px;'></div>");
include("includes/dev-data-" . strtolower($device[os]) . ".inc");
echo("</div>");
}
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
$query = "SELECT *,DATE_FORMAT(datetime, '%d/%b/%y %T') as humandate FROM `eventlog` WHERE `host` = '$_GET[id]' ORDER BY `datetime` DESC LIMIT 0,10";
$data = mysql_query($query);
echo("<p class=sectionhead>Recent Events</p><div style='height: 5px;'></div>
<table cellspacing=0 cellpadding=2 width=100%>");
while($entry = mysql_fetch_array($data)) {
include("includes/print-event-short.inc");
}
echo("</table></div>");
echo("</td><td width=50% valign=top>");
if($interfaces['total']) {
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
echo("<p class=sectionhead>Interfaces</p><div style='height: 5px;'></div>");
echo("
<table class=tablehead cellpadding=2 cellspacing=0 width=100%>
<tr bgcolor=$interfaces_colour align=center><td></td>
<td width=25%><img src='images/16/connect.png' align=absmiddle> $interfaces[total]</td>
<td width=25% class=green><img src='images/16/if-connect.png' align=absmiddle> $interfaces[up]</td>
<td width=25% class=red><img src='images/16/if-disconnect.png' align=absmiddle> $interfaces[down]</td>
<td width=25% class=grey><img src='images/16/if-disable.png' align=absmiddle> $interfaces[disabled]</td></tr>
</table>");
echo("<div style='margin: 8px; font-size: 11px; font-weight: bold;'>");
$sql = "SELECT * FROM interfaces WHERE host = '$id'";
$query = mysql_query($sql);
while($data = mysql_fetch_array($query)) {
echo("$ifsep" . generateiflink($data, makeshortif(strtolower($data['if']))));
$ifsep = ", ";
}
unset($ifsep);
echo("</div>");
echo("</div>");
}
if($services['total']) {
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
echo("<p class=sectionhead>Services</p><div style='height: 5px;'></div>");
echo("
<table class=tablehead cellpadding=2 cellspacing=0 width=100%>
<tr bgcolor=$services_colour align=center><td></td>
<td width=25%><img src='images/16/cog.png' align=absmiddle> $services[total]</td>
<td width=25% class=green><img src='images/16/cog_go.png' align=absmiddle> $services[up]</td>
<td width=25% class=red><img src='images/16/cog_error.png' align=absmiddle> $services[down]</td>
<td width=25% class=grey><img src='images/16/cog_disable.png' align=absmiddle> $services[disabled]</td></tr>
</table>");
echo("<div style='padding: 8px; font-size: 11px; font-weight: bold;'>");
$sql = "SELECT * FROM services WHERE service_host = '$id' ORDER BY service_type";
$query = mysql_query($sql);
while($data = mysql_fetch_array($query)) {
if ($data[service_status] == "0" && $data[service_ignore] == "1") { $status = "grey"; }
if ($data[service_status] == "1" && $data[service_ignore] == "1") { $status = "green"; }
if ($data[service_status] == "0" && $data[service_ignore] == "0") { $status = "red"; }
if ($data[service_status] == "1" && $data[service_ignore] == "0") { $status = "blue"; }
echo("$break<a class=$status>" . strtolower($data[service_type]) . "</a>");
$break = ", ";
}
echo("</div>");
}
echo("</td></tr></table>");
?>

View File

@@ -0,0 +1,24 @@
<?
$hostname = gethostbyid($_GET[id]);
if(mysql_result(mysql_query("select count(service_id) from services WHERE service_host = '$_GET[id]'"), 0) > '0') {
echo("<div style='margin: 5px;'><table cellpadding=7 border=0 cellspacing=0 width=100%>");
$i = "1";
$service_query = mysql_query("select * from services WHERE service_host = '$_GET[id]' ORDER BY service_type");
while($service = mysql_fetch_array($service_query)) {
include("includes/print-service.inc");
}
echo("</table></div>");
} else {
echo("No Services");
}
?>

View File

@@ -0,0 +1,15 @@
<?
$query = "SELECT * FROM `syslog` WHERE `host` = '$_GET[id]' ORDER BY `datetime` DESC LIMIT 0,250";
$data = mysql_query($query);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while($entry = mysql_fetch_array($data)) {
include("includes/print-syslog.inc");
}
echo("</table>");
?>