small cleanups

git-svn-id: http://www.observium.org/svn/observer/trunk@2483 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-09-16 10:31:48 +00:00
parent b862c91618
commit 4b40f8d9eb
4 changed files with 22 additions and 28 deletions

View File

@@ -292,13 +292,6 @@ $gentime = substr($run, 0, 5);
echo('<br /> <br /> <br /> <br /> <div id="footer">' . (isset($config['footer']) ? $config['footer'] : ''));
echo('<br />Powered by <a href="http://www.observium.org" target="_blank">Observium ' . $config['version']);
#if (file_exists('.svn/entries'))
#{
# $svn = File('.svn/entries');
# echo('-SVN r' . trim($svn[3]));
# unset($svn);
#}
echo('</a>. Copyright &copy; 2006-'. date("Y"). ' by Adam Armstrong. All rights reserved.');
if ($config['page_gen'])

View File

@@ -29,7 +29,6 @@ unset($sep);
print_optionbar_end();
echo('<table cellpadding="7" cellspacing="0" class="devicetable" width="100%">');
foreach (getlocations() as $location)

View File

@@ -21,9 +21,11 @@ include_once($config['install_dir'] . "/includes/console_colour.php");
function external_exec($command)
{
global $debug;
if($debug) { echo($command."/n"); }
if($debug) { echo($command."\n"); }
$output = shell_exec($command);
if($debug) { echo($output."/n"); }
if($debug) { echo($output."\n"); }
return $output;
}
@@ -48,6 +50,7 @@ function only_alphanumeric($string)
function logfile($string)
{
global $config;
$fd = fopen($config['log_file'],'a');
fputs($fd,$string . "\n");
fclose($fd);
@@ -120,8 +123,8 @@ function interface_errors($rrd_file, $period = '-1d') // Returns the last in/out
function getImage($host)
{
## FIXME why not pass $device? (my shitty ancient code here!)
global $config;
$data = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($host));
$type = strtolower($data['os']);
if ($config['os'][$type]['icon'] && file_exists($config['html_dir'] . "/images/os/" . $config['os'][$type]['icon'] . ".png"))
@@ -170,8 +173,8 @@ function delete_device($id)
}
dbDelete('devices', "`device_id` = ?", array($id));
$device_tables = array('entPhysical', 'devices_attribs', 'devices_perms', 'bgpPeers', 'vlans', 'vrfs', 'storage', 'alerts', 'eventlog',
$device_tables = array('entPhysical', 'devices_attribs', 'devices_perms', 'bgpPeers', 'vlans', 'vrfs', 'storage', 'alerts', 'eventlog',
'syslog', 'ports', 'services', 'alerts', 'toner', 'frequency', 'current', 'sensors');
foreach($device_tables as $table) {
@@ -211,25 +214,25 @@ function addHost($host, $community = NULL, $snmpver = 'v2c', $port = '161', $tra
{
$device_id = createHost ($host, $community, $snmpver, $port, $transport);
return $device_id;
} else {
print_error("Given hostname does not match SNMP-read hostname ($snmphost)!");
} else {
print_error("Given hostname does not match SNMP-read hostname ($snmphost)!");
}
} else {
print_error("No reply on community $community");
}
}
if (!$device_id)
{
/// Faild SNMP
print_error("Could not reach $host with given SNMP community");
if (!$device_id)
{
/// Failed SNMP
print_error("Could not reach $host with given SNMP community");
}
} else {
} else {
/// failed Reachability
print_error("Could not ping $host"); }
} else {
} else {
/// Failed DNS lookup
print_error("Could not resolve $host"); }
} else {
} else {
/// found in database
print_error("Already got host $host"); }
}
@@ -504,11 +507,10 @@ function log_event($text, $device = NULL, $type = NULL, $reference = NULL)
$insert = array('host' => ($device['device_id'] ? $device['device_id'] : "NULL"),
'reference' => ($reference ? $reference : "NULL"),
'type' => ($type ? $type : "NULL"),
'datetime' => array("NOW()"),
'datetime' => array("NOW()"),
'message' => $text);
dbInsert($insert, 'eventlog');
dbInsert($insert, 'eventlog');
}
function notify($device,$title,$message)
@@ -607,6 +609,7 @@ function isHexString($str)
function include_dir($dir, $regex = "")
{
global $device, $config, $debug, $valid;
if ($regex == "")
{
$regex = "/\.inc\.php$/";
@@ -664,5 +667,4 @@ function is_port_valid($port, $device)
return $valid;
}
?>
?>

View File

@@ -136,7 +136,7 @@ if (is_array($ospf_areas_db))
unset($ospf_area_db);
$ospf_area_count++;
} else {
dbDelete('ospf_ports', '`device_id` = ? AND `ospfAreaId` = ?', array($device['device_id'], $ospf_area_db['ospfAreaId']));
dbDelete('ospf_ports', '`device_id` = ? AND `ospfAreaId` = ?', array($device['device_id'], $ospf_area_db['ospfAreaId']));
}
}
}