some more icons, changes to device editing system

git-svn-id: http://www.observium.org/svn/observer/trunk@1221 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-06-20 17:21:35 +00:00
parent bfd6163b8f
commit 5bdb0f31e4
24 changed files with 266 additions and 163 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

BIN
html/images/icons/bind.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

BIN
html/images/icons/device.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

BIN
html/images/icons/mysql.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 790 B

View File

@@ -1,12 +1,13 @@
<?php <?php
/// Draw generic bits graph /// Draw generic bits graph
/// args: rra_in, rra_out, rrd_filename, bg, legend, from, to, width, height, inverse, $percentile /// args: rra_in, rra_out, rrd_filename, bg, legend, from, to, width, height, inverse, percentile
include("common.inc.php"); include("common.inc.php");
$unit_text = str_pad(truncate($unit_text,10),10); $unit_text = str_pad(truncate($unit_text,10),10);
$rrd_options .= " DEF:".$rra."=".$rrd_filename.":".$rra.":AVERAGE"; $rrd_options .= " DEF:".$rra."=".$rrd_filename.":".$rra.":AVERAGE";
$rrd_options .= " DEF:".$rra."_max=".$rrd_filename.":".$rra.":MAX"; $rrd_options .= " DEF:".$rra."_max=".$rrd_filename.":".$rra.":MAX";

View File

