From 5c36d4115af5bd1348fbeac26fd07ad3e3c54cbf Mon Sep 17 00:00:00 2001 From: slerena Date: Wed, 2 Jul 2008 19:48:27 +0000 Subject: [PATCH] 2008-07-01 Sancho Lerena * pandoradb.sql: Added several indexes, patch from Guruevi. * configurar_agente.php: Default "public" for snmp_community was causing a fail on blank communities (snmp community is used on WMI modules as filter key). Default value is now "" due the way get_parameter works, and don't want to change a global function. * module_manager_editor_wmi.php: Added two new fields: filter key for WMI output (using snmp_community to store it) and WMI response field number (using tcp_port to store it). * setup.php: Added global "sla_period" item to setup page. * sla_view.php: Fixed code to be more close on our coding standards. Need to improve and uses the global table functions on functions_html. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@925 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 20 ++ .../godmode/agentes/configurar_agente.php | 12 +- .../agentes/module_manager_editor_wmi.php | 7 + pandora_console/godmode/setup/setup.php | 2 + .../operation/agentes/sla_view.php | 300 +++++++++--------- pandora_console/pandoradb.sql | 25 +- 6 files changed, 196 insertions(+), 170 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8213aab1ad..c8160f7583 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,23 @@ + + +2008-07-01 Sancho Lerena + + * pandoradb.sql: Added several indexes, patch from Guruevi. + + * configurar_agente.php: Default "public" for snmp_community + was causing a fail on blank communities (snmp community is used + on WMI modules as filter key). Default value is now "" due the way + get_parameter works, and don't want to change a global function. + + * module_manager_editor_wmi.php: Added two new fields: filter key + for WMI output (using snmp_community to store it) and WMI response + field number (using tcp_port to store it). + + * setup.php: Added global "sla_period" item to setup page. + + * sla_view.php: Fixed code to be more close on our coding standards. + Need to improve and uses the global table functions on functions_html. + 2008-07-02 Esteban Sanchez * include/functions_db.php: Fixed typo in event_insert(). diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 0f3412c255..3101963c25 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -642,7 +642,7 @@ if ((isset($_POST["update_module"])) || (isset($_POST["insert_module"]))) { $form_tcp_send = get_parameter ("form_tcp_send",""); $form_tcp_rcv = get_parameter ("form_tcp_rcv",""); $form_tcp_port = get_parameter ("form_tcp_port",0); - $form_snmp_community = get_parameter ("form_snmp_community","public"); + $form_snmp_community = get_parameter ("form_snmp_community",""); $form_snmp_oid = get_parameter ("form_snmp_oid",""); $form_ip_target = get_parameter ("form_ip_target",""); $form_plugin_user = get_parameter ("form_plugin_user",""); @@ -691,15 +691,7 @@ if ((isset($_POST["update_module"])) && (!isset($_POST["oid"]))){ // if modified } else { echo "

".$lang_label["update_module_ok"]."

"; } - /* - // Init vars to null to avoid trash in forms - $id_tipo_modulo = "";$nombre = "";$descripcion = "";$modulo_max = ""; - $modulo_min = "";// Pandora 1.2 new module data: - $tcp_send = "";$tcp_rcv = "";$tcp_port = "";$ip_target = ""; - $snmp_oid = "";$snmp_community = "";$id_module_group = ""; - $module_interval = ""; $modulo_nombre = ""; $modulo_descripcion = ""; - $update_module = 0; - */ + } // ========================================================= // OID Refresh button to get SNMPWALK from data in form diff --git a/pandora_console/godmode/agentes/module_manager_editor_wmi.php b/pandora_console/godmode/agentes/module_manager_editor_wmi.php index 1049f68157..65ea6d33cf 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_wmi.php +++ b/pandora_console/godmode/agentes/module_manager_editor_wmi.php @@ -108,6 +108,13 @@ echo ''.lang_string ("WMI Query").""; echo ''; echo ''; +// Specific string and field number +echo ''; +echo ''.lang_string ("Key string").""; +echo ''; +echo ''.lang_string ("Answer field number").""; +echo ''; +echo ''; // username / password echo ''; diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 5c27a05b4d..7a488ec1be 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -98,6 +98,8 @@ $table->data[11][0] = lang_string ('style_template'); $table->data[11][1] = print_select ($file_styles, 'style', $config["style"], '', '', '', true); $table->data[12][0] = lang_string ('block_size'); $table->data[12][1] = print_input_text ('block_size', $config["block_size"], '', 5, 5, true); +$table->data[13][0] = lang_string ('sla_period'); +$table->data[13][1] = print_input_text ('sla_period', $config["sla_period"], '', 5, 5, true); echo '
'; print_input_hidden ('update_settings', 1); diff --git a/pandora_console/operation/agentes/sla_view.php b/pandora_console/operation/agentes/sla_view.php index 92fc6dc83a..45f52f4267 100644 --- a/pandora_console/operation/agentes/sla_view.php +++ b/pandora_console/operation/agentes/sla_view.php @@ -20,153 +20,55 @@ global $config; $id_user = $config["id_user"]; - if (comprueba_login() != 0) { - require ("general/noaccess.php"); - exit; + require ("general/noaccess.php"); + exit; } -if ((give_acl($id_user, 0, "AR")!=1) AND (give_acl($id_user,0,"AW")!=1)) { - audit_db($id_user,$REMOTE_ADDR, "ACL Violation", - "Trying to access SLA View"); - require ("general/noaccess.php"); - exit; +if ((give_acl($id_user, 0, "AR") != 1) AND (give_acl($id_user,0,"AW") != 1)) { + audit_db($id_user,$REMOTE_ADDR, "ACL Violation", + "Trying to access SLA View"); + require ("general/noaccess.php"); + exit; } - require ("include/functions_reporting.php"); - echo "

".lang_string("SLA view")."

"; - $id_agent = get_parameter ("id_agente", "0"); +echo "

".lang_string("SLA view")."

"; +$id_agent = get_parameter ("id_agente", "0"); - // Get all module from agent - $sql_t='SELECT * FROM tagente_estado, tagente_modulo WHERE tagente_modulo.disabled = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_agente='.$id_agent.' AND tagente_estado.estado != 100 AND tagente_estado.utimestamp != 0 ORDER BY tagente_modulo.nombre'; - $result_t=mysql_query($sql_t); - if (mysql_num_rows ($result_t)) { - echo "

".lang_string ("Automatic SLA for monitors")."

"; - echo ""; - echo ""; - echo " - - - - - "; - $color=0; - while ($row_t=mysql_fetch_array($result_t)){ - # For evey module in the status table - $est_modulo = substr($row_t["nombre"],0,25); - $est_tipo = dame_nombre_tipo_modulo($row_t["id_tipo_modulo"]); - $est_description = $row_t["descripcion"]; - $est_timestamp = $row_t["timestamp"]; - $est_estado = $row_t["estado"]; - $est_datos = $row_t["datos"]; - $est_cambio = $row_t["cambio"]; - $est_interval = $row_t["module_interval"]; - if (($est_interval != $intervalo) && ($est_interval > 0)) { - $temp_interval = $est_interval; - } else { - $temp_interval = $intervalo; - } - if ($est_estado <>100){ # si no es un modulo de tipo datos - # Determinamos si se ha caido el agente (tiempo de intervalo * 2 superado) - if ($color == 1){ - $tdcolor = "datos"; - $color = 0; - } - else { - $tdcolor = "datos2"; - $color = 1; - } - $seconds = time() - $row_t["utimestamp"]; - if ($seconds >= ($temp_interval*2)) // If every interval x 2 secs. we get nothing, there's and alert - $agent_down = 1; - else - $agent_down = 0; - - echo ""; - echo "";; - } - - - - echo ""; - else - echo "--"; - echo ""; - } +// Get all module from agent +$sql_t='SELECT * FROM tagente_estado, tagente_modulo WHERE tagente_modulo.disabled = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_agente='.$id_agent.' AND tagente_estado.estado != 100 AND tagente_estado.utimestamp != 0 ORDER BY tagente_modulo.nombre'; +$result_t=mysql_query($sql_t); +if (mysql_num_rows ($result_t)) { + echo "

".lang_string ("Automatic SLA for monitors")."

"; + echo "
X".$lang_label["type"]."".$lang_label["module_name"]."".$lang_label["SLA"]."".$lang_label["status"]."".$lang_label["interval"]."".$lang_label["last_contact"]."
"; - - if (($row_t["id_modulo"] != 1) AND ($row_t["id_tipo_modulo"] < 100)) { - if ($row_t["flag"] == 0){ - echo ""; - } else { - echo ""; - } - } - echo ""; - echo ""; - echo "".$est_modulo.""; - - $temp = get_agent_module_sla ($row_t["id_agente_modulo"], $config["sla_period"], 1, 2147483647); - if ($temp === false) - echo lang_string("N/A"); - else { - echo format_numeric($temp)." %"; - if ($est_estado == 1){ - if ($est_cambio == 1) - echo ""; - else - echo ""; - } else - echo ""; - - echo ""; - if ($temp_interval != $intervalo) - echo $temp_interval.""; - if ($agent_down == 1) { // If agent down, it's shown red and bold - echo ""; - } - else { - echo ""; - } - if ($row_t["timestamp"]=='0000-00-00 00:00:00') { - echo $lang_label["never"]; - } else { - echo human_time_comparation($row_t["timestamp"]); - } - echo "
"; + echo ""; + echo " + + + + + "; + $color=0; + while ($module_data=mysql_fetch_array($result_t)){ + # For evey module in the status table + $est_modulo = substr($module_data["nombre"],0,25); + $est_tipo = dame_nombre_tipo_modulo($module_data["id_tipo_modulo"]); + $est_description = $module_data["descripcion"]; + $est_timestamp = $module_data["timestamp"]; + $est_estado = $module_data["estado"]; + $est_datos = $module_data["datos"]; + $est_cambio = $module_data["cambio"]; + $est_interval = $module_data["module_interval"]; + if (($est_interval != $intervalo) && ($est_interval > 0)) { + $temp_interval = $est_interval; + } else { + $temp_interval = $intervalo; } - echo '
X".$lang_label["type"]."".$lang_label["module_name"]."".$lang_label["SLA"]."".$lang_label["status"]."".$lang_label["interval"]."".$lang_label["last_contact"]."
'; - - } - - - // Get all SLA report components - $sql_t = "SELECT tagente_modulo.id_agente_modulo, sla_max, sla_min, sla_limit, tagente_modulo.id_tipo_modulo, tagente_modulo.nombre, tagente_modulo.descripcion FROM treport_content_sla_combined, tagente_modulo WHERE tagente_modulo.id_agente = $id_agent AND tagente_modulo.id_agente_modulo = treport_content_sla_combined.id_agent_module AND tagente_modulo.id_tipo_modulo IN (1,4,7,8,11,15,16,22,24)"; - - $result_t=mysql_query($sql_t); - if (mysql_num_rows ($result_t)) { - echo "

".lang_string ("User-defined SLA items")."

"; - echo ""; - echo ""; - echo " - - - "; - $color=0; - while ($row_t=mysql_fetch_array($result_t)){ - - # For evey module in the status table - $id_agent_module = $row_t[0]; - $sla_max = $row_t[1]; - $sla_min = $row_t[2]; - $sla_limit = $row_t[3]; - $id_tipo_modulo = $row_t[4]; - $name = $row_t[5]; - $description = $row_t[6]; - $est_tipo = dame_nombre_tipo_modulo($id_tipo_modulo); - + if ($est_estado <>100){ # si no es un modulo de tipo datos + # Determinamos si se ha caido el agente (tiempo de intervalo * 2 superado) if ($color == 1){ $tdcolor = "datos"; $color = 0; @@ -175,28 +77,120 @@ require ("include/functions_reporting.php"); $tdcolor = "datos2"; $color = 1; } - echo ""; + $seconds = time() - $module_data["utimestamp"]; + if ($seconds >= ($temp_interval*2)) // If every interval x 2 secs. we get nothing, there's and alert + $agent_down = 1; + else + $agent_down = 0; + + echo ""; + echo ""; + echo ""; echo ""; - echo "";; } + + echo ""; + else + echo "--"; + echo ""; } - echo '
".$lang_label["type"]."".$lang_label["module_name"]."".$lang_label["SLA"]."".$lang_label["status"]."
"; + + if (($module_data["id_modulo"] != 1) AND ($module_data["id_tipo_modulo"] < 100)) { + if ($module_data["flag"] == 0){ + echo ""; + } else { + echo ""; + } + } echo ""; - echo ""; - echo "".$name; - echo " ($sla_min/$sla_max/$sla_limit) ".$est_modulo.""; - $temp = get_agent_module_sla ($row_t["id_agente_modulo"], $config["sla_period"], $sla_min, $sla_max); - if ($temp === false){ + $temp = get_agent_module_sla ($module_data["id_agente_modulo"], $config["sla_period"], 1, 2147483647); + if ($temp === false) echo lang_string("N/A"); - echo ""; - } else { - echo format_numeric($temp)." %"; - if ($temp > $sla_limit) - echo ""; - else - echo ""; - + else { + echo format_numeric ($temp)." %"; + if ($est_estado == 1){ + if ($est_cambio == 1) + echo ""; + else + echo ""; + } else + echo ""; + + echo ""; + if ($temp_interval != $intervalo) + echo $temp_interval.""; + if ($agent_down == 1) { // If agent down, it's shown red and bold + echo ""; + } + else { + echo ""; + } + if ($module_data["timestamp"] == '0000-00-00 00:00:00') { + echo lang_string ("never"); + } else { + echo human_time_comparation($module_data["timestamp"]); + } + echo "
'; } + echo ''; +} + + +// Get all SLA report components +$sql_t = "SELECT tagente_modulo.id_agente_modulo, sla_max, sla_min, sla_limit, tagente_modulo.id_tipo_modulo, tagente_modulo.nombre, tagente_modulo.descripcion FROM treport_content_sla_combined, tagente_modulo WHERE tagente_modulo.id_agente = $id_agent AND tagente_modulo.id_agente_modulo = treport_content_sla_combined.id_agent_module AND tagente_modulo.id_tipo_modulo IN (1,4,7,8,11,15,16,22,24)"; +$result_t=mysql_query($sql_t); +if (mysql_num_rows ($result_t)) { + $color=0; + echo "

".lang_string ("User-defined SLA items")."

"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + while ($module_data = mysql_fetch_array($result_t)){ + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + + # For evey module in the status table + $id_agent_module = $module_data[0]; + $sla_max = $module_data[1]; + $sla_min = $module_data[2]; + $sla_limit = $module_data[3]; + $id_tipo_modulo = $module_data[4]; + $name = $module_data[5]; + $description = $module_data[6]; + $est_tipo = dame_nombre_tipo_modulo ($id_tipo_modulo); + + echo ""; + echo ""; + echo ""; + echo "
" . lang_string ("type") . "" . lang_string ("module_name") . "" . lang_string ("SLA") . "" . lang_string ("status") . "
"; + echo ""; + echo "" . $name; + echo " ($sla_min / $sla_max / $sla_limit) "; + + $temp = get_agent_module_sla ($id_agent_module, $config["sla_period"], $sla_min, $sla_max); + if ($temp === false){ + echo lang_string("N/A"); + echo ""; + } else { + echo format_numeric($temp)." %"; + if ($temp > $sla_limit) + echo ""; + else + echo ""; + } + } + echo '
'; +} ?> diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 0de3a9a1e7..217470288b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -65,7 +65,10 @@ CREATE TABLE `tagente` ( `id_prediction_server` int(4) unsigned default '0', `id_wmi_server` int(4) unsigned default '0', `id_parent` mediumint(8) unsigned default '0', - PRIMARY KEY (`id_agente`) + PRIMARY KEY (`id_agente`), + KEY `nombre` (`nombre`), + KEY `direccion` (`direccion`), + KEY `disabled` (`disabled`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `tagente_datos` ( @@ -129,8 +132,10 @@ CREATE TABLE `tagente_estado` ( `running_by` int(10) unsigned NULL default 0, `last_execution_try` bigint(20) NOT NULL default '0', PRIMARY KEY (`id_agente_estado`), - KEY `status_index_1` (`id_agente_modulo`), - KEY `status_index_2` (`id_agente_modulo`,`estado`) + KEY `status_index_1` (`id_agente_modulo`), + KEY `status_index_2` (`id_agente_modulo`,`estado`), + KEY `current_interval` (`current_interval`), + KEY `last_execution_try` (`last_execution_try`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /* @@ -173,8 +178,9 @@ CREATE TABLE `tagente_modulo` ( `prediction_module` bigint(14) default '0', `max_timeout` tinyint(3) unsigned default '0', PRIMARY KEY (`id_agente_modulo`, `id_agente`), - KEY `tam_agente` (`id_agente`), - KEY `tam_plugin` (`id_plugin`) + KEY `tam_agente` (`id_agente`), + KEY `id_tipo_modulo` (`id_tipo_modulo`), + KEY `tam_plugin` (`id_plugin`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- snmp_oid is also used for WMI query @@ -249,7 +255,9 @@ CREATE TABLE `talerta_agente_modulo` ( `priority` tinyint(4) default '0', `al_f2_recovery` varchar(255) NOT NULL default '', `al_f3_recovery` mediumtext NOT NULL default '', - PRIMARY KEY (`id_aam`) + PRIMARY KEY (`id_aam`), + KEY `id_agente_modulo` (`id_agente_modulo`), + KEY `disable` (`disable`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -495,7 +503,10 @@ CREATE TABLE `tserver` ( `prediction_server` tinyint(3) unsigned NOT NULL default '0', `wmi_server` tinyint(3) unsigned NOT NULL default '0', `export_server` tinyint(3) unsigned NOT NULL default '0', - PRIMARY KEY (`id_server`) + PRIMARY KEY (`id_server`), + KEY `name` (`name`), + KEY `keepalive` (`keepalive`), + KEY `status` (`status`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `tsesion` (