diff --git a/addhost.php b/addhost.php index 9fea01537..1b02ee592 100755 --- a/addhost.php +++ b/addhost.php @@ -46,7 +46,7 @@ if (isset($argv[1]) && $argv[1]) { $config['snmp']['community'] = array($community); } - + if ($snmpver) { $snmpversions[] = $snmpver; diff --git a/html/pages/device/slas.inc.php b/html/pages/device/slas.inc.php index f194f1b96..f162ad71d 100644 --- a/html/pages/device/slas.inc.php +++ b/html/pages/device/slas.inc.php @@ -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(''); diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index d46130b59..0d064ae93 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -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 diff --git a/includes/discovery/cisco-sla.inc.php b/includes/discovery/cisco-sla.inc.php index e4a09ca7c..f844a5f1f 100644 --- a/includes/discovery/cisco-sla.inc.php +++ b/includes/discovery/cisco-sla.inc.php @@ -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 diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 43b26d183..5f9592178 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -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); } diff --git a/includes/polling/cisco-cef.inc.php b/includes/polling/cisco-cef.inc.php index d0b7c978e..f39efe5e6 100755 --- a/includes/polling/cisco-cef.inc.php +++ b/includes/polling/cisco-cef.inc.php @@ -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 - + ?> diff --git a/includes/polling/cisco-mac-accounting.inc.php b/includes/polling/cisco-mac-accounting.inc.php index 53b9a1f96..608530800 100755 --- a/includes/polling/cisco-mac-accounting.inc.php +++ b/includes/polling/cisco-mac-accounting.inc.php @@ -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"); } - + ?> diff --git a/includes/polling/os/fortigate.inc.php b/includes/polling/os/fortigate.inc.php index 866758c52..2c07d249c 100755 --- a/includes/polling/os/fortigate.inc.php +++ b/includes/polling/os/fortigate.inc.php @@ -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"); - ?> diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 88ca27d15..e9ce18ee4 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -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'])); } diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 34aa3e7c9..455c42b61 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -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) {