1<?php 2 3// Pandora FMS - http://pandorafms.com 4// ================================================== 5// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas 6// Please see http://pandorafms.org for full contribution list 7 8// This program is free software; you can redistribute it and/or 9// modify it under the terms of the GNU General Public License 10// as published by the Free Software Foundation for version 2. 11// This program is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14// GNU General Public License for more details. 15enterprise_include_once('include/functions_policies.php'); 16enterprise_include_once('godmode/agentes/module_manager_editor_prediction.php'); 17require_once ('include/functions_agents.php'); 18 19$disabledBecauseInPolicy = false; 20$disabledTextBecauseInPolicy = ''; 21$page = get_parameter('page', ''); 22$id_agente = get_parameter('id_agente', ''); 23$agent_name = get_parameter('agent_name', agents_get_name($id_agente)); 24$id_agente_modulo= get_parameter('id_agent_module',0); 25$custom_integer_2 = get_parameter ('custom_integer_2', 0); 26$sql = 'SELECT * 27 FROM tagente_modulo 28 WHERE id_agente_modulo = '.$id_agente_modulo; 29$row = db_get_row_sql($sql); 30$is_service = false; 31$is_synthetic = false; 32$is_synthetic_avg = false; 33$is_netflow = false; 34$ops = false; 35if ($row !== false && is_array($row)) { 36 $prediction_module = $row['prediction_module']; 37 $custom_integer_2 = $row ['custom_integer_2']; 38 // Services are an Enterprise feature. 39 $custom_integer_1 = $row['custom_integer_1']; 40 41 switch ($prediction_module) { 42 case MODULE_PREDICTION_SERVICE: 43 $is_service = true; 44 $custom_integer_2 = 0; 45 break; 46 case MODULE_PREDICTION_SYNTHETIC: 47 $ops_json = enterprise_hook('modules_get_synthetic_operations', 48 array($id_agente_modulo)); 49 50 51 $ops = json_decode($ops_json, true); 52 53 54 55 //Erase the key of array serialize as <num>** 56 $chunks = explode('**', reset(array_keys($ops))); 57 58 $first_op = explode('_', $chunks[1]); 59 60 61 62 if (isset($first_op[1]) && $first_op[1] == 'avg') { 63 $is_synthetic_avg = true; 64 } 65 else { 66 $is_synthetic = true; 67 } 68 69 $custom_integer_1 = 0; 70 $custom_integer_2 = 0; 71 break; 72 case MODULE_PREDICTION_NETFLOW: 73 $is_netflow = true; 74 $custom_integer_2 = 0; 75 break; 76 default: 77 $prediction_module = $custom_integer_1; 78 break; 79 } 80} 81else { 82 $custom_integer_1 = 0; 83} 84if (strstr($page, "policy_modules") === false) { 85 if ($config['enterprise_installed']) 86 $disabledBecauseInPolicy = policies_is_module_in_policy($id_agent_module) && policies_is_module_linked($id_agent_module); 87 else 88 $disabledBecauseInPolicy = false; 89 if ($disabledBecauseInPolicy) 90 $disabledTextBecauseInPolicy = 'disabled = "disabled"'; 91} 92 93$extra_title = __('Prediction server module'); 94 95$data = array (); 96$data[0] = __('Source module'); 97$data[0] .= ui_print_help_icon ('prediction_source_module', true); 98$data[1] = ''; 99// Services and Synthetic are an Enterprise feature. 100$module_service_synthetic_selector = enterprise_hook('get_module_service_synthetic_selector', array($is_service, $is_synthetic, $is_synthetic_avg, $is_netflow)); 101if ($module_service_synthetic_selector !== ENTERPRISE_NOT_HOOK) { 102 $data[1] = $module_service_synthetic_selector; 103 104 $table_simple->colspan['module_service_synthetic_selector'][1] = 3; 105 push_table_simple ($data, 'module_service_synthetic_selector'); 106 107 $data = array(); 108 $data[0] = ''; 109} 110 111 112 113 114$data[1] = '<div id="module_data" style="top:1em; float:left; width:50%;">'; 115$data[1] .= html_print_label(__("Agent"),'agent_name', true)."<br/>"; 116 117$params = array(); 118$params['return'] = true; 119$params['show_helptip'] = true; 120$params['input_name'] = 'agent_name'; 121$params['value'] = $agent_name; 122$params['javascript_is_function_select'] = true; 123$params['selectbox_id'] = 'prediction_module'; 124$params['none_module_text'] = __('Select Module'); 125$params['use_hidden_input_idagent'] = true; 126$params['hidden_input_idagent_id'] = 'hidden-id_agente'; 127$data[1] .= ui_print_agent_autocomplete_input($params); 128 129// Get module and agent of the target prediction module 130if (!empty($prediction_module)) { 131 $id_agente_clean = modules_get_agentmodule_agent($prediction_module); 132 $prediction_module_agent = modules_get_agentmodule_agent_name($prediction_module); 133 $agent_name_clean = $prediction_module_agent; 134} 135else { 136 $id_agente_clean = $id_agente; 137 $agent_name_clean = $agent_name; 138} 139 140$data[1] .= html_print_label(__("Module"),'prediction_module',true); 141if ($id_agente) { 142 $sql = "SELECT id_agente_modulo, nombre 143 FROM tagente_modulo 144 WHERE delete_pending = 0 145 AND history_data = 1 146 AND id_agente = " . $id_agente_clean . " 147 AND id_agente_modulo <> " . $id_agente_modulo; 148 $data[1] .= html_print_select_from_sql($sql, 'prediction_module', 149 $prediction_module, false, __('Select Module'), 0, true); 150} 151else { 152 $data[1] .= '<select id="prediction_module" name="custom_integer_1" disabled="disabled"><option value="0">Select an Agent first</option></select>'; 153} 154 155$data[1] .= html_print_label(__("Period"), 'custom_integer_2', true)."<br/>"; 156 157$periods [0] = __('Weekly'); 158$periods [1] = __('Monthly'); 159$periods [2] = __('Daily'); 160$data[1] .= html_print_select ($periods, 'custom_integer_2', $custom_integer_2, '', '', 0, true); 161 162$data[1] .= html_print_input_hidden ('id_agente', $id_agente, true); 163$data[1] .= '</div>'; 164 165$table_simple->colspan['prediction_module'][1] = 3; 166push_table_simple ($data, 'prediction_module'); 167 168// Services are an Enterprise feature. 169$selector_form = enterprise_hook('get_selector_form', array($custom_integer_1)); 170if ($selector_form !== ENTERPRISE_NOT_HOOK) { 171 $data = array(); 172 $data[0] = ''; 173 $data[1] = $selector_form; 174 175 $table_simple->colspan['service_module'][1] = 3; 176 push_table_simple ($data, 'service_module'); 177} 178 179// Synthetic modules are an Enterprise feature. 180$synthetic_module_form = enterprise_hook ('get_synthetic_module_form'); 181if ($synthetic_module_form !== ENTERPRISE_NOT_HOOK) { 182 $data = array(); 183 $data[0] = ''; 184 $data[1] = $synthetic_module_form; 185 186 $table_simple->colspan['synthetic_module'][1] = 3; 187 push_table_simple ($data, 'synthetic_module'); 188} 189 190// Netflow modules are an Enterprise feature. 191$netflow_module_form = enterprise_hook ('get_netflow_module_form', array($custom_integer_1)); 192if ($netflow_module_form !== ENTERPRISE_NOT_HOOK) { 193 $data = array(); 194 $data[0] = ''; 195 $data[1] = $netflow_module_form; 196 197 $table_simple->colspan['netflow_module_form'][1] = 3; 198 push_table_simple ($data, 'netflow_module'); 199} 200 201 202 203 204/* Removed common useless parameter */ 205unset ($table_advanced->data[3]); 206?> 207<script type="text/javascript"> 208 $(document).ready(function() { 209 <?php 210 enterprise_hook('setup_services_synth', 211 array($is_service, $is_synthetic, $is_synthetic_avg, $is_netflow, $ops)); 212 ?> 213 }); 214</script>