record discover/poll speeds, prettier "not permitted" page, and readd "base_url" to config

git-svn-id: http://www.observium.org/svn/observer/trunk@1435 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-07-19 18:21:48 +00:00
parent c51d719730
commit 3940265744
8 changed files with 126 additions and 70 deletions

View File

@@ -14,6 +14,9 @@ $config['html_dir'] = $config['install_dir'] . "/html";
$config['rrd_dir'] = $config['install_dir'] . "/rrd";
$config['observer_log'] = $config['install_dir'] . "/observium.log";
###
$config['base_url'] = "http://obeservium.company.com";
### Enable the below to use rrdcached. be sure rrd_dir is within the rrdcached dir
### and that your web server has permission to talk to rrdcached.
#$config['rrdcached'] = "unix:/var/run/rrdcached.sock";

View File

@@ -37,3 +37,6 @@ ALTER TABLE `ipv4_addresses` ADD INDEX ( `interface_id` );
ALTER TABLE `ipv6_addresses` ADD INDEX ( `interface_id` );
ALTER TABLE `ipv4_mac` ADD INDEX ( `interface_id` );
CREATE TABLE IF NOT EXISTS `ports_adsl` ( `interface_id` int(11) NOT NULL, `port_adsl_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `adslLineCoding` varchar(8) COLLATE utf8_bin NOT NULL, `adslLineType` varchar(16) COLLATE utf8_bin NOT NULL, `adslAtucInvVendorID` varchar(8) COLLATE utf8_bin NOT NULL, `adslAtucInvVersionNumber` varchar(8) COLLATE utf8_bin NOT NULL, `adslAtucCurrSnrMgn` decimal(5,1) NOT NULL, `adslAtucCurrAtn` decimal(5,1) NOT NULL, `adslAtucCurrOutputPwr` decimal(5,1) NOT NULL, `adslAtucCurrAttainableRate` int(11) NOT NULL, `adslAtucChanCurrTxRate` int(11) NOT NULL, `adslAturInvSerialNumber` varchar(8) COLLATE utf8_bin NOT NULL, `adslAturInvVendorID` varchar(8) COLLATE utf8_bin NOT NULL, `adslAturInvVersionNumber` varchar(8) COLLATE utf8_bin NOT NULL, `adslAturChanCurrTxRate` int(11) NOT NULL, `adslAturCurrSnrMgn` decimal(5,1) NOT NULL, `adslAturCurrAtn` decimal(5,1) NOT NULL, `adslAturCurrOutputPwr` decimal(5,1) NOT NULL, `adslAturCurrAttainableRate` int(11) NOT NULL, UNIQUE KEY `interface_id` (`interface_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
## 0.10.7
ALTER TABLE `devices` ADD `last_polled_timetaken` DOUBLE( 5, 2 ) NOT NULL AFTER `last_polled` , ADD `last_discovered_timetaken` DOUBLE( 5, 2 ) NOT NULL AFTER `last_polled_timetaken`;
CREATE TABLE IF NOT EXISTS `perf_times` ( `type` varchar(8) NOT NULL, `doing` varchar(64) NOT NULL, `start` int(11) NOT NULL, `duration` double(5,2) NOT NULL, `devices` int(11) NOT NULL, KEY `type` (`type`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

View File

@@ -15,23 +15,25 @@ echo("Observium v".$config['version']." Discovery\n\n");
$options = getopt("h:t:i:n:d::a::");
if ($options['h'] == "odd") {
$where = "AND MOD(device_id,2) = 1"; $doing = $options['h'];
} elseif ($options['h'] == "even") {
$where = "AND MOD(device_id,2) = 0"; $doing = $options['h'];
} elseif ($options['h'] == "all") {
$where = " "; $doing = "all";
} elseif($options['h']) {
if ($options['h'] == "odd") { $options['n'] = "1"; $options['i'] = "2"; }
elseif ($options['h'] == "even") { $options['n'] = "0"; $options['i'] = "2"; }
elseif ($options['h'] == "all") { $where = " "; $doing = "all"; }
elseif ($options['h']) {
if (is_numeric($options['h']))
{
$where = "AND `device_id` = '".$options['h']."'"; $doing = "Host ".$options['h'];
$where = "AND `device_id` = '".$options['h']."'";
$doing = $options['h'];
}
else
{
$where = "AND `hostname` LIKE '".str_replace('*','%',mres($options['h']))."'"; $doing = "Host ".$options['h'];
$where = "AND `hostname` LIKE '".str_replace('*','%',mres($options['h']))."'";
$doing = $options['h'];
}
} elseif ($options['i'] && isset($options['n'])) {
$where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'"; $doing = "Proc ".$options['n'] ."/".$options['i'];
}
if ($options['i'] && isset($options['n'])) {
$where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'";
$doing = $options['n'] ."/".$options['i'];
}
if(!$where) {
@@ -92,6 +94,9 @@ $devices_discovered = 0;
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC");
while ($device = mysql_fetch_array($device_query))
{
$device_start = utime(); // Start counting device poll time
echo($device['hostname'] . " ".$device['device_id']." ".$device['os']." ");
if($device['os'] != strtolower($device['os'])) {
mysql_query("UPDATE `devices` SET `os` = '".strtolower($device['os'])."' WHERE device_id = '".$device['device_id']."'");
@@ -144,18 +149,30 @@ while ($device = mysql_fetch_array($device_query))
}
}
$device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5);
$update_query = "UPDATE `devices` SET ";
$update_query .= " `last_discovered` = NOW(), `type` = '" . $device['type'] . "'";
$update_query .= ", `last_discovered_timetaken` = '$device_time'";
$update_query .= " WHERE `device_id` = '" . $device['device_id'] . "'";
$update_result = mysql_query($update_query);
echo("Discovered in $device_time seconds\n");
unset($cache); // Clear cache (unify all things here?)
echo("\n"); $devices_discovered++;
}
$end = utime(); $run = $end - $start;
$proctime = substr($run, 0, 5);
echo("$devices_discovered devices discovered in $proctime secs\n");
if($devices_discovered) {
mysql_query("INSERT INTO `perf_times` (`type`, `doing`, `start`, `duration`, `devices`)
VALUES ('discover', '$doing', '$start', '$proctime', '$devices_discovered')");
}
$string = $argv[0] . " $doing " . date("F j, Y, G:i") . " - $polled_devices devices discovered in $proctime secs";
if ($debug) echo("$string\n");
shell_exec("echo '".$string."' >> ".$config['logfile']);
?>

View File

@@ -1 +0,0 @@
<div class='errorbox' style='font-weight: bold;'><img src='images/16/error.png' align='absmiddle' /> Insufficient permissions to view this page</div>

View File

@@ -1,32 +1,20 @@
<?php
echo("<div style='margin:auto; text-align: center; margin-top: 20px; max-width:420px'>
<b class='rounded'>
<b class='rounded1'></b>
<b class='rounded2'></b>
<b class='rounded3'></b>
<b class='rounded4'></b>
<b class='rounded5'></b></b>
<div class='roundedfg' style='padding-left:10px;'>
<div style='margin: auto; width:350px; padding:5px;'>
<table><tr>
echo("<div style='margin:auto; text-align: center; margin-top: 50px; max-width:600px'>");
print_optionbar_start(100,600);
echo("
<table height=100% width=100%><tr>
<td><img src='images/no-48.png' valign=absmiddle></td>
<td width=10></td>
<td>
<span style='color: #990000; font-weight: bold;'>
<span style='font-size: 16px;'>Error:</span>
<span style='font-size: 16px; font-weight: bold;'>Error</span>
<br />
<span style='font-size: 12px;'>You have insufficent permissions to view this page.</span>
</span>
</td>
</tr></table>
</div>
</div>
<b class='rounded'>
<b class='rounded5'></b>
<b class='rounded4'></b>
<b class='rounded3'></b>
<b class='rounded2'></b>
<b class='rounded1'></b></b>
</div>");
</tr></table>");
print_optionbar_end();
echo("</div>");
?>

View File

@@ -89,6 +89,17 @@ function device_array($device_id)
return $device;
}
function get_device_id_by_interface_id($interface_id) {
if(is_numeric($interface_id)) {
$device_id = mysql_result(mysql_query("SELECT `device_id` FROM `ports` WHERE `interface_id` = '".$interface_id."'"),0);
}
if(is_numeric($device_id)){
return $device_id;
} else {
return FALSE;
}
}
function getHostOS($device)
{
global $config;

View File

@@ -1,5 +1,45 @@
<?php
#### Example snmpwalk with units
#### "Interval" oids have been filtered out
# adslLineCoding.1 = dmt
# adslLineType.1 = fastOrInterleaved
# adslLineSpecific.1 = zeroDotZero
# adslLineConfProfile.1 = "qwer"
# adslAtucInvSerialNumber.1 = "IES-1000 AAM1008-61"
# adslAtucInvVendorID.1 = "4"
# adslAtucInvVersionNumber.1 = "0"
# adslAtucCurrSnrMgn.1 = 150 tenth dB
# adslAtucCurrAtn.1 = 20 tenth dB
# adslAtucCurrStatus.1 = "00 00 "
# adslAtucCurrOutputPwr.1 = 100 tenth dBm
# adslAtucCurrAttainableRate.1 = 10272000 bps
# adslAturInvVendorID.1 = "0"
# adslAturInvVersionNumber.1 = "0"
# adslAturCurrSnrMgn.1 = 210 tenth dB
# adslAturCurrAtn.1 = 20 tenth dB
# adslAturCurrStatus.1 = "00 00 "
# adslAturCurrOutputPwr.1 = 0 tenth dBm
# adslAturCurrAttainableRate.1 = 1056000 bps
# adslAtucChanInterleaveDelay.1 = 6 milli-seconds
# adslAtucChanCurrTxRate.1 = 8064000 bps
# adslAtucChanPrevTxRate.1 = 0 bps
# adslAturChanInterleaveDelay.1 = 9 milli-seconds
# adslAturChanCurrTxRate.1 = 512000 bps
# adslAturChanPrevTxRate.1 = 0 bps
# adslAtucPerfLofs.1 = 0
# adslAtucPerfLoss.1 = 0
# adslAtucPerfLols.1 = 0
# adslAtucPerfLprs.1 = 0
# adslAtucPerfESs.1 = 0
# adslAtucPerfInits.1 = 1
# adslAtucPerfValidIntervals.1 = 0
# adslAtucPerfInvalidIntervals.1 = 0
# adslAturPerfLoss.1 = 0 seconds
# adslAturPerfESs.1 = 0 seconds
# adslAturPerfValidIntervals.1 = 0
# adslAturPerfInvalidIntervals.1 = 0
if($array[$device[device_id]][$port[ifIndex]]['adslLineCoding']) { // Check to make sure Port data is cached.
$this_port = &$array[$device[device_id]][$port[ifIndex]];
@@ -34,18 +74,6 @@
$rrd_create .= " RRA:MIN:0.5:1:600 RRA:MIN:0.5:6:700 RRA:MIN:0.5:24:775 RRA:MIN:0.5:288:797 ";
$rrd_create .= " RRA:MAX:0.5:1:600 RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797 ";
#ADSL-LINE-MIB::adslLineCoding.11 = INTEGER: dmt(2)
#ADSL-LINE-MIB::adslLineType.11 = INTEGER: fastOnly(2)
#ADSL-LINE-MIB::adslAtucInvVendorID.11 = STRING: "GSPN"
#ADSL-LINE-MIB::adslAtucInvVersionNumber.11 = STRING: "8"
#ADSL-LINE-MIB::adslAtucCurrSnrMgn.11 = Gauge32: 90 tenth dB
#ADSL-LINE-MIB::adslAtucCurrAtn.11 = Gauge32: 125 tenth dB
#ADSL-LINE-MIB::adslAtucCurrOutputPwr.11 = Gauge32: 185 tenth dBm
#ADSL-LINE-MIB::adslAtucCurrAttainableRate.11 = Gauge32: 9792000 bps
#ADSL-LINE-MIB::adslAturInvSerialNumber.11 = ""
#ADSL-LINE-MIB::adslAturInvVendorID.11 = STRING: "STMI"
#ADSL-LINE-MIB::adslAturInvVersionNumber.11 = STRING: "0"
$adsl_oids = array('AtucCurrSnrMgn','AtucCurrAtn','AtucCurrOutputPwr','AtucCurrAttainableRate','AtucChanCurrTxRate','AturCurrSnrMgn','AturCurrAtn','AturCurrOutputPwr','AturCurrAttainableRate','AturChanCurrTxRate','AtucPerfLofs','AtucPerfLoss','AtucPerfLprs','AtucPerfESs','AtucPerfInits','AturPerfLofs','AturPerfLoss','AturPerfLprs','AturPerfESs','AtucChanCorrectedBlks','AtucChanUncorrectBlks','AturChanCorrectedBlks','AturChanUncorrectBlks');
$adsl_db_oids = array('adslLineCoding','adslLineType','adslAtucInvVendorID','adslAtucInvVersionNumber','adslAtucCurrSnrMgn','adslAtucCurrAtn','adslAtucCurrOutputPwr',

View File

@@ -12,23 +12,25 @@ echo("Observium Poller v".$config['version']."\n\n");
$options = getopt("h:t:i:n:d::a::");
if ($options['h'] == "odd") {
$where = "AND MOD(device_id,2) = 1"; $doing = $options['h'];
} elseif ($options['h'] == "even") {
$where = "AND MOD(device_id,2) = 0"; $doing = $options['h'];
} elseif ($options['h'] == "all") {
$where = " "; $doing = "all";
} elseif ($options['h']) {
if ($options['h'] == "odd") { $options['n'] = "1"; $options['i'] = "2"; }
elseif ($options['h'] == "even") { $options['n'] = "0"; $options['i'] = "2"; }
elseif ($options['h'] == "all") { $where = " "; $doing = "all"; }
elseif ($options['h']) {
if (is_numeric($options['h']))
{
$where = "AND `device_id` = '".$options['h']."'"; $doing = "Host ".$options['h'];
$where = "AND `device_id` = '".$options['h']."'";
$doing = $options['h'];
}
else
{
$where = "AND `hostname` LIKE '".str_replace('*','%',mres($options['h']))."'"; $doing = "Host ".$options['h'];
$where = "AND `hostname` LIKE '".str_replace('*','%',mres($options['h']))."'";
$doing = $options['h'];
}
} elseif ($options['i'] && isset($options['n'])) {
$where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'"; $doing = "Proc ".$options['n'] ."/".$options['i'];
}
if ($options['i'] && isset($options['n'])) {
$where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'";
$doing = $options['n'] ."/".$options['i'];
}
if (!$where) {
@@ -248,26 +250,31 @@ while ($device = mysql_fetch_array($device_query))
echo("\n");
}
if ($poll_update) {
$poll_update_query = "UPDATE `devices` SET ";
$poll_update_query .= $poll_update;
$poll_update_query .= " WHERE `device_id` = '" . $device['device_id'] . "'";
if($debug) {echo("Updating " . $device['hostname'] . " - $poll_update_query \n");}
$poll_update_result = mysql_query($poll_update_query);
if(mysql_affected_rows() == "1") { echo("UPDATED!\n"); } else { echo("NOT UPDATED!\n"); }
} else {
echo("No Changes to " . $device['hostname'] . "\n");
}
$device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5);
$poll_update .= $poll_separator . "`last_polled_timetaken` = '$device_time'";
echo("$device_end - $device_start; $device_time $device_run");
echo("Polled in $device_time seconds\n");
$poll_update_query = "UPDATE `devices` SET ";
$poll_update_query .= $poll_update;
$poll_update_query .= " WHERE `device_id` = '" . $device['device_id'] . "'";
if($debug) {echo("Updating " . $device['hostname'] . " - $poll_update_query \n");}
$poll_update_result = mysql_query($poll_update_query);
if(mysql_affected_rows() == "1") { echo("UPDATED!\n"); } else { echo("NOT UPDATED!\n"); }
unset($storage_cache); // Clear cache of hrStorage ** MAYBE FIXME? **
$device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5);
echo("Polled in $device_time seconds\n");
unset($cache); // Clear cache (unify all things here?)
}
$poller_end = utime(); $poller_run = $poller_end - $poller_start; $poller_time = substr($poller_run, 0, 5);
if($polled_devices) {
mysql_query("INSERT INTO `perf_times` (`type`, `doing`, `start`, `duration`, `devices`)
VALUES ('poll', '$doing', '$poller_start', '$poller_time', '$polled_devices')");
}
$string = $argv[0] . " $doing " . date("F j, Y, G:i") . " - $polled_devices devices polled in $poller_time secs";
if ($debug) echo("$string\n");
shell_exec("echo '".$string."' >> ".$config['install_dir']."/observium.log"); # FIXME EWW