From d135f1334f26c0f15221f9379a550046aa24e7ae Mon Sep 17 00:00:00 2001 From: slerena Date: Mon, 16 Jun 2008 18:09:56 +0000 Subject: [PATCH] 2008-06-16 Sancho Lerena * pandoradb_data.sql: Updated some new config tokens (graph colors), updated group default names and icons, * manage_config_remote.php, godmode/menu.php: Added new config to manage/copy remote config from one agent to other(s). * agent_manager.php: When create a new agent, cannot select group "ALL". * agent_template.php: Fixed a weird bug that creates two tagente_estado records when using a module template. * alert_manager_editor.php: Fixed ACL problem assigning combined alert components. Better management of NOP in combined alerts (Automated NOP when create the first component. Added NAND, NXOR y NOR). * manage_config.php: Solved some bugs copying configuration with new modules (Added support for new module types). Added filter for group and fixed ACL problems. Code cleanup and better layout. * module_manager_editor_prediction.php: ACL checks added. * config_process.php, setup.php: Support to choose color graphs. * functions.php: Fixed typo and removed N/A for alerts with min/max = 0 * functions_db.php: Fixed another typo in give_disabled_group(), and added feature to list_group() combo to render or now group "ALL". * estado_generalagente.php: Added network push button for whole agent. * tactical.php: Some minor layout improvement. * ver_agente.php: Network FLAG change request for whole group, and fixed manual validation on combined alerts. * events.php: Event description don't show with " ' "characters. Fixed. * fgraph.php: graph_event_module() restored (was missing in last commit), added user-defined color support. * stat_win.php: Added support to choose another date for graph. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@866 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 50 +- pandora_console/general/logon_ok.php | 5 +- .../godmode/agentes/agent_manager.php | 3 +- .../godmode/agentes/agent_template.php | 5 +- .../godmode/agentes/alert_manager_editor.php | 46 +- .../godmode/agentes/configurar_agente.php | 4 +- .../godmode/agentes/manage_config.php | 702 ++++++++++-------- .../godmode/agentes/manage_config_remote.php | 142 ++++ .../module_manager_editor_prediction.php | 5 +- pandora_console/godmode/menu.php | 11 +- pandora_console/godmode/setup/setup.php | 46 +- pandora_console/include/config_process.php | 10 + pandora_console/include/functions.php | 7 +- pandora_console/include/functions_db.php | 14 +- pandora_console/include/javascript/pandora.js | 2 +- .../include/styles/pandora_minimal.css | 12 +- .../agentes/estado_generalagente.php | 27 +- .../operation/agentes/tactical.php | 3 +- .../operation/agentes/ver_agente.php | 27 +- pandora_console/operation/events/events.php | 5 +- pandora_console/pandoradb_data.sql | 35 +- pandora_console/reporting/fgraph.php | 19 +- pandora_console/reporting/stat_win.php | 122 ++- 23 files changed, 811 insertions(+), 491 deletions(-) create mode 100644 pandora_console/godmode/agentes/manage_config_remote.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7593b0e469..55f1d4e00c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,13 +1,57 @@ -2008-06-15 Esteban Sanchez +2008-06-16 Sancho Lerena + + * pandoradb_data.sql: Updated some new config tokens (graph colors), + updated group default names and icons, + + * manage_config_remote.php, godmode/menu.php: Added new config to + manage/copy remote config from one agent to other(s). + + * agent_manager.php: When create a new agent, cannot select group "ALL". + + * agent_template.php: Fixed a weird bug that creates two tagente_estado + records when using a module template. + + * alert_manager_editor.php: Fixed ACL problem assigning combined alert + components. Better management of NOP in combined alerts (Automated NOP + when create the first component. Added NAND, NXOR y NOR). + + * manage_config.php: Solved some bugs copying configuration with new + modules (Added support for new module types). Added filter for group and + fixed ACL problems. Code cleanup and better layout. + + * module_manager_editor_prediction.php: ACL checks added. + + * config_process.php, setup.php: Support to choose color graphs. + + * functions.php: Fixed typo and removed N/A for alerts with min/max = 0 + + * functions_db.php: Fixed another typo in give_disabled_group(), and added + feature to list_group() combo to render or now group "ALL". + + * estado_generalagente.php: Added network push button for whole agent. + + * tactical.php: Some minor layout improvement. + + * ver_agente.php: Network FLAG change request for whole group, and fixed + manual validation on combined alerts. + + * events.php: Event description don't show with " ' "characters. Fixed. + + * fgraph.php: graph_event_module() restored (was missing in last commit), + added user-defined color support. + + * stat_win.php: Added support to choose another date for graph. + +2008-06-16 Esteban Sanchez * reporting/fgraph.php: Fixed a regresion bug with progress bar mode. -2008-06-15 Esteban Sanchez +2008-06-16 Esteban Sanchez * reporting/fgraph.php: Fixed bug with graphic_combined_module() that was causing not to work right. -2008-06-15 Esteban Sanchez +2008-06-16 Esteban Sanchez * include/functions_html.php: Added to repository. Implements HTML functions. diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index 3e456a05e5..22972e67c4 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -97,9 +97,7 @@ } else $global_health = 100; - -echo ""; - + echo "
"; //echo "

".$lang_label["tactical_indicator"]."

