From be579b3cf9e0d2165b1410cbd85e6f6bdd16b458 Mon Sep 17 00:00:00 2001 From: Mark Nagel Date: Fri, 23 Oct 2015 09:18:05 -0700 Subject: [PATCH 1/2] Use official NET-SNMP-EXTEND-MIB first for running distro command, then fallback to the older OID subtree. --- includes/polling/os/unix.inc.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/polling/os/unix.inc.php b/includes/polling/os/unix.inc.php index 96403771ff..053eae98ef 100644 --- a/includes/polling/os/unix.inc.php +++ b/includes/polling/os/unix.inc.php @@ -32,9 +32,16 @@ if ($device['os'] == "linux" || $device['os'] == "endian") { } # Distro "extend" support - $features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.3.1.1.6.100.105.115.116.114.111", "-Oqv", "UCD-SNMP-MIB"); + + # NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.\"distro\" + $features = snmp_get($device, ".1.3.6.1.4.1.8072.1.3.2.3.1.1.6.100.105.115.116.114.111", "-Oqv", "NET-SNMP-EXTEND-MIB"); $features = str_replace("\"", "", $features); + if (!$features) { # No "extend" support, try legacy UCD-MIB shell support + $features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.3.1.1.6.100.105.115.116.114.111", "-Oqv", "UCD-SNMP-MIB"); + $features = str_replace("\"", "", $features); + } + if (!$features) { # No "extend" support, try "exec" support $features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.101.1", "-Oqv", "UCD-SNMP-MIB"); $features = str_replace("\"", "", $features); From 55379c04a64ca9560600d42d4ac73985648f562b Mon Sep 17 00:00:00 2001 From: Mark Nagel Date: Sun, 25 Oct 2015 12:21:08 -0700 Subject: [PATCH 2/2] Adjusted unix distro detection further, simplified quote stripping (cannot defer until the end due to successive tests). Replicated EXTEND handling into freebsd branch. --- includes/polling/os/unix.inc.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/includes/polling/os/unix.inc.php b/includes/polling/os/unix.inc.php index 053eae98ef..d15144de92 100644 --- a/includes/polling/os/unix.inc.php +++ b/includes/polling/os/unix.inc.php @@ -34,17 +34,14 @@ if ($device['os'] == "linux" || $device['os'] == "endian") { # Distro "extend" support # NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.\"distro\" - $features = snmp_get($device, ".1.3.6.1.4.1.8072.1.3.2.3.1.1.6.100.105.115.116.114.111", "-Oqv", "NET-SNMP-EXTEND-MIB"); - $features = str_replace("\"", "", $features); + $features = str_replace("\"", "", snmp_get($device, ".1.3.6.1.4.1.8072.1.3.2.3.1.1.6.100.105.115.116.114.111", "-Oqv", "NET-SNMP-EXTEND-MIB")); if (!$features) { # No "extend" support, try legacy UCD-MIB shell support - $features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.3.1.1.6.100.105.115.116.114.111", "-Oqv", "UCD-SNMP-MIB"); - $features = str_replace("\"", "", $features); + $features = str_replace("\"", "", snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.3.1.1.6.100.105.115.116.114.111", "-Oqv", "UCD-SNMP-MIB")); } if (!$features) { # No "extend" support, try "exec" support - $features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.101.1", "-Oqv", "UCD-SNMP-MIB"); - $features = str_replace("\"", "", $features); + $features = str_replace("\"", "", snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.101.1", "-Oqv", "UCD-SNMP-MIB")); } # Detect Dell hardware via OpenManage SNMP @@ -87,12 +84,16 @@ elseif ($device['os'] == "freebsd") { } # Distro "extend" support - $features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.3.1.1.6.100.105.115.116.114.111", "-Oqv", "UCD-SNMP-MIB"); - $features = str_replace("\"", "", $features); + + # NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.\"distro\" + $features = str_replace("\"", "", snmp_get($device, ".1.3.6.1.4.1.8072.1.3.2.3.1.1.6.100.105.115.116.114.111", "-Oqv", "NET-SNMP-EXTEND-MIB")); + + if (!$features) { # No "extend" support, try legacy UCD-MIB shell support + $features = str_replace("\"", "", snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.3.1.1.6.100.105.115.116.114.111", "-Oqv", "UCD-SNMP-MIB")); + } if (!$features) { # No "extend" support, try "exec" support - $features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.101.1", "-Oqv", "UCD-SNMP-MIB"); - $features = str_replace("\"", "", $features); + $features = str_replace("\"", "", snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.101.1", "-Oqv", "UCD-SNMP-MIB")); } if (!$features) {