syntaxer run

git-svn-id: http://www.observium.org/svn/observer/trunk@3008 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2012-04-09 15:30:45 +00:00
parent 9cea534c1b
commit a10d3f75ea
10 changed files with 64 additions and 63 deletions

View File

@@ -46,7 +46,7 @@ if (isset($argv[1]) && $argv[1])
{
$config['snmp']['community'] = array($community);
}
if ($snmpver)
{
$snmpversions[] = $snmpver;

View File

@@ -11,7 +11,7 @@ $sla_types = array('all' => 'All');
foreach ($slas as $sla)
{
$sla_type = $sla['rtt_type'];
if (!in_array($sla_type, $sla_types))
if (isset($config['sla_type_labels'][$sla_type]))
{
@@ -21,7 +21,7 @@ foreach ($slas as $sla)
{
$text = ucfirst($sla_type);
}
$sla_types[$sla_type] = $text;
}
asort($sla_types);
@@ -30,7 +30,7 @@ $sep = "";
foreach ($sla_types as $sla_type => $text)
{
if (!$vars['view']) { $vars['view'] = $sla_type; }
echo($sep);
if ($vars['view'] == $sla_type)
{
@@ -59,7 +59,7 @@ foreach ($slas as $sla)
$name .= ": ".$sla['tag'];
if ($sla['owner'])
$name .= " (Owner: ". $sla['owner'] .")";
$graph_array['type'] = "device_sla";
$graph_array['id'] = $sla['sla_id'];
echo('<tr><td>');

View File

@@ -182,6 +182,7 @@ $config['enable_inventory'] = 1; # Enable Inventory
$config['enable_pseudowires'] = 1; # Enable Pseudowires
$config['enable_vrfs'] = 1; # Enable VRFs
$config['enable_printers'] = 0; # Enable Printer support
$config['enable_sla'] = 0; # Enable Cisco SLA collection and display
### Ports extension modules

View File

@@ -5,26 +5,27 @@ if ($config['enable_sla'] && $device['os_group'] == "cisco")
echo("SLAs : ");
$slas = snmp_walk($device, "ciscoRttMonMIB.ciscoRttMonObjects.rttMonCtrl", "-Osq", "+CISCO-RTTMON-MIB");
$sla_table = array();
foreach (explode("\n", $slas) as $sla) {
foreach (explode("\n", $slas) as $sla)
{
$key_val = explode(" ", $sla, 2);
if (count($key_val) != 2)
$key_val[] = "";
$key = $key_val[0];
$value = $key_val[1];
$prop_id = explode(".", $key);
if ((count($prop_id) != 2) || !ctype_digit($prop_id[1]))
continue;
$property = $prop_id[0];
$id = intval($prop_id[1]);
$sla_table[$id][$property] = trim($value);
}
#var_dump($sla_table);
// Get existing SLAs
@@ -37,7 +38,7 @@ if ($config['enable_sla'] && $device['os_group'] == "cisco")
'sla_nr' => $sla_nr,
);
$sla_id = dbFetchCell("SELECT `sla_id` FROM `slas` WHERE `device_id` = :device_id AND `sla_nr` = :sla_nr", $query_data);
$data = array(
'device_id' => $device['device_id'],
'sla_nr' => $sla_nr,
@@ -47,7 +48,7 @@ if ($config['enable_sla'] && $device['os_group'] == "cisco")
'status' => ($sla_config['rttMonCtrlAdminStatus'] == 'active') ? 1 : 0,
'deleted' => 0,
);
// Some fallbacks for when the tag is empty
if (!$data['tag'])
{
@@ -56,11 +57,11 @@ if ($config['enable_sla'] && $device['os_group'] == "cisco")
case 'http':
$data['tag'] = $sla_config['rttMonEchoAdminURL'];
break;
case 'dns':
$data['tag'] = $sla_config['rttMonEchoAdminTargetAddressString'];
break;
case 'echo':
$parts = explode(" ", $sla_config['rttMonEchoAdminTargetAddress']);
if (count($parts) == 4)
@@ -77,8 +78,8 @@ if ($config['enable_sla'] && $device['os_group'] == "cisco")
break;
}
}
if( !$sla_id )
if (!$sla_id)
{
$sla_id = dbInsert($data, 'slas');
echo "+";
@@ -92,14 +93,14 @@ if ($config['enable_sla'] && $device['os_group'] == "cisco")
echo ".";
}
}
// Mark all remaining SLAs as deleted
foreach ($existing_slas as $existing_sla)
{
dbUpdate(array('deleted' => 1), 'slas', "`sla_id` = :sla_id", array('sla_id' => $existing_sla));
echo "-";
}
echo("\n");
} # enable_sla && cisco

View File

@@ -129,7 +129,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
// Fix high/low thresholds (i.e. on negative numbers)
list($warn_limit, $low_warn_limit) = array($low_warn_limit, $warn_limit);
}
if (dbFetchCell("SELECT COUNT(sensor_id) FROM `sensors` WHERE `poller_type`= ? AND `sensor_class` = ? AND `device_id` = ? AND sensor_type = ? AND `sensor_index` = ?", array($poller_type, $class, $device['device_id'], $type, $index)) == '0')
{
if (!$high_limit) { $high_limit = sensor_limit($class, $current); }

View File

@@ -3,20 +3,20 @@
if ($device['os_group'] == "cisco")
{
echo("Cisco CEF Switching Path: ");
$cefs = array();
$cefs = snmpwalk_cache_threepart_oid($device, "CISCO-CEF-MIB::cefSwitchingStatsEntry", $cefs, "CISCO-CEF-MIB");
$polled = time();
$cefs_query = dbFetchRows("SELECT * FROM `cef_switching` WHERE `device_id` = ?", array($device['device_id']));
foreach ($cefs_query as $ceftmp)
{
$cef_id = $device['device_id']."-".$ceftmp['entPhysicalIndex']."-".$ceftmp['afi']."-".$ceftmp['cef_index'];
$cefs_db[$cef_id] = $ceftmp['cef_switching_id'];
}
if ($debug) { print_r($cefs); }
if (is_array($cefs))
{
if (!is_array($entity_array))
@@ -40,9 +40,9 @@ if ($device['os_group'] == "cisco")
foreach ($paths as $path => $cef_stat)
{
echo(" | |-".$path.": ".$cef_stat['cefSwitchingPath']);
$cef_id = $device['device_id']."-".$entity."-".$afi."-".$path;
# if (dbFetchCell("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?", array($device['device_id'], $entity, $afi, $path)) != "1")
if (!isset($cefs_db[$cef_id]))
{
@@ -50,11 +50,11 @@ if ($device['os_group'] == "cisco")
echo("+");
}
unset($cefs_db[$cef_id]);
$cef_entry = dbFetchRow("SELECT * FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex = ? AND `afi` = ? AND `cef_index` = ?", array($device['device_id'], $entity, $afi, $path));
$filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cefswitching-".$entity."-".$afi."-".$path.".rrd");
if (!is_file($filename))
{
rrdtool_create($filename, "--step 300 \
@@ -66,12 +66,12 @@ if ($device['os_group'] == "cisco")
RRA:MAX:0.5:1:600 RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797 \
RRA:LAST:0.5:1:600 RRA:LAST:0.5:6:700 RRA:LAST:0.5:24:775 RRA:LAST:0.5:288:797");
}
### Copy HC to non-HC if they exist
if (is_numeric($cef_stat['cefSwitchingHCDrop'])) { $cef_stat['cefSwitchingDrop'] = $cef_stat['cefSwitchingHCDrop']; }
if (is_numeric($cef_stat['cefSwitchingHCPunt'])) { $cef_stat['cefSwitchingPunt'] = $cef_stat['cefSwitchingHCPunt']; }
if (is_numeric($cef_stat['cefSwitchingHCPunt2Host'])) { $cef_stat['cefSwitchingPunt2Host'] = $cef_stat['cefSwitchingHCPunt2Host']; }
$cef_stat['update']['drop'] = $cef_stat['cefSwitchingDrop'];
$cef_stat['update']['punt'] = $cef_stat['cefSwitchingPunt'];
$cef_stat['update']['punt2host'] = $cef_stat['cefSwitchingPunt2Host'];
@@ -80,25 +80,25 @@ if ($device['os_group'] == "cisco")
$cef_stat['update']['punt2host_prev'] = $cef_entry['punt2host'];
$cef_stat['update']['updated'] = $polled;
$cef_stat['update']['updated_prev'] = $cef_entry['updated'];
dbUpdate($cef_stat['update'], 'cef_switching', '`device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $path));
$rrd_update = "N:".$cef_stat['cefSwitchingDrop'].":".$cef_stat['cefSwitchingPunt'].":".$cef_stat['cefSwitchingPunt2Host'];
$ret = rrdtool_update("$filename", $rrd_update);
if ($debug) { echo(" Values: ".$cef_stat['cefSwitchingDrop'].":".$cef_stat['cefSwitchingPunt'].":".$cef_stat['cefSwitchingPunt2Host']); }
echo("\n");
}
}
}
}
## FIXME - need to delete old ones. FIXME REALLY.
print_r($cefs_db);
foreach ($cefs_db as $cef_switching_id)
{
dbDelete("cef_switching", "`cef_switching_id` = ?", array($cef_switching_id));
@@ -107,5 +107,5 @@ if ($device['os_group'] == "cisco")
echo("\n");
} # os_group = cisco
?>

View File

@@ -7,42 +7,42 @@ if ($device['os_group'] == "cisco")
$cip_oids = array('cipMacHCSwitchedBytes', 'cipMacHCSwitchedPkts');
echo("Cisco MAC - Caching OID: ");
$cip_array = array();
foreach ($cip_oids as $oid)
{
echo("$oid ");
$cip_array = snmpwalk_cache_cip($device, $oid, $cip_array, "CISCO-IP-STAT-MIB");
}
$polled = time();
$mac_entries = 0;
$acc_rows = dbFetchRows("SELECT *, A.poll_time AS poll_time FROM `mac_accounting` as A, `ports` AS I where A.interface_id = I.interface_id AND I.device_id = ?", array($device['device_id']));
foreach ($acc_rows as $acc)
{
$device_id = $acc['device_id'];
$ifIndex = $acc['ifIndex'];
$mac = $acc['mac'];
$polled_period = $polled - $acc['poll_time'];
if ($cip_array[$ifIndex][$mac])
{
$acc['update']['poll_time'] = $polled;
$acc['update']['poll_prev'] = $acc['poll_time'];
$acc['update']['poll_period'] = $polled_period;
$mac_entries++;
$b_in = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedBytes']['input'];
$b_out = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedBytes']['output'];
$p_in = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedPkts']['input'];
$p_out = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedPkts']['output'];
$this_ma = &$cip_array[$ifIndex][$mac];
/// Update metrics
foreach ($cip_oids as $oid)
{
@@ -62,11 +62,11 @@ if ($device['os_group'] == "cisco")
}
}
}
if ($debug) { echo("\n" . $acc['hostname']." ".$acc['ifDescr'] . " $mac -> $b_in:$b_out:$p_in:$p_out "); }
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd");
if (!is_file($rrdfile))
{
rrdtool_create($rrdfile,"DS:IN:COUNTER:600:0:12500000000 \
@@ -84,19 +84,19 @@ if ($device['os_group'] == "cisco")
}
$woo = "N:".($b_in+0).":".($b_out+0).":".($p_in+0).":".($p_out+0);
$ret = rrdtool_update("$rrdfile", $woo);
if ($acc['update'])
{ /// Do Updates
dbUpdate($acc['update'], 'mac_accounting', '`ma_id` = ?', array($acc['ma_id']));
} /// End Updates
}
}
unset($cip_array);
if ($mac_entries) { echo(" $mac_entries MAC accounting entries\n"); }
echo("\n");
}
?>

View File

@@ -60,5 +60,4 @@ if (is_numeric($cpu_usage))
#$mem=snmp_get($device, "FORTINET-FORTIGATE-MIB::fgSysMemUsage.0", "-Ovq");
#$memsize=snmp_get($device, "FORTINET-FORTIGATE-MIB::fgSysMemCapacity", "-Ovq");
?>

View File

@@ -446,7 +446,7 @@ foreach ($ports as $port)
elseif ($port['disabled'] != "1")
{
echo("Port Deleted"); ### Port missing from SNMP cache.
if($port['deleted'] != "1")
if ($port['deleted'] != "1")
{
dbUpdate(array('deleted' => '1'), 'ports', '`device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $port['ifIndex']));
}

View File

@@ -14,7 +14,7 @@ function snmp_get_multi($device, $oids, $options = "-OQUs", $mib = NULL, $mibdir
{
global $debug,$config,$runtime_stats,$mibs_loaded;
if(!$options) { $options = "-OQUs"; }
if (!$options) { $options = "-OQUs"; }
if (is_numeric($device['timeout']) && $device['timeout'] > 0)
{