array(), NOERR => array()); if (empty($names)) { return array(); } foreach($names as $name) { // Add query to wmi_command switch ($wizard_mode) { case 'services': $wmi_query = 'SELECT state FROM Win32_Service WHERE Name="' . io_safe_output($name) . '"'; break; case 'processes': $wmi_query = 'SELECT Name FROM Win32_Process WHERE Name="' . io_safe_output($name) . '"'; break; case 'disks': $wmi_query = 'SELECT Freespace FROM Win32_LogicalDisk WHERE DeviceID ="' . io_safe_output($name) . '"'; break; } // Add the query to values $values['snmp_oid'] = io_safe_input($wmi_query); $return = modules_create_agent_module ($id_agent, $name, $values); if($return < 0) { $results[ERR_GENERIC][] = $name; } else { $results[NOERR][] = $name; } } return $results; } function wmi_create_module_from_components($components, $values) { $results = array(ERR_GENERIC => array(), NOERR => array(), ERR_EXIST => array()); if (empty($components)) { return array(); } foreach ($components as $component_id) { $nc = db_get_row ("tnetwork_component", "id_nc", $component_id); // Compatibilize the fields between components and modules table $nc['descripcion'] = $nc['description']; unset($nc['description']); $nc['nombre'] = $nc['name']; unset($nc['name']); $nc['id_tipo_modulo'] = $nc['type']; unset($nc['type']); unset($nc['id_nc']); unset($nc['id_group']); // Store the passed values with the component values foreach ($values as $k => $v) { $nc[$k] = $v; } // Put tags in array if the component has to add them later if(!empty($nc['tags'])) { $tags = explode(',', $nc['tags']); } else { $tags = array(); } unset($nc['tags']); // Check if this module exists in the agent $module_name_check = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('delete_pending' => 0, 'nombre' => $nc['nombre'], 'id_agente' => $nc['id_agente'])); if ($module_name_check !== false) { $results[ERR_EXIST][] = $nc["nombre"]; } else { $id_agente_modulo = modules_create_agent_module($nc["id_agente"], $nc["nombre"], $nc); if ($id_agente_modulo === false) { $results[ERR_GENERIC][] = $nc["nombre"]; } else { if(!empty($tags)) { // Creating tags $tag_ids = array(); foreach ($tags as $tag_name) { $tag_id = tags_get_id($tag_name); //If tag exists in the system we store to create it $tag_ids[] = $tag_id; } tags_insert_module_tag ($id_agente_modulo, $tag_ids); } $results[NOERR][] = $nc["nombre"]; } } } return $results; } ?>