Пример #1
0
function cacti_snmp_walk($hostname, $community, $oid, $version, $username, $password, $auth_proto, $priv_pass, $priv_proto, $context, $port = 161, $timeout = 500, $retries = 0, $max_oids = 10, $method = SNMP_VALUE_LIBRARY, $environ = SNMP_POLLER)
{
    global $config, $banned_snmp_strings;
    $snmp_oid_included = true;
    $snmp_auth = '';
    $snmp_array = array();
    $temp_array = array();
    /* determine default retries */
    if ($retries == 0 || !is_numeric($retries)) {
        $retries = read_config_option('snmp_retries');
        if ($retries == '') {
            $retries = 3;
        }
    }
    /* do not attempt to poll invalid combinations */
    if ($version == 0 || !is_numeric($version) || !is_numeric($max_oids) || !is_numeric($port) || !is_numeric($retries) || !is_numeric($timeout) || $community == '' && $version != 3) {
        return array();
    }
    $path_snmpbulkwalk = read_config_option('path_snmpbulkwalk');
    if (snmp_get_method($version) == SNMP_METHOD_PHP && (!strlen($context) || $version != 3) && ($version == 1 || version_compare(phpversion(), '5.1') >= 0 || !file_exists($path_snmpbulkwalk))) {
        /* make sure snmp* is verbose so we can see what types of data
        		we are getting back */
        /* force php to return numeric oid's */
        cacti_oid_numeric_format();
        snmp_set_quick_print(0);
        /* set the output format to numeric */
        snmp_set_valueretrieval($method);
        if ($version == '1') {
            $temp_array = @snmprealwalk("{$hostname}:{$port}", "{$community}", "{$oid}", $timeout * 1000, $retries);
        } elseif ($version == '2') {
            $temp_array = @snmp2_real_walk("{$hostname}:{$port}", "{$community}", "{$oid}", $timeout * 1000, $retries);
        } else {
            if ($priv_proto == '[None]') {
                $proto = 'authNoPriv';
                $priv_proto = '';
            } else {
                $proto = 'authPriv';
            }
            $temp_array = @snmp3_real_walk("{$hostname}:{$port}", "{$username}", $proto, $auth_proto, "{$password}", $priv_proto, "{$priv_pass}", "{$oid}", $timeout * 1000, $retries);
        }
        if ($temp_array === false) {
            cacti_log("WARNING: SNMP Walk Timeout for Host:'{$hostname}', and OID:'{$oid}'", false);
        }
        /* check for bad entries */
        if (is_array($temp_array) && sizeof($temp_array)) {
            foreach ($temp_array as $key => $value) {
                foreach ($banned_snmp_strings as $item) {
                    if (strstr($value, $item) != '') {
                        unset($temp_array[$key]);
                        continue 2;
                    }
                }
            }
            $o = 0;
            for (reset($temp_array); $i = key($temp_array); next($temp_array)) {
                if ($temp_array[$i] != 'NULL') {
                    $snmp_array[$o]['oid'] = preg_replace('/^\\./', '', $i);
                    $snmp_array[$o]['value'] = format_snmp_string($temp_array[$i], $snmp_oid_included);
                }
                $o++;
            }
        }
    } else {
        /* ucd/net snmp want the timeout in seconds */
        $timeout = ceil($timeout / 1000);
        if ($version == '1') {
            $snmp_auth = '-c ' . snmp_escape_string($community);
            /* v1/v2 - community string */
        } elseif ($version == '2') {
            $snmp_auth = '-c ' . snmp_escape_string($community);
            /* v1/v2 - community string */
            $version = '2c';
            /* ucd/net snmp prefers this over '2' */
        } elseif ($version == '3') {
            if ($priv_proto == '[None]') {
                $proto = 'authNoPriv';
                $priv_proto = '';
            } else {
                $proto = 'authPriv';
            }
            if (strlen($priv_pass)) {
                $priv_pass = '******' . snmp_escape_string($priv_pass) . ' -x ' . snmp_escape_string($priv_proto);
            } else {
                $priv_pass = '';
            }
            if (strlen($context)) {
                $context = '-n ' . snmp_escape_string($context);
            } else {
                $context = '';
            }
            $snmp_auth = trim('-u ' . snmp_escape_string($username) . ' -l ' . snmp_escape_string($proto) . ' -a ' . snmp_escape_string($auth_proto) . ' -A ' . snmp_escape_string($password) . ' ' . $priv_pass . ' ' . $context);
            /* v3 - username/password */
        }
        if (file_exists($path_snmpbulkwalk) && $version > 1 && $max_oids > 1) {
            $temp_array = exec_into_array(cacti_escapeshellcmd($path_snmpbulkwalk) . " -O Qn {$snmp_auth} -v {$version} -t {$timeout} -r {$retries} -Cr{$max_oids} " . cacti_escapeshellarg($hostname) . ":{$port} " . cacti_escapeshellarg($oid));
        } else {
            $temp_array = exec_into_array(cacti_escapeshellcmd(read_config_option('path_snmpwalk')) . " -O Qn {$snmp_auth} -v {$version} -t {$timeout} -r {$retries} " . cacti_escapeshellarg($hostname) . ":{$port} " . cacti_escapeshellarg($oid));
        }
        if (substr_count(implode(' ', $temp_array), 'Timeout:')) {
            cacti_log("WARNING: SNMP Walk Timeout for Host:'{$hostname}', and OID:'{$oid}'", false);
        }
        /* check for bad entries */
        if (is_array($temp_array) && sizeof($temp_array)) {
            foreach ($temp_array as $key => $value) {
                foreach ($banned_snmp_strings as $item) {
                    if (strstr($value, $item) != '') {
                        unset($temp_array[$key]);
                        continue 2;
                    }
                }
            }
            for ($i = 0; $i < count($temp_array); $i++) {
                if ($temp_array[$i] != 'NULL') {
                    $snmp_array[$i]['oid'] = trim(preg_replace('/(.*) =.*/', "\\1", $temp_array[$i]));
                    $snmp_array[$i]['value'] = format_snmp_string($temp_array[$i], true);
                }
            }
        }
    }
    return $snmp_array;
}
Пример #2
0
function utilities_view_tech($php_info = "")
{
    global $database_default, $config, $rrdtool_versions, $poller_options, $input_types;
    /* Get table status */
    $tables = db_fetch_assoc("SHOW TABLES");
    $skip_tables = array();
    $table_status = array();
    if (sizeof($tables)) {
        foreach ($tables as $table) {
            $create_syntax = db_fetch_row("SHOW CREATE TABLE " . $table["Tables_in_" . $database_default]);
            if (sizeof($create_syntax)) {
                if (substr_count(strtoupper($create_syntax["Create Table"]), "INNODB")) {
                    $skip_tables[] = $table["Tables_in_" . $database_default];
                } else {
                    $include_tables[] = $table["Tables_in_" . $database_default];
                }
            }
        }
    }
    if (sizeof($include_tables)) {
        foreach ($include_tables as $table) {
            $status = db_fetch_row("SHOW TABLE STATUS LIKE '{$table}'");
            array_push($table_status, $status);
        }
    }
    /* Get poller stats */
    $poller_item = db_fetch_assoc("SELECT action, count(action) as total FROM poller_item GROUP BY action");
    /* Get system stats */
    $host_count = db_fetch_cell("SELECT COUNT(*) FROM host");
    $graph_count = db_fetch_cell("SELECT COUNT(*) FROM graph_local");
    $data_count = db_fetch_assoc("SELECT i.type_id, COUNT(i.type_id) AS total FROM data_template_data AS d, data_input AS i WHERE d.data_input_id = i.id AND local_data_id <> 0 GROUP BY i.type_id");
    /* Get RRDtool version */
    $rrdtool_version = "Unknown";
    if (file_exists(read_config_option("path_rrdtool")) && (function_exists('is_executable') && is_executable(read_config_option("path_rrdtool")))) {
        $out_array = array();
        exec(cacti_escapeshellcmd(read_config_option("path_rrdtool")), $out_array);
        if (sizeof($out_array) > 0) {
            if (preg_match("/^RRDtool 1\\.4/", $out_array[0])) {
                $rrdtool_version = "rrd-1.4.x";
            } else {
                if (preg_match("/^RRDtool 1\\.3\\./", $out_array[0])) {
                    $rrdtool_version = "rrd-1.3.x";
                } else {
                    if (preg_match("/^RRDtool 1\\.2\\./", $out_array[0])) {
                        $rrdtool_version = "rrd-1.2.x";
                    } else {
                        if (preg_match("/^RRDtool 1\\.0\\./", $out_array[0])) {
                            $rrdtool_version = "rrd-1.0.x";
                        }
                    }
                }
            }
        }
    }
    /* Get SNMP cli version */
    $snmp_version = read_config_option("snmp_version");
    if (file_exists(read_config_option("path_snmpget")) && (function_exists('is_executable') && is_executable(read_config_option("path_snmpget")))) {
        $snmp_version = shell_exec(cacti_escapeshellcmd(read_config_option("path_snmpget")) . " -V 2>&1");
    }
    /* Check RRDTool issues */
    $rrdtool_error = "";
    if ($rrdtool_version != read_config_option("rrdtool_version")) {
        $rrdtool_error .= "<br><font color='red'>ERROR: Installed RRDTool version does not match configured version.<br>Please visit the <a href='" . htmlspecialchars("settings.php?tab=general") . "'>Configuration Settings</a> and select the correct RRDTool Utility Version.</font><br>";
    }
    $graph_gif_count = db_fetch_cell("SELECT COUNT(*) FROM graph_templates_graph WHERE image_format_id = 2");
    if ($graph_gif_count > 0 && read_config_option("rrdtool_version") != "rrd-1.0.x") {
        $rrdtool_error .= "<br><font color='red'>ERROR: RRDTool 1.2.x does not support the GIF images format, but " . $graph_gif_count . " graph(s) and/or templates have GIF set as the image format.</font><br>";
    }
    /* Get spine version */
    $spine_version = "Unknown";
    if (file_exists(read_config_option("path_spine")) && (function_exists('is_executable') && is_executable(read_config_option("path_spine")))) {
        $out_array = array();
        exec(read_config_option("path_spine") . " --version", $out_array);
        if (sizeof($out_array) > 0) {
            $spine_version = $out_array[0];
        }
    }
    /* Display tech information */
    html_start_box("<strong>Technical Support</strong>", "100%", "", "3", "center", "");
    html_header(array("General Information"), 2);
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>Date</td>\n";
    print "\t\t<td class='textArea'>" . date("r") . "</td>\n";
    print "</tr>\n";
    api_plugin_hook_function('custom_version_info');
    print "<tr class='even'>\n";
    print "\t\t<td class='textArea'>Cacti Version</td>\n";
    print "\t\t<td class='textArea'>" . $config["cacti_version"] . "</td>\n";
    print "</tr>\n";
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>Cacti OS</td>\n";
    print "\t\t<td class='textArea'>" . $config["cacti_server_os"] . "</td>\n";
    print "</tr>\n";
    print "<tr class='even'>\n";
    print "\t\t<td class='textArea'>SNMP Version</td>\n";
    print "\t\t<td class='textArea'>" . $snmp_version . "</td>\n";
    print "</tr>\n";
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>RRDTool Version</td>\n";
    print "\t\t<td class='textArea'>" . $rrdtool_versions[$rrdtool_version] . " " . $rrdtool_error . "</td>\n";
    print "</tr>\n";
    print "<tr class='even'>\n";
    print "\t\t<td class='textArea'>Hosts</td>\n";
    print "\t\t<td class='textArea'>" . $host_count . "</td>\n";
    print "</tr>\n";
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>Graphs</td>\n";
    print "\t\t<td class='textArea'>" . $graph_count . "</td>\n";
    print "</tr>\n";
    print "<tr class='even'>\n";
    print "\t\t<td class='textArea'>Data Sources</td>\n";
    print "\t\t<td class='textArea'>";
    $data_total = 0;
    if (sizeof($data_count)) {
        foreach ($data_count as $item) {
            print $input_types[$item["type_id"]] . ": " . $item["total"] . "<br>";
            $data_total += $item["total"];
        }
        print "Total: " . $data_total;
    } else {
        print "<font color='red'>0</font>";
    }
    print "</td>\n";
    print "</tr>\n";
    html_header(array("Poller Information"), 2);
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>Interval</td>\n";
    print "\t\t<td class='textArea'>" . read_config_option("poller_interval") . "</td>\n";
    if (file_exists(read_config_option("path_spine")) && $poller_options[read_config_option("poller_type")] == 'spine') {
        $type = $spine_version;
    } else {
        $type = $poller_options[read_config_option("poller_type")];
    }
    print "</tr>\n";
    print "<tr class='even'>\n";
    print "\t\t<td class='textArea'>Type</td>\n";
    print "\t\t<td class='textArea'>" . $type . "</td>\n";
    print "</tr>\n";
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>Items</td>\n";
    print "\t\t<td class='textArea'>";
    $total = 0;
    if (sizeof($poller_item)) {
        foreach ($poller_item as $item) {
            print "Action[" . $item["action"] . "]: " . $item["total"] . "<br>";
            $total += $item["total"];
        }
        print "Total: " . $total;
    } else {
        print "<font color='red'>No items to poll</font>";
    }
    print "</td>\n";
    print "</tr>\n";
    print "<tr class='even'>\n";
    print "\t\t<td class='textArea'>Concurrent Processes</td>\n";
    print "\t\t<td class='textArea'>" . read_config_option("concurrent_processes") . "</td>\n";
    print "</tr>\n";
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>Max Threads</td>\n";
    print "\t\t<td class='textArea'>" . read_config_option("max_threads") . "</td>\n";
    print "</tr>\n";
    print "<tr class='even'>\n";
    print "\t\t<td class='textArea'>PHP Servers</td>\n";
    print "\t\t<td class='textArea'>" . read_config_option("php_servers") . "</td>\n";
    print "</tr>\n";
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>Script Timeout</td>\n";
    print "\t\t<td class='textArea'>" . read_config_option("script_timeout") . "</td>\n";
    print "</tr>\n";
    print "<tr class='even'>\n";
    print "\t\t<td class='textArea'>Max OID</td>\n";
    print "\t\t<td class='textArea'>" . read_config_option("max_get_size") . "</td>\n";
    print "</tr>\n";
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>Last Run Statistics</td>\n";
    print "\t\t<td class='textArea'>" . read_config_option("stats_poller") . "</td>\n";
    print "</tr>\n";
    html_header(array("PHP Information"), 2);
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>PHP Version</td>\n";
    print "\t\t<td class='textArea'>" . phpversion() . "</td>\n";
    print "</tr>\n";
    print "<tr class='even'>\n";
    print "\t\t<td class='textArea'>PHP OS</td>\n";
    print "\t\t<td class='textArea'>" . PHP_OS . "</td>\n";
    print "</tr>\n";
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>PHP uname</td>\n";
    print "\t\t<td class='textArea'>";
    if (function_exists("php_uname")) {
        print php_uname();
    } else {
        print "N/A";
    }
    print "</td>\n";
    print "</tr>\n";
    print "<tr class='even'>\n";
    print "\t\t<td class='textArea'>PHP SNMP</td>\n";
    print "\t\t<td class='textArea'>";
    if (function_exists("snmpget")) {
        print "Installed";
    } else {
        print "Not Installed";
    }
    print "</td>\n";
    print "</tr>\n";
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea'>max_execution_time</td>\n";
    print "\t\t<td class='textArea'>" . ini_get("max_execution_time") . "</td>\n";
    print "</tr>\n";
    print "<tr class='even'>\n";
    print "\t\t<td class='textArea'>memory_limit</td>\n";
    print "\t\t<td class='textArea'>" . ini_get("memory_limit");
    /* Calculate memory suggestion based off of data source count */
    $memory_suggestion = $data_total * 32768;
    /* Set minimum - 16M */
    if ($memory_suggestion < 16777216) {
        $memory_suggestion = 16777216;
    }
    /* Set maximum - 512M */
    if ($memory_suggestion > 536870912) {
        $memory_suggestion = 536870912;
    }
    /* Suggest values in 8M increments */
    $memory_suggestion = round($memory_suggestion / 8388608) * 8388608;
    if (memory_bytes(ini_get('memory_limit')) < $memory_suggestion) {
        print "<br><font color='red'>";
        if (ini_get('memory_limit') == -1) {
            print "You've set memory limit to 'unlimited'.<br/>";
        }
        print "It is highly suggested that you alter you php.ini memory_limit to " . memory_readable($memory_suggestion) . " or higher. <br/>\n\t\t\tThis suggested memory value is calculated based on the number of data source present and is only to be used as a suggestion, actual values may vary system to system based on requirements.";
        print "</font><br>";
    }
    print "</td>\n";
    print "</tr>\n";
    html_header(array("MySQL Table Information"), 2);
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea' colspan='2' align='center'>";
    if (sizeof($table_status) > 0) {
        print "<table border='1' cellpadding='2' cellspacing='0'>\n";
        print "<tr>\n";
        print "  <th>Name</th>\n";
        print "  <th>Rows</th>\n";
        print "  <th>Engine</th>\n";
        print "  <th>Collation</th>\n";
        print "</tr>\n";
        foreach ($table_status as $item) {
            print "<tr>\n";
            print "  <td>" . $item["Name"] . "</td>\n";
            print "  <td>" . $item["Rows"] . "</td>\n";
            if (isset($item["Engine"])) {
                print "  <td>" . $item["Engine"] . "</td>\n";
            } else {
                print "  <td>Unknown</td>\n";
            }
            if (isset($item["Collation"])) {
                print "  <td>" . $item["Collation"] . "</td>\n";
            } else {
                print "  <td>Unknown</td>\n";
            }
            print "</tr>\n";
        }
        if (sizeof($skip_tables)) {
            print "<tr><td colspan='20' align='center'><strong>The Following Tables were Skipped Due to being INNODB</strong></td></tr>";
            foreach ($skip_tables as $table) {
                print "<tr><td colspan='20' align='center'>" . $table . "</td></tr>";
            }
        }
        print "</table>\n";
    } else {
        print "Unable to retrieve table status";
    }
    print "</td>\n";
    print "</tr>\n";
    html_header(array("PHP Module Information"), 2);
    print "<tr class='odd'>\n";
    print "\t\t<td class='textArea' colspan='2'>" . $php_info . "</td>\n";
    print "</tr>\n";
    html_end_box();
}
Пример #3
0
function cacti_snmp_walk($hostname, $community, $oid, $version, $username, $password, $auth_proto, $priv_pass, $priv_proto, $context, $port = 161, $timeout = 500, $retries = 0, $max_oids = 10, $environ = SNMP_POLLER)
{
    global $config, $banned_snmp_strings;
    $snmp_oid_included = true;
    $snmp_auth = '';
    $snmp_array = array();
    $temp_array = array();
    /* determine default retries */
    if ($retries == 0 || !is_numeric($retries)) {
        $retries = read_config_option("snmp_retries");
        if ($retries == "") {
            $retries = 3;
        }
    }
    /* determine default max_oids */
    if ($max_oids == 0 || !is_numeric($max_oids)) {
        $max_oids = read_config_option("max_get_size");
        if ($max_oids == "") {
            $max_oids = 10;
        }
    }
    /* do not attempt to poll invalid combinations */
    if ($version == 0 || !is_numeric($version) || !is_numeric($max_oids) || !is_numeric($port) || !is_numeric($retries) || !is_numeric($timeout) || $community == "" && $version != 3) {
        return array();
    }
    $path_snmpbulkwalk = read_config_option("path_snmpbulkwalk");
    if (snmp_get_method($version) == SNMP_METHOD_PHP && (!strlen($context) || $version != 3) && ($version == 1 || version_compare(phpversion(), "5.1") >= 0 || !file_exists($path_snmpbulkwalk))) {
        /* make sure snmp* is verbose so we can see what types of data
        		we are getting back */
        /* force php to return numeric oid's */
        if (function_exists("snmp_set_oid_numeric_print")) {
            snmp_set_oid_numeric_print(TRUE);
        }
        if (function_exists("snmprealwalk")) {
            $snmp_oid_included = false;
        }
        snmp_set_quick_print(0);
        if ($version == "1") {
            $temp_array = @snmprealwalk("{$hostname}:{$port}", "{$community}", "{$oid}", $timeout * 1000, $retries);
        } elseif ($version == "2") {
            $temp_array = @snmp2_real_walk("{$hostname}:{$port}", "{$community}", "{$oid}", $timeout * 1000, $retries);
        } else {
            if ($priv_proto == "[None]" || $priv_pass == '') {
                $proto = "authNoPriv";
                $priv_proto = "";
            } else {
                $proto = "authPriv";
            }
            $temp_array = @snmp3_real_walk("{$hostname}:{$port}", "{$username}", $proto, $auth_proto, "{$password}", $priv_proto, "{$priv_pass}", "{$oid}", $timeout * 1000, $retries);
        }
        if ($temp_array === false) {
            cacti_log("WARNING: SNMP Walk Timeout for Host:'{$hostname}', and OID:'{$oid}'", false);
        }
        /* check for bad entries */
        if (is_array($temp_array) && sizeof($temp_array)) {
            foreach ($temp_array as $key => $value) {
                foreach ($banned_snmp_strings as $item) {
                    if (strstr($value, $item) != "") {
                        unset($temp_array[$key]);
                        continue 2;
                    }
                }
            }
        }
        $o = 0;
        for (@reset($temp_array); $i = @key($temp_array); next($temp_array)) {
            if ($temp_array[$i] != "NULL") {
                $snmp_array[$o]["oid"] = preg_replace("/^\\./", "", $i);
                $snmp_array[$o]["value"] = format_snmp_string($temp_array[$i], $snmp_oid_included);
            }
            $o++;
        }
    } else {
        /* ucd/net snmp want the timeout in seconds */
        $timeout = ceil($timeout / 1000);
        if ($version == "1") {
            $snmp_auth = read_config_option("snmp_version") == "ucd-snmp" ? snmp_escape_string($community) : "-c " . snmp_escape_string($community);
            /* v1/v2 - community string */
        } elseif ($version == "2") {
            $snmp_auth = read_config_option("snmp_version") == "ucd-snmp" ? snmp_escape_string($community) : "-c " . snmp_escape_string($community);
            /* v1/v2 - community string */
            $version = "2c";
            /* ucd/net snmp prefers this over '2' */
        } elseif ($version == "3") {
            if ($priv_proto == "[None]" || $priv_pass == '') {
                $proto = "authNoPriv";
                $priv_proto = "";
            } else {
                $proto = "authPriv";
            }
            if (strlen($priv_pass)) {
                $priv_pass = "******" . snmp_escape_string($priv_pass) . " -x " . snmp_escape_string($priv_proto);
            } else {
                $priv_pass = "";
            }
            if (strlen($context)) {
                $context = "-n " . snmp_escape_string($context);
            } else {
                $context = "";
            }
            $snmp_auth = trim("-u " . snmp_escape_string($username) . " -l " . snmp_escape_string($proto) . " -a " . snmp_escape_string($auth_proto) . " -A " . snmp_escape_string($password) . " " . $priv_pass . " " . $context);
            /* v3 - username/password */
        }
        if (read_config_option("snmp_version") == "ucd-snmp") {
            /* escape the command to be executed and vulnerable parameters
             * numeric parameters are not subject to command injection
             * snmp_auth is treated seperately, see above */
            $temp_array = exec_into_array(cacti_escapeshellcmd(read_config_option("path_snmpwalk")) . " -v{$version} -t {$timeout} -r {$retries} " . cacti_escapeshellarg($hostname) . ":{$port} {$snmp_auth} " . cacti_escapeshellarg($oid));
        } else {
            if (file_exists($path_snmpbulkwalk) && $version > 1 && $max_oids > 1) {
                $temp_array = exec_into_array(cacti_escapeshellcmd($path_snmpbulkwalk) . " -O Qn {$snmp_auth} -v {$version} -t {$timeout} -r {$retries} -Cr{$max_oids} " . cacti_escapeshellarg($hostname) . ":{$port} " . cacti_escapeshellarg($oid));
            } else {
                $temp_array = exec_into_array(cacti_escapeshellcmd(read_config_option("path_snmpwalk")) . " -O Qn {$snmp_auth} -v {$version} -t {$timeout} -r {$retries} " . cacti_escapeshellarg($hostname) . ":{$port} " . cacti_escapeshellarg($oid));
            }
        }
        if (substr_count(implode(" ", $temp_array), "Timeout:")) {
            cacti_log("WARNING: SNMP Walk Timeout for Host:'{$hostname}', and OID:'{$oid}'", false);
        }
        /* check for bad entries */
        if (is_array($temp_array) && sizeof($temp_array)) {
            foreach ($temp_array as $key => $value) {
                foreach ($banned_snmp_strings as $item) {
                    if (strstr($value, $item) != "") {
                        unset($temp_array[$key]);
                        continue 2;
                    }
                }
            }
        }
        for ($i = 0; $i < count($temp_array); $i++) {
            if ($temp_array[$i] != "NULL") {
                $snmp_array[$i]["oid"] = trim(preg_replace("/(.*) =.*/", "\\1", $temp_array[$i]));
                $snmp_array[$i]["value"] = format_snmp_string($temp_array[$i], true);
            }
        }
    }
    return $snmp_array;
}