$snmp) { $data = explode(': ',$snmp); $keydata = explode('::',$key); $keydata2 = explode('.',$keydata[1]); if(!isset($keydata2[1])) { continue; } if(array_key_exists(1,$data)){ $interfaces[$keydata2[1]][$keydata2[0]]['type'] = $data[0]; $interfaces[$keydata2[1]][$keydata2[0]]['value'] = $data[1]; }else { $interfaces[$keydata2[1]][$keydata2[0]]['type'] = ''; $interfaces[$keydata2[1]][$keydata2[0]]['value'] = $data[0]; } $interfaces[$keydata2[1]][$keydata2[0]]['oid'] = $key; $interfaces[$keydata2[1]][$keydata2[0]]['checked'] = 0; } unset($interfaces[0]); } if($create_modules) { $id_snmp_serialize = get_parameter_post('id_snmp_serialize'); $interfaces = unserialize_in_temp($id_snmp_serialize); if(!$interfaces) { $interfaces = array(); } $values = array(); if($tcp_port != ''){ $values['tcp_port'] = $tcp_port; } $values['snmp_community'] = $snmp_community; $values['ip_target'] = $ip_target; $values['tcp_send'] = $snmp_version; if($snmp_version == '3') { $values['plugin_user'] = $snmp3_auth_user; $values['plugin_pass'] = $snmp3_auth_pass; $values['plugin_parameter'] = $snmp3_auth_method; $values['custom_string_1'] = $snmp3_privacy_method; $values['custom_string_2'] = $snmp3_privacy_pass; $values['custom_string_3'] = $snmp3_security_level; } $oids = array(); foreach($interfaces as $key => $interface) { foreach($interface as $key2 => $module) { $oid = get_parameter($key."-".$key2, ''); if($oid != '') { $interfaces[$key][$key2]['checked'] = 1; $oids[$key][] = $interfaces[$key][$key2]['oid']; } else { $interfaces[$key][$key2]['checked'] = 0; } } } $modules = get_parameter('module', array()); $id_snmp = get_parameter('id_snmp'); if($id_snmp == false) { ui_print_error_message (__('No modules selected')); $id_snmp = array(); } if(agents_get_name($id_agent) == false) { ui_print_error_message (__('No agent selected or the agent does not exist')); $id_snmp = array(); } $result = false; foreach($id_snmp as $id) { foreach($modules as $module) { $oid_array = explode('.',$module); $oid_array[count($oid_array)-1] = $id; $oid = implode('.',$oid_array); // Get the name $name_array = explode('::',$oid_array[0]); $name = $name_array[1] . "_" . $interfaces[$id]['ifName']['value']; // Clean the name $name = str_replace ( "\"" , "" , $name); // Proc moduletypes if (preg_match ( "/Status/", $name_array[1])) $module_type = 18; elseif (preg_match ( "/Present/", $name_array[1])) $module_type = 18; elseif (preg_match ( "/PromiscuousMode/", $name_array[1])) $module_type = 18; // String moduletypes elseif (preg_match ( "/Alias/", $name_array[1])) $module_type = 17; elseif (preg_match ( "/Address/", $name_array[1])) $module_type = 17; elseif (preg_match ( "/Name/", $name_array[1])) $module_type = 17; elseif (preg_match ( "/Specific/", $name_array[1])) $module_type = 17; elseif (preg_match ( "/Descr/", $name_array[1])) $module_type = 17; // Specific counters (ends in s) elseif (preg_match ( "/s$/", $name_array[1])) $module_type = 16; // Otherwise, numeric else $module_type = 15; $values['id_tipo_modulo'] = $module_type; $values['descripcion'] = "(" . $ip_target." - ".$name . ") " . $interfaces[$id]['ifDescr']['value']; $values['snmp_oid'] = $oid; $values['id_modulo'] = 2; $result = modules_create_agent_module ($id_agent, $name, $values); } } ui_print_result_message ($result, __('Successfully modules created'), __('Could not be created')); } // Create the interface list for the interface $interfaces_list = array(); foreach($interfaces as $interface){ // Get the interface name, removing " " characters and avoid "blank" interfaces if (!isset($interface['ifName']) || $interface['ifName']['value'] == "") continue; $interfaces_list[$interface['ifIndex']['value']] = str_replace ( "\"" , "" , $interface['ifName']['value']); } echo '
'; echo "