2008-07-01 Sancho Lerena <slerena@gmail.com>

* 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
This commit is contained in:
slerena 2008-07-02 19:48:27 +00:00
parent 04e6c202cc
commit cb6ec99191
6 changed files with 196 additions and 170 deletions

View File

@ -1,3 +1,23 @@
2008-07-01 Sancho Lerena <slerena@gmail.com>
* 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 <estebans@artica.es>
* include/functions_db.php: Fixed typo in event_insert().

View File

@ -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 "<h3 class='suc'>".$lang_label["update_module_ok"]."</h3>";
}
/*
// 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

View File

@ -108,6 +108,13 @@ echo '<td class="datos">'.lang_string ("WMI Query")."</td>";
echo '<td class="datos"><input type="text" name="form_snmp_oid" size="25" value="'.$form_snmp_oid.'"></td>';
echo '</tr>';
// Specific string and field number
echo '<tr>';
echo '<td class="datos2">'.lang_string ("Key string")."</td>";
echo '<td class="datos2"><input type="text" name="form_snmp_community" size="20" value="'.$form_snmp_community.'"></td>';
echo '<td class="datos2">'.lang_string ("Answer field number")."</td>";
echo '<td class="datos2"><input type="text" name="form_tcp_port" size="3" value="'.$form_tcp_port.'"></td>';
echo '</tr>';
// username / password
echo '<tr>';

View File

@ -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 '<form id="form_setup" method="POST" action="index.php?sec=gsetup&amp;sec2=godmode/setup/setup">';
print_input_hidden ('update_settings', 1);

View File

@ -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 "<h2>".lang_string("SLA view")."</h2>";
$id_agent = get_parameter ("id_agente", "0");
echo "<h2>".lang_string("SLA view")."</h2>";
$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 "<h3>".lang_string ("Automatic SLA for monitors")."</h3>";
echo "<table width='750' cellpadding=4 cellspacing=4 class='databox'>";
echo "<tr><th>X</th>";
echo "<th>".$lang_label["type"]."</th>
<th>".$lang_label["module_name"]."</th>
<th>".$lang_label["SLA"]."</th>
<th>".$lang_label["status"]."</th>
<th>".$lang_label["interval"]."</th>
<th>".$lang_label["last_contact"]."</th>";
$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 "<tr><td class='".$tdcolor."'>";
if (($row_t["id_modulo"] != 1) AND ($row_t["id_tipo_modulo"] < 100)) {
if ($row_t["flag"] == 0){
echo "<a href='index.php?sec=estado& sec2=operation/agentes/ver_agente& id_agente=".$id_agente."&id_agente_modulo=".$row_t["id_agente_modulo"]."&flag=1& tab=main&refr=60'><img src='images/target.png' border='0'></a>";
} else {
echo "<a href='index.php?sec=estado& sec2=operation/agentes/ver_agente&id_agente=".$id_agente."&id_agente_modulo=".$row_t["id_agente_modulo"]."&tab=main&refr=60'><img src='images/refresh.png' border='0'></a>";
}
}
echo "<td class='".$tdcolor."'>";
echo "<img src='images/".show_icon_type($row_t["id_tipo_modulo"])."' border=0>";
echo "<td class='".$tdcolor."' title='".$est_description."'>".$est_modulo."</td>";
echo "<td class='$tdcolor'>";
$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)." %</td>";;
}
echo "<td class='".$tdcolor."' align='center'>";
if ($est_estado == 1){
if ($est_cambio == 1)
echo "<img src='images/pixel_yellow.png' width=40 height=18 title='".$lang_label["yellow_light"]."'>";
else
echo "<img src='images/pixel_red.png' width=40 height=18 title='".$lang_label["red_light"]."'>";
} else
echo "<img src='images/pixel_green.png' width=40 height=18 title='".$lang_label["green_light"]."'>";
echo "<td align='center' class='".$tdcolor."'>";
if ($temp_interval != $intervalo)
echo $temp_interval."</td>";
else
echo "--";
echo "<td class='".$tdcolor."f9'>";
if ($agent_down == 1) { // If agent down, it's shown red and bold
echo "<span class='redb'>";
}
else {
echo "<span>";
}
if ($row_t["timestamp"]=='0000-00-00 00:00:00') {
echo $lang_label["never"];
} else {
echo human_time_comparation($row_t["timestamp"]);
}
echo "</span></td>";
}
// 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 "<h3>".lang_string ("Automatic SLA for monitors")."</h3>";
echo "<table width='750' cellpadding=4 cellspacing=4 class='databox'>";
echo "<tr><th>X</th>";
echo "<th>".$lang_label["type"]."</th>
<th>".$lang_label["module_name"]."</th>
<th>".$lang_label["SLA"]."</th>
<th>".$lang_label["status"]."</th>
<th>".$lang_label["interval"]."</th>
<th>".$lang_label["last_contact"]."</th>";
$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 '</table>';
}
// 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 "<h3>".lang_string ("User-defined SLA items")."</h3>";
echo "<table width='750' cellpadding=4 cellspacing=4 class='databox'>";
echo "<tr>";
echo "<th>".$lang_label["type"]."</th>
<th>".$lang_label["module_name"]."</th>
<th>".$lang_label["SLA"]."</th>
<th>".$lang_label["status"]."</th>";
$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 "<tr>";
$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 "<tr><td class='".$tdcolor."'>";
if (($module_data["id_modulo"] != 1) AND ($module_data["id_tipo_modulo"] < 100)) {
if ($module_data["flag"] == 0){
echo "<a href='index.php?sec=estado& sec2=operation/agentes/ver_agente& id_agente=".$id_agente."&id_agente_modulo=".$module_data["id_agente_modulo"]."&flag=1& tab=main&refr=60'><img src='images/target.png' border='0'></a>";
} else {
echo "<a href='index.php?sec=estado& sec2=operation/agentes/ver_agente&id_agente=".$id_agente."&id_agente_modulo=".$module_data["id_agente_modulo"]."&tab=main&refr=60'><img src='images/refresh.png' border='0'></a>";
}
}
echo "<td class='".$tdcolor."'>";
echo "<img src='images/".show_icon_type($id_tipo_modulo)."' border=0>";
echo "<td class='".$tdcolor."' title='".$description."'>".$name;
echo " ($sla_min/$sla_max/$sla_limit) </td>";
echo "<img src='images/".show_icon_type($module_data["id_tipo_modulo"])."' border=0>";
echo "<td class='".$tdcolor."' title='".$est_description."'>".$est_modulo."</td>";
echo "<td class='$tdcolor'>";
$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 "<td class='$tdcolor'>";
} else {
echo format_numeric($temp)." %</td>";
echo "<td class='$tdcolor'>";
if ($temp > $sla_limit)
echo "<img src='images/pixel_green.png' width=40 height=18 title='".$lang_label["green_light"]."'>";
else
echo "<img src='images/pixel_red.png' width=40 height=18 title='".$lang_label["red_light"]."'>";
else {
echo format_numeric ($temp)." %</td>";;
}
echo "<td class='".$tdcolor."' align='center'>";
if ($est_estado == 1){
if ($est_cambio == 1)
echo "<img src='images/pixel_yellow.png' width=40 height=18 title='" . lang_string ("yellow_light") . "'>";
else
echo "<img src='images/pixel_red.png' width=40 height=18 title='". lang_string ("red_light") . "'>";
} else
echo "<img src='images/pixel_green.png' width=40 height=18 title='". lang_string ("green_light") . "'>";
echo "<td align='center' class='".$tdcolor."'>";
if ($temp_interval != $intervalo)
echo $temp_interval."</td>";
else
echo "--";
echo "<td class='".$tdcolor."f9'>";
if ($agent_down == 1) { // If agent down, it's shown red and bold
echo "<span class='redb'>";
}
else {
echo "<span>";
}
if ($module_data["timestamp"] == '0000-00-00 00:00:00') {
echo lang_string ("never");
} else {
echo human_time_comparation($module_data["timestamp"]);
}
echo "</span></td>";
}
echo '</table>';
}
echo '</table>';
}
// 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 "<h3>".lang_string ("User-defined SLA items")."</h3>";
echo "<table width='750' cellpadding=4 cellspacing=4 class='databox'>";
echo "<tr>";
echo "<th>" . lang_string ("type") . "</th>";
echo "<th>" . lang_string ("module_name") . "</th>";
echo "<th>" . lang_string ("SLA") . "</th>";
echo "<th>" . lang_string ("status") . "</th>";
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 "<tr>";
echo "<td class='" . $tdcolor . "'>";
echo "<img src='images/" . show_icon_type ($id_tipo_modulo) . "' border=0>";
echo "<td class='" . $tdcolor . "' title='" . $description . "'>" . $name;
echo " ($sla_min / $sla_max / $sla_limit) </td>";
echo "<td class='$tdcolor'>";
$temp = get_agent_module_sla ($id_agent_module, $config["sla_period"], $sla_min, $sla_max);
if ($temp === false){
echo lang_string("N/A");
echo "<td class='$tdcolor'>";
} else {
echo format_numeric($temp)." %</td>";
echo "<td class='$tdcolor'>";
if ($temp > $sla_limit)
echo "<img src='images/pixel_green.png' width=40 height=18 title='" . lang_label("green_light") . "'>";
else
echo "<img src='images/pixel_red.png' width=40 height=18 title='" . lang_string ("red_light") . "'>";
}
}
echo '</table>';
}
?>

View File

@ -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` (