@@ -176,7 +176,7 @@ if($config['enable_inventory'] && @mysql_result(mysql_query("SELECT * FROM `entP
if(mysql_result(mysql_query("select count(service_id) from services WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { if(mysql_result(mysql_query("select count(service_id) from services WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
echo('<li class="' . $select['srv'] . '"> echo('<li class="' . $select['srv'] . '">
<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/srv/"> <a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/srv/">
<img src="images/16/server_cog.png" align="absmiddle" border="0" /> Services <img src="images/icons/services.png" align="absmiddle" border="0" /> Services
</a> </a>
</li> </li>
'); ');

View File

@@ -1,73 +0,0 @@
<?php
$temperatures = mysql_result(mysql_query("select count(*) from temperature WHERE device_id = '" . $device['device_id'] . "'"), 0);
$storage = mysql_result(mysql_query("select count(*) from storage WHERE device_id = '" . $device['device_id'] . "'"), 0);
$diskio = mysql_result(mysql_query("select count(*) from ucd_diskio WHERE device_id = '" . $device['device_id'] . "'"), 0);
$memory = mysql_result(mysql_query("select count(*) from mempools WHERE device_id = '" . $device['device_id'] . "'"), 0);
$processor = mysql_result(mysql_query("select count(*) from processors WHERE device_id = '" . $device['device_id'] . "'"), 0);
$fans = mysql_result(mysql_query("select count(*) from fanspeed WHERE device_id = '" . $device['device_id'] . "'"), 0);
$volts = mysql_result(mysql_query("select count(*) from voltage WHERE device_id = '" . $device['device_id'] . "'"), 0);
$freqs = mysql_result(mysql_query("select count(*) from frequency WHERE device_id = '" . $device['device_id'] . "'"), 0);
$current = mysql_result(mysql_query("select count(*) from current WHERE device_id = '" . $device['device_id'] . "'"), 0);
$datas[] = 'overview';
if ($processor) { $datas[] = 'processors'; }
if ($memory) { $datas[] = 'memory'; }
if ($storage) { $datas[] = 'storage'; }
if ($diskio) { $datas[] = 'diskio'; }
if ($temperatures) { $datas[] = 'temperatures'; }
if ($fans) { $datas[] = 'fanspeeds'; }
if ($volts) { $datas[] = 'voltages'; }
if ($freqs) { $datas[] = 'frequencies'; }
if ($current) { $datas[] = 'current'; }
$type_text['overview'] = "Overview";
$type_text['temperatures'] = "Temperatures";
$type_text['memory'] = "Memory Pools";
$type_text['storage'] = "Disk Usage";
$type_text['diskio'] = "Disk IO";
$type_text['processors'] = "Processor Usage";
$type_text['voltages'] = "Voltages";
$type_text['fanspeeds'] = "Fan Speeds";
$type_text['frequencies'] = "Frequencies";
$type_text['current'] = "Current";
print_optionbar_start();
if(!$_GET['opta']) { $_GET['opta'] = "overview"; }
unset($sep);
foreach ($datas as $type) {
echo($sep);
if ($_GET['opta'] == $type)
{
echo("<strong>");
echo('<img src="images/icons/'.$type.'.png" class="optionicon" />');
} else {
echo('<img src="images/icons/greyscale/'.$type.'.png" class="optionicon" />');
}
echo("<a href='".$config['base_url']."/device/".$device['device_id']."/health/" . $type . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . $type_text[$type] ."</a>\n");
if ($_GET['opta'] == $type) { echo("</strong>"); }
$sep = " | ";
}
print_optionbar_end();
if (is_file("pages/device/health/".mres($_GET['opta']).".inc.php"))
{
include("pages/device/health/".mres($_GET['opta']).".inc.php");
} else {
foreach ($datas as $type) {
if($type != "overview") {
$graph_title = $type_text[$type];
$graph_type = "device_".$type;
include ("includes/print-device-graph.php");
}
}
}
?>

View File

@@ -0,0 +1,34 @@
<?php
$query = mysql_query("SELECT * FROM `applications` WHERE `device_id` = '".$device['device_id']."'");
print_optionbar_start();
unset($sep);
while($app = mysql_fetch_array($query)) {
echo($sep);
if(!$_GET['opta']) { $_GET['opta'] = $app['app_type']; }
if ($_GET['opta'] == $app['app_type'])
{
echo("<strong>");
echo('<img src="images/icons/'.$app['app_type'].'.png" class="optionicon" />');
} else {
echo('<img src="images/icons/greyscale/'.$app['app_type'].'.png" class="optionicon" />');
}
echo("<a href='".$config['base_url']."/device/".$device['device_id']."/apps/" . $app['app_type'] . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . $app['app_type'] ."</a>\n");
if ($_GET['opta'] == $app['app_type']) { echo("</strong>"); }
$sep = " | ";
}
print_optionbar_end();
$app = mysql_fetch_array(mysql_query("SELECT * FROM `applications` WHERE `device_id` = '".$device['device_id']."' AND `app_type` = '".$_GET['opta']."'"));
if (is_file("pages/device/apps/".mres($_GET['opta']).".inc.php"))
{
include("pages/device/apps/".mres($_GET['opta']).".inc.php");
}
?>

View File

@@ -4,96 +4,37 @@ if($_SESSION['userlevel'] < '7') {
print_error("Insufficient Privileges"); print_error("Insufficient Privileges");
} else { } else {
if($_POST['editing']) {
if($_SESSION['userlevel'] > "7") { $panes = array('device' => 'Device Settings',
include("includes/device-edit.inc.php"); 'apps' => 'Applications',
'services' => 'Services');
print_optionbar_start();
unset($sep);
foreach($panes as $type => $text) {
if(!isset($_GET['opta'])) { $_GET['opta'] = $type; }
echo($sep);
if ($_GET['opta'] == $type)
{
echo("<strong>");
echo('<img src="images/icons/'.$type.'.png" class="optionicon" />');
} else {
echo('<img src="images/icons/greyscale/'.$type.'.png" class="optionicon" />');
} }
echo("<a href='".$config['base_url']."/device/".$device['device_id']."/edit/" . $type . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . $text ."</a>\n");
if ($_GET['opta'] == $type) { echo("</strong>"); }
$sep = " | ";
} }
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '$_GET[id]'")); print_optionbar_end();
$descr = $device['purpose'];
if($updated && $update_message) { if (is_file("pages/device/edit/".mres($_GET['opta']).".inc.php"))
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
}
$device_types = array('server','network','firewall','workstation','printer','power');
echo("<table cellpadding=0 cellspacing=0><tr><td>
<h4>Edit Device</h4>
<h5>
<a href='?page=delhost&id=".$device['device_id']."'>
<img src='images/16/server_delete.png' align='absmiddle'>
Delete
</a>
</h5>
<form id='edit' name='edit' method='post' action=''>
<input type=hidden name='editing' value='yes'>
<table width='400' border='0'>
<tr>
<td><div align='right'>Description</div></td>
<td colspan='3'><input name='descr' size='32' value='" . $device['purpose'] . "'></input></td>
</tr>
<tr>
<td width='300'><div align='right'>SNMP Community</div></td>
<td colspan='3'><input name='community' size='20' value='" . $device['community'] . "'></input>
<select name='snmpver'>
<option value='v1'>v1</option>
<option value='v2c'" . ($device['snmpver'] == 'v2c' ? 'selected=selected' : '') . ">v2c</option>
</select>
</td>
</tr>
<tr>
<td align='right'>
Type
</td>
<td>
<select name='type'>");
$unknown = 1;
foreach ($device_types as $type)
{ {
echo ' <option value="'.$type.'"'; include("pages/device/edit/".mres($_GET['opta']).".inc.php");
if ($device['type'] == $type) } else {
{
echo 'selected="1"';
$unknown = 0;
}
echo ' >' . ucfirst($type) . '</option>';
} }
if ($unknown)
{
echo ' <option value="other">Other</option>';
}
echo("
</select>
</td>
</tr>
<tr>
<td><div align='right'>Disable</div></td>
<td><input name='disabled' type='checkbox' id='disabled' value='1'");
if($device['disabled']) { echo("checked=checked"); }
echo("/></td>
<td><div align='right'>Ignore</div></td>
<td><input name='ignore' type='checkbox' id='disable' value='1'");
if($device['ignore']) { echo("checked=checked"); }
echo("/></td>
</tr>");
echo('
</table>
<input type="submit" name="Submit" value="Save" />
<label><br />
</label>
</form>
</td>
<td width="50"></td><td></td></tr></table>');
} }

View File

@@ -0,0 +1,17 @@
<?php
if ($handle = opendir($config['install_dir'] . "/includes/polling/applications/")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && strstr($file, ".inc.php")) {
$file = str_replace(".inc.php", "", $file);
$servicesform .= "<option value='$file'>$file</option>";
}
}
closedir($handle);
}
echo("$servicesform");
?>

View File

@@ -0,0 +1,93 @@
<?php
if($_POST['editing']) {
if($_SESSION['userlevel'] > "7") {
include("includes/device-edit.inc.php");
}
}
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'"));
$descr = $device['purpose'];
if($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
}
$device_types = array('server','network','firewall','workstation','printer','power');
echo("<table cellpadding=0 cellspacing=0><tr><td>
<h5>
<a href='?page=delhost&id=".$device['device_id']."'>
<img src='images/16/server_delete.png' align='absmiddle'>
Delete
</a>
</h5>
<form id='edit' name='edit' method='post' action=''>
<input type=hidden name='editing' value='yes'>
<table width='400' border='0'>
<tr>
<td><div align='right'>Description</div></td>
<td colspan='3'><input name='descr' size='32' value='" . $device['purpose'] . "'></input></td>
</tr>
<tr>
<td width='300'><div align='right'>SNMP Community</div></td>
<td colspan='3'><input name='community' size='20' value='" . $device['community'] . "'></input>
<select name='snmpver'>
<option value='v1'>v1</option>
<option value='v2c'" . ($device['snmpver'] == 'v2c' ? 'selected=selected' : '') . ">v2c</option>
</select>
</td>
</tr>
<tr>
<td align='right'>
Type
</td>
<td>
<select name='type'>");
$unknown = 1;
foreach ($device_types as $type)
{
echo ' <option value="'.$type.'"';
if ($device['type'] == $type)
{
echo 'selected="1"';
$unknown = 0;
}
echo ' >' . ucfirst($type) . '</option>';
}
if ($unknown)
{
echo ' <option value="other">Other</option>';
}
echo("
</select>
</td>
</tr>
<tr>
<td><div align='right'>Disable</div></td>
<td><input name='disabled' type='checkbox' id='disabled' value='1'");
if($device['disabled']) { echo("checked=checked"); }
echo("/></td>
<td><div align='right'>Ignore</div></td>
<td><input name='ignore' type='checkbox' id='disable' value='1'");
if($device['ignore']) { echo("checked=checked"); }
echo("/></td>
</tr>");
echo('
</table>
<input type="submit" name="Submit" value="Save" />
<label><br />
</label>
</form>
</td>
<td width="50"></td><td></td></tr></table>');
?>

View File

@@ -0,0 +1,91 @@
<?php
echo('<div style="padding: 10px;">');
if($_POST['addsrv']) {
if($_SESSION['userlevel'] == '10') {
include("includes/service-add.inc.php");
}
}
if ($handle = opendir($config['install_dir'] . "/includes/services/")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && !strstr($file, ".")) {
$servicesform .= "<option value='$file'>$file</option>";
}
}
closedir($handle);
}
$query = mysql_query("SELECT * FROM `devices` ORDER BY `hostname`");
while($device = mysql_fetch_array($query)) {
$devicesform .= "<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>";
}
if($updated) { print_message("Device Settings Saved"); }
echo('<div style="float: left;">');
if(mysql_result(mysql_query("SELECT COUNT(*) from `services` WHERE `device_id` = '".$device['device_id']."'"), 0) > '0') {
$i = "1";
$service_query = mysql_query("select * from services WHERE device_id = '".$device['device_id']."' ORDER BY service_type");
while($service = mysql_fetch_array($service_query)) {
$existform .= "<option value='" . $service['service_id'] . "'>" . $service['service_type'] . "</option>";
}
}
echo("
<form id='delsrv' name='delsrv' method='post' action=''>
<input type=hidden name='delsrv' value='yes'>
<table width='200' border='0'>
<option type=hidden name=device value='".$device['device_id']."'>
<tr>
<td>
Type
</td>
<td>
<select name='type'>
$existform
</select>
</td>
</tr>
</table>
<input type='submit' name='Submit' value='Delete' />
<label><br />
</label>
</form>");
echo('</div>');
echo('<div style="width: 45%; float: right;">');
echo("
<form id='addsrv' name='addsrv' method='post' action=''>
<input type=hidden name='addsrv' value='yes'>
<table width='200' border='0'>
<option type=hidden name=device value='".$device['device_id']."'>
<tr>
<td>
Type
</td>
<td>
<select name='type'>
$servicesform
</select>
</td>
</tr>
</table>
<input type='submit' name='Submit' value='Add' />
<label><br />
</label>
</form>");
echo('</div>');
echo('</div>');
?>

View File

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

View File

@@ -180,6 +180,7 @@ while ($device = mysql_fetch_array($device_query)) {
include("includes/polling/bgpPeer.inc.php"); include("includes/polling/bgpPeer.inc.php");
include("includes/polling/toner.inc.php"); include("includes/polling/toner.inc.php");
include("includes/polling/ucd-diskio.inc.php"); include("includes/polling/ucd-diskio.inc.php");
include("includes/polling/applications.inc.php");
unset( $update ) ; unset( $update ) ;
unset( $seperator) ; unset( $seperator) ;