syntaxer run

git-svn-id: http://www.observium.org/svn/observer/trunk@3185 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2012-05-15 15:18:57 +00:00
parent 1f9eae3699
commit 4985943822
44 changed files with 65 additions and 97 deletions
-1
View File
@@ -273,7 +273,6 @@ $config['nfsen_enable'] = 0;
### Use this feature to map ugly locations to pretty locations
#config['location_map']['Under the Sink'] = "Under The Sink, The Office, London, UK";
### Ignores & Allows
# Has to be lowercase
+4 -4
View File
@@ -124,7 +124,7 @@ if ($debug) { print_r($port_stats); }
## -- i can make it a function, so that you don't know what it's doing.
## -- $ports_db = adamasMagicFunction($ports_db); ?
foreach(dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($device['device_id'])) as $port)
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($device['device_id'])) as $port)
{
$ports_db[$port['ifIndex']] = $port;
$ports_db_l[$port['ifIndex']] = $port['interface_id'];
@@ -146,7 +146,7 @@ foreach ($port_stats as $ifIndex => $port)
$ports_db[$ifIndex]['deleted'] = "0";
echo("U");
} else {
echo (".");
echo(".");
}
/// We've seen it. Remove it from the cache.
unset($ports_l[$ifIndex]);
@@ -166,9 +166,9 @@ foreach ($port_stats as $ifIndex => $port)
/// Interface Deletion
/// If it's in our $ports_l list, that means it's not been seen. Mark it deleted.
foreach($ports_l as $ifIndex => $port_id)
foreach ($ports_l as $ifIndex => $port_id)
{
if($ports_db[$ifIndex]['deleted'] == "0")
if ($ports_db[$ifIndex]['deleted'] == "0")
{
dbUpdate(array('deleted' => '1'), 'ports', '`interface_id` = ?', array($port_id));
echo("-".$ifIndex);
+1 -1
View File
@@ -289,7 +289,7 @@ function addHost($host, $snmpver, $port = '161', $transport = 'udp')
print_error("Could not resolve $host"); }
} else {
/// found in database
print_error("Already got host $host");
print_error("Already got host $host");
}
return 0;
}
+5 -5
View File
@@ -28,11 +28,11 @@ rrdtool_update($nginx_rrd, "N:$req:$active:$reading:$writing:$waiting");
/// Unset the variables we set here
unset($nginx);
unset($nginx_rrd);
unset($active);
unset($reading);
unset($writing);
unset($nginx);
unset($nginx_rrd);
unset($active);
unset($reading);
unset($writing);
unset($req);
?>
+1 -1
View File
@@ -84,7 +84,7 @@
$poll_device['sysLocation'] = str_replace("\"","", $poll_device['sysLocation']);
/// Rewrite sysLocation if there is a mapping array (database too?)
if(!empty($poll_device['sysLocation']) && is_array($config['location_map']))
if (!empty($poll_device['sysLocation']) && is_array($config['location_map']))
{
$poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']);
}
+6 -8
View File
@@ -1,24 +1,22 @@
<?php
function rewrite_location($location){
function rewrite_location($location)
{
// FIXME -- also check the database for rewrites?
global $config, $debug;
global $config;
global $debug;
if(isset($config['location_map'][$location]))
if (isset($config['location_map'][$location]))
{
$location = $config['location_map'][$location];
}
return $location;
return $location;
}
function formatMac($mac)
{
$mac = preg_replace("/(..)(..)(..)(..)(..)(..)/", "\\1:\\2:\\3:\\4:\\5:\\6", $mac);
return $mac;
}
+3 -3
View File
@@ -207,12 +207,12 @@ function rrdtool_create($filename, $options)
function rrdtool_update($filename, $options)
{
/// Do some sanitisation on the data if passed as an array.
if(is_array($options))
if (is_array($options))
{
$values[] = "N";
foreach($options as $value)
foreach ($options as $value)
{
if(!is_numeric($value)) { $value = U; }
if (!is_numeric($value)) { $value = U; }
$values[] = $value;
}
$options = implode(':', $values);
+11 -11
View File
@@ -36,7 +36,7 @@ function snmp_get_multi($device, $oids, $options = "-OQUs", $mib = NULL, $mibdir
$device['transport'] = "udp";
}
$cmd = $config['snmpget'];
$cmd = $config['snmpget'];
$cmd .= snmp_gen_auth ($device);
if ($options) { $cmd .= " " . $options; }
@@ -94,18 +94,18 @@ function snmp_get($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL)
echo("Please report this to the Observium team.");
}
$cmd = $config['snmpget'];
$cmd = $config['snmpget'];
$cmd .= snmp_gen_auth ($device);
if ($options) { $cmd .= " " . $options; }
if ($mib) { $cmd .= " -m " . $mib; }
if ($mibdir) { $cmd .= " -M " . $mibdir; }
if ($mibdir) { $cmd .= " -M " . $mibdir; }
else { $cmd .= " -M ".$config['mibdir']; }
if (isset($timeout)) { $cmd .= " -t " . $timeout; }
if (isset($retries)) { $cmd .= " -r " . $retries; }
$cmd .= " " . $device['transport'].":".$device['hostname'].":".$device['port'];
$cmd .= " " . $oid;
if (!$debug) { $cmd .= " 2>/dev/null"; }
$data = trim(external_exec($cmd));
@@ -150,7 +150,7 @@ function snmp_walk($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL)
{
$snmpcommand = $config['snmpbulkwalk'];
}
$cmd = $snmpcommand;
$cmd .= snmp_gen_auth ($device);
@@ -217,7 +217,7 @@ function snmpwalk_cache_cip($device, $oid, $array, $mib = 0)
$cmd = $snmpcommand;
$cmd .= snmp_gen_auth ($device);
$cmd .= " -O snQ";
$cmd .= " -O snQ";
if ($mib) { $cmd .= " -m $mib"; }
$cmd .= " -M ".$config['install_dir']."/mibs";
if (isset($timeout)) { $cmd .= " -t " . $timeout; }
@@ -286,7 +286,7 @@ function snmp_cache_ifIndex($device)
$cmd = $snmpcommand;
$cmd .= snmp_gen_auth ($device);
$cmd .= " -O Qs";
$cmd .= " -O Qs";
$cmd .= " -M " . $config['install_dir']."/mibs";
$cmd .= " -m IF-MIB ifIndex";
@@ -552,7 +552,7 @@ function snmp_cache_slotport_oid($oid, $device, $array, $mib = 0)
$cmd = $snmpcommand;
$cmd .= snmp_gen_auth ($device);
$cmd .= " -O QUs";
$cmd .= " -O QUs";
if ($mib) { $cmd .= " -m $mib"; }
$cmd .= " -M ".$config['install_dir']."/mibs";
if (isset($timeout)) { $cmd .= " -t " . $timeout; }
@@ -614,7 +614,7 @@ function snmp_cache_port_oids($oids, $port, $device, $array, $mib=0)
$cmd = $config['snmpget'];
$cmd .= snmp_gen_auth ($device);
$cmd .= " -O vq";
$cmd .= " -O vq";
if (isset($timeout)) { $cmd .= " -t " . $timeout; }
if (isset($retries)) { $cmd .= " -r " . $retries; }
$cmd .= " -M ".$config['install_dir']."/mibs";
@@ -663,7 +663,7 @@ function snmp_cache_portIfIndex($device, $array)
$cmd = $config['snmpwalk'];
$cmd .= snmp_gen_auth ($device);
$cmd .= " -CI -m CISCO-STACK-MIB -O q";
$cmd .= " -CI -m CISCO-STACK-MIB -O q";
$cmd .= " -M ".$config['install_dir']."/mibs";
if (isset($timeout)) { $cmd .= " -t " . $timeout; }
if (isset($retries)) { $cmd .= " -r " . $retries; }
@@ -710,7 +710,7 @@ function snmp_cache_portName($device, $array)
$cmd = $config['snmpwalk'];
$cmd .= snmp_gen_auth ($device);
$cmd .= " -CI -m CISCO-STACK-MIB -O Qs";
$cmd .= " -CI -m CISCO-STACK-MIB -O Qs";
$cmd .= " -M ".$config['install_dir']."/mibs";
if (isset($timeout)) { $cmd .= " -t " . $timeout; }
if (isset($retries)) { $cmd .= " -r " . $retries; }