2009-03-02 Evi Vanoost <vanooste@rcbi.rochester.edu>

* include/functions_reporting.php: Rewrote get_agentmodule_sla with
	faster calculations (count in SQL).
	
	* include/functions_ui.php: Added print_moduletype_icon that prints the
	whole (correct) icon including rollover text
	
	* include/functions_db.php: Updated some documenation and removed 
	deprecated functions that are now in the auth parts. Renamed 
	return_status_agent_module to get_agentmodule_status
	
	* operation/agentes/sla_view.php: Made it use the 2.0 SQL and HTML
	functions
	
	* godmode/agentes/configurar_agente.php: Fixed tab links
	
	* operation/events/events.php, include/functions_visual_map.php,
	operation/agentes/networkmap.php, operation/agentes/status_monitor.php,
	operation/agentes/estado_grupo.php, operation/agentes/ver_agente.php,
	operation/reporting/custom_reporting.php, 
	operation/reporting/reporting_viewer.php,
	operation/reporting/reporting_xml.php, godmode/setup/links.php,
	godmode/setup/setup.php, godmode/reporting/map_builder.php,
	godmode/reporting/reporting_builder.php: Fixed renamed functions

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1497 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2009-03-02 19:16:46 +00:00
parent 6c09f221bd
commit 50ac06cce0
20 changed files with 188 additions and 271 deletions

View File

@ -1,3 +1,29 @@
2009-03-02 Evi Vanoost <vanooste@rcbi.rochester.edu>
* include/functions_reporting.php: Rewrote get_agentmodule_sla with
faster calculations (count in SQL).
* include/functions_ui.php: Added print_moduletype_icon that prints the
whole (correct) icon including rollover text
* include/functions_db.php: Updated some documenation and removed
deprecated functions that are now in the auth parts. Renamed
return_status_agent_module to get_agentmodule_status
* operation/agentes/sla_view.php: Made it use the 2.0 SQL and HTML
functions
* godmode/agentes/configurar_agente.php: Fixed tab links
* operation/events/events.php, include/functions_visual_map.php,
operation/agentes/networkmap.php, operation/agentes/status_monitor.php,
operation/agentes/estado_grupo.php, operation/agentes/ver_agente.php,
operation/reporting/custom_reporting.php,
operation/reporting/reporting_viewer.php,
operation/reporting/reporting_xml.php, godmode/setup/links.php,
godmode/setup/setup.php, godmode/reporting/map_builder.php,
godmode/reporting/reporting_builder.php: Fixed renamed functions
2009-03-02 Esteban Sanchez <estebans@artica.es> 2009-03-02 Esteban Sanchez <estebans@artica.es>
* include/functions_menu.php: Added to repository. Functions for menu. * include/functions_menu.php: Added to repository. Functions for menu.

View File

@ -211,12 +211,12 @@ print_image ("images/lightbulb.png", false, $img_arr);
echo '&nbsp; '.__('Modules').'</a></li>'; echo '&nbsp; '.__('Modules').'</a></li>';
echo '<li class="'.($tab == "alert" ? 'nomn_high' : 'nomn').'">'; echo '<li class="'.($tab == "alert" ? 'nomn_high' : 'nomn').'">';
echo '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=module&amp;id_agente='.$id_agente.'">'; echo '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=alert&amp;id_agente='.$id_agente.'">';
print_image ("images/bell.png", false, $img_arr); print_image ("images/bell.png", false, $img_arr);
echo '&nbsp; '.__('Alerts').'</a></li>'; echo '&nbsp; '.__('Alerts').'</a></li>';
echo '<li class="'.($tab == "template" ? 'nomn_high' : 'nomn').'">'; echo '<li class="'.($tab == "template" ? 'nomn_high' : 'nomn').'">';
echo '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=module&amp;id_agente='.$id_agente.'">'; echo '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=template&amp;id_agente='.$id_agente.'">';
print_image ("images/network.png", false, $img_arr); print_image ("images/network.png", false, $img_arr);
echo '&nbsp; '.__('Net. Templates').'</a></li>'; echo '&nbsp; '.__('Net. Templates').'</a></li>';

