$id_agente,
'id_tipo_modulo' => $row2["type"],
'descripcion' => __('Created by template ').$name_template. ' . '.$row2["description"],
'nombre' => $row2["name"],
'max' => $row2["max"],
'min' => $row2["min"],
'module_interval' => $row2["module_interval"],
'tcp_port' => $row2["tcp_port"],
'tcp_send' => $row2["tcp_send"],
'tcp_rcv' => $row2["tcp_rcv"],
'snmp_community' => $row2["snmp_community"],
'snmp_oid' => $row2["snmp_oid"],
'ip_target' => $direccion_agente,
'id_module_group' => $row2["id_module_group"],
'id_modulo' => $row2["id_modulo"],
'plugin_user' => $row2["plugin_user"],
'plugin_pass' => $row2["plugin_pass"],
'plugin_parameter' => $row2["plugin_parameter"],
'max_timeout' => $row2["max_timeout"],
'max_retries' => $row2["max_retries"],
'id_plugin' => $row2['id_plugin'],
'post_process' => $row2['post_process'],
'min_warning' => $row2['min_warning'],
'max_warning' => $row2['max_warning'],
'str_warning' => $row2['str_warning'],
'min_critical' => $row2['min_critical'],
'max_critical' => $row2['max_critical'],
'str_critical' => $row2['str_critical'],
'critical_inverse' => $row2['critical_inverse'],
'warning_inverse' => $row2['warning_inverse'],
'critical_instructions' => $row2['critical_instructions'],
'warning_instructions' => $row2['warning_instructions'],
'unknown_instructions' => $row2['unknown_instructions']
);
// 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' => $row2["name"], 'id_agente' => $id_agente));
if ($module_name_check !== false) {
$modules_already_added[] = $row2["name"];
$error_count++;
}
else {
$id_agente_modulo = db_process_sql_insert('tagente_modulo', $values);
// Set the initial module status
if ($row2["type"] == 21 || $row2["type"] == 22 || $row2["type"] == 23) {
$status = 0;
} else {
$status = 4;
}
// Create with different estado if proc type or data type
if ($id_agente_modulo !== false) {
$success_count++;
$values = array(
'id_agente_modulo' => $id_agente_modulo,
'datos' => 0,
'timestamp' => '01-01-1970 00:00:00',
'estado' => $status,
'id_agente' => $id_agente,
'utimestamp' => 0);
db_process_sql_insert('tagente_estado', $values);
// Update module status count
if ($status == 4) {
db_process_sql ('UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente=' . (int)$id_agente);
} else {
db_process_sql ('UPDATE tagente SET total_count=total_count+1, normal_count=normal_count+1 WHERE id_agente=' . (int)$id_agente);
}
}
else
$error_count++;
}
}
}
if ($error_count > 0) {
if (empty($modules_already_added))
ui_print_error_message(__('Error adding modules') . sprintf(' (%s)', $error_count));
else
ui_print_error_message(__('Error adding modules. The following errors already exists: ') . implode(', ', $modules_already_added));
}
if ($success_count > 0)
ui_print_success_message(__('Modules successfully added'));
}
// Main header
// ==========================
// TEMPLATE ASSIGMENT FORM
// ==========================
echo "
";
echo '