diff --git a/config.php.default b/config.php.default index e7c0acf77e..196bce576b 100755 --- a/config.php.default +++ b/config.php.default @@ -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"; diff --git a/database-update.sql b/database-update.sql index 975a5fd661..9c1cf2feab 100644 --- a/database-update.sql +++ b/database-update.sql @@ -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; diff --git a/discovery.php b/discovery.php index bb8a942a22..4ffabe5bab 100755 --- a/discovery.php +++ b/discovery.php @@ -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']); ?> diff --git a/html/includes/error-no-perm-dev.inc.php b/html/includes/error-no-perm-dev.inc.php deleted file mode 100644 index 20bf8fd1bc..0000000000 --- a/html/includes/error-no-perm-dev.inc.php +++ /dev/null @@ -1 +0,0 @@ -
Insufficient permissions to view this page
diff --git a/html/includes/error-no-perm.inc.php b/html/includes/error-no-perm.inc.php index d486877702..307774d989 100644 --- a/html/includes/error-no-perm.inc.php +++ b/html/includes/error-no-perm.inc.php @@ -1,32 +1,20 @@ - - - - - - -
-
- +echo("
"); +print_optionbar_start(100,600); +echo(" +
-
- Error: + Error +
You have insufficent permissions to view this page.
-
-
- - - - - - -"); + "); +print_optionbar_end(); +echo(""); ?> diff --git a/includes/functions.php b/includes/functions.php index 4cffec98eb..38f98d8fa7 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -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; diff --git a/includes/polling/port-adsl.inc.php b/includes/polling/port-adsl.inc.php index bdc486e17e..4c0a68a21b 100755 --- a/includes/polling/port-adsl.inc.php +++ b/includes/polling/port-adsl.inc.php @@ -1,5 +1,45 @@ > ".$config['install_dir']."/observium.log"); # FIXME EWW