2009-02-02 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/configurar_agente.php, godmode/agentes/module_manager.php, godmode/agentes/module_manager_editor.php, godmode/agentes/module_manager_editor_data.php, godmode/agentes/module_manager_editor_network.php, godmode/agentes/module_manager_editor_plugin.php, godmode/agentes/module_manager_editor_prediction.php, godmode/agentes/module_manager_editor_wmi.php: Agent module editions rewritten. The interface should be clearer now and SNMP walking much more faster, since it's done with AJAX. Some cleanup might be needed yet. * godmode/agentes/module_manager_editor_common.php: Added to repository. Common part for agent module editors. * images/edit.png, images/spinner.gif: Added to repository. * include/javascript/jquery.form.js: Added to repository. jQuery form plugin. * include/javascript/jquery.pandora.js: Added to repository. Special Pandora addons for jQuery library. * include/javascript/pandora.js: Added an extension to Array javascript objects to check if an array has an element. * include/styles/pandora.css: Added styling for new module editors. * include/functions_db.php: Added get_moduletype_description(). * index.php: Added Pandora jQuery extensions. * pandoradb.sql, pandoradb_migrate_20_to_21.sql: Removed alert_text useless field from talert_templates. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1417 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
dc83eaee30
commit
f7e49b71d3
|
@ -1,3 +1,40 @@
|
|||
2009-02-02 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* godmode/agentes/configurar_agente.php,
|
||||
godmode/agentes/module_manager.php,
|
||||
godmode/agentes/module_manager_editor.php,
|
||||
godmode/agentes/module_manager_editor_data.php,
|
||||
godmode/agentes/module_manager_editor_network.php,
|
||||
godmode/agentes/module_manager_editor_plugin.php,
|
||||
godmode/agentes/module_manager_editor_prediction.php,
|
||||
godmode/agentes/module_manager_editor_wmi.php: Agent module editions
|
||||
rewritten. The interface should be clearer now and SNMP walking much
|
||||
more faster, since it's done with AJAX. Some cleanup might be needed
|
||||
yet.
|
||||
|
||||
* godmode/agentes/module_manager_editor_common.php: Added to
|
||||
repository. Common part for agent module editors.
|
||||
|
||||
* images/edit.png, images/spinner.gif: Added to repository.
|
||||
|
||||
* include/javascript/jquery.form.js: Added to repository. jQuery form
|
||||
plugin.
|
||||
|
||||
* include/javascript/jquery.pandora.js: Added to repository. Special
|
||||
Pandora addons for jQuery library.
|
||||
|
||||
* include/javascript/pandora.js: Added an extension to Array
|
||||
javascript objects to check if an array has an element.
|
||||
|
||||
* include/styles/pandora.css: Added styling for new module editors.
|
||||
|
||||
* include/functions_db.php: Added get_moduletype_description().
|
||||
|
||||
* index.php: Added Pandora jQuery extensions.
|
||||
|
||||
* pandoradb.sql, pandoradb_migrate_20_to_21.sql: Removed alert_text
|
||||
useless field from talert_templates.
|
||||
|
||||
2009-01-30 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||
|
||||
* include/config.inc.php: Updated documentation on LDAP implementation.
|
||||
|
|
|
@ -35,12 +35,10 @@ if (! give_acl($config["id_user"], $group, "AW")) {
|
|||
exit;
|
||||
}
|
||||
|
||||
|
||||
// Get passed variables
|
||||
$tab = get_parameter_get ("tab", "main");
|
||||
$form_moduletype = get_parameter_post ("form_moduletype");
|
||||
$form_alerttype = get_parameter ("form_alerttype");
|
||||
$moduletype = get_parameter_get ("moduletype");
|
||||
$tab = get_parameter ('tab', 'main');
|
||||
$alerttype = get_parameter ('alerttype');
|
||||
$id_agent_module = (int) get_parameter ('id_agent_module');
|
||||
|
||||
// Init vars
|
||||
$descripcion = "";
|
||||
|
@ -51,7 +49,7 @@ $campo_3 = "";
|
|||
$maximo = 0;
|
||||
$minimo = 0;
|
||||
$nombre_agente = "";
|
||||
$direccion_agente = get_parameter ("direccion", "");
|
||||
$direccion_agente = get_parameter ('direccion');
|
||||
$intervalo = 300;
|
||||
$id_server = "";
|
||||
$max_alerts = 0;
|
||||
|
@ -108,26 +106,24 @@ $grupo = 0;
|
|||
$id_os = 0;
|
||||
$custom_id = "";
|
||||
|
||||
// ================================
|
||||
// Create AGENT
|
||||
// ================================
|
||||
// We need to create agent BEFORE showing tabs, because we need to get agent_id
|
||||
// This is not very clean, but...
|
||||
if (isset ($_POST["create_agent"])) { // Create a new and shiny agent
|
||||
$nombre_agente = get_parameter_post ("agente", "");
|
||||
$direccion_agente = get_parameter_post ("direccion", "");
|
||||
$grupo = get_parameter_post ("grupo", 0);
|
||||
$intervalo = get_parameter_post ("intervalo", 300);
|
||||
$comentarios = get_parameter_post ("comentarios", "");
|
||||
$modo = get_parameter_post ("modo", 0);
|
||||
$id_parent = get_parameter_post ("id_parent", 0);
|
||||
$id_network_server = get_parameter_post ("network_server", 0);
|
||||
$id_plugin_server = get_parameter_post ("plugin_server", 0);
|
||||
$id_prediction_server = get_parameter_post ("prediction_server", 0);
|
||||
$id_wmi_server = get_parameter_post ("wmi_server", 0);
|
||||
$id_os = get_parameter_post ("id_os", 0);
|
||||
$disabled = get_parameter_post ("disabled", 0);
|
||||
$custom_id = get_parameter_post ("custom_id", "");
|
||||
$create_agent = (bool) get_parameter ('create_agent');
|
||||
|
||||
// Create agent
|
||||
if ($create_agent) {
|
||||
$nombre_agente = (string) get_parameter_post ("agente");
|
||||
$direccion_agente = (string) get_parameter_post ("direccion");
|
||||
$grupo = (int) get_parameter_post ("grupo");
|
||||
$intervalo = (string) get_parameter_post ("intervalo", 300);
|
||||
$comentarios = (string)get_parameter_post ("comentarios");
|
||||
$modo = (int) get_parameter_post ("modo");
|
||||
$id_parent = (int) get_parameter_post ("id_parent");
|
||||
$id_network_server = (int) get_parameter_post ("network_server");
|
||||
$id_plugin_server = (int) get_parameter_post ("plugin_server");
|
||||
$id_prediction_server = (int) get_parameter_post ("prediction_server");
|
||||
$id_wmi_server = (int) get_parameter_post ("wmi_server");
|
||||
$id_os = (int) get_parameter_post ("id_os");
|
||||
$disabled = (int) get_parameter_post ("disabled");
|
||||
$custom_id = (string) get_parameter_post ("custom_id");
|
||||
|
||||
// Check if agent exists (BUG WC-50518-2)
|
||||
if ($nombre_agente == "") {
|
||||
|
@ -137,65 +133,72 @@ if (isset ($_POST["create_agent"])) { // Create a new and shiny agent
|
|||
$agent_creation_error = __('There is already an agent in the database with this name');
|
||||
$agent_created_ok = 0;
|
||||
} else {
|
||||
$sql = sprintf ("INSERT INTO tagente
|
||||
(nombre, direccion, id_grupo, intervalo, comentarios, modo, id_os, disabled, id_network_server, id_plugin_server, id_wmi_server, id_prediction_server, id_parent, custom_id)
|
||||
VALUES
|
||||
('%s', '%s', %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d, '%s')",
|
||||
$nombre_agente, $direccion_agente, $grupo, $intervalo, $comentarios, $modo, $id_os, $disabled, $id_network_server, $id_plugin_server, $id_wmi_server, $id_prediction_server, $id_parent, $custom_id);
|
||||
$id_agente = process_sql ($sql, "insert_id");
|
||||
$id_agente = process_sql_insert ('tagente',
|
||||
array ('nombre' => $nombre_agente,
|
||||
'direccion' => $direccion_agente,
|
||||
'id_grupo' => $grupo, 'intervalo' => $intervalo,
|
||||
'comentarios' => $comentarios, 'modo' => $modo,
|
||||
'id_os' => $id_os, 'disabled' => $disabled,
|
||||
'id_network_server' => $id_network_server,
|
||||
'id_plugin_server' => $id_plugin_server,
|
||||
'id_wmi_server' => $id_wmi_server,
|
||||
'id_prediction_server' => $id_prediction_server,
|
||||
'id_parent' => $id_parent, 'custom_id' => $custom_id));
|
||||
enterprise_hook ('update_agent', array ($id_agente));
|
||||
if ($id_agente !== false) {
|
||||
$agent_created_ok = 1;
|
||||
$agent_creation_error = "";
|
||||
// Create address for this agent in taddress
|
||||
agent_add_address ($id_agente, $direccion_agente);
|
||||
|
||||
$agent_created_ok = true;
|
||||
|
||||
// Create special module agent_keepalive
|
||||
$sql = "INSERT INTO tagente_modulo
|
||||
(nombre, id_agente, id_tipo_modulo, descripcion, id_modulo,min_warning, max_warning )
|
||||
VALUES
|
||||
('agent_keepalive',".$id_agente.",100,'Agent Keepalive monitor',1 ,0,1)";
|
||||
$id_agent_module = process_sql ($sql, "insert_id");
|
||||
$id_agent_module = process_sql_insert ('tagente_modulo',
|
||||
array ('nombre' => 'agent_keepalive',
|
||||
'id_agente' => $id_agente,
|
||||
'id_tipo_modulo' => 100,
|
||||
'descripcion' => __('Ageng keepalive monitor'),
|
||||
'id_modulo' => 1,
|
||||
'min_warning' => 0,
|
||||
'max_warning' => 1));
|
||||
|
||||
if ($id_agent_module !== false) {
|
||||
// Create agent_keepalive in tagente_estado table
|
||||
$sql = "INSERT INTO tagente_estado
|
||||
(id_agente_modulo, datos, timestamp, estado, id_agente, last_try, utimestamp, current_interval, running_by, last_execution_try)
|
||||
VALUES
|
||||
(".$id_agent_module.",'',0,0,".$id_agente.",0,0,0,0,0)";
|
||||
$result = process_sql ($sql);
|
||||
if ($result === false) {
|
||||
$agent_created_ok = 0;
|
||||
// Do not translate tagente_estado, is the table name
|
||||
$agent_creation_error = __("There was a problem creating record in tagente_estado table");
|
||||
}
|
||||
$result = process_sql_insert ('tagente_modulo',
|
||||
array ('id_agente_modulo' => $id_agent_module,
|
||||
'datos' => '',
|
||||
'timestamp' => 0,
|
||||
'estado' => 0,
|
||||
'id_agente' => $id_agente,
|
||||
'last_try' => 0,
|
||||
'utimestamp' => 0,
|
||||
'current_interval' => 0,
|
||||
'running_by' => 0,
|
||||
'last_execution_try' => 0));
|
||||
if ($result === false)
|
||||
$agent_created_ok = false;
|
||||
} else {
|
||||
$agent_created_ok = 0;
|
||||
$agent_creation_error = __("There was a problem creating agent_keepalive module");
|
||||
$agent_created_ok = false;
|
||||
}
|
||||
|
||||
// Create address for this agent in taddress
|
||||
agent_add_address ($id_agente, $direccion_agente);
|
||||
} else {
|
||||
$id_agente = -1;
|
||||
$agent_created_ok = 0;
|
||||
$agent_creation_error = __("There was a problem creating the agent");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show tabs
|
||||
// -----------------
|
||||
echo "<div id='menu_tab_frame'>";
|
||||
echo "<div id='menu_tab_left'><ul class='mn'>";
|
||||
echo "<li class='nomn'>";
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=$id_agente'>
|
||||
<img src='images/setup.png' class='top' border='0'> ".substr(get_agent_name ($id_agente),0,21)."</a>";
|
||||
<img src='images/setup.png' class='top'> ".substr(get_agent_name ($id_agente),0,21)."</a>";
|
||||
echo "</li>";
|
||||
echo "</ul></div>";
|
||||
|
||||
echo "<div id='menu_tab'><ul class='mn'>";
|
||||
|
||||
echo "<li class='nomn'>";
|
||||
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente'><img src='images/zoom.png' width='16' class='top' border='0'> ".__('View')."</a>";
|
||||
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente'><img src='images/zoom.png' width='16' class='top'> ".__('View')."</a>";
|
||||
echo "</li>";
|
||||
|
||||
if ($tab == "main") {
|
||||
|
@ -203,7 +206,7 @@ if ($tab == "main") {
|
|||
} else {
|
||||
echo "<li class='nomn'>";
|
||||
}
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente=$id_agente'><img src='images/cog.png' width='16' class='top' border='0'> ".__('Setup')."</a>";
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente=$id_agente'><img src='images/cog.png' width='16' class='top'> ".__('Setup')."</a>";
|
||||
echo "</li>";
|
||||
|
||||
if ($tab == "module") {
|
||||
|
@ -211,7 +214,7 @@ if ($tab == "module") {
|
|||
} else {
|
||||
echo "<li class='nomn'>";
|
||||
}
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente=$id_agente'><img src='images/lightbulb.png' width='16' class='top' border='0'> ".__('Modules')."</a>";
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente=$id_agente'><img src='images/lightbulb.png' width='16' class='top'> ".__('Modules')."</a>";
|
||||
echo "</li>";
|
||||
|
||||
if ($tab == "alert") {
|
||||
|
@ -219,7 +222,7 @@ if ($tab == "alert") {
|
|||
} else {
|
||||
echo "<li class='nomn'>";
|
||||
}
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente=$id_agente'><img src='images/bell.png' width='16' class='top' border='0'> ". __('Alerts')."</a>";
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente=$id_agente'><img src='images/bell.png' width='16' class='top'> ". __('Alerts')."</a>";
|
||||
echo "</li>";
|
||||
|
||||
if ($tab == "template") {
|
||||
|
@ -237,13 +240,14 @@ echo "</div>";
|
|||
echo "</div>"; // menu_tab_frame
|
||||
|
||||
// Make some space between tabs and title
|
||||
echo "<div style='height: 25px'> </div>"; //Some browsers (IE) might not always show an empty div, added space
|
||||
// IE might not always show an empty div, added space
|
||||
echo "<div style='height: 25px'> </div>";
|
||||
|
||||
// Show agent creation results
|
||||
if (isset ($_POST["create_agent"])) {
|
||||
if ($agent_created_ok == 0){
|
||||
if ($create_agent) {
|
||||
if (! $agent_created_ok) {
|
||||
echo "<h3 class='error'>".__('There was a problem creating agent')."</h3>";
|
||||
echo $agent_creation_error;
|
||||
echo __('There was a problem creating agent_keepalive module');
|
||||
} else {
|
||||
echo "<h3 class='suc'>".__('Agent successfully created')."</h3>";
|
||||
}
|
||||
|
@ -290,11 +294,12 @@ if (isset($_GET["delete_alert_comp"])) { // if modified some parameter
|
|||
|
||||
// Combined ALERT - Add component
|
||||
// ================================
|
||||
if (isset($_POST["add_alert_combined"])){ // Update an existing alert
|
||||
$alerta_id_aam = get_parameter ("update_alert",-1);
|
||||
$component_item = get_parameter ("component_item",-1);
|
||||
$component_operation = get_parameter ("component_operation","AND");
|
||||
$sql = sprintf ("INSERT INTO tcompound_alert (id, id_aam, operation) VALUES (%d, %d, '%s')", $alerta_id_aam, $component_item, $component_operation);
|
||||
if (isset($_POST["add_alert_combined"])) { // Update an existing alert
|
||||
$alerta_id_aam = get_parameter ('update_alert', -1);
|
||||
$component_item = get_parameter ('component_item', -1);
|
||||
$component_operation = get_parameter ('component_operation', 'AND');
|
||||
$sql = sprintf ("INSERT INTO tcompound_alert (id, id_aam, operation) VALUES (%d, %d, '%s')",
|
||||
$alerta_id_aam, $component_item, $component_operation);
|
||||
$result = process_sql ($sql);
|
||||
if ($result === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem creating the combined alert').'</h3>';
|
||||
|
@ -376,9 +381,9 @@ if ((isset($agent_created_ok)) && ($agent_created_ok == 1)){
|
|||
|
||||
// Read agent data
|
||||
// This should be at the end of all operation checks, to read the changess
|
||||
if (isset($_GET["id_agente"])) {
|
||||
if (isset($_REQUEST["id_agente"])) {
|
||||
//This has been done in the beginning of the page, but if an agent was created, this id might change
|
||||
$id_agente = get_parameter_get ("id_agente");
|
||||
$id_agente = (int) get_parameter ('id_agente');
|
||||
$id_grupo = dame_id_grupo ($id_agente);
|
||||
if (give_acl ($config["id_user"], $id_grupo, "AW") != 1) {
|
||||
audit_db($config["id_user"],$REMOTE_ADDR, "ACL Violation","Trying to admin an agent without access");
|
||||
|
@ -390,10 +395,7 @@ if (isset($_GET["id_agente"])) {
|
|||
if (empty ($agent)) {
|
||||
//Close out the page
|
||||
echo '<h3 class="error">'.__('There was a problem loading agent').'</h3>';
|
||||
echo '</table></div><div id="foot">';
|
||||
include ("general/footer.php");
|
||||
echo "</div>";
|
||||
exit;
|
||||
return;
|
||||
}
|
||||
|
||||
$intervalo = $agent["intervalo"]; // Define interval in seconds
|
||||
|
@ -413,194 +415,140 @@ if (isset($_GET["id_agente"])) {
|
|||
$custom_id = $agent["custom_id"];
|
||||
}
|
||||
|
||||
// Read data module if editing module
|
||||
// ==================================
|
||||
if ((isset ($_GET["update_module"])) && (!isset ($_POST["oid"])) && (!isset ($_POST["update_module"]))) {
|
||||
$update_module = 1;
|
||||
$id_agente_modulo = (int) get_parameter_get ("update_module",0);
|
||||
|
||||
$module = get_db_row ('tagente_modulo', 'id_agente_modulo', $id_agente_modulo);
|
||||
|
||||
if ($module === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem loading the module').'</h3>';
|
||||
} else {
|
||||
$modulo_id_agente = $module["id_agente"];
|
||||
$modulo_id_tipo_modulo = $module["id_tipo_modulo"];
|
||||
$modulo_nombre = $module["nombre"];
|
||||
$modulo_descripcion = $module["descripcion"];
|
||||
$tcp_send = $module["tcp_send"];
|
||||
$tcp_rcv = $module["tcp_rcv"];
|
||||
$ip_target = $module["ip_target"];
|
||||
$snmp_community = $module["snmp_community"];
|
||||
$snmp_oid = $module["snmp_oid"];
|
||||
$id_module_group = $module["id_module_group"];
|
||||
$module_interval = $module["module_interval"];
|
||||
$modulo_max = $module["max"];
|
||||
if (empty ($modulo_max))
|
||||
$modulo_max = "N/A";
|
||||
if (empty ($modulo_min))
|
||||
$modulo_min = "N/A";
|
||||
$custom_id = $module["custom_id"];
|
||||
}
|
||||
}
|
||||
$update_module = (bool) get_parameter ('update_module');
|
||||
$create_module = (bool) get_parameter ('create_module');
|
||||
$edit_module = (bool) get_parameter ('edit_module');
|
||||
|
||||
// GET DATA for MODULE UPDATE OR MODULE INSERT
|
||||
// ===========================================
|
||||
if ((isset ($_POST["update_module"])) || (isset ($_POST["insert_module"]))) {
|
||||
if (isset ($_POST["update_module"])) {
|
||||
$update_module = 1;
|
||||
$id_agente_modulo = get_parameter_post ("id_agente_modulo",0);
|
||||
}
|
||||
|
||||
if ($update_module || $create_module) {
|
||||
$id_grupo = dame_id_grupo ($id_agente);
|
||||
|
||||
if (give_acl ($config["id_user"], $id_grupo, "AW") == 0) {
|
||||
audit_db ($config["id_user"],$REMOTE_ADDR, "ACL Violation","Trying to create a module without admin rights");
|
||||
if (! give_acl ($config["id_user"], $id_grupo, "AW")) {
|
||||
audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to create a module without admin rights");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
$form_id_tipo_modulo = (int) get_parameter ("form_id_tipo_modulo",0);
|
||||
$form_name = (string) get_parameter ("form_name",0);
|
||||
$form_description = (string) get_parameter ("form_description","");
|
||||
$form_id_module_group = (int) get_parameter ("form_id_module_group",0);
|
||||
$form_flag = (bool) get_parameter ("form_flag",0);
|
||||
$form_post_process = (float) get_parameter ("form_post_process",0);
|
||||
$form_prediction_module = (int) get_parameter ("form_prediction_module",0);
|
||||
$form_max_timeout = (int) get_parameter ("form_max_timeout",0);
|
||||
$form_minvalue = (int) get_parameter_post ("form_minvalue",0);
|
||||
$form_maxvalue = (int) get_parameter ("form_maxvalue",0);
|
||||
$form_interval = (int) get_parameter ("form_interval",300);
|
||||
$form_id_prediction_module = (int) get_parameter ("form_id_prediction_module",0);
|
||||
$form_id_plugin = (int) get_parameter ("form_id_plugin",0);
|
||||
$form_id_export = (int) get_parameter ("form_id_export",0);
|
||||
$form_disabled = (bool) get_parameter ("form_disabled",0);
|
||||
$form_tcp_send = (string) get_parameter ("form_tcp_send","");
|
||||
$form_tcp_rcv = (string) get_parameter ("form_tcp_rcv","");
|
||||
$form_tcp_port = (int) get_parameter ("form_tcp_port",0);
|
||||
$form_snmp_community = (string) get_parameter ("form_snmp_community","");
|
||||
$form_snmp_oid = (string) get_parameter ("form_snmp_oid","");
|
||||
$form_ip_target = (string) get_parameter ("form_ip_target","");
|
||||
$form_plugin_user = (string) get_parameter ("form_plugin_user","");
|
||||
$form_plugin_pass = (string) get_parameter ("form_plugin_pass","");
|
||||
$form_plugin_parameter = (string) get_parameter ("form_plugin_parameter","");
|
||||
$form_id_modulo = (int) get_parameter ("form_id_modulo",0);
|
||||
$form_custom_id = (string) get_parameter ("form_custom_id","");
|
||||
$form_history_data = (int) get_parameter('form_history_data',0);
|
||||
$form_min_warning = (float) get_parameter ('form_min_warning', 0);
|
||||
$form_max_warning = (float) get_parameter ('form_max_warning', 0);
|
||||
$form_min_critical = (float) get_parameter ('form_min_critical', 0);
|
||||
$form_max_critical = (float) get_parameter ('form_max_critical', 0);
|
||||
$form_ff_event = (int) get_parameter ('form_ff_event', 0);
|
||||
$id_module_type = (int) get_parameter ('id_module_type');
|
||||
$name = (string) get_parameter ('name');
|
||||
$description = (string) get_parameter ('description');
|
||||
$id_module_group = (int) get_parameter ('id_module_group');
|
||||
$flag = (bool) get_parameter ('flag');
|
||||
$post_process = (float) get_parameter ('post_process');
|
||||
$prediction_module = (int) get_parameter ('prediction_module');
|
||||
$max_timeout = (int) get_parameter ('max_timeout');
|
||||
$minvalue = (int) get_parameter_post ("minvalue");
|
||||
$maxvalue = (int) get_parameter ('maxvalue');
|
||||
$interval = (int) get_parameter ("interval", 300);
|
||||
$id_prediction_module = (int) get_parameter ('id_prediction_module');
|
||||
$id_plugin = (int) get_parameter ('id_plugin');
|
||||
$id_export = (int) get_parameter ('id_export');
|
||||
$disabled = (bool) get_parameter ('disabled');
|
||||
$tcp_send = (string) get_parameter ('tcp_send');
|
||||
$tcp_rcv = (string) get_parameter ('tcp_rcv');
|
||||
$tcp_port = (int) get_parameter ('tcp_port');
|
||||
$snmp_community = (string) get_parameter ('snmp_community');
|
||||
$snmp_oid = (string) get_parameter ('snmp_oid');
|
||||
if (empty ($snmp_oid)) {
|
||||
/* The user did not set any OID manually but did a SNMP walk */
|
||||
$snmp_oid = (string) get_parameter ('select_snmp_oid');
|
||||
}
|
||||
$ip_target = (string) get_parameter ('ip_target');
|
||||
$plugin_user = (string) get_parameter ('plugin_user');
|
||||
$plugin_pass = (string) get_parameter ('plugin_pass');
|
||||
$plugin_parameter = (string) get_parameter ('plugin_parameter');
|
||||
$custom_id = (string) get_parameter ('custom_id');
|
||||
$history_data = (int) get_parameter('history_data');
|
||||
$min_warning = (float) get_parameter ('min_warning');
|
||||
$max_warning = (float) get_parameter ('max_warning');
|
||||
$min_critical = (float) get_parameter ('min_critical');
|
||||
$max_critical = (float) get_parameter ('max_critical');
|
||||
$ff_event = (int) get_parameter ('ff_event');
|
||||
}
|
||||
|
||||
// MODULE UPDATE
|
||||
// =================
|
||||
if ((isset ($_POST["update_module"])) && (!isset ($_POST["oid"]))) { // if modified something
|
||||
if (isset ($_POST["form_combo_snmp_oid"])) {
|
||||
$form_combo_snmp_oid = get_parameter_post ("form_combo_snmp_oid");
|
||||
if ($snmp_oid == "") {
|
||||
$snmp_oid = $form_combo_snmp_oid;
|
||||
}
|
||||
}
|
||||
if ($update_module) {
|
||||
$id_agent_module = (int) get_parameter ('id_agent_module');
|
||||
|
||||
$sql = sprintf ("UPDATE tagente_modulo SET
|
||||
descripcion = '%s',
|
||||
id_module_group = %d,
|
||||
nombre = '%s',
|
||||
max = %d,
|
||||
min = %d,
|
||||
module_interval = %d,
|
||||
tcp_port = %d,
|
||||
tcp_send = '%s',
|
||||
tcp_rcv = '%s',
|
||||
snmp_community = '%s',
|
||||
snmp_oid = '%s',
|
||||
ip_target = '%s',
|
||||
flag = %d,
|
||||
id_modulo = %d,
|
||||
disabled = %d,
|
||||
id_export = %d,
|
||||
plugin_user = '%s',
|
||||
plugin_pass = '%s',
|
||||
plugin_parameter = '%s',
|
||||
id_plugin = %d,
|
||||
post_process = %f,
|
||||
prediction_module = %d,
|
||||
max_timeout = %d,
|
||||
custom_id = '%s',
|
||||
history_data = %d,
|
||||
min_warning = %f,
|
||||
max_warning = %f,
|
||||
min_critical = %f,
|
||||
max_critical = %f,
|
||||
min_ff_event = %d
|
||||
WHERE id_agente_modulo = %d", $form_description, $form_id_module_group, $form_name, $form_maxvalue, $form_minvalue, $form_interval, $form_tcp_port, $form_tcp_send, $form_tcp_rcv,
|
||||
$form_snmp_community, $form_snmp_oid, $form_ip_target, $form_flag, $form_id_modulo, $form_disabled, $form_id_export, $form_plugin_user, $form_plugin_pass,
|
||||
$form_plugin_parameter, $form_id_plugin, $form_post_process, $form_prediction_module, $form_max_timeout, $form_custom_id, $form_history_data, $form_min_warning, $form_max_warning, $form_min_critical, $form_max_critical, $form_ff_event, $id_agente_modulo);
|
||||
process_sql_update ('tagente_modulo',
|
||||
array ('descripcion' => $description,
|
||||
'id_module_group' => $id_module_group, 'nombre' => $name,
|
||||
'max' => $maxvalue, 'min' => $minvalue, 'module_interval' => $interval,
|
||||
'tcp_port' => $tcp_port, 'tcp_send' => $tcp_send,
|
||||
'tcp_rcv' => $tcp_rcv, 'snmp_community' => $snmp_community,
|
||||
'snmp_oid' => $snmp_oid, 'ip_target' => $ip_target,
|
||||
'flag' => $flag, 'disabled' => $disabled,
|
||||
'id_export' => $id_export, 'plugin_user' => $plugin_user,
|
||||
'plugin_pass' => $plugin_pass, 'plugin_parameter' => $plugin_parameter,
|
||||
'id_plugin' => $id_plugin, 'post_process' => $post_process,
|
||||
'prediction_module' => $prediction_module,
|
||||
'max_timeout' => $max_timeout, 'custom_id' => $custom_id,
|
||||
'history_data' => $history_data,
|
||||
'min_warning' => $min_warning, 'max_warning' => $max_warning,
|
||||
'min_critical' => $min_critical, 'max_critical' => $max_critical,
|
||||
'min_ff_event' => $ff_event
|
||||
),
|
||||
'id_agente_modulo = '.$id_agent_module);
|
||||
$result = process_sql ($sql);
|
||||
|
||||
if ($result === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem updating module').'</h3>';
|
||||
} else {
|
||||
echo '<h3 class="suc">'.__('Module successfully updated').'</h3>';
|
||||
}
|
||||
|
||||
}
|
||||
// =========================================================
|
||||
// OID Refresh button to get SNMPWALK from data in form
|
||||
// This code is also applied when submitting a new module (insert_module = 1)
|
||||
// =========================================================
|
||||
if (isset ($_POST["oid"])){
|
||||
snmp_set_quick_print (1);
|
||||
$snmpwalk = snmprealwalk ($form_ip_target, $form_snmp_community, '');
|
||||
|
||||
if (empty ($snmpwalk)) {
|
||||
echo '<h3 class="error">'.__('Cannot read from SNMP source').'</h3>';
|
||||
} else {
|
||||
echo '<h3 class="suc">'.__('SNMP source has been scanned').'</h3>';
|
||||
$id_agent_module = false;
|
||||
$edit_module = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// =========================================================
|
||||
// MODULE INSERT
|
||||
// =========================================================
|
||||
|
||||
if (((!isset ($_POST["nc"]) OR ($_POST["nc"] == -1))) && (!isset ($_POST["oid"])) && (isset ($_POST["insert_module"])) && (isset ($_POST['crtbutton']))) {
|
||||
|
||||
if (isset ($_POST["form_combo_snmp_oid"])) {
|
||||
$combo_snmp_oid = get_parameter_post ("form_combo_snmp_oid");
|
||||
if ($create_module) {
|
||||
if (isset ($_POST["combo_snmp_oid"])) {
|
||||
$combo_snmp_oid = get_parameter_post ("combo_snmp_oid");
|
||||
}
|
||||
if ($form_snmp_oid == ""){
|
||||
$form_snmp_oid = $combo_snmp_oid;
|
||||
if ($snmp_oid == ""){
|
||||
$snmp_oid = $combo_snmp_oid;
|
||||
}
|
||||
if ($form_tcp_port == "") {
|
||||
$form_tcp_port= "0";
|
||||
}
|
||||
$sql = sprintf ("INSERT INTO tagente_modulo
|
||||
(id_agente, id_tipo_modulo, nombre, descripcion, max, min, snmp_oid, snmp_community,
|
||||
id_module_group, module_interval, ip_target, tcp_port, tcp_rcv, tcp_send, id_export,
|
||||
plugin_user, plugin_pass, plugin_parameter, id_plugin, post_process, prediction_module,
|
||||
max_timeout, disabled, id_modulo, custom_id, history_data, min_warning, max_warning, min_critical, max_critical, min_ff_event)
|
||||
VALUES (%d,%d,'%s','%s',%d,%d,'%s','%s',%d,%d,'%s',%d,'%s','%s',%d,'%s','%s','%s',%d,%d,%d,%d,%d,%d,'%s', %d, %f, %f, %f, %f, %d)",
|
||||
$id_agente, $form_id_tipo_modulo, $form_name, $form_description, $form_maxvalue, $form_minvalue, $form_snmp_oid, $form_snmp_community,
|
||||
$form_id_module_group, $form_interval, $form_ip_target, $form_tcp_port, $form_tcp_rcv, $form_tcp_send, $form_id_export, $form_plugin_user, $form_plugin_pass,
|
||||
$form_plugin_parameter, $form_id_plugin, $form_post_process, $form_id_prediction_module, $form_max_timeout, $form_disabled, $form_id_modulo, $form_custom_id, $form_history_data, $form_min_warning, $form_max_warning, $form_min_critical, $form_max_critical, $form_ff_event);
|
||||
$id_agente_modulo = process_sql ($sql, 'insert_id');
|
||||
|
||||
if ($id_agente_modulo === false){
|
||||
|
||||
$id_module = (int) get_parameter ('id_module');
|
||||
|
||||
$id_agent_module = process_sql_insert ('tagente_modulo',
|
||||
array ('id_agente' => $id_agente,
|
||||
'id_tipo_modulo' => $id_module_type,
|
||||
'nombre' => $name, 'descripcion' => $description, 'max' => $maxvalue,
|
||||
'min' => $minvalue, 'snmp_oid' => $snmp_oid,
|
||||
'snmp_community' => $snmp_community,
|
||||
'id_module_group' => $id_module_group, 'module_interval' => $interval,
|
||||
'ip_target' => $ip_target, 'tcp_port' => $tcp_port,
|
||||
'tcp_rcv' => $tcp_rcv, 'tcp_send' => $tcp_send,
|
||||
'id_export' => $id_export, 'plugin_user' => $plugin_user,
|
||||
'plugin_pass' => $plugin_pass, 'plugin_parameter' => $plugin_parameter,
|
||||
'id_plugin' => $id_plugin, 'post_process' => $post_process,
|
||||
'prediction_module' => $id_prediction_module,
|
||||
'max_timeout' => $max_timeout, 'disabled' => $disabled,
|
||||
'id_modulo' => $id_module, 'custom_id' => $custom_id,
|
||||
'history_data' => $history_data, 'min_warning' => $min_warning,
|
||||
'max_warning' => $max_warning, 'min_critical' => $min_critical,
|
||||
'max_critical' => $max_critical, 'min_ff_event' => $ff_event
|
||||
));
|
||||
|
||||
if ($id_agent_module === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem adding module').'</h3>';
|
||||
$edit_module = true;
|
||||
} else {
|
||||
$sql = sprintf ("INSERT INTO tagente_estado
|
||||
(id_agente_modulo,datos,timestamp,estado,id_agente, utimestamp, status_changes, last_status)
|
||||
VALUES (%d, 0,'0000-00-00 00:00:00',0,%d,0,0,0)",$id_agente_modulo,$id_agente);
|
||||
|
||||
$result = process_sql ($sql);
|
||||
$result = process_sql_insert ('tagente_estado',
|
||||
array ('id_agente_modulo' => $id_agent_module,
|
||||
'datos' => 0, 'timestamp' => '0000-00-00 00:00:00',
|
||||
'estado' => 0, 'id_agente' => $id_agente,
|
||||
'utimestamp' => 0, 'status_changes' => 0,
|
||||
'last_status' => 0
|
||||
));
|
||||
if ($result !== false) {
|
||||
echo '<h3 class="suc">'.__('Module added successfully').'</h3>';
|
||||
} else {
|
||||
echo '<h3 class="error">'.__('Module added successfully').' - '.__('Status init unsuccessful').'</h3>';
|
||||
}
|
||||
$id_agent_module = false;
|
||||
$edit_module = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,7 +558,7 @@ if (isset ($_GET["delete_module"])){ // DELETE agent module !
|
|||
$id_borrar_modulo = (int) get_parameter_get ("delete_module",0);
|
||||
$id_grupo = (int) dame_id_grupo ($id_agente);
|
||||
|
||||
if (give_acl ($config["id_user"], $id_grupo, "AW") == 0){
|
||||
if (! give_acl ($config["id_user"], $id_grupo, "AW")) {
|
||||
audit_db($config["id_user"],$REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to delete a module without admin rights");
|
||||
require ("general/noaccess.php");
|
||||
|
@ -657,16 +605,15 @@ if (isset ($_GET["delete_module"])){ // DELETE agent module !
|
|||
// -----------------------------------
|
||||
// Load page depending on tab selected
|
||||
// -----------------------------------
|
||||
|
||||
switch ($tab) {
|
||||
case "main":
|
||||
require ("agent_manager.php");
|
||||
break;
|
||||
case "module":
|
||||
if (($form_moduletype == "") && ($moduletype == "")) {
|
||||
require ("module_manager.php");
|
||||
} else {
|
||||
if ($id_agent_module || $edit_module) {
|
||||
require ("module_manager_editor.php");
|
||||
} else {
|
||||
require ("module_manager.php");
|
||||
}
|
||||
break;
|
||||
case "alert":
|
||||
|
|
|
@ -31,7 +31,6 @@ echo "<h2>".__('Agent configuration')." > ".__('Modules')."</h2>";
|
|||
echo '<table width="300" cellpadding="4" cellspacing="4" class="databox">';
|
||||
echo '<form name="modulo" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente.'">';
|
||||
echo "<tr><td class='datos'>";
|
||||
echo '<select name="form_moduletype">';
|
||||
|
||||
// Check if there is at least one server of each type available to assign that
|
||||
// kind of modules. If not, do not show server type in combo
|
||||
|
@ -48,16 +47,19 @@ if ($develop_bypass) {
|
|||
$prediction_available = 1;
|
||||
}
|
||||
|
||||
echo "<option value='dataserver'>".__('Create a new data server module');
|
||||
if ($network_available == 1)
|
||||
echo "<option value='networkserver'>".__('Create a new network server module');
|
||||
if ($plugin_available == 1)
|
||||
echo "<option value='pluginserver'>".__('Create a new plugin Server module');
|
||||
if ($wmi_available == 1)
|
||||
echo "<option value='wmiserver'>".__('Create a new WMI Server module');
|
||||
if ($prediction_available == 1)
|
||||
echo "<option value='predictionserver'>".__('Create a new prediction Server module');
|
||||
echo "</select></td>";
|
||||
$servers = array ();
|
||||
$servers['dataserver'] = __('Create a new data server module');
|
||||
if ($network_available)
|
||||
$servers['networkserver'] = __('Create a new network server module');
|
||||
if ($plugin_available)
|
||||
$servers['pluginserver'] = __('Create a new plugin Server module');
|
||||
if ($wmi_available)
|
||||
$servers['wmiserver'] = __('Create a new WMI Server module');
|
||||
if ($prediction_available)
|
||||
$servers['predictionserver'] = __('Create a new prediction Server module');
|
||||
print_select ($servers, 'moduletype', '', '', '', '', false, false, false);
|
||||
print_input_hidden ('edit_module', 1);
|
||||
echo '</td>';
|
||||
echo '<td class="datos">';
|
||||
echo '<input align="right" name="updbutton" type="submit" class="sub wand" value="'.__('Create').'">';
|
||||
echo "</form>";
|
||||
|
@ -69,7 +71,7 @@ echo "</table>";
|
|||
|
||||
echo "<h3>".__('Assigned modules')."</h3>";
|
||||
$sql1='SELECT * FROM tagente_modulo WHERE delete_pending = 0 AND id_agente = "'.$id_agente.'"
|
||||
ORDER BY id_module_group, nombre ';
|
||||
ORDER BY id_module_group, nombre ';
|
||||
$result=mysql_query($sql1);
|
||||
if ($row=mysql_num_rows($result)){
|
||||
echo '<table width="750" cellpadding="4" cellspacing="4" class="databox">';
|
||||
|
@ -147,8 +149,8 @@ if ($row=mysql_num_rows($result)){
|
|||
echo "<img src='images/cross.png' border=0 title='".__('Delete')."'>";
|
||||
echo "</b></a> ";
|
||||
// Update module
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=$id_agente&tab=module&update_module=".$row["id_agente_modulo"]."&moduletype=$id_module#modules'>";
|
||||
echo "<img src='images/config.png' border=0 title='".__('Update')."' onLoad='type_change()'></b></a>";
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=$id_agente&tab=module&edit_module=1&id_agent_module=".$row["id_agente_modulo"]."'>";
|
||||
echo "<img src='images/config.png' border=0 title='".__('Update')."'></b></a>";
|
||||
|
||||
// Make a data normalization
|
||||
if (($id_tipo == 22) OR ($id_tipo == 1) OR ($id_tipo == 4) OR ($id_tipo == 7) OR
|
||||
|
|
|
@ -16,140 +16,356 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
if (defined ('AJAX')) {
|
||||
$get_network_component = (bool) get_parameter ('get_network_component');
|
||||
$snmp_walk = (bool) get_parameter ('snmp_walk');
|
||||
$get_module_component = (bool) get_parameter ('get_module_component');
|
||||
|
||||
if ($get_module_component) {
|
||||
$id_component = (int) get_parameter ('id_module_component');
|
||||
|
||||
$component = get_db_row ('tnetwork_component', 'id_nc', $id_component);
|
||||
|
||||
echo json_encode ($component);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($snmp_walk) {
|
||||
$ip_target = (string) get_parameter ('ip_target');
|
||||
$snmp_community = (string) get_parameter ('snmp_community');
|
||||
|
||||
snmp_set_quick_print (1);
|
||||
$snmpwalk = snmprealwalk ($ip_target, $snmp_community, NULL);
|
||||
if ($snmpwalk === false) {
|
||||
echo json_encode ($snmpwalk);
|
||||
return;
|
||||
}
|
||||
|
||||
$result = array ();
|
||||
foreach ($snmpwalk as $id => $value) {
|
||||
$value = substr ($id, 0, 35)." - ".substr ($value, 0, 20);
|
||||
$result[$id] = substr ($value, 0, 55);
|
||||
}
|
||||
asort ($result);
|
||||
echo json_encode ($result);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset ($id_agente)) {
|
||||
die ("Not Authorized");
|
||||
}
|
||||
|
||||
require_once ("include/functions_exportserver.php");
|
||||
|
||||
// Following variables come from module_manager.php -> configurar_agente.php :
|
||||
//
|
||||
// $form_moduletype: could be [1] Agent module/Data server, [2] network server, [4] plugin server, [6] wmiserver, or [5] predictionserver
|
||||
// $moduletype: helper to fix get/post method; copy of $form_moduletype just to edit modules, not to create them
|
||||
|
||||
if (($form_moduletype == "") && ($moduletype != "")) {
|
||||
switch ($moduletype) {
|
||||
case "1":
|
||||
$form_moduletype = "dataserver";
|
||||
break;
|
||||
case "2":
|
||||
$form_moduletype = "networkserver";
|
||||
break;
|
||||
case "4":
|
||||
$form_moduletype = "pluginserver";
|
||||
break;
|
||||
case "5":
|
||||
$form_moduletype = "predictionserver";
|
||||
break;
|
||||
case "6":
|
||||
$form_moduletype = "wmiserver";
|
||||
break;
|
||||
//This will make sure that blank pages will
|
||||
//have at least some debug info in them
|
||||
default:
|
||||
echo '<h3 class="error">DEBUG: Invalid module type specified in '.__FILE__.':'.__LINE__.'</h3>';
|
||||
echo 'Most likely you have recently upgraded from an earlier version of Pandora and either <br />
|
||||
1) forgot to use the database converter<br />
|
||||
2) used a bad version of the database converter (see Bugreport #2124706 for the solution)<br />
|
||||
3) found a new bug - please report a way to duplicate this error';
|
||||
return; //We return control to the invoking script so the page finishes rendering
|
||||
}
|
||||
}
|
||||
|
||||
// Get form
|
||||
$form_network_component = get_parameter ("form_network_component", "");
|
||||
|
||||
// Using network component to fill some fields
|
||||
if (($form_moduletype == "networkserver" || $form_moduletype == "wmiserver") && ($form_network_component != "") && (!isset($_POST['crtbutton'])) && (!isset($_POST['oid']))) {
|
||||
// Preload data from template
|
||||
$row = get_db_row ("tnetwork_component", 'id_nc', $form_network_component);
|
||||
if (empty ($row))
|
||||
unmanaged_error ("Cannot load tnetwork_component reference from previous page");
|
||||
|
||||
$form_id_tipo_modulo = $row["type"];
|
||||
$form_id_module_group = $row["id_module_group"];
|
||||
$form_name = $row["name"];
|
||||
$form_descripcion = $row["description"];
|
||||
$form_tcp_send = $row["tcp_send"];
|
||||
$form_tcp_rcv = $row["tcp_rcv"];
|
||||
$form_tcp_port = $row["tcp_port"];
|
||||
$form_snmp_community = $row["snmp_community"];
|
||||
$form_snmp_oid = $row["snmp_oid"];
|
||||
$form_id_module_group = $row["id_module_group"];
|
||||
$form_interval = $row["module_interval"];
|
||||
$form_maxvalue = $row["max"];
|
||||
$form_minvalue = $row["min"];
|
||||
$form_max_timeout = $row["max_timeout"];
|
||||
$form_id_export = 0;
|
||||
$form_disabled = 0;
|
||||
$form_plugin_user = $row["plugin_user"];
|
||||
$form_plugin_pass = $row["plugin_pass"];
|
||||
$form_plugin_parameter = $row["plugin_parameter"];
|
||||
$form_prediction_module = "";
|
||||
$form_id_plugin = "";
|
||||
$form_post_process = "";
|
||||
$form_custom_id = "";
|
||||
|
||||
} elseif (!isset($_POST['oid'])) {
|
||||
// Clean up specific network modules fields
|
||||
$form_name = "";
|
||||
$form_description = "";
|
||||
$form_id_module_group = 1;
|
||||
$form_id_tipo_modulo = 1;
|
||||
$form_post_process = "";
|
||||
$form_max_timeout = "";
|
||||
$form_minvalue = "";
|
||||
$form_maxvalue = "";
|
||||
$form_interval = "";
|
||||
$form_prediction_module = "";
|
||||
$form_id_plugin = "";
|
||||
$form_id_export = "";
|
||||
$form_disabled= "0";
|
||||
$form_tcp_send = "";
|
||||
$form_tcp_rcv = "";
|
||||
$form_tcp_port = "";
|
||||
if ($id_agent_module) {
|
||||
$module = get_agent_module ($id_agent_module);
|
||||
$moduletype = $module['id_modulo'];
|
||||
$name = $module['nombre'];
|
||||
$description = $module['descripcion'];
|
||||
$id_module_group = $module['id_module_group'];
|
||||
$id_module_type = $module['id_tipo_modulo'];
|
||||
$max = $module['max'];
|
||||
$min = $module['min'];
|
||||
$interval = $module['module_interval'];
|
||||
if ($interval == 0) {
|
||||
$interval = get_agent_interval ($id_agente);
|
||||
}
|
||||
$tcp_port = $module['tcp_port'];
|
||||
$tcp_send = $module['tcp_send'];
|
||||
$tcp_rcv = $module['tcp_rcv'];
|
||||
$snmp_community = $module['snmp_community'];
|
||||
$snmp_oid = $module['snmp_oid'];
|
||||
$ip_target = $module['ip_target'];
|
||||
if (empty ($ip_target)) {
|
||||
$ip_target = get_agent_address ($id_agente);
|
||||
}
|
||||
$disabled = $module['disabled'];
|
||||
$id_export = $module['id_export'];
|
||||
$plugin_user = $module['plugin_user'];
|
||||
$plugin_pass = $module['plugin_pass'];
|
||||
$plugin_parameter = $module['plugin_parameter'];
|
||||
$id_plugin = $module['id_plugin'];
|
||||
$post_process = $module['post_process'];
|
||||
$prediction_module = $module['prediction_module'];
|
||||
$max_timeout = $module['max_timeout'];
|
||||
$custom_id = $module['custom_id'];
|
||||
$history_data = $module['history_data'];
|
||||
$min_warning = $module['min_warning'];
|
||||
$max_warning = $module['max_warning'];
|
||||
$min_critical = $module['min_critical'];
|
||||
$max_critical = $module['max_critical'];
|
||||
$ff_event = $module['min_ff_event'];
|
||||
} else {
|
||||
$moduletype = (string) get_parameter ('moduletype');
|
||||
|
||||
if ($form_moduletype == "wmiserver")
|
||||
$form_snmp_community = "";
|
||||
// Clean up specific network modules fields
|
||||
$name = '';
|
||||
$description = '';
|
||||
$id_module_group = 1;
|
||||
$id_module_type = 1;
|
||||
$post_process = '';
|
||||
$max_timeout = '';
|
||||
$min = '';
|
||||
$max = '';
|
||||
$interval = '';
|
||||
$prediction_module = '';
|
||||
$id_plugin = '';
|
||||
$id_export = '';
|
||||
$disabled = "0";
|
||||
$tcp_send = '';
|
||||
$tcp_rcv = '';
|
||||
$tcp_port = '';
|
||||
|
||||
if ($moduletype == "wmiserver")
|
||||
$snmp_community = '';
|
||||
else
|
||||
$form_snmp_community = "public";
|
||||
$form_snmp_oid = "";
|
||||
$form_ip_target = $direccion_agente; // taken from configurar_agente.php
|
||||
$form_plugin_user = "";
|
||||
$form_plugin_pass = "";
|
||||
$form_plugin_parameter = "";
|
||||
$form_custom_id = "";
|
||||
$form_history_data = 1;
|
||||
$form_min_warning = 0;
|
||||
$form_max_warning = 0;
|
||||
$form_min_critical = 0;
|
||||
$form_max_critical = 0;
|
||||
$form_ff_event = 0;
|
||||
$snmp_community = "public";
|
||||
$snmp_oid = '';
|
||||
$ip_target = get_agent_address ($id_agente);
|
||||
$plugin_user = '';
|
||||
$plugin_pass = '';
|
||||
$plugin_parameter = '';
|
||||
$custom_id = '';
|
||||
$history_data = 1;
|
||||
$min_warning = 0;
|
||||
$max_warning = 0;
|
||||
$min_critical = 0;
|
||||
$max_critical = 0;
|
||||
$ff_event = 0;
|
||||
}
|
||||
|
||||
switch ($form_moduletype) {
|
||||
case "dataserver":
|
||||
include $config["homedir"]."/godmode/agentes/module_manager_editor_data.php";
|
||||
break;
|
||||
case "networkserver":
|
||||
include $config["homedir"]."/godmode/agentes/module_manager_editor_network.php";
|
||||
break;
|
||||
case "pluginserver":
|
||||
include $config["homedir"]."/godmode/agentes/module_manager_editor_plugin.php";
|
||||
break;
|
||||
case "predictionserver":
|
||||
include $config["homedir"]."/godmode/agentes/module_manager_editor_prediction.php";
|
||||
break;
|
||||
case "wmiserver":
|
||||
include $config["homedir"]."/godmode/agentes/module_manager_editor_wmi.php";
|
||||
break;
|
||||
default:
|
||||
echo '<h3 class="error">DEBUG: Invalid module type specified in '.__FILE__.':'.__LINE__.'</h3>';
|
||||
echo 'Most likely you have recently upgraded from an earlier version of Pandora and either <br />
|
||||
1) forgot to use the database converter<br />
|
||||
2) used a bad version of the database converter (see Bugreport #2124706 for the solution)<br />
|
||||
3) found a new bug - please report a way to duplicate this error';
|
||||
return;
|
||||
|
||||
switch ($moduletype) {
|
||||
case "dataserver":
|
||||
$moduletype = 1;
|
||||
case 1:
|
||||
require ('module_manager_editor_common.php');
|
||||
require ('module_manager_editor_data.php');
|
||||
break;
|
||||
case "networkserver":
|
||||
$moduletype = 2;
|
||||
case 2:
|
||||
require ('module_manager_editor_common.php');
|
||||
require ('module_manager_editor_network.php');
|
||||
break;
|
||||
case "pluginserver":
|
||||
$moduletype = 3;
|
||||
case 3:
|
||||
require ('module_manager_editor_common.php');
|
||||
require ('module_manager_editor_plugin.php');
|
||||
break;
|
||||
case "predictionserver":
|
||||
$moduletype = 4;
|
||||
case 4:
|
||||
require ('module_manager_editor_common.php');
|
||||
require ('module_manager_editor_prediction.php');
|
||||
break;
|
||||
case "wmiserver":
|
||||
$moduletype = 5;
|
||||
case 5:
|
||||
require ('module_manager_editor_common.php');
|
||||
require ('module_manager_editor_wmi.php');
|
||||
break;
|
||||
default:
|
||||
echo '<h3 class="error">DEBUG: Invalid module type specified in '.__FILE__.':'.__LINE__.'</h3>';
|
||||
echo 'Most likely you have recently upgraded from an earlier version of Pandora and either <br />
|
||||
1) forgot to use the database converter<br />
|
||||
2) used a bad version of the database converter (see Bugreport #2124706 for the solution)<br />
|
||||
3) found a new bug - please report a way to duplicate this error';
|
||||
return; //We return control to the invoking script so the page finishes rendering
|
||||
}
|
||||
|
||||
echo '<h3>'.__('Module assignment');
|
||||
if (isset ($extra_title))
|
||||
echo ' - '.$extra_title;
|
||||
echo '</h3>';
|
||||
|
||||
echo '<h3 id="message" class="error invisible"></h3>';
|
||||
|
||||
echo '<form method="post" id="module_form">';
|
||||
print_table ($table_simple);
|
||||
|
||||
echo '<a href="#" id="show_advanced">'.__('Advanced options').' » </a>';
|
||||
|
||||
echo '<div id="advanced" style="display: none">';
|
||||
print_table ($table_advanced);
|
||||
echo '</div>';
|
||||
|
||||
// Submit
|
||||
echo '<div class="action-buttons" style="width: '.$table_simple->width.'">';
|
||||
if ($id_agent_module) {
|
||||
print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"');
|
||||
print_input_hidden ('update_module', 1);
|
||||
print_input_hidden ('id_agent_module', $id_agent_module);
|
||||
} else {
|
||||
print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"');
|
||||
print_input_hidden ('id_module', $moduletype);
|
||||
print_input_hidden ('create_module', 1);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
?>
|
||||
|
||||
<script type="text/javascript" src="include/javascript/jquery.ui.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/jquery.form.js"></script>
|
||||
|
||||
<script language="javascript">
|
||||
/* Modules ids to check types */
|
||||
var icmp = Array (6, 7);
|
||||
var tcp = Array (8, 9, 10, 11);
|
||||
var snmp = Array (15, 16, 17, 18);
|
||||
|
||||
$(document).ready (function () {
|
||||
$("#id_module_type").change (function () {
|
||||
if (icmp.in_array (this.value)) {
|
||||
$("tr#simple-snmp_1, tr#simple-snmp_2, tr#advanced-tcp_send, tr#advanced-tcp_receive").hide ();
|
||||
$("#text-tcp_port").attr ("disabled", "1");
|
||||
} else if (snmp.in_array (this.value)) {
|
||||
$("tr#simple-snmp_1, tr#simple-snmp_2").show ();
|
||||
$("tr#advanced-tcp_send, tr#advanced-tcp_receive").hide ();
|
||||
$("#text-tcp_port").removeAttr ("disabled");
|
||||
} else if (tcp.in_array (this.value)) {
|
||||
$("tr#simple-snmp_1, tr#simple-snmp_2").hide ();
|
||||
$("tr#advanced-tcp_send, tr#advanced-tcp_receive").show ();
|
||||
$("#text-tcp_port").removeAttr ("disabled");
|
||||
}
|
||||
});
|
||||
$("#network_component").change (function () {
|
||||
$("#component_loading").show ();
|
||||
$(".error").hide ();
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "godmode/agentes/module_manager_editor",
|
||||
"get_module_component" : 1,
|
||||
"id_module_component" : this.value
|
||||
},
|
||||
function (data, status) {
|
||||
$("#text-name").attr ("value", data["name"]);
|
||||
$("#textarea_description").attr ("value", data["description"]);
|
||||
$("#id_module_type option[value="+data["type"]+"]").select (1);
|
||||
$("#text-max").attr ("value", data["max"]);
|
||||
$("#text-min").attr ("value", data["min"]);
|
||||
$("#text-module_interval").attr ("value", data["module_interval"]);
|
||||
$("#text-tcp_port").attr ("value", data["tcp_port"]);
|
||||
$("#textarea_tcp_send").attr ("value", data["tcp_send"]);
|
||||
$("#textarea_tcp_rcv").attr ("value", data["tcp_rcv"]);
|
||||
$("#text-snmp_community").attr ("value", data["snmp_community"]);
|
||||
$("#text-snmp_oid").attr ("value", data["snmp_oid"]).show ();
|
||||
$("#oid, img#edit_oid").hide ();
|
||||
$("#id_module_group option["+data["id_group"]+"]").select (1);
|
||||
//$("#id_module_group").attr ("value", data["id_module_group"]);
|
||||
//$("#text_plugin_user").attr ("value", data["plugin_user"]);
|
||||
//$("#text_plugin_pass").attr ("value", data["plugin_pass"]);
|
||||
//$("#text_plugin_parameter").attr ("value", data["plugin_parameter"]);
|
||||
$("#max_timeout").attr ("value", data["max_timeout"]);
|
||||
if (data["history_data"])
|
||||
$("#checkbox-history_data").check ();
|
||||
else
|
||||
$("#checkbox-history_data").uncheck ();
|
||||
$("#text-min_warning").attr ("value", (data["min_warning"] == 0) ? 0 : data["min_warning"]);
|
||||
$("#text-max_warning").attr ("value", (data["max_warning"] == 0) ? 0 : data["min_warning"]);
|
||||
$("#text-min_critical").attr ("value", (data["min_critical"] == 0) ? 0 : data["min_critical"]);
|
||||
$("#text-max_critical").attr ("value", (data["max_critical"] == 0) ? 0 : data["max_critical"]);
|
||||
$("#text-ff_threshold").attr ("value", (data["min_ff_event"] == 0) ? 0 : data["min_ff_event"]);
|
||||
$("#component_loading").hide ();
|
||||
$("#id_module_type").change ();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
});
|
||||
|
||||
$("#text-ip_target").keyup (function () {
|
||||
if (this.value != '') {
|
||||
$("#button-snmp_walk").enable ();
|
||||
} else {
|
||||
$("#button-snmp_walk").disable ();
|
||||
}
|
||||
});
|
||||
|
||||
$("#button-snmp_walk").click (function () {
|
||||
$(this).disable ();
|
||||
$("#oid_loading").show ();
|
||||
$("span.error").hide ();
|
||||
$("#select_snmp_oid").empty ().hide ();
|
||||
$("#text-snmp_oid").hide ().attr ("value", "");
|
||||
$("span#oid").show ();
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "godmode/agentes/module_manager_editor",
|
||||
"snmp_walk" : 1,
|
||||
"ip_target" : $("#text-ip_target").fieldValue (),
|
||||
"snmp_community" : $("#text-snmp_community").fieldValue ()
|
||||
},
|
||||
function (data, status) {
|
||||
if (data == false) {
|
||||
$("span.error").show ();
|
||||
$("#oid_loading").hide ();
|
||||
$("#edit_oid").hide ();
|
||||
return false;
|
||||
}
|
||||
jQuery.each (data, function (id, value) {
|
||||
opt = $("<option></option>").attr ("value", id).html (value);
|
||||
$("#select_snmp_oid").append (opt);
|
||||
});
|
||||
$("#select_snmp_oid").show ();
|
||||
$("#oid_loading").hide ();
|
||||
$("#button-snmp_walk").enable ();
|
||||
$("#edit_oid").show ();
|
||||
$("#button-snmp_walk").enable ();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
});
|
||||
|
||||
$("img#edit_oid").click (function () {
|
||||
$("#oid").hide ();
|
||||
$("#text-snmp_oid").show ()
|
||||
.attr ("value", $("#select_snmp_oid").fieldValue ());
|
||||
$(this).hide ();
|
||||
});
|
||||
|
||||
$("form#module_form").submit (function () {
|
||||
if ($("#text-name").attr ("value") == "") {
|
||||
$("#text-name").pulsate ().focus ();
|
||||
$("#message").hide ().empty ()
|
||||
.text ("<?php echo __('No module name provided') ?>")
|
||||
.slideDown ();
|
||||
return false;
|
||||
}
|
||||
|
||||
module = $("#id_module_type").attr ("value");
|
||||
|
||||
if (icmp.in_array (module) || tcp.in_array (module) || snmp.in_array (module)) {
|
||||
/* Network module */
|
||||
if ($("#text-ip_target").attr ("value") == "") {
|
||||
$("#text-ip_target").pulsate ().focus ();
|
||||
$("#message").hide ().empty ()
|
||||
.text ("<?php echo __('No target IP provided') ?>")
|
||||
.slideDown ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (snmp.in_array (module)) {
|
||||
if ($("#text-snmp_oid").attr ("value") == "") {
|
||||
if ($("#select_snmp_oid").attr ("value") == "") {
|
||||
$("#message").hide ().empty ()
|
||||
.text ("<?php echo __('No SNMP OID provided') ?>")
|
||||
.slideDown ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$("#message").hide ();
|
||||
return true;
|
||||
});
|
||||
|
||||
$("a#show_advanced").click (function () {
|
||||
$("div#advanced").show ();
|
||||
$(this).remove ();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// ============================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
if (! isset ($id_agente)) {
|
||||
die ("Not Authorized");
|
||||
}
|
||||
|
||||
function prepend_table_simple ($row, $id = false) {
|
||||
global $table_simple;
|
||||
|
||||
if ($id)
|
||||
$data = array ($id => $row);
|
||||
else
|
||||
$data = array ($row);
|
||||
|
||||
$table_simple->data = array_merge ($data, $table_simple->data);
|
||||
}
|
||||
|
||||
function push_table_simple ($row, $id = false) {
|
||||
global $table_simple;
|
||||
|
||||
if ($id)
|
||||
$data = array ($id => $row);
|
||||
else
|
||||
$data = array ($row);
|
||||
|
||||
$table_simple->data = array_merge ($table_simple->data, $data);
|
||||
}
|
||||
|
||||
function prepend_table_advanced ($row, $id = false) {
|
||||
global $table_advanced;
|
||||
|
||||
if ($id)
|
||||
$data = array ($id => $row);
|
||||
else
|
||||
$data = array ($row);
|
||||
|
||||
$table_advanced->data = array_merge ($data, $table_advanced->data);
|
||||
}
|
||||
|
||||
function push_table_advanced ($row, $id = false) {
|
||||
global $table_advanced;
|
||||
|
||||
if ($id)
|
||||
$data = array ($id => $row);
|
||||
else
|
||||
$data = array ($row);
|
||||
|
||||
$table_advanced->data = array_merge ($table_advanced->data, $data);
|
||||
}
|
||||
|
||||
$update_module_id = (int) get_parameter_get ('update_module');
|
||||
|
||||
$table_simple->id = 'simple';
|
||||
$table_simple->width = '90%';
|
||||
$table_simple->class = 'databox_color';
|
||||
$table_simple->data = array ();
|
||||
$table_simple->colspan = array ();
|
||||
$table_simple->style = array ();
|
||||
$table_simple->style[0] = 'font-weight: bold';
|
||||
$table_simple->style[2] = 'font-weight: bold';
|
||||
|
||||
$table_simple->data[0][0] = __('Name');
|
||||
$table_simple->data[0][1] = print_input_text ('name', $name, '', 20, 100, true);
|
||||
$table_simple->data[0][2] = __('Disabled');
|
||||
$table_simple->data[0][3] = print_checkbox ("disabled", 1, $disabled, true);
|
||||
|
||||
$table_simple->data[1][0] = __('Type').' '.pandora_help ('module_type', true);
|
||||
if ($id_agent_module) {
|
||||
$table_simple->data[1][1] = '<em>'.get_moduletype_description ($id_module_type).'</em>';
|
||||
} else {
|
||||
switch ($moduletype) {
|
||||
case 1:
|
||||
case "dataserver":
|
||||
$categories = array (0, 1, 2, 6, 7, 8, 9, -1);
|
||||
break;
|
||||
case 2:
|
||||
case "networkserver":
|
||||
$categories = array (3, 4, 5);
|
||||
break;
|
||||
case 3:
|
||||
case "pluginserver":
|
||||
$categories = array (0, 1, 2, 9);
|
||||
break;
|
||||
case 4:
|
||||
case "predictionserver":
|
||||
$categories = array (1, 2);
|
||||
break;
|
||||
case 5:
|
||||
case "wmiserver":
|
||||
$categories = array (0, 1, 2);
|
||||
break;
|
||||
}
|
||||
|
||||
$sql = sprintf ('SELECT id_tipo, descripcion
|
||||
FROM ttipo_modulo
|
||||
WHERE categoria IN (%s)
|
||||
ORDER BY descripcion',
|
||||
implode (',', $categories));
|
||||
$table_simple->data[1][1] = print_select_from_sql ($sql, 'id_module_type',
|
||||
'', '', '', '', true, false, false);
|
||||
}
|
||||
|
||||
$table_simple->data[1][2] = __('Module group');
|
||||
$table_simple->data[1][3] = print_select_from_sql ('SELECT id_mg, name FROM tmodule_group ORDER BY name',
|
||||
'id_module_group', $id_module_group, '', __('Not assigned'), '0',
|
||||
true);
|
||||
|
||||
$table_simple->data[2][0] = __('Warning status');
|
||||
$table_simple->data[2][1] = '<em>'.__('Min.').'</em>';
|
||||
$table_simple->data[2][1] .= print_input_text ('min_warning', $min_warning,
|
||||
'', 5, 15, true);
|
||||
$table_simple->data[2][1] .= '<br /><em>'.__('Max.').'</em>';
|
||||
$table_simple->data[2][1] .= print_input_text ('max_warning', $max_warning,
|
||||
'', 5, 15, true);
|
||||
$table_simple->data[2][2] = __('Critical status');
|
||||
$table_simple->data[2][3] = '<em>'.__('Min.').'</em>';
|
||||
$table_simple->data[2][3] .= print_input_text ('min_critical', $min_critical,
|
||||
'', 5, 15, true);
|
||||
$table_simple->data[2][3] .= '<br /><em>'.__('Max.').'</em>';
|
||||
$table_simple->data[2][3] .= print_input_text ('max_critical', $max_critical,
|
||||
'', 5, 15, true);
|
||||
|
||||
/* FF stands for Flip-flop */
|
||||
$table_simple->data[3][0] = __('FF threshold').' '.pandora_help ('ff_threshold', true);
|
||||
$table_simple->data[3][1] = print_input_text ('ff_event', $ff_event,
|
||||
'', 5, 15, true);
|
||||
$table_simple->data[3][2] = __('Historical data');
|
||||
$table_simple->data[3][3] = print_checkbox ("history_data", 1, $history_data, true);
|
||||
|
||||
/* Advanced form part */
|
||||
$table_advanced->id = 'advanced';
|
||||
$table_advanced->width = '90%';
|
||||
$table_advanced->class = 'databox_color';
|
||||
$table_advanced->data = array ();
|
||||
$table_advanced->style = array ();
|
||||
$table_advanced->style[0] = 'font-weight: bold';
|
||||
$table_advanced->style[2] = 'font-weight: bold';
|
||||
$table_advanced->colspan = array ();
|
||||
|
||||
$table_advanced->data[0][0] = __('Description');
|
||||
$table_advanced->colspan[0][1] = 3;
|
||||
$table_advanced->data[0][1] = print_textarea ('description', 2, 65,
|
||||
$description, '', true);
|
||||
|
||||
$table_advanced->data[1][0] = __('Custom ID');
|
||||
$table_advanced->data[1][1] = print_input_text ('custom_id', $custom_id,
|
||||
'', 20, 65, true);
|
||||
|
||||
$table_advanced->data[2][0] = __('Interval');
|
||||
$table_advanced->data[2][1] = print_input_text ('module_interval', $interval,
|
||||
'', 5, 10, true);
|
||||
|
||||
$table_advanced->data[2][2] = __('Post process').' '.pandora_help ('postprocess', true);
|
||||
$table_advanced->data[2][3] = print_input_text ('post_process',
|
||||
$post_process, '', 5, 5, true);
|
||||
|
||||
$table_advanced->data[3][0] = __('Min. value');
|
||||
$table_advanced->data[3][1] = print_input_text ('min', $min, '', 5, 15, true);
|
||||
$table_advanced->data[3][2] = __('Max. value');
|
||||
$table_advanced->data[3][3] = print_input_text ('max', $max, '', 5, 15, true);
|
||||
|
||||
$table_advanced->data[4][0] = __('Export target');
|
||||
$table_advanced->data[4][1] = print_select_from_sql ('SELECT id, name FROM tserver_export ORDER BY name',
|
||||
'id_export', $id_export, '',__('None'),'0', true, false, false);
|
||||
$table_advanced->colspan[4][1] = 3;
|
||||
?>
|
|
@ -21,219 +21,7 @@ if (!isset ($id_agente)) {
|
|||
die ("Not Authorized");
|
||||
}
|
||||
|
||||
// get the variable form_moduletype
|
||||
$form_moduletype = get_parameter_post ("form_moduletype");
|
||||
// get the module to update
|
||||
$update_module_id = get_parameter_get ("update_module",NULL);
|
||||
// the variable that checks whether the module is disabled or not must be setcommitedversion
|
||||
$disabled_status = false;
|
||||
$extra_title = __('Data server module');
|
||||
|
||||
// Specific ACL check
|
||||
if (give_acl ($config["id_user"], 0, "AW")!=1) {
|
||||
audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation","Trying to access agent manager");
|
||||
require ($config["homedir"]."/general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check whether we are updataing and get data if so
|
||||
if ($update_module_id != NULL){
|
||||
$row = get_db_row ("tagente_modulo", 'id_agente_modulo', $update_module_id);
|
||||
if (empty ($row))
|
||||
unmanaged_error("Cannot load tnetwork_component reference from previous page");
|
||||
|
||||
$id_agente = $row['id_agente'];
|
||||
$form_id_tipo_modulo = $row['id_tipo_modulo']; // It doesn't matter
|
||||
$form_description = $row['descripcion'];
|
||||
$form_name = $row['nombre'];
|
||||
$form_minvalue = $row['min'];
|
||||
$form_maxvalue = $row['max'];
|
||||
$form_interval = $row['module_interval'];
|
||||
$form_tcp_port = $row['tcp_port'];
|
||||
$form_tcp_send = $row['tcp_send'];
|
||||
$form_tcp_rcv = $row['tcp_rcv'];
|
||||
$form_snmp_community = $row['snmp_community'];
|
||||
$form_snmp_oid = $row['snmp_oid'];
|
||||
$form_ip_target = $row['ip_target'];
|
||||
$form_id_module_group = $row['id_module_group'];
|
||||
$form_flag = $row['flag'];
|
||||
$tbl_id_modulo = $row['id_modulo']; // It doesn't matter
|
||||
$tbl_disabled = $row['disabled'];
|
||||
$form_id_export = $row['id_export'];
|
||||
$form_plugin_user = $row['plugin_user'];
|
||||
$form_plugin_pass = $row['plugin_pass'];
|
||||
$form_plugin_parameter = $row['plugin_parameter'];
|
||||
$form_id_plugin = $row['id_plugin'];
|
||||
$form_post_process = $row['post_process'];
|
||||
$form_prediction_module = $row['prediction_module'];
|
||||
$form_max_timeout = $row['max_timeout'];
|
||||
$form_custom_id = $row['custom_id'];
|
||||
$form_history_data = $row['history_data'];
|
||||
$form_min_warning = $row['min_warning'];
|
||||
$form_max_warning = $row['max_warning'];
|
||||
$form_min_critical = $row['min_critical'];
|
||||
$form_max_critical = $row['max_critical'];
|
||||
$form_ff_event = $row['min_ff_event'];
|
||||
|
||||
if ($tbl_disabled == 1)
|
||||
$disabled_status = true;
|
||||
}
|
||||
|
||||
echo "<h3>".__('Module assignment')." - ".__('Data server module')."</h3>";
|
||||
echo '<form name="modulo" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente.'&form_moduletype='.$form_moduletype.'">';
|
||||
|
||||
// Whether in update or insert mode
|
||||
if ($update_module_id == NULL) {
|
||||
print_input_hidden ("insert_module", 1);
|
||||
} else {
|
||||
print_input_hidden ("update_module", 1);
|
||||
}
|
||||
|
||||
//id_agente_module
|
||||
print_input_hidden ("id_agente_modulo", $update_module_id);
|
||||
|
||||
// id_modulo 1 - Dataserver
|
||||
print_input_hidden ("form_id_modulo", 1);
|
||||
echo '<table width="600" cellpadding="4" cellspacing="4" class="databox_color">';
|
||||
echo '<tr><td class="datos2">'. __('Module name').'</td><td class="datos2">';
|
||||
print_input_text ("form_name", $form_name, '', 35);
|
||||
echo '</td><td class="datos2">'. __('Disabled').'</td><td class="datos2">';
|
||||
print_checkbox ("form_disabled", 1, $disabled_status);
|
||||
echo '</td></tr>';
|
||||
|
||||
// module type / max timeout
|
||||
echo '<tr><td class="datos2">'.__('Module type');
|
||||
pandora_help("module_type");
|
||||
echo '</td><td class="datos2" colspan="3">';
|
||||
|
||||
if ($update_module_id != NULL){
|
||||
//We don't pass it along as hidden anymore because the update query
|
||||
//doesn't need that specific value to change.
|
||||
echo '<span class="redi">Not available in edition mode</span>';
|
||||
} else {
|
||||
$sql = "SELECT id_tipo, nombre FROM ttipo_modulo WHERE categoria IN (0,1,2,6,7,8,9,-1) ORDER BY categoria, nombre";
|
||||
$result = get_db_all_rows_sql ($sql); //This database is always filled
|
||||
|
||||
foreach ($result as $row) {
|
||||
$fields[$row["id_tipo"]] = $row["nombre"];
|
||||
}
|
||||
print_select ($fields, "form_id_tipo_modulo", '', '', '', '', false, false, false);
|
||||
}
|
||||
echo '</td></tr>';
|
||||
|
||||
// Post process / Export server
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Post process');
|
||||
pandora_help("postprocess");
|
||||
echo '</td><td class="datos2">';
|
||||
print_input_text ("form_post_process",$form_post_process, '', 5);
|
||||
// Export target is a server where the data will be sent
|
||||
echo '</td><td class="datos2">'.__('Export target').'</td>';
|
||||
echo '<td class="datos2">';
|
||||
|
||||
$fields = array ();
|
||||
$sql = "SELECT id, name FROM tserver_export ORDER BY name";
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
|
||||
if ($result === false)
|
||||
$result = array ();
|
||||
|
||||
foreach ($result as $row) {
|
||||
$fields[$row["id"]] = $row["name"];
|
||||
}
|
||||
|
||||
print_select ($fields, "form_id_export", $form_id_export,'',__('None'),'0', false, false, false);
|
||||
|
||||
echo '</td></tr>';
|
||||
|
||||
// Max / min value
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Min. Value').'</td>';
|
||||
echo '<td class="datos">';
|
||||
print_input_text ("form_minvalue",$form_minvalue,'',5);
|
||||
echo '</td><td class="datos">'.__('Max. Value').'</td>';
|
||||
echo '<td class="datos">';
|
||||
print_input_text ("form_maxvalue",$form_maxvalue,'',5);
|
||||
echo '</td></tr>';
|
||||
|
||||
// Interval & id_module_group
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Interval').'</td>';
|
||||
echo '<td class="datos2"><input type="text" name="form_interval" size="5" value="'.$form_interval.'"></td>';
|
||||
echo '<td class="datos2">'.__('Module group').'</td>';
|
||||
echo '<td class="datos2">';
|
||||
|
||||
$fields = array ();
|
||||
$sql = "SELECT id_mg, name FROM tmodule_group";
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
|
||||
if ($result === false)
|
||||
$result = array ();
|
||||
|
||||
$fields[0] = __("Not assigned");
|
||||
|
||||
foreach ($result as $row) {
|
||||
$fields[$row["id_mg"]] = $row["name"];
|
||||
}
|
||||
|
||||
|
||||
print_select ($fields, "form_id_module_group", $form_id_module_group,'','','',false,false,false);
|
||||
echo '</td></tr>';
|
||||
|
||||
// Max / min value
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Min. Value')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_minvalue" size="5" value="'.$form_minvalue.'"></td>';
|
||||
echo '<td class="datos2">'.__('Max. Value')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_maxvalue" size="5" value="'.$form_maxvalue.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// Warning value threshold
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Warning status')."</td>";
|
||||
echo '<td class="datos2">'.__("Min.").' <input type="text" name="form_min_warning" size="5" value="'.$form_min_warning.'">';
|
||||
echo ' '.__("Max.").' <input type="text" name="form_max_warning" size="5" value="'.$form_max_warning.'"></td>';
|
||||
|
||||
// Critical value threshold
|
||||
echo '<td class="datos2">'.__('Critical status')."</td>";
|
||||
echo '<td class="datos2">'.__("Min.").' <input type="text" name="form_min_critical" size="5" value="'.$form_min_critical.'">';
|
||||
echo ' '.__("Max.").' <input type="text" name="form_max_critical" size="5" value="'.$form_max_critical.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// History data ?
|
||||
echo "<tr>";
|
||||
echo '<td class="datos2">'.__('Historical data')."</td>";
|
||||
echo '<td class="datos2">';
|
||||
print_checkbox ("form_history_data", 1, $form_history_data, false);
|
||||
|
||||
//FF stands for Flip-Flop
|
||||
echo '<td class="datos">'.__('FF threshold');
|
||||
pandora_help ("ff_threshold");
|
||||
echo '</td>';
|
||||
echo '<td class="datos"><input type="text" name="form_ff_event" size="5" value="'.$form_ff_event.'"></td>';
|
||||
|
||||
|
||||
// Description
|
||||
echo '<tr>';
|
||||
echo '<td valign="top" class="datos">'.__('Description')."</td>";
|
||||
echo '<td valign="top" class="datos" colspan="3">';
|
||||
print_textarea ("form_description", 2, 65, $form_description);
|
||||
echo '</td></tr>';
|
||||
|
||||
// Custom ID
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Custom ID')."</td>";
|
||||
echo '<td class="datos2" colspan="3"><input type="text" name="form_custom_id" size="20" value="'.$form_custom_id.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
echo '</table>';
|
||||
|
||||
//Submit
|
||||
echo '<table width="600" cellpadding="4" cellspacing="4">';
|
||||
echo '<td valign="top" align="right">';
|
||||
if ($update_module_id == NULL){
|
||||
print_submit_button (__('Create'), "crtbutton", false,'class="sub wand"');
|
||||
} else {
|
||||
print_submit_button (__('Update'), "updbutton", false,'class="sub wand"');
|
||||
}
|
||||
echo '</td></tr></table>';
|
||||
/* No extra fields at this moment */
|
||||
?>
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<?PHP
|
||||
<?php
|
||||
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// ========================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnológicas, http://www.artica.es
|
||||
// Copyright (c) 2008 Jorge Gonzalez <jorge.gonzalez@artica.es>
|
||||
// Copyright (c) 2008 Esteban Sanchez <estebans@artica.es>
|
||||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
|
@ -22,313 +23,102 @@ if (!isset ($id_agente)) {
|
|||
die ("Not Authorized");
|
||||
}
|
||||
|
||||
// get the variable form_moduletype
|
||||
$form_moduletype = get_parameter_post ("form_moduletype");
|
||||
// get the module to update
|
||||
$update_module_id = get_parameter_get ("update_module");
|
||||
// the variable that checks whether the module is disabled or not must be setcommitedversion
|
||||
$disabled_status = NULL;
|
||||
$extra_title = __('Network server module');
|
||||
|
||||
// Specific ACL check
|
||||
if (give_acl($config["id_user"], 0, "AW")!=1) {
|
||||
audit_db($config["id_user"], $REMOTE_ADDR, "ACL Violation","Trying to access agent manager");
|
||||
require ($config["homedir"]."/general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
$data = array ();
|
||||
$data[0] = __('Using module component').' ';
|
||||
$data[0] .= pandora_help ('network_component', true);
|
||||
|
||||
|
||||
// Check whether we are updataing and get data if so
|
||||
if ($update_module_id != NULL){
|
||||
$row = get_db_row ("tagente_modulo", 'id_agente_modulo', $update_module_id);
|
||||
if ($row == 0){
|
||||
unmanaged_error("Cannot load tnetwork_component reference from previous page");
|
||||
}
|
||||
else{
|
||||
$id_agente = $row['id_agente'];
|
||||
$form_id_tipo_modulo = $row['id_tipo_modulo']; // It doesn't matter
|
||||
$form_description = $row['descripcion'];
|
||||
$form_name = $row['nombre'];
|
||||
$form_minvalue = $row['min'];
|
||||
$form_maxvalue = $row['max'];
|
||||
$form_interval = $row['module_interval'];
|
||||
$form_tcp_port = $row['tcp_port'];
|
||||
$form_tcp_send = $row['tcp_send'];
|
||||
$form_tcp_rcv = $row['tcp_rcv'];
|
||||
$form_snmp_community = $row['snmp_community'];
|
||||
$form_snmp_oid = $row['snmp_oid'];
|
||||
$form_ip_target = $row['ip_target'];
|
||||
$form_id_module_group = $row['id_module_group'];
|
||||
$form_flag = $row['flag'];
|
||||
$tbl_id_modulo = $row['id_modulo']; // It doesn't matter
|
||||
$tbl_disabled = $row['disabled'];
|
||||
$form_id_export = $row['id_export'];
|
||||
$form_plugin_user = $row['plugin_user'];
|
||||
$form_plugin_pass = $row['plugin_pass'];
|
||||
$form_plugin_parameter = $row['plugin_parameter'];
|
||||
$form_id_plugin = $row['id_plugin'];
|
||||
$form_post_process = $row['post_process'];
|
||||
$form_prediction_module = $row['prediction_module'];
|
||||
$form_max_timeout = $row['max_timeout'];
|
||||
$form_custom_id = $row['custom_id'];
|
||||
$form_history_data = $row['history_data'];
|
||||
$form_min_warning = $row['min_warning'];
|
||||
$form_max_warning = $row['max_warning'];
|
||||
$form_min_critical = $row['min_critical'];
|
||||
$form_max_critical = $row['max_critical'];
|
||||
$form_ff_event = $row['min_ff_event'];
|
||||
if ($tbl_disabled == 1){
|
||||
$disabled_status = 'checked="ckecked"';
|
||||
} else {
|
||||
$disabled_status = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<h3>".__('Module assignment')." - ".__('Network server module')."</h3>";
|
||||
echo '<table width="680" cellpadding="4" cellspacing="4" class="databox_color">';
|
||||
// Create from Network Component
|
||||
echo '<form name="modulo" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente.'&form_moduletype='.$form_moduletype.'">';
|
||||
// Whether in update or insert mode
|
||||
if ($update_module_id == NULL){
|
||||
echo "<input type='hidden' name='insert_module' value='1'>";
|
||||
if (empty ($update_module_id)) {
|
||||
$data[1] = print_select_from_sql ('SELECT id_nc, name FROM tnetwork_component WHERE id_modulo = 2',
|
||||
'network_component', '', '', '---'.__('Manual setup').'---', 0, true);
|
||||
$data[1] .= ' <span id="component_loading" class="invisible">';
|
||||
$data[1] .= '<img src="images/spinner.gif" />';
|
||||
$data[1] .= '</span>';
|
||||
} else {
|
||||
echo "<input type='hidden' name='update_module' value='1'>";
|
||||
/* TODO: Print network component if available */
|
||||
$data[1] = 'TODO';
|
||||
}
|
||||
$table_simple->colspan['module_component'][1] = 3;
|
||||
$table_simple->rowstyle['module_component'] = 'background-color: #D4DDC6';
|
||||
|
||||
//id_agente_module
|
||||
echo "<input type='hidden' name='id_agente_modulo'' value='".$update_module_id."'>";
|
||||
prepend_table_simple ($data, 'module_component');
|
||||
|
||||
// id_modulo 2 - Network
|
||||
echo "<input type='hidden' name='form_id_modulo' value='2'>";
|
||||
$data = array ();
|
||||
$data[0] = __('Target IP');
|
||||
$data[1] = print_input_text ('ip_target', $ip_target, '', 15, 60, true);
|
||||
$data[2] = _('Port');
|
||||
$data[3] = print_input_text ('tcp_port', $tcp_port, '', 5, 20, true);
|
||||
|
||||
// Network component usage
|
||||
echo "<tr><td class='datos3'>";
|
||||
echo __('Using Module Component');
|
||||
pandora_help ("network_component");
|
||||
echo "</td><td class='datos3' colspan=2>";
|
||||
push_table_simple ($data, 'target_ip');
|
||||
|
||||
if ($update_module_id != NULL){
|
||||
echo "<span class='redi'>Not available in edition mode</span>";
|
||||
echo "<input type='hidden' name='form_id_tipo_modulo' value='".$form_id_tipo_modulo."'>";
|
||||
$snmp_versions['1'] = 'v. 1';
|
||||
$snmp_versions['2'] = 'v. 2';
|
||||
$snmp_versions['2c'] = 'v. 2c';
|
||||
$data = array ();
|
||||
$data[0] = __('SNMP community');
|
||||
$data[1] = print_input_text ('snmp_community', $snmp_community, '', 15, 60, true);
|
||||
|
||||
$data[2] = _('SNMP version');
|
||||
$snmp_version = 1;
|
||||
if ($id_module_type >= 15 && $id_module_type <= 18) {
|
||||
$data[3] = print_select ($snmp_versions, 'snmp_version', $snmp_version,
|
||||
'', '', '', true);
|
||||
} else {
|
||||
echo '<select name="form_network_component">';
|
||||
echo '<option>---'.__('Manual setup').'---</option>';
|
||||
$sql1='SELECT * FROM tnetwork_component WHERE id_modulo = 2 ORDER BY name';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id_nc"]."'>";
|
||||
echo substr($row["name"],0,30);
|
||||
echo " / ";
|
||||
echo substr($row["description"],0,32);
|
||||
echo "</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
}
|
||||
echo '</td>';
|
||||
echo '<td class="datos3">';
|
||||
echo '<input type="hidden" name="form_moduletype" value="'.$form_moduletype.'">';
|
||||
if ($update_module_id == NULL){
|
||||
echo '<input align="right" name="updbutton" type="submit" class="sub next" value="'.__('Get data').'">';
|
||||
$data[3] = print_select ($snmp_versions, 'snmp_version', 0, '', '',
|
||||
'', true);
|
||||
}
|
||||
|
||||
// Name / IP_target
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Module name')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_name" size="20" value="'.$form_name.'"></td>';
|
||||
echo '<td class="datos2">'.__('Disabled')."</td>";
|
||||
echo '<td class="datos2"><input type="checkbox" name="form_disabled" value="1" "'.$disabled_status.'"></td>';
|
||||
echo '</tr>';
|
||||
push_table_simple ($data, 'snmp_1');
|
||||
|
||||
// Ip target, tcp port
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Target IP')."</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_ip_target" size="25" value="'.$form_ip_target.'"></td>';
|
||||
echo '<td class="datos">'.__('TCP port')."</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_tcp_port" size="5" value="'.$form_tcp_port.'"></td>';
|
||||
echo '</tr>';
|
||||
$data = array ();
|
||||
$data[0] = __('SNMP OID');
|
||||
$data[1] = '<span class="left">';
|
||||
$data[1] .= print_input_text ('snmp_oid', $snmp_oid, '', 30, 120, true);
|
||||
$data[1] .= '<span class="invisible" id="oid">';
|
||||
$data[1] .= print_select (array (), 'select_snmp_oid', $snmp_oid, '', '', 0, true);
|
||||
$data[1] .= '<img src="images/edit.png" class="invisible clickable" id="edit_oid" />';
|
||||
$data[1] .= '</span>';
|
||||
$data[1] .= '<span class="error invisible">'.__('Unable to do SNMP walk').'</span>';
|
||||
$data[1] .= '</span> <span class="right"><span id="oid_loading" class="invisible">';
|
||||
$data[1] .= '<img src="images/spinner.gif" />';
|
||||
$data[1] .= '</span>';
|
||||
$data[1] .= print_button (__('SNMP walk'), 'snmp_walk', $ip_target == '', '',
|
||||
'class="sub next"', true);
|
||||
$data[1] .= pandora_help ('snmpwalk', true);
|
||||
$data[1] .= '</span>';
|
||||
$table_simple->colspan['snmp_2'][1] = 3;
|
||||
|
||||
// module type / max timeout
|
||||
echo '</tr><tr>';
|
||||
echo '<td class="datos2">'.__('Module type');
|
||||
pandora_help ("module_type");
|
||||
echo '</td>';
|
||||
push_table_simple ($data, 'snmp_2');
|
||||
|
||||
echo '<td class="datos2">';
|
||||
if ($update_module_id != NULL){
|
||||
echo "<span class='redi'>Not available in edition mode</span>";
|
||||
echo "<input type='hidden' name='form_id_tipo_modulo' value='".$form_id_tipo_modulo."'>";
|
||||
} else {
|
||||
echo '<select name="form_id_tipo_modulo">';
|
||||
if ($form_id_tipo_modulo != 0)
|
||||
echo "<option value='".$form_id_tipo_modulo."'>".giveme_module_type($form_id_tipo_modulo)."</option>";
|
||||
|
||||
$sql1='SELECT id_tipo, nombre FROM ttipo_modulo WHERE categoria IN (3,4,5) ORDER BY nombre;';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id_tipo"]."'>".$row["nombre"]."</option>";
|
||||
}
|
||||
echo '</select>';
|
||||
/* Advanced stuff */
|
||||
$data = array ();
|
||||
$data[0] = __('TCP send').' '.pandora_help ("tcp_send", true);
|
||||
$data[1] = print_textarea ('tcp_send', 2, 65,
|
||||
$tcp_send, '', true);
|
||||
$table_advanced->colspan['tcp_send'][1] = 3;
|
||||
|
||||
push_table_advanced ($data, 'tcp_send');
|
||||
|
||||
$data[0] = __('TCP receive');
|
||||
$data[1] = print_textarea ('tcp_rcv', 2, 65,
|
||||
$tcp_rcv, '', true);
|
||||
$table_advanced->colspan['tcp_receive'][1] = 3;
|
||||
|
||||
push_table_advanced ($data, 'tcp_receive');
|
||||
|
||||
if ($id_module_type >= 15 && $id_module_type <= 18) {
|
||||
/* SNMP */
|
||||
$table_advanced->rowstyle['tcp_send'] = 'display: none';
|
||||
$table_advanced->rowstyle['tcp_receive'] = 'display: none';
|
||||
} elseif ($id_module_type >= 8 && $id_module_type <= 11) {
|
||||
/* TCP or ICMP */
|
||||
$table_simple->rowstyle['snmp_1'] = 'display: none';
|
||||
$table_simple->rowstyle['snmp_2'] = 'display: none';
|
||||
} elseif (empty ($update_module_id)) {
|
||||
$table_advanced->rowstyle['tcp_send'] = 'display: none';
|
||||
$table_advanced->rowstyle['tcp_receive'] = 'display: none';
|
||||
$table_simple->rowstyle['snmp_1'] = 'display: none';
|
||||
$table_simple->rowstyle['snmp_2'] = 'display: none';
|
||||
}
|
||||
|
||||
echo '<td class="datos2">'.__('Max. timeout')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_max_timeout" size="4" value="'.$form_max_timeout.'"></td></tr>';
|
||||
|
||||
// Interval & id_module_group
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Interval')."</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_interval" size="5" value="'.$form_interval.'"></td>';
|
||||
echo '<td class="datos">'.__('Module group')."</td>";
|
||||
echo '<td class="datos">';
|
||||
echo '<select name="form_id_module_group">';
|
||||
if ($form_id_module_group != 0){
|
||||
echo "<option value='".$form_id_module_group."'>".dame_nombre_grupomodulo($form_id_module_group)."</option>";
|
||||
}
|
||||
$sql1='SELECT * FROM tmodule_group';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id_mg"]."'>".$row["name"]."</option>";
|
||||
}
|
||||
echo '</select>';
|
||||
|
||||
// Snmp walk
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('SNMP walk');
|
||||
pandora_help ("snmpwalk");
|
||||
echo '</td>';
|
||||
echo '<td class="datos2" colspan=2>';
|
||||
echo '<select name="form_combo_snmp_oid">';
|
||||
// FILL OID Combobox
|
||||
if (isset($_POST["oid"])){
|
||||
for (reset($snmpwalk); $i = key($snmpwalk); next($snmpwalk)) {
|
||||
// OJO, al indice tengo que restarle uno, el SNMP funciona con indices a partir de 0
|
||||
// y el cabron de PHP me devuelve indices a partir de 1 !!!!!!!
|
||||
//echo "$i: $a[$i]<br />\n";
|
||||
$snmp_output = substr($i,0,35)." - ".substr($snmpwalk[$i],0,20);
|
||||
echo "<option value=".$i.">".salida_limpia(substr($snmp_output,0,55))."</option>";
|
||||
}
|
||||
}
|
||||
echo "</select>";
|
||||
echo '<td class="datos2">';
|
||||
echo '<input type="submit" class="sub next" name="oid" value="SNMP Walk">';
|
||||
|
||||
// Snmp Oid / community
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('SNMP OID');
|
||||
pandora_help ("snmpoid");
|
||||
echo '</td>';
|
||||
echo '<td class="datos"><input type="text" name="form_snmp_oid" size="25" value="'.$form_snmp_oid.'"></td>';
|
||||
echo '<td class="datos">'.__('SNMP Community')."</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_snmp_community" size="12" value="'.$form_snmp_community.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// SNMP version
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('SNMP version');
|
||||
$snmp_versions["1"] = "1";
|
||||
$snmp_versions["2"] = "2";
|
||||
$snmp_versions["2c"] = "2c";
|
||||
echo '</td>';
|
||||
echo '<td>';
|
||||
// SNMP module, tcp_send contains the snmp version
|
||||
if ($form_id_tipo_modulo >= 15 && $form_id_tipo_modulo <= 18) {
|
||||
print_select ($snmp_versions, 'form_tcp_send', $form_tcp_send, '', '', '', false, false);
|
||||
} else {
|
||||
print_select ($snmp_versions, 'form_tcp_send_void', 0, '', '', '', false, false);
|
||||
}
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
|
||||
// Max / min value
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Min. Value')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_minvalue" size="5" value="'.$form_minvalue.'"></td>';
|
||||
echo '<td class="datos2">'.__('Max. Value')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_maxvalue" size="5" value="'.$form_maxvalue.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// Warning value threshold
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Warning status')."</td>";
|
||||
echo '<td class="datos2">'.__("Min.").' <input type="text" name="form_min_warning" size="5" value="'.$form_min_warning.'">';
|
||||
echo ' '.__("Max.").' <input type="text" name="form_max_warning" size="5" value="'.$form_max_warning.'"></td>';
|
||||
|
||||
// Critical value threshold
|
||||
echo '<td class="datos2">'.__('Critical status')."</td>";
|
||||
echo '<td class="datos2">'.__("Min.").' <input type="text" name="form_min_critical" size="5" value="'.$form_min_critical.'">';
|
||||
echo ' '.__("Max.").' <input type="text" name="form_max_critical" size="5" value="'.$form_max_critical.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// History data ?
|
||||
echo "<tr>";
|
||||
echo '<td class="datos2">'.__('Historical data')."</td>";
|
||||
echo '<td class="datos2">';
|
||||
print_checkbox ("form_history_data", 1, $form_history_data, false);
|
||||
|
||||
//FF stands for Flip-Flop
|
||||
echo '<td class="datos">'.__('FF threshold');
|
||||
pandora_help ("ff_threshold");
|
||||
echo '</td>';
|
||||
echo '<td class="datos"><input type="text" name="form_ff_event" size="5" value="'.$form_ff_event.'"></td>';
|
||||
|
||||
// Post process / Export server
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Post process');
|
||||
pandora_help ("postprocess");
|
||||
echo '</td>';
|
||||
echo '<td class="datos"><input type="text" name="form_post_process" size="5" value="'.$form_post_process.'"></td>';
|
||||
// Export target is a server where the data will be sent
|
||||
echo '<td class="datos">'.__('Export target')."</td>";
|
||||
echo '<td class="datos"><select name="form_id_export">';
|
||||
if ($form_id_export != 0){
|
||||
echo "<option value='".$form_id_export."'>".dame_nombre_servidorexportacion($form_id_export)."</option>";
|
||||
}
|
||||
echo "<option value='0'>".__('None')."</option>";
|
||||
$sql1='SELECT id, name FROM tserver_export ORDER BY name;';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id"]."'>".$row["name"]."</option>";
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</tr>';
|
||||
|
||||
// tcp send / rcv value
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2" valign="top">'.__('TCP send');
|
||||
pandora_help ("tcp_send");
|
||||
echo "</td>";
|
||||
|
||||
if ($form_id_tipo_modulo >= 15 && $form_id_tipo_modulo <= 18) {
|
||||
echo '<td class="datos2" colspan=3 ><textarea cols=65 style="height:55px;" name="form_tcp_send_void"></textarea>';
|
||||
} else {
|
||||
echo '<td class="datos2" colspan=3 ><textarea cols=65 style="height:55px;" name="form_tcp_send">'.$form_tcp_send.'</textarea>';
|
||||
}
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2" valign="top">'.__('TCP receive')."</td>";
|
||||
echo '<td class="datos2" colspan=3><textarea cols=65 style="height:55px;" name="form_tcp_rcv">'.$form_tcp_rcv.'</textarea>';
|
||||
echo '</tr>';
|
||||
|
||||
// Description
|
||||
echo '<tr>';
|
||||
echo '<td valign="top" class="datos">'.__('Description')."</td>";
|
||||
echo '<td valign="top" class="datos" colspan="3"><textarea name="form_description" cols="65" rows="2">'.$form_description.'</textarea>';
|
||||
echo '</tr>';
|
||||
|
||||
// Custom ID
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Custom ID')."</td>";
|
||||
echo '<td class="datos2" colspan="3"><input type="text" name="form_custom_id" size="20" value="'.$form_custom_id.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
echo '</table>';
|
||||
|
||||
// Submit
|
||||
echo '<table width="680" cellpadding="4" cellspacing="4">';
|
||||
echo '<td valign="top" align="right">';
|
||||
if ($update_module_id == NULL){
|
||||
echo '<input name="crtbutton" type="submit" class="sub wand" value="'.__('Create').'">';
|
||||
} else {
|
||||
echo '<input name="updbutton" type="submit" class="sub wand" value="'.__('Update').'">';
|
||||
}
|
||||
echo '</table>';
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?PHP
|
||||
<?php
|
||||
|
||||
// Pandora FMS - the Free Monitoring System
|
||||
// ========================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnológicas, http://www.artica.es
|
||||
|
@ -22,245 +23,37 @@ if (!isset ($id_agente)) {
|
|||
die ("Not Authorized");
|
||||
}
|
||||
|
||||
// get the variable form_moduletype
|
||||
$form_moduletype = get_parameter_post ("form_moduletype");
|
||||
// get the module to update
|
||||
$update_module_id = get_parameter_get ("update_module");
|
||||
// the variable that checks whether the module is disabled or not must be setcommitedversion
|
||||
$disabled_status = NULL;
|
||||
$extra_title = __('Plugin server module');
|
||||
|
||||
// Specific ACL check
|
||||
if (give_acl($config["id_user"], 0, "AW")!=1) {
|
||||
audit_db($config["id_user"], $REMOTE_ADDR, "ACL Violation","Trying to access agent manager");
|
||||
require ($config["homedir"]."/general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
$data = array ();
|
||||
$data[0] = __('Plugin');
|
||||
$data[1] = print_select_from_sql ('SELECT id, name FROM tplugin ORDER BY name',
|
||||
'id_plugin', $id_plugin, '', __('None'), 0, true, false, false);
|
||||
$table_simple->colspan['plugin_1'][1] = 3;
|
||||
|
||||
// Check whether we are updataing and get data if so
|
||||
if ($update_module_id != NULL){
|
||||
$row = get_db_row ("tagente_modulo", 'id_agente_modulo', $update_module_id);
|
||||
if ($row == 0){
|
||||
unmanaged_error("Cannot load tnetwork_component reference from previous page");
|
||||
}
|
||||
else{
|
||||
$id_agente = $row['id_agente'];
|
||||
$form_id_tipo_modulo = $row['id_tipo_modulo']; // It doesn't matter
|
||||
$form_description = $row['descripcion'];
|
||||
$form_name = $row['nombre'];
|
||||
$form_minvalue = $row['min'];
|
||||
$form_maxvalue = $row['max'];
|
||||
$form_interval = $row['module_interval'];
|
||||
$form_tcp_port = $row['tcp_port'];
|
||||
$form_tcp_send = $row['tcp_send'];
|
||||
$form_tcp_rcv = $row['tcp_rcv'];
|
||||
$form_snmp_community = $row['snmp_community'];
|
||||
$form_snmp_oid = $row['snmp_oid'];
|
||||
$form_ip_target = $row['ip_target'];
|
||||
$form_id_module_group = $row['id_module_group'];
|
||||
$form_flag = $row['flag'];
|
||||
$tbl_id_modulo = $row['id_modulo']; // It doesn't matter
|
||||
$tbl_disabled = $row['disabled'];
|
||||
$form_id_export = $row['id_export'];
|
||||
$form_plugin_user = $row['plugin_user'];
|
||||
$form_plugin_pass = $row['plugin_pass'];
|
||||
$form_plugin_parameter = $row['plugin_parameter'];
|
||||
$form_id_plugin = $row['id_plugin'];
|
||||
$form_post_process = $row['post_process'];
|
||||
$form_prediction_module = $row['prediction_module'];
|
||||
$form_max_timeout = $row['max_timeout'];
|
||||
$form_custom_id = $row['custom_id'];
|
||||
$form_history_data = $row['history_data'];
|
||||
$form_min_warning = $row['min_warning'];
|
||||
$form_max_warning = $row['max_warning'];
|
||||
$form_min_critical = $row['min_critical'];
|
||||
$form_max_critical = $row['max_critical'];
|
||||
$form_ff_event = $row['min_ff_event'];
|
||||
push_table_simple ($data, 'plugin_1');
|
||||
|
||||
if ($tbl_disabled == 1){
|
||||
$disabled_status = 'checked="ckecked"';
|
||||
} else {
|
||||
$disabled_status = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = array ();
|
||||
$data[0] = __('Target IP');
|
||||
$data[1] = print_input_text ('ip_target', $ip_target, '', 15, 60, true);
|
||||
$data[2] = _('Port');
|
||||
$data[3] = print_input_text ('tcp_port', $tcp_port, '', 5, 20, true);
|
||||
|
||||
echo "<h3>".__('Module assignment')." - ".__('Plugin server module')."</h3>";
|
||||
echo '<table width="680" cellpadding="4" cellspacing="4" class="databox_color">';
|
||||
echo '<form name="modulo" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente.'&form_moduletype='.$form_moduletype.'">';
|
||||
// Whether in update or insert mode
|
||||
if ($update_module_id == NULL){
|
||||
echo "<input type='hidden' name='insert_module' value='1'>";
|
||||
} else {
|
||||
echo "<input type='hidden' name='update_module' value='1'>";
|
||||
}
|
||||
push_table_simple ($data, 'target_ip');
|
||||
|
||||
//id_agente_module
|
||||
echo "<input type='hidden' name='id_agente_modulo'' value='".$update_module_id."'>";
|
||||
$data = array ();
|
||||
$data[0] = __('Username');
|
||||
$data[1] = print_input_text ('plugin_user', $plugin_user, '', 15, 60, true);
|
||||
$data[2] = _('Password');
|
||||
$data[3] = print_input_password ('plugin_pass', $plugin_pass, '', 15, 60, true);
|
||||
|
||||
// id_modulo 4 - PLugin
|
||||
echo "<input type='hidden' name='form_id_modulo' value='4'>";
|
||||
push_table_simple ($data, 'plugin_2');
|
||||
|
||||
// Name / IP_target
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Module name')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_name" size="20" value="'.$form_name.'"></td>';
|
||||
echo '<td class="datos2">'.__('Disabled')."</td>";
|
||||
echo '<td class="datos2"><input type="checkbox" name="form_disabled" value="1" "'.$disabled_status.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// Ip target, Plugin Parameter
|
||||
echo "<tr>";
|
||||
echo '<td class="datos">'.__('Target IP')."</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_ip_target" size="20" value="'.$form_ip_target.'"></td>';
|
||||
echo '<td class="datos">'.__('plugin')."</td>";
|
||||
echo '<td class="datos">';
|
||||
// Get actual plugin ID and nicename
|
||||
echo '<select name="form_id_plugin">';
|
||||
if ($form_id_plugin != 0){
|
||||
echo "<option value='".$form_id_plugin."'>".dame_nombre_pluginid($form_id_plugin)."</option>";
|
||||
}
|
||||
echo "<option value='0'>".__('None')."</option>";
|
||||
$sql1='SELECT id, name FROM tplugin ORDER BY name;';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id"]."'>".$row["name"]."</option>";
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</tr>';
|
||||
|
||||
echo '</tr><tr>';
|
||||
echo '<td class="datos2">'.__('Plugin parameters');
|
||||
pandora_help ("plugin_parameters");
|
||||
echo '</td>';
|
||||
echo '<td class="datos2"><input type="text" name="form_plugin_parameter" size="30" value="'.$form_plugin_parameter.'"></td>';
|
||||
|
||||
echo '<td class="datos2">'.__('Port')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_tcp_port" size="4" value="'.$form_tcp_port.'"></td>';
|
||||
|
||||
// username / password
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Username')."</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_plugin_user" size="10" value="'.$form_plugin_user.'"></td>';
|
||||
echo '<td class="datos">'.__('Password')."</td>";
|
||||
echo '<td class="datos"><input type="password" name="form_plugin_pass" size="10" value="'.$form_plugin_pass.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// module type / max timeout
|
||||
echo '</tr><tr>';
|
||||
echo '<td class="datos2">'.__('Module type');
|
||||
pandora_help ("module_type");
|
||||
echo '</td>';
|
||||
echo '<td class="datos2">';
|
||||
|
||||
if ($update_module_id != NULL){
|
||||
echo "<span class='redi'>Not available in edition mode</span>";
|
||||
echo "<input type='hidden' name='form_id_tipo_modulo' value='".$form_id_tipo_modulo."'>";
|
||||
} else {
|
||||
echo '<select name="form_id_tipo_modulo">';
|
||||
$sql1='SELECT id_tipo, nombre FROM ttipo_modulo WHERE categoria IN (0,1,2,9) ORDER BY nombre;';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id_tipo"]."'>".$row["nombre"]."</option>";
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
|
||||
echo '<td class="datos2">'.__('Max. timeout')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_max_timeout" size="5" value="'.$form_max_timeout.'"></td></tr>';
|
||||
|
||||
// Warning value threshold
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Warning status')."</td>";
|
||||
echo '<td class="datos2">'.__("Min.").' <input type="text" name="form_min_warning" size="5" value="'.$form_min_warning.'">';
|
||||
echo ' '.__("Max.").' <input type="text" name="form_max_warning" size="5" value="'.$form_max_warning.'"></td>';
|
||||
|
||||
// Critical value threshold
|
||||
echo '<td class="datos2">'.__('Critical status')."</td>";
|
||||
echo '<td class="datos2">'.__("Min.").' <input type="text" name="form_min_critical" size="5" value="'.$form_min_critical.'">';
|
||||
echo ' '.__("Max.").' <input type="text" name="form_max_critical" size="5" value="'.$form_max_critical.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// History data ?
|
||||
echo "<tr>";
|
||||
echo '<td class="datos2">'.__('Historical data')."</td>";
|
||||
echo '<td class="datos2">';
|
||||
print_checkbox ("form_history_data", 1, $form_history_data, false);
|
||||
|
||||
//FF stands for Flip-Flop
|
||||
echo '<td class="datos">'.__('FF threshold');
|
||||
pandora_help ("ff_threshold");
|
||||
echo '</td>';
|
||||
echo '<td class="datos"><input type="text" name="form_ff_event" size="5" value="'.$form_ff_event.'"></td>';
|
||||
|
||||
|
||||
// Interval & id_module_group
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Interval')."</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_interval" size="5" value="'.$form_interval.'"></td>';
|
||||
echo '<td class="datos">'.__('Module group')."</td>";
|
||||
echo '<td class="datos">';
|
||||
echo '<select name="form_id_module_group">';
|
||||
if ($form_id_module_group != 0){
|
||||
echo "<option value='".$form_id_module_group."'>".dame_nombre_grupomodulo($form_id_module_group)."</option>";
|
||||
}
|
||||
$sql1='SELECT * FROM tmodule_group';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id_mg"]."'>".$row["name"]."</option>";
|
||||
}
|
||||
echo '</select>';
|
||||
|
||||
// Max / min value
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Min. Value')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_minvalue" size="5" value="'.$form_minvalue.'"></td>';
|
||||
echo '<td class="datos2">'.__('Max. Value')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_maxvalue" size="5" value="'.$form_maxvalue.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// Post process / Export server
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Post process');
|
||||
pandora_help ("postprocess");
|
||||
echo '</td>';
|
||||
echo '<td class="datos"><input type="text" name="form_post_process" size="5" value="'.$form_post_process.'"></td>';
|
||||
// Export target is a server where the data will be sent
|
||||
echo '<td class="datos">'.__('Export target')."</td>";
|
||||
echo '<td class="datos"><select name="form_id_export">';
|
||||
if ($form_id_export != 0){
|
||||
echo "<option value='".$form_id_export."'>".dame_nombre_servidorexportacion($form_id_export)."</option>";
|
||||
}
|
||||
echo "<option value='0'>".__('None')."</option>";
|
||||
$sql1='SELECT id, name FROM tserver_export ORDER BY name;';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id"]."'>".$row["name"]."</option>";
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</tr>';
|
||||
|
||||
// Description
|
||||
echo '<tr>';
|
||||
echo '<td valign="top" class="datos2">'.__('Description')."</td>";
|
||||
echo '<td valign="top" class="datos2" colspan="3"><textarea name="form_description" cols="65" rows="2">'.$form_description.'</textarea>';
|
||||
echo '</tr>';
|
||||
|
||||
// Custom ID
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Custom ID')."</td>";
|
||||
echo '<td class="datos" colspan="3"><input type="text" name="form_custom_id" size="20" value="'.$form_custom_id.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
echo '</table>';
|
||||
|
||||
// Submit
|
||||
echo '<table width="680" cellpadding="4" cellspacing="4">';
|
||||
echo '<td valign="top" align="right">';
|
||||
if ($update_module_id == NULL){
|
||||
echo '<input name="crtbutton" type="submit" class="sub wand" value="'.__('Create').'">';
|
||||
} else {
|
||||
echo '<input name="updbutton" type="submit" class="sub wand" value="'.__('Update').'">';
|
||||
}
|
||||
echo '</table>';
|
||||
$data = array ();
|
||||
$data[0] = __('Plugin parameters');
|
||||
$data[0] .= pandora_help ('plugin_parameters', true);
|
||||
$data[1] = print_input_text ('plugin_parameter', $plugin_parameter, '', 30, 60, true);
|
||||
$table_simple->colspan['plugin_3'][1] = 3;
|
||||
|
||||
push_table_simple ($data, 'plugin_3');
|
||||
?>
|
||||
|
|
|
@ -21,162 +21,29 @@ if (!isset ($id_agente)) {
|
|||
die ("Not Authorized");
|
||||
}
|
||||
|
||||
// get the variable form_moduletype
|
||||
$form_moduletype = get_parameter_post ("form_moduletype");
|
||||
// get the module to update
|
||||
$update_module_id = get_parameter_get ("update_module");
|
||||
// the variable that checks whether the module is disabled or not must be setcommitedversion
|
||||
$disabled_status = NULL;
|
||||
|
||||
// Specific ACL check
|
||||
if (give_acl($config["id_user"], 0, "AW") != 1) {
|
||||
audit_db($config["id_user"], $REMOTE_ADDR, "ACL Violation","Trying to access agent manager");
|
||||
require ($config["homedir"]."/general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check whether we are updataing and get data if so
|
||||
if ($update_module_id != NULL){
|
||||
$row = get_db_row ("tagente_modulo", 'id_agente_modulo', $update_module_id);
|
||||
if ($row == 0){
|
||||
unmanaged_error("Cannot load tnetwork_component reference from previous page");
|
||||
}
|
||||
else{
|
||||
$id_agente = $row['id_agente'];
|
||||
$form_id_tipo_modulo = $row['id_tipo_modulo']; // It doesn't matter
|
||||
$form_description = $row['descripcion'];
|
||||
$form_name = $row['nombre'];
|
||||
$form_minvalue = $row['min'];
|
||||
$form_maxvalue = $row['max'];
|
||||
$form_interval = $row['module_interval'];
|
||||
$form_tcp_port = $row['tcp_port'];
|
||||
$form_tcp_send = $row['tcp_send'];
|
||||
$form_tcp_rcv = $row['tcp_rcv'];
|
||||
$form_snmp_community = $row['snmp_community'];
|
||||
$form_snmp_oid = $row['snmp_oid'];
|
||||
$form_ip_target = $row['ip_target'];
|
||||
$form_id_module_group = $row['id_module_group'];
|
||||
$form_flag = $row['flag'];
|
||||
$tbl_id_modulo = $row['id_modulo']; // It doesn't matter
|
||||
$tbl_disabled = $row['disabled'];
|
||||
$form_id_export = $row['id_export'];
|
||||
$form_plugin_user = $row['plugin_user'];
|
||||
$form_plugin_pass = $row['plugin_pass'];
|
||||
$form_plugin_parameter = $row['plugin_parameter'];
|
||||
$form_id_plugin = $row['id_plugin'];
|
||||
$form_post_process = $row['post_process'];
|
||||
$form_prediction_module = $row['prediction_module'];
|
||||
$form_max_timeout = $row['max_timeout'];
|
||||
$form_custom_id = $row['custom_id'];
|
||||
|
||||
if ($tbl_disabled == 1){
|
||||
$disabled_status = 'checked="ckecked"';
|
||||
} else {
|
||||
$disabled_status = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<h3>".__('Module assignment')." - ".__('Prediction server module')."</h3>";
|
||||
echo '<form name="modulo" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente.'">';
|
||||
// Whether in update or insert mode
|
||||
if ($update_module_id == NULL){
|
||||
print_input_hidden ("insert_module", 1);
|
||||
} else {
|
||||
print_input_hidden ("update_module", 1);
|
||||
}
|
||||
|
||||
//id_agente_module
|
||||
print_input_hidden ("id_agente_modulo", $update_module_id);
|
||||
|
||||
// id_modulo 5 - Prediction
|
||||
print_input_hidden ("form_id_modulo", 5);
|
||||
|
||||
// name / disabled
|
||||
echo '<table width="600" cellpadding="4" cellspacing="4" class="databox_color">';
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Module name').'</td>';
|
||||
echo '<td class="datos2">';
|
||||
print_input_text ("form_name", $form_name, '', 35);
|
||||
echo '<td class="datos2">'.__('Disabled').'</td>';
|
||||
echo '<td class="datos2">';
|
||||
print_checkbox ("form_disabled", 1, $disabled_status);
|
||||
echo '</td></tr>';
|
||||
|
||||
//Source module
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Source module');
|
||||
pandora_help ("prediction_source_module");
|
||||
echo '</td>';
|
||||
echo '<td class="datos" colspan="3">';
|
||||
$extra_title = __('Prediction server module');
|
||||
|
||||
$data = array ();
|
||||
$data[0] = __('Source module');
|
||||
$data[0] .= pandora_help ('prediction_source_module', true);
|
||||
$agents = get_group_agents (array_keys (get_user_groups ($config["id_user"], "AW")));
|
||||
$fields = array ();
|
||||
|
||||
foreach ($agents as $agent_id => $agent_name) {
|
||||
$modules = get_agent_modules ($agent_id);
|
||||
$modules = get_agent_modules ($agent_id, false, 'disabled = 0 AND history_data = 1');
|
||||
foreach ($modules as $module_id => $module_name) {
|
||||
$fields[$module_id] = $agent_name.' / '.$module_name;
|
||||
}
|
||||
}
|
||||
$data[1] = print_select ($fields, 'prediction_module', $prediction_module, '',
|
||||
'', '', true);
|
||||
$table_simple->colspan['prediction_module'][1] = 3;
|
||||
|
||||
print_select ($fields, "form_prediction_module", $form_prediction_module);
|
||||
echo '</td></tr>';
|
||||
|
||||
// module type / interval
|
||||
echo '<tr><td class="datos2">'. __('Module type') .'</td><td class="datos2">';
|
||||
if (!empty ($update_module_id)) {
|
||||
echo '<span class="redi">Not available in edition mode</span>';
|
||||
print_input_hidden ("form_id_tipo_modulo", $form_id_tipo_modulo);
|
||||
} else {
|
||||
$fields = array ();
|
||||
$fields[1] = get_moduletype_name (1);
|
||||
$fields[2] = get_moduletype_name (2);
|
||||
print_select ($fields, "form_id_tipo_modulo");
|
||||
}
|
||||
|
||||
echo '<td class="datos2">'.__('Interval').'</td><td class="datos2">';
|
||||
print_input_text ("form_interval", $form_interval, '', 5);
|
||||
echo '</td></tr>';
|
||||
|
||||
// Post process / Export server
|
||||
echo '<tr><td class="datos">'.__('Module group').'</td><td class="datos">';
|
||||
$fields = get_modulegroups ();
|
||||
print_select ($fields, "form_id_module_group", $form_id_module_group);
|
||||
|
||||
// Export target is a server where the data will be sent
|
||||
echo '<td class="datos">'.__('Export target').'</td>';
|
||||
echo '<td class="datos">';
|
||||
|
||||
$fields = get_exportservers_info ();
|
||||
$fields[0] = __('None');
|
||||
|
||||
print_select ($fields, "form_id_export", $form_id_export);
|
||||
echo '</td></tr>';
|
||||
|
||||
// Description
|
||||
echo '<tr>';
|
||||
echo '<td valign="top" class="datos2">'.__('Description').'</td>';
|
||||
echo '<td valign="top" class="datos2" colspan="3">';
|
||||
print_textarea ("form_description", 2, 65, $form_description);
|
||||
echo '</td></tr>';
|
||||
|
||||
// Custom ID
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Custom ID').'</td>';
|
||||
echo '<td class="datos" colspan="3">';
|
||||
print_input_text ("form_custom_id", $form_custom_id, '', 20);
|
||||
echo '</td></tr>';
|
||||
|
||||
echo '</table>';
|
||||
|
||||
// Submit
|
||||
echo '<div style="width:680px; text-align: right">';
|
||||
if ($update_module_id == NULL){
|
||||
print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"');
|
||||
} else {
|
||||
print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"');
|
||||
}
|
||||
echo '</div>';
|
||||
push_table_simple ($data, 'prediction_module');
|
||||
|
||||
/* Removed common useless parameter */
|
||||
unset ($table_simple->data[2]);
|
||||
unset ($table_simple->data[3]);
|
||||
unset ($table_advanced->data[3]);
|
||||
unset ($table_advanced->data[2][2]);
|
||||
unset ($table_advanced->data[2][3]);
|
||||
?>
|
||||
|
|
|
@ -21,277 +21,59 @@ if (!isset ($id_agente)) {
|
|||
die ("Not Authorized");
|
||||
}
|
||||
|
||||
// get the variable form_moduletype
|
||||
$form_moduletype = get_parameter_post ("form_moduletype");
|
||||
// get the module to update
|
||||
$update_module_id = get_parameter_get ("update_module");
|
||||
// the variable that checks whether the module is disabled or not must be setcommitedversion
|
||||
$disabled_status = NULL;
|
||||
$extra_title = __('WMI server module');
|
||||
|
||||
// Specific ACL check
|
||||
if (give_acl($config["id_user"], 0, "AW")!=1) {
|
||||
audit_db($config["id_user"], $REMOTE_ADDR, "ACL Violation","Trying to access agent manager");
|
||||
require ($config["homedir"]."/general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
$data = array ();
|
||||
$data[0] = __('Using module component').' ';
|
||||
$data[0] .= pandora_help ('network_component', true);
|
||||
|
||||
// Check whether we are updataing and get data if so
|
||||
if ($update_module_id != NULL){
|
||||
$row = get_db_row ("tagente_modulo", 'id_agente_modulo', $update_module_id);
|
||||
if ($row == 0){
|
||||
unmanaged_error("Cannot load tnetwork_component reference from previous page");
|
||||
}
|
||||
else{
|
||||
$id_agente = $row['id_agente'];
|
||||
$form_id_tipo_modulo = $row['id_tipo_modulo'];
|
||||
$form_description = $row['descripcion'];
|
||||
$form_name = $row['nombre'];
|
||||
$form_minvalue = $row['min'];
|
||||
$form_maxvalue = $row['max'];
|
||||
$form_interval = $row['module_interval'];
|
||||
$form_tcp_port = $row['tcp_port'];
|
||||
$form_tcp_send = $row['tcp_send'];
|
||||
$form_tcp_rcv = $row['tcp_rcv'];
|
||||
$form_snmp_community = $row['snmp_community'];
|
||||
$form_snmp_oid = $row['snmp_oid'];
|
||||
$form_ip_target = $row['ip_target'];
|
||||
$form_id_module_group = $row['id_module_group'];
|
||||
$form_flag = $row['flag'];
|
||||
$tbl_id_modulo = $row['id_modulo']; // It doesn't matter
|
||||
$tbl_disabled = $row['disabled'];
|
||||
$form_id_export = $row['id_export'];
|
||||
$form_plugin_user = $row['plugin_user'];
|
||||
$form_plugin_pass = $row['plugin_pass'];
|
||||
$form_plugin_parameter = $row['plugin_parameter'];
|
||||
$form_id_plugin = $row['id_plugin'];
|
||||
$form_post_process = $row['post_process'];
|
||||
$form_prediction_module = $row['prediction_module'];
|
||||
$form_max_timeout = $row['max_timeout'];
|
||||
$form_custom_id = $row['custom_id'];
|
||||
$form_history_data = $row['history_data'];
|
||||
$form_min_warning = $row['min_warning'];
|
||||
$form_max_warning = $row['max_warning'];
|
||||
$form_min_critical = $row['min_critical'];
|
||||
$form_max_critical = $row['max_critical'];
|
||||
$form_ff_event = $row['min_ff_event'];
|
||||
|
||||
if ($tbl_disabled == 1){
|
||||
$disabled_status = 'checked="ckecked"';
|
||||
} else {
|
||||
$disabled_status = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<h3>".__('Module assignment')." - ".__('WMI server module')."</h3>";
|
||||
echo '<table width="680" cellpadding="4" cellspacing="4" class="databox_color">';
|
||||
echo '<form name="modulo" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente.'&form_moduletype='.$form_moduletype.'">';
|
||||
// Whether in update or insert mode
|
||||
if ($update_module_id == NULL){
|
||||
echo "<input type='hidden' name='insert_module' value='1'>";
|
||||
if (empty ($update_module_id)) {
|
||||
$data[1] = print_select_from_sql ('SELECT id_nc, name FROM tnetwork_component WHERE id_modulo = 6',
|
||||
'network_component', '', '', '---'.__('Manual setup').'---', 0, true);
|
||||
$data[1] .= ' <span id="component_loading" class="invisible">';
|
||||
$data[1] .= '<img src="images/spinner.gif" />';
|
||||
$data[1] .= '</span>';
|
||||
} else {
|
||||
echo "<input type='hidden' name='update_module' value='1'>";
|
||||
/* TODO: Print network component if available */
|
||||
$data[1] = 'TODO';
|
||||
}
|
||||
$table_simple->colspan['module_component'][1] = 3;
|
||||
$table_simple->rowstyle['module_component'] = 'background-color: #D4DDC6';
|
||||
|
||||
//id_agente_module
|
||||
echo "<input type='hidden' name='id_agente_modulo'' value='".$update_module_id."'>";
|
||||
prepend_table_simple ($data, 'module_component');
|
||||
|
||||
// id_modulo 6 - WMI
|
||||
echo "<input type='hidden' name='form_id_modulo' value='6'>";
|
||||
$data = array ();
|
||||
$data[0] = __('Target IP');
|
||||
$data[1] = print_input_text ('ip_target', $ip_target, '', 15, 60, true);
|
||||
$data[2] = _('Namespace');
|
||||
$data[2] .= pandora_help ('wminamespace', true);
|
||||
$data[3] = print_input_text ('tcp_send', $tcp_send, '', 5, 20, true);
|
||||
|
||||
// WMI component usage
|
||||
echo "<tr><td class='datos3'>";
|
||||
echo __('Using Module Component');
|
||||
pandora_help ("network_component");
|
||||
echo "</td><td class='datos3' colspan=2>";
|
||||
push_table_simple ($data, 'target_ip');
|
||||
|
||||
if ($update_module_id != NULL){
|
||||
echo "<span class='redi'>Not available in edition mode</span>";
|
||||
echo "<input type='hidden' name='form_id_tipo_modulo' value='".$form_id_tipo_modulo."'>";
|
||||
} else {
|
||||
echo '<select name="form_network_component">';
|
||||
echo '<option>---'.__('Manual setup').'---</option>';
|
||||
$result=mysql_query('SELECT * FROM tnetwork_component WHERE id_modulo = 6 ORDER BY name');
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id_nc"]."'>";
|
||||
echo substr($row["name"],0,30);
|
||||
echo " / ";
|
||||
echo substr($row["description"],0,15);
|
||||
echo "</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
}
|
||||
$data = array ();
|
||||
$data[0] = __('Username');
|
||||
$data[1] = print_input_text ('plugin_user', $plugin_user, '', 15, 60, true);
|
||||
$data[2] = _('Password');
|
||||
$data[3] = print_input_password ('plugin_pass', $plugin_pass, '', 15, 60, true);
|
||||
|
||||
echo '</td>';
|
||||
echo '<td class="datos3">';
|
||||
echo '<input type="hidden" name="form_moduletype" value="'.$form_moduletype.'">';
|
||||
if ($update_module_id == NULL){
|
||||
echo '<input align="right" name="updbutton" type="submit" class="sub next" value="'.__('Get data').'">';
|
||||
}
|
||||
push_table_simple ($data, 'user_pass');
|
||||
|
||||
// Name / IP_target
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Module name')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_name" size="20" value="'.$form_name.'"></td>';
|
||||
echo '<td class="datos2">'.__('Disabled')."</td>";
|
||||
echo '<td class="datos2"><input type="checkbox" name="form_disabled" value="1" "'.$disabled_status.'"></td>';
|
||||
echo '</tr>';
|
||||
$data = array ();
|
||||
$data[0] = __('WMI Query');
|
||||
$data[0] .= pandora_help ('wmiquery', true);
|
||||
$data[1] = print_input_text ('snmp_oid', $snmp_oid, '', 35, 60, true);
|
||||
$table_simple->colspan['wmi_query'][1] = 3;
|
||||
|
||||
// Ip target / Namespace
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Target IP')."</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_ip_target" size="20" value="'.$form_ip_target.'"></td>';
|
||||
echo '<td class="datos">'.__('Namespace');
|
||||
pandora_help("wminamespace");
|
||||
echo "</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_tcp_send" size="10" value="'.$form_tcp_send.'"></td>';
|
||||
echo '</tr>';
|
||||
push_table_simple ($data, 'wmi_query');
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('WMI Query');
|
||||
pandora_help("wmiquery");
|
||||
echo '<td class="datos2" colspan="3"><input type="text" name="form_snmp_oid" size="70" value="'.$form_snmp_oid.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// Specific string and field number
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Key string');
|
||||
pandora_help("wmikey");
|
||||
echo "</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_snmp_community" size="20" value="'.$form_snmp_community.'"></td>';
|
||||
echo '<td class="datos">'.__('Field number');
|
||||
pandora_help("wmifield");
|
||||
echo "</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_tcp_port" size="3" value="'.$form_tcp_port.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// username / password
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Username')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_plugin_user" size="10" value="'.$form_plugin_user.'"></td>';
|
||||
echo '<td class="datos2">'.__('Password')."</td>";
|
||||
echo '<td class="datos2"><input type="password" name="form_plugin_pass" size="10" value="'.$form_plugin_pass.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
|
||||
// module type / max timeout
|
||||
echo '</tr><tr>';
|
||||
echo '<td class="datos">'.__('Module type');
|
||||
pandora_help("module_type");
|
||||
echo '</td>';
|
||||
echo '<td class="datos">';
|
||||
if ($update_module_id != NULL){
|
||||
echo "<span class='redi'>Not available in edition mode</span>";
|
||||
echo "<input type='hidden' name='form_id_tipo_modulo' value='".$form_id_tipo_modulo."'>";
|
||||
} else {
|
||||
echo '<select name="form_id_tipo_modulo">';
|
||||
if ($form_id_tipo_modulo != 0) {
|
||||
echo "<option value='".$form_id_tipo_modulo."'>".giveme_module_type($form_id_tipo_modulo)."</option>";
|
||||
}
|
||||
$sql1='SELECT id_tipo, nombre FROM ttipo_modulo WHERE categoria IN (0,1,2) ORDER BY nombre;';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id_tipo"]."'>".$row["nombre"]."</option>";
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
|
||||
echo '<td class="datos">'.__('Max. timeout')."</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_max_timeout" size="5" value="'.$form_max_timeout.'"></td></tr>';
|
||||
|
||||
// Interval & id_module_group
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Interval')."</td>";
|
||||
echo '<td class="datos2"><input type="text" name="form_interval" size="5" value="'.$form_interval.'"></td>';
|
||||
echo '<td class="datos2">'.__('Module group')."</td>";
|
||||
echo '<td class="datos2">';
|
||||
echo '<select name="form_id_module_group">';
|
||||
if ($form_id_module_group != 0){
|
||||
echo "<option value='".$form_id_module_group."'>".dame_nombre_grupomodulo($form_id_module_group)."</option>";
|
||||
}
|
||||
$sql1='SELECT * FROM tmodule_group';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id_mg"]."'>".$row["name"]."</option>";
|
||||
}
|
||||
echo '</select>';
|
||||
|
||||
// Max / min value
|
||||
echo '<tr>';
|
||||
echo '<td class="datos">'.__('Min. Value')."</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_minvalue" size="5" value="'.$form_minvalue.'"></td>';
|
||||
echo '<td class="datos">'.__('Max. Value')."</td>";
|
||||
echo '<td class="datos"><input type="text" name="form_maxvalue" size="5" value="'.$form_maxvalue.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
|
||||
// Warning value threshold
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Warning status')."</td>";
|
||||
echo '<td class="datos2">'.__("Min.").' <input type="text" name="form_min_warning" size="5" value="'.$form_min_warning.'">';
|
||||
echo ' '.__("Max.").' <input type="text" name="form_max_warning" size="5" value="'.$form_max_warning.'"></td>';
|
||||
|
||||
// Critical value threshold
|
||||
echo '<td class="datos2">'.__('Critical status')."</td>";
|
||||
echo '<td class="datos2">'.__("Min.").' <input type="text" name="form_min_critical" size="5" value="'.$form_min_critical.'">';
|
||||
echo ' '.__("Max.").' <input type="text" name="form_max_critical" size="5" value="'.$form_max_critical.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
// History data ?
|
||||
echo "<tr>";
|
||||
echo '<td class="datos2">'.__('Historical data')."</td>";
|
||||
echo '<td class="datos2">';
|
||||
print_checkbox ("form_history_data", 1, $form_history_data, false);
|
||||
|
||||
//FF stands for Flip-Flop
|
||||
echo '<td class="datos">'.__('FF threshold');
|
||||
pandora_help ("ff_threshold");
|
||||
echo '</td>';
|
||||
echo '<td class="datos"><input type="text" name="form_ff_event" size="5" value="'.$form_ff_event.'"></td>';
|
||||
|
||||
// Post process / Export server
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Post process');
|
||||
pandora_help("postprocess");
|
||||
echo '</td>';
|
||||
echo '<td class="datos2"><input type="text" name="form_post_process" size="5" value="'.$form_post_process.'"></td>';
|
||||
// Export target is a server where the data will be sent
|
||||
echo '<td class="datos2">'.__('Export target')."</td>";
|
||||
echo '<td class="datos2"><select name="form_id_export">';
|
||||
if ($form_id_export != 0){
|
||||
echo "<option value='".$form_id_export."'>".dame_nombre_servidorexportacion($form_id_export)."</option>";
|
||||
}
|
||||
echo "<option value='0'>".__('None')."</option>";
|
||||
$sql1='SELECT id, name FROM tserver_export ORDER BY name;';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row["id"]."'>".$row["name"]."</option>";
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</tr>';
|
||||
|
||||
// Description
|
||||
echo '<tr>';
|
||||
echo '<td valign="top" class="datos">'.__('Description')."</td>";
|
||||
echo '<td valign="top" class="datos" colspan="3"><textarea name="form_description" cols="65" rows="2">'.$form_description.'</textarea>';
|
||||
echo '</tr>';
|
||||
|
||||
// Custom ID
|
||||
echo '<tr>';
|
||||
echo '<td class="datos2">'.__('Custom ID')."</td>";
|
||||
echo '<td class="datos2" colspan="3"><input type="text" name="form_custom_id" size="20" value="'.$form_custom_id.'"></td>';
|
||||
echo '</tr>';
|
||||
|
||||
echo '</table>';
|
||||
|
||||
// Submit
|
||||
echo '<table width="680" cellpadding="4" cellspacing="4">';
|
||||
echo '<td valign="top" align="right">';
|
||||
if ($update_module_id == NULL){
|
||||
echo '<input name="crtbutton" type="submit" class="sub wand" value="'.__('Create').'">';
|
||||
} else {
|
||||
echo '<input name="updbutton" type="submit" class="sub wand" value="'.__('Update').'">';
|
||||
}
|
||||
echo '</table>';
|
||||
$data = array ();
|
||||
$data[0] = __('Key string');
|
||||
$data[0] .= pandora_help ('wmikey', true);
|
||||
$data[1] = print_input_text ('snmp_community', $snmp_community, '', 20, 60, true);
|
||||
$data[2] = __('Field number');
|
||||
$data[2] .= pandora_help ('wmifield', true);
|
||||
$data[3] = print_input_text ('tcp_port', $tcp_port, '', 5, 15, true);
|
||||
|
||||
push_table_simple ($data, 'key_field');
|
||||
?>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 574 B |
Binary file not shown.
After Width: | Height: | Size: 673 B |
|
@ -870,6 +870,17 @@ function get_moduletype_name ($id_type) {
|
|||
return (string) get_db_value ('nombre', 'ttipo_modulo', 'id_tipo', (int) $id_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the module type description
|
||||
*
|
||||
* @param int $id_type Type id
|
||||
*
|
||||
* @return string Description of the given type.
|
||||
*/
|
||||
function get_moduletype_description ($id_type) {
|
||||
return (string) get_db_value ('descripcion', 'ttipo_modulo', 'id_tipo', (int) $id_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all module types (default) or if "remote" or "agent"
|
||||
* is passed it will return only remote (ICMP, SNMP, TCP...) module types
|
||||
|
|
|
@ -0,0 +1,602 @@
|
|||
/*
|
||||
* jQuery Form Plugin
|
||||
* version: 2.12 (06/07/2008)
|
||||
* @requires jQuery v1.2.2 or later
|
||||
*
|
||||
* Examples and documentation at: http://malsup.com/jquery/form/
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Revision: $Id$
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
/*
|
||||
Usage Note:
|
||||
-----------
|
||||
Do not use both ajaxSubmit and ajaxForm on the same form. These
|
||||
functions are intended to be exclusive. Use ajaxSubmit if you want
|
||||
to bind your own submit handler to the form. For example,
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#myForm').bind('submit', function() {
|
||||
$(this).ajaxSubmit({
|
||||
target: '#output'
|
||||
});
|
||||
return false; // <-- important!
|
||||
});
|
||||
});
|
||||
|
||||
Use ajaxForm when you want the plugin to manage all the event binding
|
||||
for you. For example,
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#myForm').ajaxForm({
|
||||
target: '#output'
|
||||
});
|
||||
});
|
||||
|
||||
When using ajaxForm, the ajaxSubmit function will be invoked for you
|
||||
at the appropriate time.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ajaxSubmit() provides a mechanism for immediately submitting
|
||||
* an HTML form using AJAX.
|
||||
*/
|
||||
$.fn.ajaxSubmit = function(options) {
|
||||
// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
|
||||
if (!this.length) {
|
||||
log('ajaxSubmit: skipping submit process - no element selected');
|
||||
return this;
|
||||
}
|
||||
|
||||
if (typeof options == 'function')
|
||||
options = { success: options };
|
||||
|
||||
options = $.extend({
|
||||
url: this.attr('action') || window.location.toString(),
|
||||
type: this.attr('method') || 'GET'
|
||||
}, options || {});
|
||||
|
||||
// hook for manipulating the form data before it is extracted;
|
||||
// convenient for use with rich editors like tinyMCE or FCKEditor
|
||||
var veto = {};
|
||||
this.trigger('form-pre-serialize', [this, options, veto]);
|
||||
if (veto.veto) {
|
||||
log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
|
||||
return this;
|
||||
}
|
||||
|
||||
var a = this.formToArray(options.semantic);
|
||||
if (options.data) {
|
||||
options.extraData = options.data;
|
||||
for (var n in options.data)
|
||||
a.push( { name: n, value: options.data[n] } );
|
||||
}
|
||||
|
||||
// give pre-submit callback an opportunity to abort the submit
|
||||
if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
|
||||
log('ajaxSubmit: submit aborted via beforeSubmit callback');
|
||||
return this;
|
||||
}
|
||||
|
||||
// fire vetoable 'validate' event
|
||||
this.trigger('form-submit-validate', [a, this, options, veto]);
|
||||
if (veto.veto) {
|
||||
log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
|
||||
return this;
|
||||
}
|
||||
|
||||
var q = $.param(a);
|
||||
|
||||
if (options.type.toUpperCase() == 'GET') {
|
||||
options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
|
||||
options.data = null; // data is null for 'get'
|
||||
}
|
||||
else
|
||||
options.data = q; // data is the query string for 'post'
|
||||
|
||||
var $form = this, callbacks = [];
|
||||
if (options.resetForm) callbacks.push(function() { $form.resetForm(); });
|
||||
if (options.clearForm) callbacks.push(function() { $form.clearForm(); });
|
||||
|
||||
// perform a load on the target only if dataType is not provided
|
||||
if (!options.dataType && options.target) {
|
||||
var oldSuccess = options.success || function(){};
|
||||
callbacks.push(function(data) {
|
||||
$(options.target).html(data).each(oldSuccess, arguments);
|
||||
});
|
||||
}
|
||||
else if (options.success)
|
||||
callbacks.push(options.success);
|
||||
|
||||
options.success = function(data, status) {
|
||||
for (var i=0, max=callbacks.length; i < max; i++)
|
||||
callbacks[i](data, status, $form);
|
||||
};
|
||||
|
||||
// are there files to upload?
|
||||
var files = $('input:file', this).fieldValue();
|
||||
var found = false;
|
||||
for (var j=0; j < files.length; j++)
|
||||
if (files[j])
|
||||
found = true;
|
||||
|
||||
// options.iframe allows user to force iframe mode
|
||||
if (options.iframe || found) {
|
||||
// hack to fix Safari hang (thanks to Tim Molendijk for this)
|
||||
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
|
||||
if ($.browser.safari && options.closeKeepAlive)
|
||||
$.get(options.closeKeepAlive, fileUpload);
|
||||
else
|
||||
fileUpload();
|
||||
}
|
||||
else
|
||||
$.ajax(options);
|
||||
|
||||
// fire 'notify' event
|
||||
this.trigger('form-submit-notify', [this, options]);
|
||||
return this;
|
||||
|
||||
|
||||
// private function for handling file uploads (hat tip to YAHOO!)
|
||||
function fileUpload() {
|
||||
var form = $form[0];
|
||||
|
||||
if ($(':input[@name=submit]', form).length) {
|
||||
alert('Error: Form elements must not be named "submit".');
|
||||
return;
|
||||
}
|
||||
|
||||
var opts = $.extend({}, $.ajaxSettings, options);
|
||||
|
||||
var id = 'jqFormIO' + (new Date().getTime());
|
||||
var $io = $('<iframe id="' + id + '" name="' + id + '" />');
|
||||
var io = $io[0];
|
||||
|
||||
if ($.browser.msie || $.browser.opera)
|
||||
io.src = 'javascript:false;document.write("");';
|
||||
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
|
||||
|
||||
var xhr = { // mock object
|
||||
responseText: null,
|
||||
responseXML: null,
|
||||
status: 0,
|
||||
statusText: 'n/a',
|
||||
getAllResponseHeaders: function() {},
|
||||
getResponseHeader: function() {},
|
||||
setRequestHeader: function() {}
|
||||
};
|
||||
|
||||
var g = opts.global;
|
||||
// trigger ajax global events so that activity/block indicators work like normal
|
||||
if (g && ! $.active++) $.event.trigger("ajaxStart");
|
||||
if (g) $.event.trigger("ajaxSend", [xhr, opts]);
|
||||
|
||||
var cbInvoked = 0;
|
||||
var timedOut = 0;
|
||||
|
||||
// add submitting element to data if we know it
|
||||
var sub = form.clk;
|
||||
if (sub) {
|
||||
var n = sub.name;
|
||||
if (n && !sub.disabled) {
|
||||
options.extraData = options.extraData || {};
|
||||
options.extraData[n] = sub.value;
|
||||
if (sub.type == "image") {
|
||||
options.extraData[name+'.x'] = form.clk_x;
|
||||
options.extraData[name+'.y'] = form.clk_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// take a breath so that pending repaints get some cpu time before the upload starts
|
||||
setTimeout(function() {
|
||||
// make sure form attrs are set
|
||||
var t = $form.attr('target'), a = $form.attr('action');
|
||||
$form.attr({
|
||||
target: id,
|
||||
encoding: 'multipart/form-data',
|
||||
enctype: 'multipart/form-data',
|
||||
method: 'POST',
|
||||
action: opts.url
|
||||
});
|
||||
|
||||
// support timout
|
||||
if (opts.timeout)
|
||||
setTimeout(function() { timedOut = true; cb(); }, opts.timeout);
|
||||
|
||||
// add "extra" data to form if provided in options
|
||||
var extraInputs = [];
|
||||
try {
|
||||
if (options.extraData)
|
||||
for (var n in options.extraData)
|
||||
extraInputs.push(
|
||||
$('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />')
|
||||
.appendTo(form)[0]);
|
||||
|
||||
// add iframe to doc and submit the form
|
||||
$io.appendTo('body');
|
||||
io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
|
||||
form.submit();
|
||||
}
|
||||
finally {
|
||||
// reset attrs and remove "extra" input elements
|
||||
$form.attr('action', a);
|
||||
t ? $form.attr('target', t) : $form.removeAttr('target');
|
||||
$(extraInputs).remove();
|
||||
}
|
||||
}, 10);
|
||||
|
||||
function cb() {
|
||||
if (cbInvoked++) return;
|
||||
|
||||
io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
|
||||
|
||||
var operaHack = 0;
|
||||
var ok = true;
|
||||
try {
|
||||
if (timedOut) throw 'timeout';
|
||||
// extract the server response from the iframe
|
||||
var data, doc;
|
||||
|
||||
doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
|
||||
|
||||
if (doc.body == null && !operaHack && $.browser.opera) {
|
||||
// In Opera 9.2.x the iframe DOM is not always traversable when
|
||||
// the onload callback fires so we give Opera 100ms to right itself
|
||||
operaHack = 1;
|
||||
cbInvoked--;
|
||||
setTimeout(cb, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
xhr.responseText = doc.body ? doc.body.innerHTML : null;
|
||||
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
|
||||
xhr.getResponseHeader = function(header){
|
||||
var headers = {'content-type': opts.dataType};
|
||||
return headers[header];
|
||||
};
|
||||
|
||||
if (opts.dataType == 'json' || opts.dataType == 'script') {
|
||||
var ta = doc.getElementsByTagName('textarea')[0];
|
||||
xhr.responseText = ta ? ta.value : xhr.responseText;
|
||||
}
|
||||
else if (opts.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
|
||||
xhr.responseXML = toXml(xhr.responseText);
|
||||
}
|
||||
data = $.httpData(xhr, opts.dataType);
|
||||
}
|
||||
catch(e){
|
||||
ok = false;
|
||||
$.handleError(opts, xhr, 'error', e);
|
||||
}
|
||||
|
||||
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
|
||||
if (ok) {
|
||||
opts.success(data, 'success');
|
||||
if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);
|
||||
}
|
||||
if (g) $.event.trigger("ajaxComplete", [xhr, opts]);
|
||||
if (g && ! --$.active) $.event.trigger("ajaxStop");
|
||||
if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');
|
||||
|
||||
// clean up
|
||||
setTimeout(function() {
|
||||
$io.remove();
|
||||
xhr.responseXML = null;
|
||||
}, 100);
|
||||
};
|
||||
|
||||
function toXml(s, doc) {
|
||||
if (window.ActiveXObject) {
|
||||
doc = new ActiveXObject('Microsoft.XMLDOM');
|
||||
doc.async = 'false';
|
||||
doc.loadXML(s);
|
||||
}
|
||||
else
|
||||
doc = (new DOMParser()).parseFromString(s, 'text/xml');
|
||||
return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* ajaxForm() provides a mechanism for fully automating form submission.
|
||||
*
|
||||
* The advantages of using this method instead of ajaxSubmit() are:
|
||||
*
|
||||
* 1: This method will include coordinates for <input type="image" /> elements (if the element
|
||||
* is used to submit the form).
|
||||
* 2. This method will include the submit element's name/value data (for the element that was
|
||||
* used to submit the form).
|
||||
* 3. This method binds the submit() method to the form for you.
|
||||
*
|
||||
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
|
||||
* passes the options argument along after properly binding events for submit elements and
|
||||
* the form itself.
|
||||
*/
|
||||
$.fn.ajaxForm = function(options) {
|
||||
return this.ajaxFormUnbind().bind('submit.form-plugin',function() {
|
||||
$(this).ajaxSubmit(options);
|
||||
return false;
|
||||
}).each(function() {
|
||||
// store options in hash
|
||||
$(":submit,input:image", this).bind('click.form-plugin',function(e) {
|
||||
var $form = this.form;
|
||||
$form.clk = this;
|
||||
if (this.type == 'image') {
|
||||
if (e.offsetX != undefined) {
|
||||
$form.clk_x = e.offsetX;
|
||||
$form.clk_y = e.offsetY;
|
||||
} else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
|
||||
var offset = $(this).offset();
|
||||
$form.clk_x = e.pageX - offset.left;
|
||||
$form.clk_y = e.pageY - offset.top;
|
||||
} else {
|
||||
$form.clk_x = e.pageX - this.offsetLeft;
|
||||
$form.clk_y = e.pageY - this.offsetTop;
|
||||
}
|
||||
}
|
||||
// clear form vars
|
||||
setTimeout(function() { $form.clk = $form.clk_x = $form.clk_y = null; }, 10);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
|
||||
$.fn.ajaxFormUnbind = function() {
|
||||
this.unbind('submit.form-plugin');
|
||||
return this.each(function() {
|
||||
$(":submit,input:image", this).unbind('click.form-plugin');
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* formToArray() gathers form element data into an array of objects that can
|
||||
* be passed to any of the following ajax functions: $.get, $.post, or load.
|
||||
* Each object in the array has both a 'name' and 'value' property. An example of
|
||||
* an array for a simple login form might be:
|
||||
*
|
||||
* [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
|
||||
*
|
||||
* It is this array that is passed to pre-submit callback functions provided to the
|
||||
* ajaxSubmit() and ajaxForm() methods.
|
||||
*/
|
||||
$.fn.formToArray = function(semantic) {
|
||||
var a = [];
|
||||
if (this.length == 0) return a;
|
||||
|
||||
var form = this[0];
|
||||
var els = semantic ? form.getElementsByTagName('*') : form.elements;
|
||||
if (!els) return a;
|
||||
for(var i=0, max=els.length; i < max; i++) {
|
||||
var el = els[i];
|
||||
var n = el.name;
|
||||
if (!n) continue;
|
||||
|
||||
if (semantic && form.clk && el.type == "image") {
|
||||
// handle image inputs on the fly when semantic == true
|
||||
if(!el.disabled && form.clk == el)
|
||||
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
|
||||
continue;
|
||||
}
|
||||
|
||||
var v = $.fieldValue(el, true);
|
||||
if (v && v.constructor == Array) {
|
||||
for(var j=0, jmax=v.length; j < jmax; j++)
|
||||
a.push({name: n, value: v[j]});
|
||||
}
|
||||
else if (v !== null && typeof v != 'undefined')
|
||||
a.push({name: n, value: v});
|
||||
}
|
||||
|
||||
if (!semantic && form.clk) {
|
||||
// input type=='image' are not found in elements array! handle them here
|
||||
var inputs = form.getElementsByTagName("input");
|
||||
for(var i=0, max=inputs.length; i < max; i++) {
|
||||
var input = inputs[i];
|
||||
var n = input.name;
|
||||
if(n && !input.disabled && input.type == "image" && form.clk == input)
|
||||
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
|
||||
}
|
||||
}
|
||||
return a;
|
||||
};
|
||||
|
||||
/**
|
||||
* Serializes form data into a 'submittable' string. This method will return a string
|
||||
* in the format: name1=value1&name2=value2
|
||||
*/
|
||||
$.fn.formSerialize = function(semantic) {
|
||||
//hand off to jQuery.param for proper encoding
|
||||
return $.param(this.formToArray(semantic));
|
||||
};
|
||||
|
||||
/**
|
||||
* Serializes all field elements in the jQuery object into a query string.
|
||||
* This method will return a string in the format: name1=value1&name2=value2
|
||||
*/
|
||||
$.fn.fieldSerialize = function(successful) {
|
||||
var a = [];
|
||||
this.each(function() {
|
||||
var n = this.name;
|
||||
if (!n) return;
|
||||
var v = $.fieldValue(this, successful);
|
||||
if (v && v.constructor == Array) {
|
||||
for (var i=0,max=v.length; i < max; i++)
|
||||
a.push({name: n, value: v[i]});
|
||||
}
|
||||
else if (v !== null && typeof v != 'undefined')
|
||||
a.push({name: this.name, value: v});
|
||||
});
|
||||
//hand off to jQuery.param for proper encoding
|
||||
return $.param(a);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the value(s) of the element in the matched set. For example, consider the following form:
|
||||
*
|
||||
* <form><fieldset>
|
||||
* <input name="A" type="text" />
|
||||
* <input name="A" type="text" />
|
||||
* <input name="B" type="checkbox" value="B1" />
|
||||
* <input name="B" type="checkbox" value="B2"/>
|
||||
* <input name="C" type="radio" value="C1" />
|
||||
* <input name="C" type="radio" value="C2" />
|
||||
* </fieldset></form>
|
||||
*
|
||||
* var v = $(':text').fieldValue();
|
||||
* // if no values are entered into the text inputs
|
||||
* v == ['','']
|
||||
* // if values entered into the text inputs are 'foo' and 'bar'
|
||||
* v == ['foo','bar']
|
||||
*
|
||||
* var v = $(':checkbox').fieldValue();
|
||||
* // if neither checkbox is checked
|
||||
* v === undefined
|
||||
* // if both checkboxes are checked
|
||||
* v == ['B1', 'B2']
|
||||
*
|
||||
* var v = $(':radio').fieldValue();
|
||||
* // if neither radio is checked
|
||||
* v === undefined
|
||||
* // if first radio is checked
|
||||
* v == ['C1']
|
||||
*
|
||||
* The successful argument controls whether or not the field element must be 'successful'
|
||||
* (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
|
||||
* The default value of the successful argument is true. If this value is false the value(s)
|
||||
* for each element is returned.
|
||||
*
|
||||
* Note: This method *always* returns an array. If no valid value can be determined the
|
||||
* array will be empty, otherwise it will contain one or more values.
|
||||
*/
|
||||
$.fn.fieldValue = function(successful) {
|
||||
for (var val=[], i=0, max=this.length; i < max; i++) {
|
||||
var el = this[i];
|
||||
var v = $.fieldValue(el, successful);
|
||||
if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length))
|
||||
continue;
|
||||
v.constructor == Array ? $.merge(val, v) : val.push(v);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the value of the field element.
|
||||
*/
|
||||
$.fieldValue = function(el, successful) {
|
||||
var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
|
||||
if (typeof successful == 'undefined') successful = true;
|
||||
|
||||
if (successful && (!n || el.disabled || t == 'reset' ||
|
||||
(t == 'checkbox' || t == 'radio') && !el.checked ||
|
||||
(t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
|
||||
tag == 'select' && el.selectedIndex == -1))
|
||||
return null;
|
||||
|
||||
if (tag == 'select') {
|
||||
var index = el.selectedIndex;
|
||||
if (index < 0) return null;
|
||||
var a = [], ops = el.options;
|
||||
var one = (t == 'select-one');
|
||||
var max = (one ? index+1 : ops.length);
|
||||
for(var i=(one ? index : 0); i < max; i++) {
|
||||
var op = ops[i];
|
||||
if (op.selected) {
|
||||
// extra pain for IE...
|
||||
var v = $.browser.msie && !(op.attributes['value'].specified) ? op.text : op.value;
|
||||
if (one) return v;
|
||||
a.push(v);
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return el.value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears the form data. Takes the following actions on the form's input fields:
|
||||
* - input text fields will have their 'value' property set to the empty string
|
||||
* - select elements will have their 'selectedIndex' property set to -1
|
||||
* - checkbox and radio inputs will have their 'checked' property set to false
|
||||
* - inputs of type submit, button, reset, and hidden will *not* be effected
|
||||
* - button elements will *not* be effected
|
||||
*/
|
||||
$.fn.clearForm = function() {
|
||||
return this.each(function() {
|
||||
$('input,select,textarea', this).clearFields();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears the selected form elements.
|
||||
*/
|
||||
$.fn.clearFields = $.fn.clearInputs = function() {
|
||||
return this.each(function() {
|
||||
var t = this.type, tag = this.tagName.toLowerCase();
|
||||
if (t == 'text' || t == 'password' || tag == 'textarea')
|
||||
this.value = '';
|
||||
else if (t == 'checkbox' || t == 'radio')
|
||||
this.checked = false;
|
||||
else if (tag == 'select')
|
||||
this.selectedIndex = -1;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Resets the form data. Causes all form elements to be reset to their original value.
|
||||
*/
|
||||
$.fn.resetForm = function() {
|
||||
return this.each(function() {
|
||||
// guard against an input with the name of 'reset'
|
||||
// note that IE reports the reset function as an 'object'
|
||||
if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType))
|
||||
this.reset();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Enables or disables any matching elements.
|
||||
*/
|
||||
$.fn.enable = function(b) {
|
||||
if (b == undefined) b = true;
|
||||
return this.each(function() {
|
||||
this.disabled = !b
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks/unchecks any matching checkboxes or radio buttons and
|
||||
* selects/deselects and matching option elements.
|
||||
*/
|
||||
$.fn.select = function(select) {
|
||||
if (select == undefined) select = true;
|
||||
return this.each(function() {
|
||||
var t = this.type;
|
||||
if (t == 'checkbox' || t == 'radio')
|
||||
this.checked = select;
|
||||
else if (this.tagName.toLowerCase() == 'option') {
|
||||
var $sel = $(this).parent('select');
|
||||
if (select && $sel[0] && $sel[0].type == 'select-one') {
|
||||
// deselect all other options
|
||||
$sel.find('option').select(false);
|
||||
}
|
||||
this.selected = select;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// helper fn for console logging
|
||||
// set $.fn.ajaxSubmit.debug to true to enable debug logging
|
||||
function log() {
|
||||
if ($.fn.ajaxSubmit.debug && window.console && window.console.log)
|
||||
window.console.log('[jquery.form] ' + Array.prototype.join.call(arguments,''));
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
$(document).ready (function () {
|
||||
$.fn.check = function () {
|
||||
return this.each (function () {
|
||||
this.checked = true;
|
||||
})};
|
||||
|
||||
$.fn.uncheck = function () {
|
||||
return this.each (function () {
|
||||
this.checked = false;
|
||||
})};
|
||||
$.fn.enable = function () {
|
||||
return $(this).removeAttr ("disabled");
|
||||
};
|
||||
$.fn.disable = function () {
|
||||
return $(this).attr ("disabled", "disabled");
|
||||
};
|
||||
$.fn.pulsate = function () {
|
||||
return $(this).fadeIn ("normal", function () {
|
||||
$(this).fadeOut ("normal", function () {
|
||||
$(this).fadeIn ("normal", function () {
|
||||
$(this).fadeOut ("normal", function () {
|
||||
$(this).fadeIn ().focus ();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/* Function to hide/unhide a specific Div id */
|
||||
function toggleDiv (divid){
|
||||
if (document.getElementById(divid).style.display == 'none') {
|
||||
|
@ -33,3 +32,19 @@ function html_entity_decode (str) {
|
|||
return ta.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to search an element in an array.
|
||||
*
|
||||
* Extends the array object to use it like a method in an array object. Example:
|
||||
* <code>
|
||||
a = Array (4, 7, 9);
|
||||
alert (a.in_array (4)); // true
|
||||
alert (a.in_array (5)); // false
|
||||
*/
|
||||
Array.prototype.in_array = function () {
|
||||
for (var j in this) {
|
||||
if(this[j] == arguments[0])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -755,3 +755,18 @@ select#template, select#action {
|
|||
input[type=image] {
|
||||
border:0px;
|
||||
}
|
||||
table#simple select#id_module_type {
|
||||
width: 200px;
|
||||
}
|
||||
table#simple select#select_snmp_oid,
|
||||
table#simple select#id_plugin {
|
||||
width: 270px;
|
||||
}
|
||||
table#simple input#text-plugin_parameter,
|
||||
table#simple input#text-snmp_oid,
|
||||
table#simple select#prediction_module {
|
||||
width: 100%;
|
||||
}
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
@ -143,9 +143,10 @@ echo '<title>Pandora FMS - '.__('the Flexible Monitoring System').'</title>
|
|||
<meta name="robots" content="index, follow" />
|
||||
<link rel="icon" href="images/pandora.ico" type="image/ico" />
|
||||
<link rel="stylesheet" href="include/styles/'.$config["style"].'.css" type="text/css" />
|
||||
<script type="text/javascript" src="include/javascript/wz_jsgraphics.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/jquery.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/pandora.js"></script>';
|
||||
<script type="text/javascript" src="include/javascript/wz_jsgraphics.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/pandora.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/jquery.pandora.js"></script>';
|
||||
|
||||
enterprise_hook ('load_html_header');
|
||||
|
||||
|
|
|
@ -237,7 +237,6 @@ CREATE TABLE IF NOT EXISTS `talert_templates` (
|
|||
`time_threshold` int(10) NOT NULL default '0',
|
||||
`max_alerts` int(4) unsigned NOT NULL default '1',
|
||||
`min_alerts` int(4) unsigned NOT NULL default '0',
|
||||
`alert_text` varchar(255) default '',
|
||||
`time_from` time default '00:00:00',
|
||||
`time_to` time default '00:00:00',
|
||||
`monday` tinyint(1) default 1,
|
||||
|
|
|
@ -68,7 +68,6 @@ CREATE TABLE IF NOT EXISTS `talert_templates` (
|
|||
`time_threshold` int(10) NOT NULL default '0',
|
||||
`max_alerts` int(4) unsigned NOT NULL default '1',
|
||||
`min_alerts` int(4) unsigned NOT NULL default '0',
|
||||
`alert_text` varchar(255) default '',
|
||||
`time_from` time default '00:00:00',
|
||||
`time_to` time default '00:00:00',
|
||||
`monday` tinyint(1) default 1,
|
||||
|
|
Loading…
Reference in New Issue