refactor: Various Code Cleanup (#5777)

* refactor: Various Code Cleanup

* moar
This commit is contained in:
Søren Rosiak 2017-02-05 23:37:08 +01:00 committed by Neil Lathwood
parent 883095deac
commit 414efb3539
10 changed files with 20 additions and 66 deletions

View File

@ -126,8 +126,6 @@ foreach (dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_id`') as $bill) {
'bill_used' => $used,
'bill_overuse' => $overuse,
'bill_percent' => $percent,
'bill_datefrom' => $datefrom,
'bill_dateto' => $dateto,
'bill_id' => $bill['bill_id'],
);
dbInsert($update, 'bill_history');

View File

@ -329,31 +329,33 @@ We declare two specific graphs for users and sessions numbers. Theses two graphs
```php
<?php
$version = trim(snmp_get($device, "productVersion.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hardware = "Juniper " . trim(snmp_get($device, "productName.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hostname = trim(snmp_get($device, "sysName.0", "-OQv", "SNMPv2-MIB"),'"');
$version = preg_replace('/[\r\n\"]+/', ' ', snmp_get($device, "productVersion.0", "-OQv", "PULSESECURE-PSG-MIB"));
$hardware = "Juniper " . preg_replace('/[\r\n\"]+/', ' ', snmp_get($device, "productName.0", "-OQv", "PULSESECURE-PSG-MIB"));
$hostname = trim($poll_device['sysName'], '"');
$users = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv');
$users = snmp_get($device, 'iveConcurrentUsers.0', '-OQv', 'PULSESECURE-PSG-MIB');
if (is_numeric($users)) {
$rrd_def = 'DS:users:GAUGE:600:0:U';
$fields = array(
'users' => $users
)
'users' => $users,
);
$tags = compact('rrd_def');
data_update($device, 'pulse_users', $tags, $fields);
$graphs['pulse_users'] = true;
}
$sessions = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv');
$sessions = snmp_get($device, 'iveConcurrentUsers.0', '-OQv', 'PULSESECURE-PSG-MIB');
if (is_numeric($sessions)) {
$rrd_def = array(
'DS:sessions:GAUGE:600:0:U',
}
$rrd_def = 'DS:sessions:GAUGE:600:0:U';
$fields = array(
'sessions' => $sessions
'sessions' => $sessions,
);
$tags = compact('rrd_def');
data_update($device, 'pulse_sessions', $tags, $fields);
$graphs['pulse_sessions'] = true;

View File

@ -1041,7 +1041,7 @@ function print_mib_poller_disabled()
{
echo '<h4>MIB polling is not enabled</h4>
<p>
Set <tt>$config[\'poller_modules\'][\'mib\'] = 1;</tt> in <tt>config.php</tt> or enable for this device specifically to enable.
Set <code>$config[\'poller_modules\'][\'mib\'] = 1;</code> in <code>config.php</code> or enable for this device specifically to enable.
</p>';
} // print_mib_poller_disabled

View File

@ -34,7 +34,6 @@ if ($config['enable_vrf_lite_cisco']) {
d_echo("\n[DEBUG]\nUsing $mib\n[/DEBUG]\n");
d_echo("\n[DEBUG List Vrf only name]\n$listVrf\n[/DEBUG]\n");
$tableVrf;
foreach (explode("\n", $listVrf) as $lineVrf) {
$tmpVrf = explode(" ", $lineVrf, 2);
//the $tmpVrf[0] will be the context

View File

@ -519,7 +519,6 @@ function discover_link($local_port_id, $protocol, $remote_port_id, $remote_hostn
$update_data = array(
'remote_platform' => $remote_platform,
'remote_version' => $remote_version,
'remote_version' => $remote_version,
'local_device_id' => $local_device_id,
'remote_device_id' => $remote_device_id,
);

View File

@ -14,7 +14,6 @@ foreach ($hrDevice_oids as $oid) {
d_echo($hrDevices);
if (is_array($hrDevices)) {
$hrDevices = $hrDevices;
foreach ($hrDevices as $hrDevice) {
if (is_array($hrDevice) && is_numeric($hrDevice['hrDeviceIndex'])) {
if (dbFetchCell('SELECT COUNT(*) FROM `hrDevice` WHERE device_id = ? AND hrDeviceIndex = ?', array($device['device_id'], $hrDevice['hrDeviceIndex']))) {

View File

@ -95,7 +95,6 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == 'linux') {
break;
case 'M':
case 'MiB':
$vmwVmMemSize = $vmwVmMemSize;
break;
case 'MB':
$vmwVmMemSize = $vmwVmMemSize * 1000000 / 1048576;

View File

@ -126,22 +126,22 @@ if ($device['os_group'] == 'cisco') {
// Check thresholds for this entry (bit dirty, but it works!)
if (is_array($t_oids[$index])) {
foreach ($t_oids[$index] as $t_index => $entry) {
foreach ($t_oids[$index] as $t_index => $key) {
// Critical Limit
if ($entry['entSensorThresholdSeverity'] == 'major' && $entry['entSensorThresholdRelation'] == 'greaterOrEqual') {
$limit = ($entry['entSensorThresholdValue'] * $multiplier / $divisor);
if ($key['entSensorThresholdSeverity'] == 'major' && $key['entSensorThresholdRelation'] == 'greaterOrEqual') {
$limit = ($key['entSensorThresholdValue'] * $multiplier / $divisor);
}
if ($entry['entSensorThresholdSeverity'] == 'major' && $entry['entSensorThresholdRelation'] == 'lessOrEqual') {
if ($key['entSensorThresholdSeverity'] == 'major' && $key['entSensorThresholdRelation'] == 'lessOrEqual') {
$limit_low = ($entry['entSensorThresholdValue'] * $multiplier / $divisor);
}
// Warning Limit
if ($entry['entSensorThresholdSeverity'] == 'minor' && $entry['entSensorThresholdRelation'] == 'greaterOrEqual') {
if ($key['entSensorThresholdSeverity'] == 'minor' && $key['entSensorThresholdRelation'] == 'greaterOrEqual') {
$warn_limit = ($entry['entSensorThresholdValue'] * $multiplier / $divisor);
}
if ($entry['entSensorThresholdSeverity'] == 'minor' && $entry['entSensorThresholdRelation'] == 'lessOrEqual') {
if ($key['entSensorThresholdSeverity'] == 'minor' && $key['entSensorThresholdRelation'] == 'lessOrEqual') {
$warn_limit_low = ($entry['entSensorThresholdValue'] * $multiplier / $divisor);
}
}//end foreach

View File

@ -19,7 +19,6 @@ $mapping = array(
'IDBLBSe' => 'cr',
'IBLFh' => 'ct',
'IBLWn' => 'cu',
'IBLWn' => 'cu',
'SRows' => 'ck',
'SRange' => 'cj',
'SMPs' => 'ci',

View File

@ -367,7 +367,6 @@ $rewrite_extreme_hardware = array(
'.1.3.6.1.4.1.1916.2.23' => 'EnetSwitch 24Port',
'.1.3.6.1.4.1.1916.2.83' => 'Sentriant CE150',
'.1.3.6.1.4.1.1916.2.58' => 'Summit 400-48t',
'.1.3.6.1.4.1.1916.2.59' => 'Summit 400-48t',
'.1.3.6.1.4.1.1916.2.71' => 'Summit X450a-24t',
'.1.3.6.1.4.1.1916.2.81' => 'Summit X450a-24t',
'.1.3.6.1.4.1.1916.2.1' => 'Summit 1',
@ -385,7 +384,6 @@ $rewrite_extreme_hardware = array(
'.1.3.6.1.4.1.1916.2.61' => 'Summit 300-24',
'.1.3.6.1.4.1.1916.2.55' => 'Summit 300-48',
'.1.3.6.1.4.1.1916.2.4' => 'Summit 4',
'.1.3.6.1.4.1.1916.2.58' => 'Summit 400-24',
'.1.3.6.1.4.1.1916.2.64' => 'Summit 400-24p',
'.1.3.6.1.4.1.1916.2.63' => 'Summit 400-24t',
'.1.3.6.1.4.1.1916.2.59' => 'Summit 400-24x',
@ -410,8 +408,6 @@ $rewrite_extreme_hardware = array(
'.1.3.6.1.4.1.1916.2.90' => 'Summit X250-24x',
'.1.3.6.1.4.1.1916.2.92' => 'Summit X250-48p',
'.1.3.6.1.4.1.1916.2.91' => 'Summit X250-48t',
'.1.3.6.1.4.1.1916.2.93' => 'Summit X250/X450-24 (3-Stack)',
'.1.3.6.1.4.1.1916.2.88' => 'Summit X250e-24t (Single)',
'.1.3.6.1.4.1.1916.2.66' => 'Summit X450-24t',
'.1.3.6.1.4.1.1916.2.65' => 'Summit X450-24x',
'.1.3.6.1.4.1.1916.2.80' => 'Summit X450a-24tDC',
@ -421,8 +417,6 @@ $rewrite_extreme_hardware = array(
'.1.3.6.1.4.1.1916.2.87' => 'Summit X450a-48tDC',
'.1.3.6.1.4.1.1916.2.72' => 'Summit X450e-24p',
'.1.3.6.1.4.1.1916.2.79' => 'Summit X450e-48p',
'.1.3.6.1.4.1.1916.2.62' => 'Black Diamond 8810',
'.1.3.6.1.4.1.1916.2.67' => 'SummitStack',
'.1.3.6.1.4.1.1916.2.100' => 'Summit x150-24t',
'.1.3.6.1.4.1.1916.2.114' => 'Summit x650-24x',
'.1.3.6.1.4.1.1916.2.129' => 'NWI-e450a',
@ -574,23 +568,6 @@ $rewrite_ironware_hardware = array(
'snFESX448FiberPlus2XGPremSwitch' => 'FESX448Fiber+2XG-PREM',
'snFESX448FiberPlus2XGPremRouter' => 'FESX448Fiber+2XG-PREM',
'snFESX424P' => 'FES 24G POE',
'snFESX424P' => 'FESX424POE',
'snFESX424P' => 'FESX424POE',
'snFESX424P' => 'FES 24GPOE-PREM',
'snFESX424P' => 'FESX424POE-PREM',
'snFESX424P' => 'FESX424POE-PREM',
'snFESX424P' => 'FES 24GPOE + 1 10G',
'snFESX424P' => 'FESX424POE+1XG',
'snFESX424P' => 'FESX424POE+1XG',
'snFESX424P' => 'FES 24GPOE + 1 10G-PREM',
'snFESX424P' => 'FESX424POE+1XG-PREM',
'snFESX424P' => 'FESX424POE+1XG-PREM',
'snFESX424P' => 'FES 24GPOE + 2 10G',
'snFESX424P' => 'FESX424POE+2XG',
'snFESX424P' => 'FESX424POE+2XG',
'snFESX424P' => 'FES 24GPOE + 2 10G-PREM',
'snFESX424P' => 'FESX424POE+2XG-PREM',
'snFESX424P' => 'FESX424POE+2XG-PREM',
'snFESX624' => 'FastIron Edge V6 Switch(FES) 24G',
'snFESX624Switch' => 'FESX624',
'snFESX624Router' => 'FESX624',
@ -664,23 +641,6 @@ $rewrite_ironware_hardware = array(
'snFESX648FiberPlus2XGPremSwitch' => 'FESX648Fiber+2XG-PREM',
'snFESX648FiberPlus2XGPremRouter' => 'FESX648Fiber+2XG-PREM',
'snFESX624P' => 'FastIron Edge V6 Switch(FES) 24G POE',
'snFESX624P' => 'FESX624POE',
'snFESX624P' => 'FESX624POE',
'snFESX624P' => 'FastIron Edge V6 Switch(FES) 24GPOE-PREM',
'snFESX624P' => 'FESX624POE-PREM',
'snFESX624P' => 'FESX624POE-PREM',
'snFESX624P' => 'FastIron Edge V6 Switch(FES) 24GPOE + 1 10G',
'snFESX624P' => 'FESX624POE+1XG',
'snFESX624P' => 'FESX624POE+1XG',
'snFESX624P' => 'FastIron Edge V6 Switch(FES) 24GPOE + 1 10G-PREM',
'snFESX624P' => 'FESX624POE+1XG-PREM',
'snFESX624P' => 'FESX624POE+1XG-PREM',
'snFESX624P' => 'FastIron Edge V6 Switch(FES) 24GPOE + 2 10G',
'snFESX624P' => 'FESX624POE+2XG',
'snFESX624P' => 'FESX624POE+2XG',
'snFESX624P' => 'FastIron Edge V6 Switch(FES) 24GPOE + 2 10G-PREM',
'snFESX624P' => 'FESX624POE+2XG-PREM',
'snFESX624P' => 'FESX624POE+2XG-PREM',
'snFWSX424' => 'FWSX24G',
'snFWSX424Switch' => 'FWSX424',
'FWSX24GSwitch' => 'FWSX424',
@ -947,7 +907,6 @@ $rewrite_ifname = array(
'-802.1q' => '',
'bvi' => 'BVI',
'vlan' => 'Vlan',
'ether' => 'Ether',
'tunnel' => 'Tunnel',
'serial' => 'Serial',
'-aal5 layer' => ' aal5',