"; //echo ""; @@ -118,7 +116,6 @@ echo "
"; echo "
".lang_string("Alert level").""; echo "
"; - echo "
"; $query1 = "SELECT COUNT(id_usuario) FROM tusuario"; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index f39229b3b2..734baad789 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -109,11 +109,10 @@ else echo ''.$lang_label["group"].''; echo '"; echo ""; diff --git a/pandora_console/godmode/agentes/agent_template.php b/pandora_console/godmode/agentes/agent_template.php index 5bb8772147..3acb25c148 100644 --- a/pandora_console/godmode/agentes/agent_template.php +++ b/pandora_console/godmode/agentes/agent_template.php @@ -47,8 +47,6 @@ if (isset($_POST["template_id"])){ $os_version = $row["os_version"]; $agent_version = $row["agent_version"]; $disabled= $row["disabled"]; - $agent_type= $row["agent_type"]; - $server = $row["id_server"]; } $id_np = $_POST["template_id"]; @@ -104,6 +102,7 @@ if (isset($_POST["template_id"])){ )"; } mysql_query ($sql_insert); + $sql_insert = ""; } } echo "

".$lang_label["add_mod_ok"]."

"; @@ -125,7 +124,7 @@ echo ""; echo "
".$lang_label['template'].""; echo ""; // Add to combo single alerts - $result_alert = mysql_query("SELECT tagente_modulo.id_agente_modulo, tagente.nombre, tagente_modulo.nombre, id_aam FROM talerta_agente_modulo, tagente_modulo, tagente WHERE talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_agente = tagente.id_agente"); + $result_alert = mysql_query("SELECT tagente_modulo.id_agente_modulo, tagente.nombre, tagente_modulo.nombre, id_aam, tagente.id_grupo FROM talerta_agente_modulo, tagente_modulo, tagente WHERE talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_agente = tagente.id_agente"); while ($alertrow = mysql_fetch_array($result_alert)){ - echo ""; - echo lang_string ("Operation"); - echo ""; - echo ""; - echo ""; + + + // there is any component already in this alert ? + + $result = mysql_query ("SELECT COUNT(*) FROM tcompound_alert, talerta_agente_modulo WHERE tcompound_alert.id = $id_aam AND talerta_agente_modulo.id_aam = tcompound_alert.id_aam"); + $row=mysql_fetch_array($result); + if ($row[0] > 0){ + echo ""; + echo lang_string ("Operation"); + echo ""; + echo ""; + } else { + echo ""; + } + echo ""; echo ''; echo ""; echo "
"; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 192a2d3972..b860316a33 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -134,8 +134,7 @@ if ( isset ($_POST["create_agent"])) { // Create a new and shining agent $agent_creation_error = ""; $id_agente = mysql_insert_id (); // Create special MODULE agent_keepalive - $sql_insert = "INSERT INTO tagente_modulo (nombre, id_agente, id_tipo_modulo, descripcion, id_modulo) - VALUES ('agent_keepalive', ".$id_agente.",100,'Agent Keepalive monitor',1)"; + $sql_insert = "INSERT INTO tagente_modulo (nombre, id_agente, id_tipo_modulo, descripcion, id_modulo) VALUES ('agent_keepalive', ".$id_agente.",100,'Agent Keepalive monitor',1)"; $result=mysql_query($sql_insert); $id_agent_module = mysql_insert_id(); // And create MODULE agent_keepalive in tagente_estado table @@ -435,7 +434,6 @@ if (isset($_POST["update_alert"])){ // Update an existing alert $result=mysql_query($sql_insert); if (! $result) { echo "

".$lang_label["update_alert_no"]."

"; - // echo "SQL DEBUG ".$sql_insert; } else echo "

".$lang_label["update_agent_ok"]."