View File

@ -83,7 +83,7 @@ if ($id_group)
$table->data[2][1] = print_select_from_sql ($sql, 'id_parent', $id_parent, '', 'None', 0, true); $table->data[2][1] = print_select_from_sql ($sql, 'id_parent', $id_parent, '', 'None', 0, true);
$table->data[2][1] .= ' <span id="parent_preview">'; $table->data[2][1] .= ' <span id="parent_preview">';
if ($id_parent) { if ($id_parent) {
echo '<img src="images/groups_small/'.dame_grupo_icono ($id_parent).'.png" />'; echo '<img src="images/groups_small/'.get_group_icon ($id_parent).'.png" />';
} }
echo'</span>'; echo'</span>';

View File

@ -278,7 +278,7 @@ if (! $edit_layout && ! $id_layout) {
$data = array (); $data = array ();
$data[0] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/map_builder&id_layout='.$map['id'].'">'.$map['name'].'</a>'; $data[0] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/map_builder&id_layout='.$map['id'].'">'.$map['name'].'</a>';
$data[1] = '<img src="images/'.dame_grupo_icono ($map['id_group']).'.png" /> '; $data[1] = '<img src="images/'.get_group_icon ($map['id_group']).'.png" /> ';
$data[1] .= get_group_name ($map['id_group']); $data[1] .= get_group_name ($map['id_group']);
$data[2] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/map_builder&id_layout='.$map['id'].'&delete_layout=1"> $data[2] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/map_builder&id_layout='.$map['id'].'&delete_layout=1">
<img src="images/cross.png"></a>'; <img src="images/cross.png"></a>';

View File

@ -351,7 +351,7 @@ if ($edit_sla_report_content) {
} }
$table->data[1][1] .= ' <span id="icon_preview">'; $table->data[1][1] .= ' <span id="icon_preview">';
if ($report_id_group) { if ($report_id_group) {
$table->data[1][1] .= '<img src="images/groups_small/'.dame_grupo_icono ($report_id_group).'.png" />'; $table->data[1][1] .= '<img src="images/groups_small/'.get_group_icon ($report_id_group).'.png" />';
} }
$table->data[1][1] .= '</span>'; $table->data[1][1] .= '</span>';
$table->data[2][0] = __('Private'); $table->data[2][0] = __('Private');

View File

@ -21,7 +21,7 @@ require_once ("include/config.php");
check_login (); check_login ();
if (! give_acl ($config['id_user'], 0, "PM") || ! dame_admin ($config['id_user'])) { if (! give_acl ($config['id_user'], 0, "PM") || ! is_user_admin ($config['id_user'])) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access Link Management"); audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access Link Management");
require ("general/noaccess.php"); require ("general/noaccess.php");
exit; exit;

View File

@ -21,7 +21,7 @@ require_once ("include/config.php");
check_login (); check_login ();
if (! give_acl ($config['id_user'], 0, "PM") || ! dame_admin ($config['id_user'])) { if (! give_acl ($config['id_user'], 0, "PM") || ! is_user_admin ($config['id_user'])) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access Setup Management"); audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access Setup Management");
require ("general/noaccess.php"); require ("general/noaccess.php");
exit; exit;

View File

