$val) { $snmp_array[$o]["oid"] = ereg_replace("^\.", "", $key); $snmp_array[$o]["value"] = format_snmp_string($val); $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_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */ }elseif ($version == "2") { $snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */ $version = "2c"; /* ucd/net snmp prefers this over '2' */ }elseif ($version == "3") { $snmp_auth = "-u $username -l authPriv -a MD5 -A $password -x DES -X $password"; /* v3 - username/password */ } if (read_config_option("snmp_version") == "ucd-snmp") { $temp_array = exec_into_array(read_config_option("path_snmpwalk") . " -v$version -t $timeout -r $retries $hostname:$port $snmp_auth $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); 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