1)) { $temp_array = exec_into_array(read_config_option("path_snmpbulkwalk") . " -O QfntUe $snmp_auth -v $version -t $timeout -r $retries -Cr50 $hostname:$port $oid"); }else{ $temp_array = exec_into_array(read_config_option("path_snmpwalk") . " -O QfntUe $snmp_auth -v $version -t $timeout -r $retries $hostname:$port $oid"); } } if ((sizeof($temp_array) == 0) || (substr_count($temp_array[0], "No Such Object"))) { return array(); } for ($i=0; $i < count($temp_array); $i++) { $snmp_array[$i]["oid"] = trim(ereg_replace("(.*) =.*", "\\1", $temp_array[$i])); $snmp_array[$i]["value"] = format_snmp_string($temp_array[$i]); } } return $snmp_array; } function format_snmp_string($string) { /* strip off all leading junk (the oid and stuff) */ $string = trim(ereg_replace(".*= ?", "", $string)); /* remove ALL quotes */ $string = str_replace("\"", "", $string); $string = str_replace("'", "", $string); $string = str_replace(">", "", $string); $string = str_replace("<", "", $string); $string = str_replace("\\", "", $string); /* Remove invalid chars */ $k = strlen($string); for ($i=0; $i < $k; $i++) { if ((ord($string[$i]) <= 31) || (ord($string[$i]) >= 127)) { $string[$i] = " "; } } $string = trim($string); if (preg_match("/(hex:\?)?([a-fA-F0-9]{1,2}(:|\s)){5}/", $string)) { $octet = ""; /* strip of the 'hex:' */ $string = eregi_replace("hex: ?", "", $string); /* split the hex on the delimiter */ $octets = preg_split("/\s|:/", $string); /* loop through each octet and format it accordingly */ for ($i=0;($i