@ -1021,14 +1021,7 @@ function get_os_name ($id_os) {
} }
/** /**
* DEPRECATED: Use get_user_email * @deprecated Use is_user_admin
*/
function dame_email ($id_user) {
return get_user_email ($id_user);
}
/**
* DEPRECATED: Use is_user_admin
*/ */
function dame_admin ($id_user) { function dame_admin ($id_user) {
return is_user_admin ($id_user); return is_user_admin ($id_user);
@ -1061,17 +1054,6 @@ function check_alert_fired ($id_agent) {
return false; return false;
} }
/**
* Check is a user exists in the system
*
* @param string User id.
*
* @return bool True if the user exists.
*/
function existe ($id_user) {
return is_user ($id_user);
}
/** /**
* Get the interval value of an agent module. * Get the interval value of an agent module.
* *
@ -1517,11 +1499,12 @@ function get_db_row_sql ($sql) {
* Get the first row of a database query into a table. * Get the first row of a database query into a table.
* *
* The SQL statement executed would be something like: * The SQL statement executed would be something like:
* "SELECT * FROM $table WHERE $field_search = $condition" * "SELECT (*||$fields) FROM $table WHERE $field_search = $condition"
* *
* @param string Table to get the row * @param string Table to get the row
* @param string Field to filter elementes * @param string Field to filter elements
* @param string Condition the field must have. * @param string Condition the field must have.
* @param mixed Fields to select (array or string or false/empty for *)
* *
* @return mixed The first row of a database query or false. * @return mixed The first row of a database query or false.
*/ */
@ -2037,7 +2020,7 @@ function format_array_to_where_clause_sql ($values, $join = 'AND', $prefix = fal
* *
* @return bool True if there were alerts fired. * @return bool True if there were alerts fired.
*/ */
function return_status_agent_module ($id_agentmodule = 0) { function get_agentmodule_status ($id_agentmodule = 0) {
$status = get_db_value ('estado', 'tagente_estado', 'id_agente_modulo', $id_agentmodule); $status = get_db_value ('estado', 'tagente_estado', 'id_agente_modulo', $id_agentmodule);
$times_fired = get_db_value ('SUM(times_fired)', 'talert_template_modules', 'id_agent_module', $id_agentmodule); $times_fired = get_db_value ('SUM(times_fired)', 'talert_template_modules', 'id_agent_module', $id_agentmodule);

View File

@ -17,8 +17,6 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
global $config;
require_once ($config["homedir"]."/include/functions_agents.php"); require_once ($config["homedir"]."/include/functions_agents.php");
/** /**
@ -33,84 +31,40 @@ require_once ($config["homedir"]."/include/functions_agents.php");
* *
* @return int SLA percentage of the requested module. * @return int SLA percentage of the requested module.
*/ */
function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value = false, $date = 0) { function get_agentmodule_sla ($id_agentmodule, $period = 0, $min_value = 1, $max_value = false, $date = 0) {
if (empty ($date)) if (empty ($date)) {
$date = get_system_time (); $date = get_system_time ();
}
if (empty ($period))
return false; //We can't calculate a 0 period (division by zero)
if (empty ($period)) {
global $config;
$period = $config["sla_period"];
}
$datelimit = $date - $period; // start date $datelimit = $date - $period; // start date
/* Get all the data in the interval */ /* Get the total data entries in the interval */
$sql = sprintf ('SELECT datos, utimestamp FROM tagente_datos $sql = sprintf ('SELECT COUNT(*) FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d AND utimestamp <= %d', $id_agentmodule, $datelimit, $date);
WHERE id_agente_modulo = %d $total = get_db_sql ($sql);
AND utimestamp > %d AND utimestamp <= %d
ORDER BY utimestamp ASC', if (empty ($total)) {
$id_agent_module, $datelimit, $date); //No data to calculate on so we return 100 (fail to good)
$datas = get_db_all_rows_sql ($sql); return 100;
if ($datas === false) { }
/* Try to get data from tagente_estado. It may found nothing because of $sql = sprintf ('SELECT COUNT(*) FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d AND utimestamp <= %d AND datos < %d', $id_agentmodule, $datelimit, $date, $min_value);
data compression */ if ($max_value > $min_value) {
$sql = sprintf ('SELECT datos, utimestamp FROM tagente_estado $sql .= sprintf (' AND datos > %d', $max_value);
WHERE id_agente_modulo = %d }
AND utimestamp > %d AND utimestamp <= %d $bad = get_db_sql ($sql);
ORDER BY utimestamp ASC', if (empty ($bad)) {
$id_agent_module, $datelimit, $date); $bad = 0;
$data = get_db_sql ($sql);
if ($data === false) {
//No data to calculate on so we return 0.
return 0;
}
$datas = array ();
array_push ($datas, $data);
} }
$last_data = ""; //Calculate percentage
$total_badtime = 0; $result = 100 - ($bad / $total) * 100;
$interval_begin = 0;
$interval_last = $date;
$previous_data_timestamp = 0;
/* Get also the previous data before the selected interval. */ return $result;
$previous_data = get_previous_data ($id_agent_module, $datelimit);
if ($previous_data) {
/* Add data to the beginning */
array_unshift ($datas, $previous_data);
$previous_data_timestamp = $previous_data['utimestamp'];
}
foreach ($datas as $data) {
if ($data["datos"] < $min_value || ($max_value !== false && $data["datos"] > $max_value)) {
if ($interval_begin == 0) {
$interval_begin = $data["utimestamp"];
}
} elseif ($interval_begin != 0) {
// Here ends interval with data outside valid values,
// Need to add this time to counter
$interval_last = $data["utimestamp"];
$temp_time = $interval_last - $interval_begin;
$total_badtime += $temp_time;
$interval_begin = 0;
$interval_last = 0;
}
}
/* Check the last interval, if any */
if ($interval_begin != 0) {
/* The last time was the time of the previous data in the
interval. That means that in all the interval, the data was
not between the expected values, so the SLA is zero. */
if ($interval_begin = $previous_data_timestamp)
return 0;
$total_badtime += $interval_last - $interval_begin;
}
$result = 100 - ($total_badtime / $period) * 100;
return max ($result, 0);
} }
/** /**

View File

@ -892,4 +892,22 @@ function debug ($var) {
print_r ($var); print_r ($var);
echo '</pre>'; echo '</pre>';
} }
/**
* Prints icon of a module type
*
* @param int Module Type ID
* @param bool Whether to return or print
*
* @return string An HTML string with the icon. Printed if return is false
*/
function print_moduletype_icon ($id_moduletype, $return = false) {
$type = get_db_row ("ttipo_modulo", "id_tipo", (int) $id_moduletype, array ("nombre", "icon"));
if ($type === false) {
$type = array ();
$type["nombre"] = __('Unknown Type');
$type["icon"] = 'b_down.png';
}
return print_image ("images/".$type["icon"], $return, array ("border" => 0, "title" => $type["nombre"]));
}
?> ?>

View File

@ -46,11 +46,11 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
$id_agent = get_db_value ("id_agente", "tagente_estado", "id_agente_modulo", $layout_data['id_agente_modulo']); $id_agent = get_db_value ("id_agente", "tagente_estado", "id_agente_modulo", $layout_data['id_agente_modulo']);
$id_agent_module_parent = get_db_value ("id_agente_modulo", "tlayout_data", "id", $layout_data["parent_item"]); $id_agent_module_parent = get_db_value ("id_agente_modulo", "tlayout_data", "id", $layout_data["parent_item"]);
// Item value // Item value
$status = return_status_agent_module ($layout_data['id_agente_modulo']); $status = get_agentmodule_status ($layout_data['id_agente_modulo']);
if ($layout_data['no_link_color'] == 1) if ($layout_data['no_link_color'] == 1)
$status_parent = 3; $status_parent = 3;
else else
$status_parent = return_status_agent_module ($id_agent_module_parent); $status_parent = get_agentmodule_status ($id_agent_module_parent);
// Status for a whole agent // Status for a whole agent
} elseif ($layout_data['id_agent'] != 0) { } elseif ($layout_data['id_agent'] != 0) {
@ -285,13 +285,13 @@ function get_layout_status ($id_layout = 0) {
// Module // Module
} elseif ($data["id_agente_modulo"] != 0) { } elseif ($data["id_agente_modulo"] != 0) {
$temp_status = return_status_agent_module ($data["id_agente_modulo"]); $temp_status = get_agentmodule_status ($data["id_agente_modulo"]);
if ($temp_status > $temp_total) if ($temp_status > $temp_total)
$temp_total = $temp_status; $temp_total = $temp_status;
// Agent // Agent
} else { } else {
$temp_status = return_status_agent ($data["id_agent"]); $temp_status = get_agentmodule_status ($data["id_agent"]);
if ($temp_status > $temp_total) if ($temp_status > $temp_total)
$temp_total = $temp_status; $temp_total = $temp_status;
} }

