refactor: Remove unecessary OS checks in proc / mem polling (#6414)

This commit is contained in:
Neil Lathwood
2017-04-15 02:01:45 +01:00
committed by Tony Murray
parent 78c77ac637
commit 7f83148e80
27 changed files with 164 additions and 216 deletions

View File

@@ -1,6 +1,5 @@
<?php
if ($device['os'] == 'avaya-ers') {
// Memory information only known to work with 5500 and 5600 switches
if (preg_match('/5[56][0-9][0-9]/', $device['sysDescr'])) {
$index = $mempool['mempool_index'];
@@ -12,4 +11,3 @@ if ($device['os'] == 'avaya-ers') {
$mempool['free'] = $avail;
$mempool['used'] = ($total - $avail);
}
}

View File

@@ -1,6 +1,5 @@
<?php
if ($device['os'] == 'ciscowlc') {
echo "Cisco WLC";
$total = str_replace('"', "", snmp_get($device, "1.3.6.1.4.1.14179.1.1.5.2.0", '-OvQ'));
@@ -9,4 +8,3 @@ if ($device['os'] == 'ciscowlc') {
$mempool['total'] = ($total * 1024);
$mempool['free'] = ($avail * 1024);
$mempool['used'] = (($total - $avail) * 1024);
}

View File

@@ -10,10 +10,8 @@
* the source code distribution for details.
*/
if ($device['os'] == 'edgeswitch') {
$total = snmp_get($device, '.1.3.6.1.4.1.4413.1.1.1.1.4.2.0', '-Oqv');
$free = snmp_get($device, '.1.3.6.1.4.1.4413.1.1.1.1.4.1.0', '-Oqv');
$mempool['total'] = $total;
$mempool['free'] = $free;
$mempool['used'] = $total - $free;
}

View File

@@ -10,11 +10,9 @@
* the source code distribution for details.
*/
if ($device['os'] == "enterasys") {
$free = snmp_get($device, 'etsysResourceStorageAvailable.3.ram.0', '-OvQ', 'ENTERASYS-RESOURCE-UTILIZATION-MIB');
$total = snmp_get($device, 'etsysResourceStorageSize.3.ram.0', '-OvQ', 'ENTERASYS-RESOURCE-UTILIZATION-MIB');
$mempool['used'] = (($total - $free) * 1024);
$mempool['free'] = ($free * 1024);
$mempool['total'] = ($total * 1024);
}

View File

@@ -1,6 +1,5 @@
<?php
if ($device['os'] == 'xos') {
echo 'EXTREME-SOFTWARE-MONITOR-MIB';
$total = str_replace('"', "", snmp_get($device, "1.3.6.1.4.1.1916.1.32.2.2.1.2.1", '-OvQ'));
@@ -9,4 +8,3 @@ if ($device['os'] == 'xos') {
$mempool['total'] = ($total * 1024);
$mempool['free'] = ($avail * 1024);
$mempool['used'] = (($total - $avail) * 1024);
}

View File

@@ -1,6 +1,5 @@
<?php
if ($device['os'] == 'hirschmann') {
$mem_allocated = snmp_get($device, 'HMPRIV-MGMT-SNMP-MIB::hmMemoryAllocated.0', '-OvQU');
$mem_free = snmp_get($device, 'HMPRIV-MGMT-SNMP-MIB::hmMemoryFree.0', '-OvQU');
$perc = $mem_allocated / ($mem_allocated + $mem_free) * 100;
@@ -11,4 +10,3 @@ if ($device['os'] == 'hirschmann') {
$mempool['free'] = $mem_free;
echo '(U: '.$mempool['used'].' T: '.$mempool['total'].' F: '.$mempool['free'].') ';
}

View File

@@ -10,7 +10,6 @@
* the source code distribution for details.
*/
if ($device['os'] == "hpblmos") {
//UCD-SNMP-MIB::memAvailReal.0
$free = intval(preg_replace('/[^0-9]+/', '', snmp_get($device, '.1.3.6.1.4.1.2021.4.6.0', '-Oqv')), 10);
//UCD-SNMP-MIB::memTotalReal.0
@@ -19,4 +18,3 @@ if ($device['os'] == "hpblmos") {
$mempool['total'] = $total;
$mempool['free'] = $free;
$mempool['used'] = $total - $free;
}

View File

@@ -23,13 +23,11 @@
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
if ($device['os'] === 'jetstream') {
$oid = '.1.3.6.1.4.1.11863.6.4.1.2.1.1.2.' . $mempool['mempool_index'];
$used = snmp_get($device, $oid, '-OvQ');
$mempool['total'] = 100;
$mempool['free'] = ($mempool['total'] - $used);
$mempool['used'] = $used;
}
unset(
$oid,

View File

@@ -20,8 +20,6 @@
"The usage of memory size in %."
*/
if ($device['os'] == 'moxa-etherdevice') {
$mempool['total'] = snmp_get($device, "totalMemory.0", '-OvQ', 'MOXA-IKS6726A-MIB');
$mempool['used'] = snmp_get($device, "usedMemory.0", '-OvQ', 'MOXA-IKS6726A-MIB');
$mempool['free'] = snmp_get($device, "freeMemory.0", '-OvQ', 'MOXA-IKS6726A-MIB');
}

View File

@@ -23,11 +23,9 @@
* @author Tony Murray <murraytony@gmail.com>
*/
if ($device['os'] == 'netonix') {
$total = snmp_get($device, "UCD-SNMP-MIB::memTotalReal.0", "-OvQU") * 1024;
$free = snmp_get($device, "UCD-SNMP-MIB::memAvailReal.0", "-OvQU") * 1024;
$mempool['total'] = $total;
$mempool['free'] = $free;
$mempool['used'] = $total - $free;
}

View File

@@ -10,7 +10,6 @@
* the source code distribution for details.
*/
if ($device['os'] == "nxos") {
echo "Cisco Nexus";
$used = snmp_get($device, '.1.3.6.1.4.1.9.9.109.1.1.1.1.12.1', '-OvQ');
$free = snmp_get($device, '.1.3.6.1.4.1.9.9.109.1.1.1.1.13.1', '-OvQ');
@@ -18,4 +17,3 @@ if ($device['os'] == "nxos") {
$mempool['used'] = ($used * 1024);
$mempool['free'] = ($free * 1024);
$mempool['total'] = (($used + $free) * 1024);
}

View File

@@ -2,7 +2,6 @@
echo 'PBN MemPool'.'\n';
if ($device['os'] == 'pbn') {
// find out wich build number we have
preg_match('/^.* Build (?<build>\d+)/', $device['version'], $version);
d_echo($version);
@@ -21,4 +20,3 @@ if ($device['os'] == 'pbn') {
echo "PERC " .$perc."%\n";
echo "Avail " .$mempool['total']."\n";
}
}

View File

@@ -14,7 +14,6 @@
echo 'Pulse Secure MemPool'.'\n';
if ($device['os'] == 'pulse') {
$perc = str_replace('"', "", snmp_get($device, "PULSESECURE-PSG-MIB::iveMemoryUtil.0", '-OvQ'));
$memory_available = str_replace('"', "", snmp_get($device, "UCD-SNMP-MIB::memTotalReal.0", '-OvQ'));
$mempool['total'] = $memory_available;
@@ -26,4 +25,3 @@ if ($device['os'] == 'pulse') {
echo "PERC " .$perc."%\n";
echo "Avail " .$mempool['total']."\n";
}

View File

@@ -4,7 +4,6 @@
echo 'ProxySG MemPool'.'\n';
if ($device['os'] == 'sgos') {
$used = str_replace('"', "", snmp_get($device, "BLUECOAT-SG-PROXY-MIB::sgProxyMemSysUsage.0", '-OUvQ'));
$total = str_replace('"', "", snmp_get($device, "BLUECOAT-SG-PROXY-MIB::sgProxyMemAvailable.0", '-OUvQ'));
$free = ($total - $used);
@@ -13,4 +12,3 @@ if ($device['os'] == 'sgos') {
$mempool['used'] = ($used);
$mempool['free'] = ($free);
$mempool['total'] = (($used + $free));
}

View File

@@ -9,7 +9,7 @@
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if ($device['os'] == 'sonicwall') {
echo 'SonicWALL-MEMORY-POOL: ';
$perc = str_replace('"', "", snmp_get($device, 'SONICWALL-FIREWALL-IP-STATISTICS-MIB::sonicCurrentRAMUtil.0', '-OvQ'));
if (is_numeric($perc)) {
@@ -18,4 +18,3 @@ if ($device['os'] == 'sonicwall') {
$mempool['total'] = 100;
$mempool['free'] = 100 - $perc;
}
}

View File

@@ -10,7 +10,6 @@
* the source code distribution for details.
*/
if ($device['os'] == 'zywall') {
d_echo('Zywall');
$perc = snmp_get($device, ".1.3.6.1.4.1.890.1.6.22.1.2.0", '-OvQ');
if (is_numeric($perc)) {
@@ -19,4 +18,3 @@ if ($device['os'] == 'zywall') {
$mempool['total'] = 100;
$mempool['free'] = 100 - $perc;
}
}

View File

@@ -23,7 +23,6 @@
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
if ($device['group'] == 'zyxel') {
echo 'Zyxel: ';
$oid = '.1.3.6.1.4.1.890.1.15.3.2.5.0';
$perc = snmp_get($device, $oid, '-OvQ');
@@ -33,7 +32,6 @@ if ($device['group'] == 'zyxel') {
$mempool['total'] = 100;
$mempool['free'] = 100 - $perc;
}
}
unset(
$oid,

View File

@@ -9,10 +9,8 @@
*/
echo 'Cambium CPU Usage';
if ($device['os'] == 'cambium') {
$usage = str_replace('"', "", snmp_get($device, 'CAMBIUM-PMP80211-MIB::sysCPUUsage.0', '-OvQ'));
if (is_numeric($usage)) {
$proc = ($usage / 10);
}
}

View File

@@ -1,6 +1,6 @@
<?php
echo 'DNOS CPU Usage';
if ($device['os'] == 'dnos') {
$get_series = explode('.', snmp_get($device, 'mib-2.1.2.0', '-Onvsbq', 'F10-PRODUCTS-MIB', 'dnos'), 2); // Get series From MIB
$series = $get_series[0];
$descr = 'CPU';
@@ -12,4 +12,3 @@ if ($device['os'] == 'dnos') {
preg_match('/(\d*\.\d*)/', snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.9.0', '-OvQ'), $matches);
$proc = $matches[0];
}
}

View File

@@ -11,9 +11,7 @@
*/
d_echo('EdgeSwitch CPU usage:');
if ($device['os'] == 'edgeswitch') {
//SNMPv2-SMI::enterprises.4413.1.1.1.1.4.9.0
$proc_usage = snmp_get($device, '.1.3.6.1.4.1.4413.1.1.1.1.4.9.0', '-Ovq');
preg_match('/([0-9]+.[0-9]+)/', $proc_usage, $usage);
$proc = $usage[0];
}

View File

@@ -4,11 +4,9 @@
// Hardcoded polling of CPU usage on Extreme devices due to the lack of multiplier for CPU usage.
//
// iso.3.6.1.4.1.1916.1.32.1.4.1.9.1 = STRING: "7.3"
if ($device['os'] == 'xos') {
$usage = str_replace('"', "", snmp_get($device, '1.3.6.1.4.1.1916.1.32.1.4.1.9.1', '-OvQ', 'EXTREME-BASE-MIB'));
if (is_numeric($usage)) {
$proc = ($usage * 100);
//substr(snmp_get($device, '1.3.6.1.4.1.1916.1.32.1.4.1.9.1', '-Ovq', 'EXTREME-BASE-MIB'), 0, 2);
}
}

View File

@@ -10,8 +10,6 @@
* the source code distribution for details.
*/
if ($device['os'] == 'hpblmos') {
$idle = snmp_get($device, '.1.3.6.1.4.1.2021.11.11.0', '-Ovqn');
$usage = 100 - $idle;
$proc = $usage;
}

View File

@@ -12,10 +12,8 @@
echo 'Moxa EtherDevice CPU Usage';
if ($device['os'] == 'moxa-etherdevice') {
$usage = snmp_get($device, 'cpuLoading30s.0', '-OvQ', 'MOXA-IKS6726A-MIB');
if (is_numeric($usage)) {
$proc = ($usage * 100);
}
}

View File

@@ -1,6 +1,5 @@
<?php
if ($device['os'] == 'pbn') {
echo 'PBN CPU Usage';
// find out wich build number we have
@@ -15,4 +14,3 @@ if ($device['os'] == 'pbn') {
$proc = ($usage * 100);
}
}
}

View File

@@ -14,10 +14,8 @@
echo 'Pulse Secure CPU Usage';
if ($device['os'] == 'pulse') {
$usage = str_replace('"', "", snmp_get($device, 'PULSESECURE-PSG-MIB::iveCpuUtil.0', '-OvQ'));
if (is_numeric($usage)) {
$proc = ($usage * 100);
}
}

View File

@@ -2,10 +2,8 @@
echo 'ProxySG CPU Usage';
if ($device['os'] == 'sgos') {
$usage = str_replace('"', "", snmp_get($device, 'BLUECOAT-SG-PROXY-MIB::sgProxyCpuCoreBusyPerCent.0', '-OvQ'));
if (is_numeric($usage)) {
$proc = ($usage * 100);
}
}

View File

@@ -1,9 +1,7 @@
<?php
echo 'Viprinet CPU Usage';
if ($device['os'] == 'viprinux') {
$usage = str_replace('"', "", snmp_get($device, 'VIPRINET-MIB::vpnRouterCPULoad.0', '-OvQ'));
if (is_numeric($usage)) {
$proc = ($usage * 100);
}
}