save some more sql queries, remove automatic syslog refresh

git-svn-id: http://www.observium.org/svn/observer/trunk@2641 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-10-03 15:03:35 +00:00
parent 40c52955f3
commit 9e12148dd3
3 changed files with 15 additions and 9 deletions

View File

@@ -1,6 +1,8 @@
<?php
foreach (dbFetchRows("SELECT * FROM `devices`") as $device)
## FIXME queries such as the one below should probably go into index.php?
foreach (dbFetchRows("SELECT * FROM `devices` ORDER BY `hostname`") as $device)
{
if (get_dev_attrib($device,'override_sysLocation_bool'))
{

View File

@@ -1,5 +1,3 @@
<meta http-equiv="refresh" content="60">
<?php if ($_GET['opta'] == "expunge" && $_SESSION['userlevel'] >= '10') { dbFetchCell("TRUNCATE TABLE `syslog`"); } ?>
<?php print_optionbar_start('25'); ?>
@@ -14,7 +12,7 @@
<select name="program" id="program">
<option value="">All Programs</option>
<?php
foreach (dbFetchRows("SELECT `program` FROM `syslog` GROUP BY `program` ORDER BY `program`") as $data)
foreach (dbFetchRows("SELECT DISTINCT `program` FROM `syslog` ORDER BY `program`") as $data)
{
echo("<option value='".$data['program']."'");
if ($data['program'] == $_POST['program']) { echo("selected"); }
@@ -28,18 +26,17 @@
<select name="device" id="device">
<option value="">All Devices</option>
<?php
foreach (dbFetchRows("SELECT * FROM `devices` ORDER BY `hostname`") as $data)
foreach (get_all_devices() as $hostname)
{
echo("<option value='".$data['device_id']."'");
echo("<option value='".getidbyname($hostname)."'");
if ($data['device_id'] == $_POST['device']) { echo("selected"); }
if (getidbyname($hostname) == $_POST['device']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
echo(">".$hostname."</option>");
}
?>
</select>
</label>
<input type=submit class=submit value=Search>
</form>

View File

@@ -120,6 +120,13 @@ function get_port_by_ifIndex($device_id, $ifIndex)
return dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device_id, $ifIndex));
}
function get_all_devices($device, $type = "")
{
global $cache;
# FIXME respect $type (server, network, etc) -- needs an array fill in topnav.
return array_keys($cache['devices']['hostname']);
}
function port_by_id_cache($port_id)
{