View File

@ -70,7 +70,7 @@ foreach ($groups as $id_group => $group_name) {
'warning' => 0, 'warning' => 0,
'alerts' => 0, 'alerts' => 0,
'down' => 0, 'down' => 0,
'icon' => dame_grupo_icono ($id_group), 'icon' => get_group_icon ($id_group),
'id_group' => $id_group, 'id_group' => $id_group,
'name' => $group_name); 'name' => $group_name);

View File

@ -164,7 +164,7 @@ function create_pandora_node ($name, $font_size = 10) {
// Opens a group definition // Opens a group definition
function open_group ($id) { function open_group ($id) {
$img = 'images/'.dame_grupo_icono ($id).'.png'; $img = 'images/'.get_group_icon ($id).'.png';
$name = get_group_name ($id); $name = get_group_name ($id);
$group = 'subgraph cluster_' . $id . $group = 'subgraph cluster_' . $id .

View File

@ -12,13 +12,14 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public Liccense
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Load global vars // Load global vars
require_once ("include/config.php"); require_once ("include/config.php");
require_once ("include/functions_reporting.php");
check_login(); check_login();
@ -29,166 +30,101 @@ if (! give_acl ($config['id_user'], 0, "AR") && ! give_acl ($config['id_user'],
exit; exit;
} }
require ("include/functions_reporting.php");
echo "<h2>".__('SLA view')."</h2>"; echo "<h2>".__('SLA view')."</h2>";
$id_agent = get_parameter ("id_agente", "0"); $id_agent = get_parameter ("id_agente", 0);
$intervalo = get_agent_interval ($id_agent); $interval = get_agent_interval ($id_agent);
$modules = get_agent_modules ($id_agent, '*', array ('disabled' => 0, 'history_data' => 1, 'delete_pending' => 0));
$offset = get_parameter ("offset", 0);
// Get all module from agent // 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'; echo "<h3>".__('Automatic SLA for monitors')."</h3>";
$result_t=mysql_query($sql_t); pagination (count ($modules), "index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=sla&id_agente=".$id_agent, $offset);
if (mysql_num_rows ($result_t)) {
echo "<h3>".__('Automatic SLA for monitors')."</h3>";
echo "<table width='750' cellpadding=4 cellspacing=4 class='databox'>";
echo "<tr><th>X</th>";
echo "<th>".__('Type')."</th>
<th>".__('Module name')."</th>
<th>".__('S.L.A.')."</th>
<th>".__('Status')."</th>
<th>".__('Interval')."</th>
<th>".__('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 = get_moduletype_name ($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 ($intervalo != $est_interval && $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 = get_system_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)) { $table->width = '95%';
if ($module_data["flag"] == 0){ $table->cellpadding = 4;
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>"; $table->cellspacing = 4;
} else { $table->class = "databox";
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($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 ($module_data["id_agente_modulo"], $config["sla_period"], 1); $table->head = array ();
if ($temp === false) $table->head[0] = __('Type');
echo __('N/A'); $table->head[1] = __('Module name');
else { $table->head[2] = __('S.L.A.');
echo format_numeric ($temp)." %</td>";; $table->head[3] = __('Status');
} $table->head[4] = __('Interval');
echo "<td class='".$tdcolor."' align='center'>"; $table->align = array ();
if ($est_estado == 1){ $table->align[0] = "center";
if ($est_cambio == 1) $table->align[1] = "center";
echo "<img src='images/pixel_yellow.png' width=40 height=18 title='" . __('Change between Green/Red state') . "'>"; $table->align[2] = "center";
else $table->align[3] = "center";
echo "<img src='images/pixel_red.png' width=40 height=18 title='". __('At least one monitor fails') . "'>"; $table->align[4] = "center";
} else
echo "<img src='images/pixel_green.png' width=40 height=18 title='". __('All Monitors OK') . "'>";
echo "<td align='center' class='".$tdcolor."'>"; $table->data = array ();
if ($temp_interval != $intervalo) $loc = 0;
echo $temp_interval."</td>";
else foreach ($modules as $module_id => $module) {
echo "--"; if ($loc < $offset) {
echo "<td class='".$tdcolor."f9'>"; $loc++;
if ($agent_down == 1) { // If agent down, it's shown red and bold continue; //Skip offset
echo "<span class='redb'>"; } elseif ($loc >= $offset + $config["block_size"]) {
} continue;
else {
echo "<span>";
}
if ($module_data["timestamp"] == '0000-00-00 00:00:00') {
echo __('Never');
} else {
echo human_time_comparation($module_data["timestamp"]);
}
echo "</span></td>";
}
} }
echo '</table>'; $data = array ();
} $data[0] = print_moduletype_icon ($module["id_tipo_modulo"], true);
$data[1] = print_string_substr ($module["nombre"], 25, true);
$data[2] = format_numeric (get_agentmodule_sla ($module_id, $config["sla_period"], 1)).'%';
//TODO: Make this work for all new status
// Get all SLA report components $status = get_agentmodule_status ($module_id);
$sql = "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)"; if ($status == 1){
$result_t = mysql_query ($sql); $data[3] = print_image ("images/pixel_red.png", true, array ("width" => 40, "height" => 18, "title" => __('Module Down')));
if (mysql_num_rows ($result_t)) { } else {
$color=0; $data[3] = print_image ("images/pixel_green.png", true, array ("width" => 40, "height" => 18, "title" => __('Module Up')));
echo "<h3>".__('User-defined SLA items')." - ";
echo human_time_description_raw($config["sla_period"]). " </h3>";
echo "<table width='750' cellpadding=4 cellspacing=4 class='databox'>";
echo "<tr>";
echo "<th>" . __('Type') . "</th>";
echo "<th>" . __('Module name') . "</th>";
echo "<th>" . __('S.L.A.') . "</th>";
echo "<th>" . __('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 = get_moduletype_name ($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 __('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='" . __('All Monitors OK') . "'>";
else
echo "<img src='images/pixel_red.png' width=40 height=18 title='" . __('At least one monitor fails') . "'>";
}
} }
echo '</table>';
if ($module["module_interval"] > 0) {
$data[4] = $module["module_interval"];
} else {
$data[4] = $interval;
}
array_push ($table->data, $data);
$loc++;
} }
print_table ($table);
unset ($table);
// Get all SLA report components
$sql = "SELECT id_agent_module, sla_max, sla_min, sla_limit FROM treport_content_sla_combined WHERE id_agent_module IN (".implode (",",array_keys ($modules)).")";
$result = get_db_all_rows_sql ($sql);
if ($result !== false) {
echo "<h3>".__('User-defined SLA items')." - ".human_time_description_raw ($config["sla_period"])."</h3>";
$table->width = '95%';
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('Type');
$table->head[1] = __('Module name');
$table->head[2] = __('S.L.A.');
$table->head[3] = __('Status');
$table->data = array ();
foreach ($result as $sla_data) {
$data = array ();
$data[0] = print_moduletype_icon ($modules[$sla_data["id_agent_module"]]["id_tipo_modulo"], true);
$data[1] = print_string_substr ($modules[$sla_data["id_agent_module"]]["nombre"], 25, true);
$data[1] .= "(".$sla_data["sla_min"]." / ".$sla_data["sla_max"]." / ".$sla_data["sla_limit"].")";
$data[2] = format_numeric (get_agentmodule_sla ($sla_data["id_agent_module"], $config["sla_period"], 1)).'%';
$status = get_agentmodule_status ($sla_data["id_agent_module"]);
if ($status == 1){
$data[3] = print_image ("images/pixel_red.png", true, array ("width" => 40, "height" => 18, "title" => __('Module Down')));
} else {
$data[3] = print_image ("images/pixel_green.png", true, array ("width" => 40, "height" => 18, "title" => __('Module Up')));
}
array_push ($table->data, $data);
}
print_table ($table);
unset ($table);
}
?> ?>

View File

@ -213,7 +213,7 @@ $table->align[6] = "right";
foreach ($result as $row) { foreach ($result as $row) {
$data = array (); $data = array ();
//This should be processed locally. Don't rely on other URL's to do our dirty work. Maybe a process_agentmodule_flag function //TODO: This should be processed locally. Don't rely on other URL's to do our dirty work. Maybe a process_agentmodule_flag function
$data[0] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$row["id_agent"].'&id_agente_modulo='.$row["id_agente_modulo"].'&flag=1&refr=60">'; $data[0] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$row["id_agent"].'&id_agente_modulo='.$row["id_agente_modulo"].'&flag=1&refr=60">';
if ($row["flag"] == 0) { if ($row["flag"] == 0) {
$data[0] .= '<img src="images/target.png" />'; $data[0] .= '<img src="images/target.png" />';

View File

@ -54,7 +54,7 @@ if (is_ajax ()) {
echo '<h3>'.$agent['nombre'].'</h3>'; echo '<h3>'.$agent['nombre'].'</h3>';
echo '<strong>'.__('Main IP').':</strong> '.$agent['direccion'].'<br />'; echo '<strong>'.__('Main IP').':</strong> '.$agent['direccion'].'<br />';
echo '<strong>'.__('Group').':</strong> '; echo '<strong>'.__('Group').':</strong> ';
echo '<img src="images/groups_small/'.dame_grupo_icono ($agent['id_grupo']).'.png" /> '; echo '<img src="images/groups_small/'.get_group_icon ($agent['id_grupo']).'.png" /> ';
echo get_group_name ($agent['id_grupo']).'<br />'; echo get_group_name ($agent['id_grupo']).'<br />';
echo '<strong>'.__('Last contact').':</strong> '.human_time_comparation($agent['ultimo_contacto']).'<br />'; echo '<strong>'.__('Last contact').':</strong> '.human_time_comparation($agent['ultimo_contacto']).'<br />';

View File

@ -105,7 +105,7 @@ $group_rep = (int) get_parameter ("group_rep", 1);
if ($ev_group > 1 && in_array ($ev_group, array_keys ($groups))) { if ($ev_group > 1 && in_array ($ev_group, array_keys ($groups))) {
//If a group is selected and it's in the groups allowed //If a group is selected and it's in the groups allowed
$sql_post = " AND id_grupo = $ev_group"; $sql_post = " AND id_grupo = $ev_group";
} elseif (dame_admin ($config["id_user"])) { } elseif (is_user_admin ($config["id_user"])) {
//Do nothing if you're admin, you get full access //Do nothing if you're admin, you get full access
$sql_post = ""; $sql_post = "";
$groups[0] = __('System Events'); $groups[0] = __('System Events');
@ -207,7 +207,7 @@ if ($result === false)
$agents = array (); $agents = array ();
$agents[-1] = __('All'); $agents[-1] = __('All');
if (dame_admin ($config["id_user"])) { if (is_user_admin ($config["id_user"])) {
$agents[0] = __('System'); $agents[0] = __('System');
} }

View File

@ -53,7 +53,7 @@ $table->align[3] = 'center';
$table->data = array (); $table->data = array ();
foreach ($reports as $report) { foreach ($reports as $report) {
if ($report['private'] && ($report['id_user'] != $config['id_user'] && ! dame_admin ($config['id_user']))) { if ($report['private'] && ($report['id_user'] != $config['id_user'] && ! is_user_admin ($config['id_user']))) {
continue; continue;
} }

View File

@ -41,7 +41,7 @@ if (! give_acl ($config['id_user'], $report['id_group'], "AR")) {
require ("include/functions_reporting.php"); require ("include/functions_reporting.php");
/* Check if the user can see the graph */ /* Check if the user can see the graph */
if ($report['private'] && ($report['id_user'] != $config['id_user'] && ! dame_admin ($config['id_user']))) { if ($report['private'] && ($report['id_user'] != $config['id_user'] && ! is_user_admin ($config['id_user']))) {
include ("general/noaccess.php"); include ("general/noaccess.php");
return; return;
} }
@ -231,7 +231,7 @@ foreach ($contents as $content) {
$data[0] .= $sla['sla_min']."<br />"; $data[0] .= $sla['sla_min']."<br />";
$data[0] .= '<strong>'.__('SLA Limit')."</strong> : "; $data[0] .= '<strong>'.__('SLA Limit')."</strong> : ";
$data[0] .= $sla['sla_limit']; $data[0] .= $sla['sla_limit'];
$sla_value = get_agent_module_sla ($sla['id_agent_module'], $content['period'], $sla_value = get_agentmodule_sla ($sla['id_agent_module'], $content['period'],
$sla['sla_min'], $sla['sla_max'], $datetime); $sla['sla_min'], $sla['sla_max'], $datetime);
if ($sla_value === false) { if ($sla_value === false) {
$data[1] = '<span style="font: bold 3em Arial, Sans-serif; color: #0000FF;">'; $data[1] = '<span style="font: bold 3em Arial, Sans-serif; color: #0000FF;">';
@ -325,7 +325,7 @@ foreach ($contents as $content) {
} }
$data = array (); $data = array ();
$monitor_value = format_numeric (get_agent_module_sla ($content['id_agent_module'], $content['period'], 1, false, $datetime)); $monitor_value = format_numeric (get_agentmodule_sla ($content['id_agent_module'], $content['period'], 1, false, $datetime));
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'; $data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">';
$data[0] .= $monitor_value.' % <img src="images/b_green.png" height="32" width="32" /></p>'; $data[0] .= $monitor_value.' % <img src="images/b_green.png" height="32" width="32" /></p>';
$monitor_value = format_numeric (100 - $monitor_value, 2) ; $monitor_value = format_numeric (100 - $monitor_value, 2) ;

View File

@ -112,7 +112,7 @@ if (! give_acl ($config['id_user'], $report['id_group'], "AR")) {
} }
/* Check if the user can see the graph */ /* Check if the user can see the graph */
if ($report['private'] && ($report['id_user'] != $config['id_user'] && ! dame_admin ($config['id_user']))) { if ($report['private'] && ($report['id_user'] != $config['id_user'] && ! is_user_admin ($config['id_user']))) {
return; return;
} }
@ -203,7 +203,7 @@ foreach ($contents as $content) {
$sla_data["max"] = $sla['sla_max']; $sla_data["max"] = $sla['sla_max'];
$sla_data["min"] = $sla['sla_min']; $sla_data["min"] = $sla['sla_min'];
$sla_value = get_agent_module_sla ($sla['id_agent_module'], $content['period'], $sla['sla_min'], $sla['sla_max'], $datetime); $sla_value = get_agentmodule_sla ($sla['id_agent_module'], $content['period'], $sla['sla_min'], $sla['sla_max'], $datetime);
if ($sla_value === false) { if ($sla_value === false) {
$sla_data["error"] = __('Unknown'); $sla_data["error"] = __('Unknown');
} else { } else {
@ -234,7 +234,7 @@ foreach ($contents as $content) {
case 6: case 6:
case 'monitor_report': case 'monitor_report':
$data["title"] = __('Monitor report'); $data["title"] = __('Monitor report');
$monitor_value = format_numeric (get_agent_module_sla ($content['id_agent_module'], $content['period'], 1, false, $datetime)); $monitor_value = format_numeric (get_agentmodule_sla ($content['id_agent_module'], $content['period'], 1, false, $datetime));
$data["objdata"]["good"] = $monitor_value; $data["objdata"]["good"] = $monitor_value;
$data["objdata"]["bad"] = format_numeric (100 - $monitor_value, 2); $data["objdata"]["bad"] = format_numeric (100 - $monitor_value, 2);
break; break;