"; diff --git a/pandora_console/godmode/agentes/manage_config.php b/pandora_console/godmode/agentes/manage_config.php index 3c187186e2..8b3532975b 100644 --- a/pandora_console/godmode/agentes/manage_config.php +++ b/pandora_console/godmode/agentes/manage_config.php @@ -1,9 +1,9 @@ // This program is free software; you can redistribute it and/or @@ -21,319 +21,407 @@ // Load global vars require("include/config.php"); -if (comprueba_login() == 0) - $id_user = $_SESSION["id_usuario"]; - if ( (give_acl($id_user, 0, "LM")==1) OR (give_acl($id_user, 0, "AW")==1) ){ +comprueba_login(); + +$id_user = $_SESSION["id_usuario"]; +$id_group = get_parameter ("id_group",0); +$origen = get_parameter ("origen", -1); +$update_agent = get_parameter ("update_agent", -1); +$update_group = get_parameter ("update_group", -1); + +if ( (give_acl($id_user, 0, "LM")==0) AND (give_acl($id_user, 0, "AW")==0) ){ + audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent Config Management Admin section"); + require ("general/noaccess.php"); +} - if ((isset($_GET["operacion"])) AND (! isset($_POST["update_agent"]))){ - // DATA COPY - if (isset($_POST["copy"])) { - echo "

".$lang_label["datacopy"]."

"; - // Initial checkings - - // if selected more than 0 agents - $destino = $_POST["destino"]; - if (count($destino) <= 0){ - echo "

ERROR: ".$lang_label["noagents_cp"]."

"; - echo ""; - include ("general/footer.php"); - exit; - } - $origen_modulo = $_POST["origen_modulo"]; - if (count($origen_modulo) <= 0){ - echo "

ERROR: ".$lang_label["nomodules_selected"]."

"; - echo ""; - include ("general/footer.php"); - exit; - } +// Operations +// --------------- +if ((isset($_GET["operacion"])) AND ($update_agent == -1) AND ($update_group == -1) ) { - $multiple=1; + // DATA COPY + // --------- + if (isset($_POST["copy"])) { + echo "

".$lang_label["datacopy"]."

"; + // Initial checkings - // Source - $id_origen = $_POST["origen"]; - - // If selected modules or alerts - if (isset($_POST["modules"])) - $modulos = 1; - else - $modulos = 0; - if (isset($_POST["alerts"])) - $alertas = 1; - else - $alertas = 0; - if (($alertas + $modulos) == 0){ - echo "

ERROR: ".$lang_label["you_must_select_modules"]."

";; - echo ""; - include ("general/footer.php"); - exit; - } - - // Copy - for ($a=0;$a
".$lang_label["copyage"]." [".dame_nombre_agente($id_origen)."] -> [".dame_nombre_agente($id_agente)."]"; - if ($multiple == 0) - $b=-1; + // if selected more than 0 agents + $destino = $_POST["destino"]; + if (count($destino) <= 0){ + echo "

ERROR: ".$lang_label["noagents_cp"]."

"; + echo ""; + include ("general/footer.php"); + exit; + } + $origen_modulo = $_POST["origen_modulo"]; + if (count($origen_modulo) <= 0){ + echo "

ERROR: ".$lang_label["nomodules_selected"]."

"; + echo ""; + include ("general/footer.php"); + exit; + } + + $multiple=1; + + // Source + $id_origen = $_POST["origen"]; + + // If selected modules or alerts + if (isset($_POST["modules"])) + $modulos = 1; + else + $modulos = 0; + if (isset($_POST["alerts"])) + $alertas = 1; + else + $alertas = 0; + if (($alertas + $modulos) == 0){ + echo "

ERROR: ".$lang_label["you_must_select_modules"]."

";; + echo ""; + include ("general/footer.php"); + exit; + } + + // Copy + // ---- + for ($a=0;$a
".$lang_label["copyage"]." [".dame_nombre_agente($id_origen)."] -> [".dame_nombre_agente($id_agente)."]"; + if ($multiple == 0) + $b=-1; + else + $b=0; + + // Module read + if ($modulos == 1){ + for ($b=$b; $b < count($origen_modulo); $b++){ + if ($multiple == 0) + $sql1='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_origen; else - $b=0; + $sql1='SELECT * FROM tagente_modulo WHERE id_agente_modulo = '.$origen_modulo[$b]; + $result1=mysql_query($sql1); + while ($row=mysql_fetch_array($result1)){ + $o_id_agente_modulo = $row["id_agente_modulo"]; + $o_id_tipo_modulo = $row["id_tipo_modulo"]; + $o_nombre = $row["nombre"]; + $d_id_agente = $id_agente; // Rapelace with destination agent id + // Read every module in source agent + $o_descripcion = $row["descripcion"]; + $o_max = $row["max"]; + $o_min = $row["min"]; + $o_module_interval = $row["module_interval"]; + $o_tcp_port = $row["tcp_port"]; + $o_tcp_send = $row["tcp_send"]; + $o_tcp_rcv = $row["tcp_rcv"]; + $o_snmp_community = $row["snmp_community"]; + $o_snmp_oid = $row["snmp_oid"]; + // Replace IP Address for main ip address of destination module + $real_ip_address = give_agent_address ($id_agente); + $o_ip_target = $real_ip_address; + $o_id_module_group = $row["id_module_group"]; + // 2.0 new modules + $o_max_timeout = $row["max_timeout"]; + $o_prediction_module = $row["prediction_module"]; + $o_post_process = $row["post_process"]; + $o_id_plugin = $row["id_plugin"]; + $o_plugin_parameter = $row["plugin_parameter"]; + $o_plugin_user = $row["plugin_user"]; + $o_plugin_pass = $row["plugin_pass"]; + $o_id_modulo = $row["id_modulo"]; - // Module read - if ($modulos ==1){ - for ($b=$b; $b < count($origen_modulo); $b++){ - if ($multiple == 0) - $sql1='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_origen; - else - $sql1='SELECT * FROM tagente_modulo WHERE id_agente_modulo = '.$origen_modulo[$b]; - $result1=mysql_query($sql1); - while ($row=mysql_fetch_array($result1)){ - $o_id_agente_modulo = $row["id_agente_modulo"]; - $o_id_tipo_modulo = $row["id_tipo_modulo"]; - $o_nombre = $row["nombre"]; - $d_id_agente = $id_agente; // Rapelace with destination agent id - // Read every module in source agent - $o_descripcion = $row["descripcion"]; - $o_max = $row["max"]; - $o_min = $row["min"]; - $o_module_interval = $row["module_interval"]; - $o_tcp_port = $row["tcp_port"]; - $o_tcp_send = $row["tcp_send"]; - $o_tcp_rcv = $row["tcp_rcv"]; - $o_snmp_community = $row["snmp_community"]; - $o_snmp_oid = $row["snmp_oid"]; - // Replace IP Address for main ip address of destination module - $real_ip_address = give_agent_address ($id_agente); - $o_ip_target = $real_ip_address; - $o_id_module_group = $row["id_module_group"]; - - // Write every module in destination agent - if ($o_nombre != "agent_keepalive") { - $sql = "INSERT INTO tagente_modulo (id_agente,id_tipo_modulo,descripcion,nombre, max, min, module_interval, tcp_port, tcp_send, tcp_rcv, snmp_community, snmp_oid, ip_target, id_module_group, flag) VALUES - (".$d_id_agente.",'".$o_id_tipo_modulo."','".$o_descripcion."','".$o_nombre."', '$o_max', '$o_min', '$o_module_interval', '$o_tcp_port','$o_tcp_send','$o_tcp_rcv','$o_snmp_community','$o_snmp_oid','$o_ip_target',$o_id_module_group, 1)"; - $result2=mysql_query($sql); - $o_id_agente_modulo = mysql_insert_id(); - - // Create with different estado if proc type or data type - if ( - ($o_id_tipo_modulo == 2) || - ($o_id_tipo_modulo == 6) || - ($o_id_tipo_modulo == 9) || - ($o_id_tipo_modulo == 12) || - ($o_id_tipo_modulo == 18)){ - $sql_status_insert = "INSERT INTO tagente_estado - (id_agente_modulo,datos,timestamp,cambio,estado,id_agente, utimestamp) - VALUES ( - $o_id_agente_modulo, 0,'0000-00-00 00:00:00',0,0,'".$d_id_agente."',0 - )"; - } else { - $sql_status_insert = "INSERT INTO tagente_estado - (id_agente_modulo,datos,timestamp,cambio,estado,id_agente, utimestamp) - VALUES ( - $o_id_agente_modulo, 0,'0000-00-00 00:00:00',0,100,'".$d_id_agente."',0 - )"; - } - $result_status=mysql_query($sql_status_insert); - echo "
  ".$lang_label["copymod"]." ->".$o_nombre; - } - } - } - } - if ($multiple == 0) - $b=-1; - else - $b=0; - // Alertas - if ($alertas == 1){ - for ($b=$b; $b < count($origen_modulo); $b++){ - if ($multiple == 0) - $sql1='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_origen; - else - $sql1='SELECT * FROM tagente_modulo WHERE id_agente_modulo = '.$origen_modulo[$b]; - $result1=mysql_query($sql1); - while ($row=mysql_fetch_array($result1)){ - $o_id_agente_modulo = $row["id_agente_modulo"]; - $o_id_tipo_modulo = $row["id_tipo_modulo"]; - $o_nombre = $row["nombre"]; - $d_id_agente = $id_agente; // destination agent id - // For each agent module, given as $o_id_agente_modulo: - // Searching if destination agent has a agente_modulo with same type and name that source - $sqlp="SELECT * FROM tagente_modulo WHERE id_agente = ".$d_id_agente." AND nombre = '".$o_nombre."' AND id_tipo_modulo = ".$o_id_tipo_modulo; - $resultp=mysql_query($sqlp); - if ( $rowp=mysql_fetch_array($resultp)){ - // If rowp success get ID - $d_id_agente_modulo = $rowp["id_agente_modulo"]; - // Read every alert from source agent - $sql2='SELECT * FROM talerta_agente_modulo WHERE id_agente_modulo = '.$o_id_agente_modulo; - $result3=mysql_query($sql2); - while ($row3=mysql_fetch_array($result3)){ - $o_id_alerta = $row3["id_alerta"]; - $o_al_campo1 = $row3["al_campo1"]; - $o_al_campo2 = $row3["al_campo2"]; - $o_al_campo3 = $row3["al_campo3"]; - $o_descripcion = $row3["descripcion"]; - $o_dis_max = $row3["dis_max"]; - $o_dis_min = $row3["dis_min"]; - $o_time_threshold = $row3["time_threshold"]; - $o_last_fired = "2001-01-01 00:00:00"; - $o_max_alerts = $row3["max_alerts"]; - $o_min_alerts = $row3["min_alerts"]; - $o_times_fired = 0; - // Insert - $sql_al="INSERT INTO talerta_agente_modulo (id_agente_modulo, id_alerta, al_campo1, al_campo2, al_campo3, descripcion, dis_max, dis_min, time_threshold, last_fired, max_alerts, times_fired, min_alerts) VALUES ( ".$d_id_agente_modulo.", - ".$o_id_alerta.", - '".$o_al_campo1."', - '".$o_al_campo2."', - '".$o_al_campo3."', - '".$o_descripcion."', - ".$o_dis_max.", - ".$o_dis_min.", - ".$o_time_threshold.", - '".$o_last_fired."', - ".$o_max_alerts.", - ".$o_times_fired.", $o_min_alerts)"; - $result_al=mysql_query($sql_al); - // echo "DEBUG SQL: $sql_al
"; - echo "
  ".$lang_label["copyale"]." ->".$o_descripcion; - } - } else - echo "

ERROR: ".$lang_label["notfoundmod"].$o_nombre.$lang_label["inagent"].dame_nombre_agente($d_id_agente)."

"; - } //while - } // for - } - } - } //end if copy modules or alerts - - // DELETE DATA - elseif (isset($_POST["delete"])) { - echo "

".$lang_label["deletedata"]."

"; - // Initial checkings - - // if selected more than 0 agents - $destino = $_POST["destino"]; - if (count($destino) <= 0){ - echo "

ERROR: ".$lang_label["noagents_del"]."

"; - break; - } - - // If selected modules or alerts - if (isset($_POST["modules"])) - $modulos = 1; - else - $modulos = 0; - if (isset($_POST["alerts"])) - $alertas = 1; - else - $alertas = 0; - if (($alertas + $modulos) == 0){ - echo "

ERROR: ".$lang_label["del_sel_err"]."

"; - break; - } - - // Delete - for ($a=0;$a ".$lang_label["deleting_data"]." -> ".dame_nombre_agente($id_agente); - - // Deleting data - $sql1='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_agente; - $result1=mysql_query($sql1); - while ($row=mysql_fetch_array($result1)){ - $sql_delete1="DELETE FROM tagente_datos WHERE id_agente_modulo=".$row["id_agente_modulo"]; - $sql_delete2="DELETE FROM tagente_datos_inc WHERE id_agente_modulo=".$row["id_agente_modulo"]; - $sql_delete3="DELETE FROM tagente_datos_string WHERE id_agente_modulo=".$row["id_agente_modulo"]; - $result=mysql_query($sql_delete1); - $result=mysql_query($sql_delete2); - $result=mysql_query($sql_delete3); - } - - // Delete conf - $sql_delete5 ="DELETE FROM tagente_modulo WHERE id_agente = ".$id_agente; // delete from table tagente_modulo - $sql_delete6 ="DELETE FROM tagente_estado WHERE id_agente = ".$id_agente; // detele from table tagente_estado - $result=mysql_query($sql_delete5); - $result=mysql_query($sql_delete6); - } - // delete alerts definitions - if ($alertas == 1){ - // delete data - $sql1='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_agente; - $result1=mysql_query($sql1); - while ($row=mysql_fetch_array($result1)){ - $sql_delete1="DELETE FROM talerta_agente_modulo WHERE id_agente_modulo=".$row["id_agente_modulo"]; - $result = mysql_query($sql_delete1); - } // while - }//if - }// for - }//delete - - } else { // Form view - ?> + + // Write every module in destination agent + if ($o_nombre != "agent_keepalive") { + $sql = "INSERT INTO tagente_modulo ( + id_agente,id_tipo_modulo,descripcion, nombre, max, min, + module_interval, tcp_port, tcp_send, tcp_rcv, snmp_community, + snmp_oid, ip_target, id_module_group, flag, + max_timeout, prediction_module, post_process, id_plugin, + plugin_parameter, plugin_user, plugin_pass, id_modulo + ) VALUES ( + $d_id_agente, '$o_id_tipo_modulo', '$o_descripcion', + '$o_nombre', '$o_max', '$o_min', '$o_module_interval', + '$o_tcp_port', '$o_tcp_send', '$o_tcp_rcv', '$o_snmp_community', + '$o_snmp_oid', '$o_ip_target', $o_id_module_group, 1, + $o_max_timeout, $o_prediction_module, '$o_post_process', + $o_id_plugin, '$o_plugin_parameter', '$o_plugin_user', + '$o_plugin_pass', $o_id_modulo + )"; +echo "DEBUG SQL: $sql
"; + $result2=mysql_query($sql); + if (! $result2) + echo "

".lang_string("Problem updating database")."

"; + $o_id_agente_modulo = mysql_insert_id(); -

> -

-
- - - '; + echo '


- "; + + // Source group + echo ' -
'. lang_string ("Source group"). '

'; + echo ''; + echo '  '; + echo ''; + echo '

'; + + // Source agent + echo ''. lang_string ("source_agent").'

'; + + // Show combo with SOURCE agents + if ($id_group != 0) + $sql1 = "SELECT * FROM tagente WHERE id_grupo = $id_group ORDER BY nombre "; + else + $sql1 = 'SELECT * FROM tagente ORDER BY nombre'; + echo '  

'; - echo "".$lang_label["modules"]."

"; - echo ""; - ?> -


- -

-

-
- -
-

- - -
- '; ?> - '; ?> -
-
- -'; + + echo '  '; + echo ''; + echo '

'; + + // Source Module(s) + echo "".$lang_label["modules"]."

"; + echo ""; + + echo '
'; + echo ''.lang_string ("copy_conf"). '

'; + echo ''; + echo '
'.lang_string ("modules"); + echo ''; + echo '
'.lang_string ("alerts"); + echo ''; + echo '
'; + + + // Destination agent + echo '
'; + echo ''.$lang_label["toagent"].'

'; + echo "'; + + // Form buttons + echo '
'; + echo ''; + echo ''; + echo '
'; + echo '
'; + } + ?> diff --git a/pandora_console/godmode/agentes/manage_config_remote.php b/pandora_console/godmode/agentes/manage_config_remote.php new file mode 100644 index 0000000000..bd20f6d7e1 --- /dev/null +++ b/pandora_console/godmode/agentes/manage_config_remote.php @@ -0,0 +1,142 @@ +".$lang_label["datacopy"].""; + // Initial checkings + + // if selected more than 0 agents + $destino = $_POST["destino"]; + if (count($destino) <= 0){ + echo "

ERROR: ".$lang_label["noagents_cp"]."

"; + echo ""; + include ("general/footer.php"); + exit; + } + + // Source + $id_origen = $_POST["origen"]; + + // Copy files + for ($a=0;$a
".$lang_label["copyage"]." [".$agent_name_src."] -> [".$agent_name_dst."]"; + + $source = $config["remote_config"]."/".md5($agent_name_src); + $destination = $config["remote_config"]."/".md5($agent_name_dst); + copy ( $source.".md5", $destination.".md5" ); + copy ( $source.".conf", $destination.".conf" ); + } // for each destination agent + } //end if copy modules or alerts + + + // ============ + // Form view + // ============ + } else { + + // title + echo '

'.lang_string ("agent_conf"). '>'. lang_string ("config_manage").'

'; + echo ''; + echo ""; + + // Source group + echo ''; + echo '
'. lang_string ("Source group"). '

'; + echo ''; + echo '  '; + echo ''; + echo '

'; + + // Source agent + echo ''. lang_string ("source_agent").'

'; + + // Show combo with SOURCE agents + if ($id_group != 0) + $sql1 = "SELECT * FROM tagente WHERE id_grupo = $id_group ORDER BY nombre "; + else + $sql1 = 'SELECT * FROM tagente ORDER BY nombre'; + echo ''; + + echo '  '; + echo ''; + echo '

'; + + // Destination agent + echo '
'; + echo ''.$lang_label["toagent"].'

'; + echo "'; + + // Form buttons + echo '
'; + echo ''; + echo '
'; + echo '
'; + + } + +?> diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index 306b2eed24..d5de8b79ec 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -105,10 +105,11 @@ echo ''; echo ''.lang_string ("source_module").""; echo ''; echo '"; echo ""; diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index b4a7d71a91..b248161365 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -43,9 +43,16 @@ if (comprueba_login() == 0){ if (isset($_GET["sec2"]) && $_GET["sec2"] == "godmode/agentes/manage_config"){ echo "
"; } - else echo ""; + else + echo ""; + if (isset($_GET["sec2"]) && $_GET["sec2"] == "godmode/agentes/manage_config_remote"){ + echo "
"; + } + else + echo ""; // Manage groups if ((give_acl($id_user, 0, "PM")==1)){ diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 979dd05130..5bab9be85b 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -33,6 +33,10 @@ if (comprueba_login() == 0) $config["style"] = $_POST["style"]; $config["remote_config"] = $_POST["remote_config"]; + $config["graph_color1"] = $_POST["graph_color1"]; + $config["graph_color2"] = $_POST["graph_color2"]; + $config["graph_color3"] = $_POST["graph_color3"]; + $result2=mysql_query("UPDATE tconfig SET VALUE='".$config["remote_config"]."' WHERE TOKEN='remote_config'"); $result2=mysql_query("UPDATE tconfig SET VALUE='".$config["block_size"]."' WHERE TOKEN='block_size'"); $result2=mysql_query("UPDATE tconfig SET VALUE='".$config["language"]."' WHERE TOKEN='language_code'"); @@ -43,6 +47,10 @@ if (comprueba_login() == 0) $result2=mysql_query("UPDATE tconfig SET VALUE='".$config["show_unknown"]."' WHERE token='show_unknown'"); $result2=mysql_query("UPDATE tconfig SET VALUE='".$config["show_lastalerts"]."' WHERE token='show_lastalerts'"); $result2=mysql_query("UPDATE tconfig SET VALUE='".$config["style"]."' WHERE token='style'"); + $result2=mysql_query("UPDATE tconfig SET VALUE='".$config["graph_color1"]."' WHERE token='graph_color1'"); + $result2=mysql_query("UPDATE tconfig SET VALUE='".$config["graph_color2"]."' WHERE token='graph_color2'"); + $result2=mysql_query("UPDATE tconfig SET VALUE='".$config["graph_color3"]."' WHERE token='graph_color3'"); + } echo "

".$lang_label["setup_screen"]." > "; echo $lang_label["general_config"]."

"; @@ -66,21 +74,29 @@ if (comprueba_login() == 0) echo ''.lang_string ("Remote config directory"); echo ''; - echo ''.$lang_label["days_compact"]; - echo ''; - - echo ''.$lang_label["days_purge"]; - echo ''; - - echo ''.$lang_label["graph_res"]; - echo ''; - - echo ''.$lang_label["step_compact"].''; - echo ''; + echo ''.lang_string("Graph color (min)"); + echo ''; + echo ''.lang_string("Graph color (avg)"); + echo ''; + + echo ''.lang_string("Graph color (max)"); + echo ''; + + echo ''.$lang_label["days_compact"]; + echo ''; - echo ''.$lang_label["show_unknown"].''; - echo ''; + + echo ''.$lang_label["graph_res"]; + echo ''; + + echo ''.$lang_label["step_compact"].''; + echo ''; + + echo ''.$lang_label["show_unknown"].''; + echo ''; + echo ''.$lang_label["show_lastalerts"]; + echo '"; - //if ($agent_type == 0) { - echo ' - '.$lang_label["os"].' - - - '.dame_so_name($id_os); - if ($os_version != "") - echo ' '.salida_limpia($os_version); - /* - } elseif ($agent_type == 1) { - echo ' - '.$lang_label["agent_type"].' - '; - }*/ + echo ' + '.$lang_label["os"].' + + - '.dame_so_name($id_os); + if ($os_version != "") + echo ' '.salida_limpia($os_version); echo ''; echo ''; @@ -147,7 +142,7 @@ if (comprueba_login() == 0) { // Last contact echo ' - + '.$lang_label["last_contact"]." / ".$lang_label["remote"].' '; @@ -182,7 +177,7 @@ if (comprueba_login() == 0) { } echo " ".$lang_label['next_contact']." - + diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index 077c2b7d4f..cc9545bd02 100644 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -64,7 +64,7 @@ // Monitor checks // ~~~~~~~~~~~~~~~ echo ""; - echo "
"; + echo "
"; echo ""; // Summary @@ -79,6 +79,7 @@ echo ""; diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index db828a807e..12ee8e7406 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -34,11 +34,22 @@ if (comprueba_login() == 0) { if ($validate_alert != ""){ if (give_acl($id_usuario, $id_grupo, "AW")==1){ $alert_row = get_db_row ("talerta_agente_modulo", "id_aam", $validate_alert); - $am_row = get_db_row ("tagente_modulo", "id_agente_modulo", $alert_row["id_agente_modulo"]); - $ag_row = get_db_row ("tagente", "id_agente", $am_row["id_agente"]); + if ($alert_row["id_agente_modulo"] != 0){ + $am_row = get_db_row ("tagente_modulo", "id_agente_modulo", $alert_row["id_agente_modulo"]); + $ag_row = get_db_row ("tagente", "id_agente", $am_row["id_agente"]); + } else { + $ag_row = get_db_row ("tagente", "id_agente", $alert_row ["id_agent"]); + } $alert_name = $alert_row["descripcion"]; - event_insert("Manual validation of alert for '$alert_name'", $ag_row["id_grupo"], $am_row["id_agente"], 1, $id_usuario, "alert_manual_validation", 1, $alert_row["id_agente_modulo"], $validate_alert); + // Single alerts + if ($alert_row["id_agente_modulo"] != 0){ + event_insert("Manual validation of alert for '$alert_name'", $ag_row["id_grupo"], $am_row["id_agente"], 1, $config["id_user"], "alert_manual_validation", 1, $alert_row["id_agente_modulo"], $validate_alert); + + // Combined alerts + } else { + event_insert("Manual validation of alert for '$alert_name'", $ag_row["id_grupo"], $alert_row ["id_agent"], 1, $config["id_user"], "alert_manual_validation", 1, 0, $validate_alert); + } $sql='UPDATE talerta_agente_modulo SET times_fired = 0, internal_counter = 0 WHERE id_aam = '.$validate_alert; $result=mysql_query($sql); } @@ -53,6 +64,15 @@ if (comprueba_login() == 0) { } } } + // Check for Network FLAG change request + if (isset($_GET["flag_agent"])){ + if ($_GET["flag_agent"]==1){ + if (give_acl($id_usuario, $id_grupo, "AW")==1){ + $query ="UPDATE tagente_modulo SET flag=1 WHERE id_agente = ". $id_agente; + $res=mysql_query($query); + } + } + } if (give_acl($id_usuario,$id_grupo, "AR") == 1){ echo "
"; echo "
".lang_string("Alert level").""; echo "
"; + echo "

"; echo "
"; + $event_title = safe_input ($row2["evento"]); + echo ""; echo substr($row2["evento"],0,45); if (strlen($row2["evento"]) > 45) echo ".."; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 4d5023dab0..66b6099210 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -46,7 +46,22 @@ INSERT INTO `talerta` VALUES (9,'Jabber Alert','echo _field3_ | sendxmpp -r _fie /*!40000 ALTER TABLE `tconfig` DISABLE KEYS */; LOCK TABLES `tconfig` WRITE; INSERT INTO `tconfig` VALUES -(1,'language_code','en'),(3,'block_size','20'),(4,'days_purge','60'),(5,'days_compact','15'),(6,'graph_res','5'),(7,'step_compact','1'),(8,'db_scheme_version','2.0'),(9,'db_scheme_build','PD80401'),(13,'show_unknown','0'),(14,'show_lastalerts','1'),(15,'style','pandora'),(16, 'remote_config', '/var/spool/pandora/data_in'); +(1,'language_code','en'), +(3,'block_size','20'), +(4,'days_purge','60'), +(5,'days_compact','15'), +(6,'graph_res','5'), +(7,'step_compact','1'), +(8,'db_scheme_version','2.0'), +(9,'db_scheme_build','PD80401'), +(13,'show_unknown','0'), +(14,'show_lastalerts','1'), +(15,'style','pandora'), +(16, 'remote_config', '/var/spool/pandora/data_in'), +(17, 'graph_color1', '#38B800'), +(18, 'graph_color2', '#42D100'), +(19, 'graph_color3', '#89FF09') +; UNLOCK TABLES; /*!40000 ALTER TABLE `tconfig` ENABLE KEYS */; @@ -66,15 +81,15 @@ UNLOCK TABLES; -- LOCK TABLES `tgrupo` WRITE; -INSERT INTO `tgrupo` VALUES (1,'All','world',0,0); -INSERT INTO `tgrupo` VALUES (2,'Servers','server_database',0,0); -INSERT INTO `tgrupo` VALUES (3,'IDS','eye',0,0); -INSERT INTO `tgrupo` VALUES (4,'Firewalls','firewall',0,0); -INSERT INTO `tgrupo` VALUES (8,'Databases','database_gear',0,0); -INSERT INTO `tgrupo` VALUES (9,'Network','transmit',0,0); -INSERT INTO `tgrupo` VALUES (10,'Not classified','house',0,0); -INSERT INTO `tgrupo` VALUES (11,'Workstations','computer',0,0); -INSERT INTO `tgrupo` VALUES (12,'Applications','applications',0,0); +INSERT INTO `tgrupo` VALUES +(1,'All','world',0,0), +(2,'Servers','server_database',0,0), +(4,'Firewalls','firewall',0,0), +(8,'Databases','database_gear',0,0), +(9,'Network','transmit',0,0), +(10,'Unknown','world',0,0), +(11,'Workstations','computer',0,0), +(12,'Applications','applications',0,0); UNLOCK TABLES; /*!40000 ALTER TABLE `tgrupo` ENABLE KEYS */; diff --git a/pandora_console/reporting/fgraph.php b/pandora_console/reporting/fgraph.php index a45fb23deb..45f83b1364 100644 --- a/pandora_console/reporting/fgraph.php +++ b/pandora_console/reporting/fgraph.php @@ -587,7 +587,7 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event, // Show alert limits if ($show_alert == 1){ $Plot =& $Plotarea->addNew('Image_Graph_Axis_Marker_Area', IMAGE_GRAPH_AXIS_Y); - $Plot->setFillColor( 'blue@0.1' ); + $Plot->setFillColor( 'gray@0.1' ); $Plot->setLowerBound( $alert_low); $Plot->setUpperBound( $alert_high ); } @@ -626,15 +626,13 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event, $Plot->setFillStyle($FillArray); if ($avg_only == 1){ - $FillArray->addColor('green@0.6'); + $FillArray->addColor($config["graph_color1"]); } else { - $FillArray->addColor('yellow@0.5'); - $FillArray->addColor('orange@0.6'); - $FillArray->addColor('#e37907@0.7'); - $FillArray->addColor('red@0.7'); - $FillArray->addColor('blue@0.7'); - $FillArray->addColor('green@0.7'); - $FillArray->addColor('black@0.7'); + $FillArray->addColor($config["graph_color3"]); + $FillArray->addColor($config["graph_color2"]); + $FillArray->addColor($config["graph_color1"]); + + } $AxisY_Weather =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); @@ -1963,6 +1961,7 @@ function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event, // Generic parameter handling // ************************** +$id_agent = (int) get_parameter ('id_agent'); $tipo = (string) get_parameter ('tipo'); $pure = (bool) get_parameter ('pure'); $period = (int) get_parameter ('period', 86400); @@ -2013,6 +2012,8 @@ if ($graphic_type) { case "db_agente_purge": grafico_db_agentes_purge($id, $width, $height); break; + case "event_module": + graph_event_module ($width, $height, $id_agent); case "group_events": grafico_eventos_grupo($width, $height); break; diff --git a/pandora_console/reporting/stat_win.php b/pandora_console/reporting/stat_win.php index c95d4c03bc..556a930826 100644 --- a/pandora_console/reporting/stat_win.php +++ b/pandora_console/reporting/stat_win.php @@ -1,8 +1,8 @@ @@ -22,7 +22,10 @@ // Global & session management include ('../include/config.php'); -session_start(); +if (!isset($_SESSION["id_user"])){ + session_start(); + session_write_close(); +} include ('../include/functions.php'); include ('../include/functions_db.php'); @@ -37,32 +40,25 @@ if (comprueba_login() != 0) { } // Parsing the refresh before sending any header -if (isset($_GET['refresh']) and is_numeric($_GET['refresh']) and $_GET['refresh']>0) { +$refresh = get_parameter ("refresh", -1); +if ($refresh != -1) header( 'refresh: ' . $_GET['refresh'] ); - } + echo ' Pandora FMS Graph '; -; +echo ""; +echo ""; // Get input parameters -if (isset($_GET["label"])) - $label = entrada_limpia($_GET["label"]); - +$label = get_parameter ("label",""); if (!isset($_GET["period"]) OR (!isset($_GET["id"]))) { echo "

".$lang_label["graf_error"]."

"; exit; } -if (isset($_GET["draw_events"])) - $draw_events = entrada_limpia($_GET["draw_events"]); -else - $draw_events = 0; -if (isset($_GET["period"])) - $period = entrada_limpia($_GET["period"]); -else - $period = 3600; // 1 hour (the most fast query possible) +$period = get_parameter ( "period", 3600); switch ($period) { case 3600: $period_label = $lang_label["hour"]; @@ -92,49 +88,22 @@ switch ($period) { default: $period_label = human_time_description_raw ($period); } -if (isset($_GET["draw_alerts"])) - $draw_alerts = entrada_limpia($_GET["draw_alerts"]); -else - $draw_alerts = 0; -if (isset($_GET["avg_only"])) - $avg_only = entrada_limpia($_GET["avg_only"]); -else - $avg_only = 0; -if (isset($_GET["refresh"])) - $refresh = entrada_limpia($_GET["refresh"]); -else - $refresh = 0; -if (isset($_GET["period"])) - $period = entrada_limpia($_GET["period"]); -else - $period = 86400; // 1 day default period -if (isset($_GET["id"])) - $id = entrada_limpia($_GET["id"]); -else - $id = 0; -if (isset($_GET["width"])) - $width = entrada_limpia($_GET["width"]); -else - $width = 525; -if (isset($_GET["height"])) - $height = entrada_limpia ($_GET["height"]); -else - $height = 220; -if (isset($_GET["label"])) - $label = entrada_limpia ($_GET["label"]); -else - $label = ""; - -if (isset($_GET["zoom"])){ - $zoom = entrada_limpia ($_GET["zoom"]); - if ($zoom > 1){ - $height=$height*($zoom/2.1); - $width=$width*($zoom/1.4); - } +$draw_alerts = get_parameter("draw_alerts", 0); +$avg_only = get_parameter ("avg_only", 0); +$period = get_parameter ("period", 86400); +$id = get_parameter ("id", 0); +$width = get_parameter ("width", 555); +$height = get_parameter ("height", 245); +$label = get_parameter ("label", ""); +$start_date = get_parameter ("start_date", date("Y-m-d")); +$draw_events = get_parameter ("draw_events", 0); +$graph_type = get_parameter ("type", "sparse"); +$zoom = get_parameter ("zoom", 1); +if ($zoom > 1){ + $height=$height*($zoom/2.1); + $width=$width*($zoom/1.4); } -else - $zoom = "1"; if ($zoom > 1) { echo " @@ -144,12 +113,12 @@ if ($zoom > 1) { "; } -$graph_type = "sparse"; -if (isset($_GET["type"])) - $graph_type = entrada_limpia($_GET["type"]); - - -echo ""; +$current = date("Y-m-d"); +if ($start_date != $current){ + $utime = strtotime ($start_date); + echo ""; +} else + echo ""; echo ""; echo "
"; @@ -168,11 +137,11 @@ echo "