2008-07-07 Esteban Sanchez <estebans@artica.es>
* godmode/reporting/graph_builder.php: Tab style correction. * godmode/reporting/reporting_builder.php: Button label renamed. * include/functions_db.php: Added functions from functions_reporting.php. * include/functions_reporting.php: Added missing documentation. Added check to avoid division by zero on alert_reporting(). Avoid $return flag as parameter in some functions. * include/functions_reporting_pdf.php: Avoid $return flag when calling some functions. * operation/reporting/reporting_viewer.php: Do not use a span with font-size when showing sla report. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@937 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
485207a9d7
commit
0daf8ebf1d
|
@ -1,3 +1,22 @@
|
|||
2008-07-07 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* godmode/reporting/graph_builder.php: Tab style correction.
|
||||
|
||||
* godmode/reporting/reporting_builder.php: Button label renamed.
|
||||
|
||||
* include/functions_db.php: Added functions from
|
||||
functions_reporting.php.
|
||||
|
||||
* include/functions_reporting.php: Added missing documentation. Added
|
||||
check to avoid division by zero on alert_reporting(). Avoid $return
|
||||
flag as parameter in some functions.
|
||||
|
||||
* include/functions_reporting_pdf.php: Avoid $return flag when calling
|
||||
some functions.
|
||||
|
||||
* operation/reporting/reporting_viewer.php: Do not use a span with
|
||||
font-size when showing sla report.
|
||||
|
||||
2008-07-04 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* operation/reporting/reporting_viewer.php: Added a loading div that
|
||||
|
|
|
@ -40,13 +40,13 @@ if (comprueba_login() != 0) {
|
|||
exit;
|
||||
}
|
||||
|
||||
if ((give_acl($id_user,0,"AW") != 1 ) AND (dame_admin($id_user)!=1)) {
|
||||
if ((give_acl($id_user,0,"AW") != 1 ) && (dame_admin($id_user)!=1)) {
|
||||
audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access graph builder");
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_GET["store_graph"])){
|
||||
if (isset($_GET["store_graph"])) {
|
||||
$name = entrada_limpia($_POST["name"]);
|
||||
$description = entrada_limpia($_POST["description"]);
|
||||
$module_number = entrada_limpia($_POST["module_number"]);
|
||||
|
@ -55,8 +55,8 @@ if (isset($_GET["store_graph"])){
|
|||
$height = entrada_limpia($_POST["height"]);
|
||||
$events = entrada_limpia($_POST["events"]);
|
||||
$stacked = get_parameter ("stacked",0);
|
||||
if ($events == "") // Temporal workaround
|
||||
$events = 0;
|
||||
if ($events == "") // Temporal workaround
|
||||
$events = 0;
|
||||
$period = entrada_limpia($_POST["period"]);
|
||||
// Create graph
|
||||
$sql = "INSERT INTO tgraph
|
||||
|
@ -69,7 +69,7 @@ if (isset($_GET["store_graph"])){
|
|||
$height,
|
||||
$private,
|
||||
$events,
|
||||
$stacked)";
|
||||
$stacked)";
|
||||
//echo "DEBUG $sql<br>";
|
||||
$res = mysql_query($sql);
|
||||
if ($res){
|
||||
|
@ -91,7 +91,7 @@ if (isset($_GET["store_graph"])){
|
|||
}
|
||||
|
||||
if (isset($_GET["get_agent"])) {
|
||||
$id_agent = $_POST["id_agent"];
|
||||
$id_agent = $_POST["id_agent"];
|
||||
if (isset($_POST["chunk"]))
|
||||
$chunkdata = $_POST["chunk"];
|
||||
}
|
||||
|
@ -144,32 +144,32 @@ if (isset($_GET["delete_module"] )) {
|
|||
}
|
||||
|
||||
if ($add_module) {
|
||||
$id_agent = $_POST["id_agent"];
|
||||
$id_module = $_POST["id_module"];
|
||||
if (isset($_POST["factor"]))
|
||||
$factor = $_POST["factor"];
|
||||
else
|
||||
$factor = 1;
|
||||
$period = $_POST["period"];
|
||||
$render = $_POST["render"];
|
||||
$stacked = get_parameter ("stacked",0);
|
||||
$id_agent = $_POST["id_agent"];
|
||||
$id_module = $_POST["id_module"];
|
||||
if (isset($_POST["factor"]))
|
||||
$factor = $_POST["factor"];
|
||||
else
|
||||
$factor = 1;
|
||||
$period = $_POST["period"];
|
||||
$render = $_POST["render"];
|
||||
$stacked = get_parameter ("stacked",0);
|
||||
// $alerts = $_POST["alerts"];
|
||||
if (isset($_POST["chunk"]))
|
||||
$chunkdata = $_POST["chunk"];
|
||||
$chunkdata = $_POST["chunk"];
|
||||
$events = $_POST["events"];
|
||||
$factor = $_POST["factor"];
|
||||
if ($_POST["width"]!= "")
|
||||
$width = $_POST["width"];
|
||||
if ($_POST["height"]!= "")
|
||||
$height = $_POST["height"];
|
||||
if ($id_module > 0){
|
||||
if ($_POST["width"]!= "")
|
||||
$width = $_POST["width"];
|
||||
if ($_POST["height"]!= "")
|
||||
$height = $_POST["height"];
|
||||
if ($id_module > 0){
|
||||
if (!isset($chunkdata) OR ($chunkdata == ""))
|
||||
$chunkdata = "$id_agent,$id_module,$factor";
|
||||
else
|
||||
$chunkdata = $chunkdata."|$id_agent,$id_module,$factor";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Parse CHUNK information into showable information
|
||||
// Split id to get all parameters
|
||||
if (! isset($_GET["delete_module"])){
|
||||
|
@ -210,8 +210,8 @@ if (isset($chunk1)) {
|
|||
echo "<input type='hidden' name='chunk' value='$chunkdata'>";
|
||||
if (isset($id_agent))
|
||||
echo "<input type='hidden' name='id_agent' value='$id_agent'>";
|
||||
if (isset($period))
|
||||
echo "<input type='hidden' name='period' value='$period'>";
|
||||
if (isset($period))
|
||||
echo "<input type='hidden' name='period' value='$period'>";
|
||||
|
||||
echo "<table width='500' cellpadding=4 cellpadding=4 class='databox'>";
|
||||
echo "<tr>
|
||||
|
@ -339,35 +339,50 @@ echo "<input type='text' name='height' value='$height' size=6>";
|
|||
|
||||
|
||||
switch ($period) {
|
||||
case 3600: $period_label = "Hour";
|
||||
break;
|
||||
case 7200: $period_label = "2 Hours";
|
||||
break;
|
||||
case 10800: $period_label = "3 Hours";
|
||||
break;
|
||||
case 21600: $period_label = "6 Hours";
|
||||
break;
|
||||
case 43200: $period_label = "12 Hours";
|
||||
break;
|
||||
case 86400: $period_label = "Day";
|
||||
break;
|
||||
case 172800: $period_label = "Two days";
|
||||
break;
|
||||
case 345600: $period_label = "Four days";
|
||||
break;
|
||||
case 604800: $period_label = "Last Week";
|
||||
break;
|
||||
case 1296000: $period_label = "15 Days";
|
||||
break;
|
||||
case 2592000: $period_label = "Last Month";
|
||||
break;
|
||||
case 5184000: $period_label = "Two Month";
|
||||
break;
|
||||
case 15552000: $period_label = "Six Months";
|
||||
break;
|
||||
case 31104000: $period_label = "One year";
|
||||
break;
|
||||
default: $period_label = "Day";
|
||||
case 3600:
|
||||
$period_label = "Hour";
|
||||
break;
|
||||
case 7200:
|
||||
$period_label = "2 Hours";
|
||||
break;
|
||||
case 10800:
|
||||
$period_label = "3 Hours";
|
||||
break;
|
||||
case 21600:
|
||||
$period_label = "6 Hours";
|
||||
break;
|
||||
case 43200:
|
||||
$period_label = "12 Hours";
|
||||
break;
|
||||
case 86400:
|
||||
$period_label = "Day";
|
||||
break;
|
||||
case 172800:
|
||||
$period_label = "Two days";
|
||||
break;
|
||||
case 345600:
|
||||
$period_label = "Four days";
|
||||
break;
|
||||
case 604800:
|
||||
$period_label = "Last Week";
|
||||
break;
|
||||
case 1296000:
|
||||
$period_label = "15 Days";
|
||||
break;
|
||||
case 2592000:
|
||||
$period_label = "Last Month";
|
||||
break;
|
||||
case 5184000:
|
||||
$period_label = "Two Month";
|
||||
break;
|
||||
case 15552000:
|
||||
$period_label = "Six Months";
|
||||
break;
|
||||
case 31104000:
|
||||
$period_label = "One year";
|
||||
break;
|
||||
default:
|
||||
$period_label = "Day";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -514,7 +514,7 @@ if ($edit_sla_report_content) {
|
|||
echo '<form method="post" action="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder">';
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
print_input_hidden ('edit_report', 1);
|
||||
print_submit_button (lang_string ('add'), 'create', false, 'class="sub next"');
|
||||
print_submit_button (lang_string ('Create report'), 'create', false, 'class="sub next"');
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
}
|
||||
|
|
|
@ -549,6 +549,61 @@ function get_monitor_last_down_timestamp_in_period ($id_agent_module, $period, $
|
|||
return get_db_sql ($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the monitors defined in an group.
|
||||
*
|
||||
* @param id_group Group id to get all the monitors.
|
||||
*
|
||||
* @return An array with all the monitors defined in the group (tagente_modulo).
|
||||
*/
|
||||
function get_monitors_in_group ($id_group) {
|
||||
$sql = sprintf ('SELECT tagente_modulo.*
|
||||
FROM tagente_modulo, ttipo_modulo, tagente
|
||||
WHERE id_tipo_modulo = id_tipo
|
||||
AND tagente.id_agente = tagente_modulo.id_agente
|
||||
AND ttipo_modulo.nombre like "%%_proc"
|
||||
AND tagente.id_grupo = %d', $id_group);
|
||||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the monitors defined in an agent.
|
||||
*
|
||||
* @param id_agent Agent id to get all the monitors.
|
||||
*
|
||||
* @return An array with all the monitors defined (tagente_modulo).
|
||||
*/
|
||||
function get_monitors_in_agent ($id_agent) {
|
||||
$sql = sprintf ('SELECT tagente_modulo.*
|
||||
FROM tagente_modulo, ttipo_modulo, tagente
|
||||
WHERE id_tipo_modulo = id_tipo
|
||||
AND tagente.id_agente = tagente_modulo.id_agente
|
||||
AND ttipo_modulo.nombre like "%%_proc"
|
||||
AND tagente.id_agente = %d', $id_agent);
|
||||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the monitors down during a period of time.
|
||||
*
|
||||
* @param monitors An array with all the monitors to check. Each
|
||||
* element of the array must be a dictionary.
|
||||
* @param period Period of time to check the monitors.
|
||||
* @param date Beginning date to check the monitors.
|
||||
*
|
||||
* @return An array with all the monitors that went down in that
|
||||
* period of time.
|
||||
*/
|
||||
function get_monitors_down ($monitors, $period = 0, $date = 0) {
|
||||
$monitors_down = array ();
|
||||
foreach ($monitors as $monitor) {
|
||||
$down = get_monitor_downs_in_period ($monitor['id_agente_modulo'], $period, $date);
|
||||
if ($down)
|
||||
array_push ($monitors_down, $monitor);
|
||||
}
|
||||
return $monitors_down;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the times an alerts fired during a period.
|
||||
*
|
||||
|
@ -570,6 +625,53 @@ function get_alert_fires_in_period ($id_agent_module, $period, $date = 0) {
|
|||
return (int) get_db_sql ($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the alerts defined in a group.
|
||||
*
|
||||
* It gets all the alerts of all the agents on a given group.
|
||||
*
|
||||
* @param id_group Group id to check.
|
||||
*
|
||||
* @return An array with alerts dictionaries defined in a group.
|
||||
*/
|
||||
function get_alerts_in_group ($id_group) {
|
||||
$alerts = array ();
|
||||
$agents = get_agents_in_group ($id_group);
|
||||
foreach ($agents as $agent) {
|
||||
$agent_alerts = get_alerts_in_agent ($agent['id_agente']);
|
||||
$alerts = array_merge ($alerts, $agent_alerts);
|
||||
}
|
||||
|
||||
return $alerts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the alerts fired during a period, given a list of alerts.
|
||||
*
|
||||
* @param alerts A list of alerts to check. See get_alerts_in_group()
|
||||
* @param period Period of time to check fired alerts.
|
||||
* @param date Beginning date to check fired alerts in UNIX format (current date by default)
|
||||
*
|
||||
* @return An array with the alert id as key and the number of times
|
||||
* the alert was fired (only included if it was fired).
|
||||
*/
|
||||
function get_alerts_fired ($alerts, $period = 0, $date = 0) {
|
||||
if (! $date)
|
||||
$date = time ();
|
||||
$datelimit = $date - $period;
|
||||
|
||||
$alerts_fired = array ();
|
||||
$agents = array ();
|
||||
foreach ($alerts as $alert) {
|
||||
$fires = get_alert_fires_in_period ($alert['id_agente_modulo'], $period, $date);
|
||||
if (! $fires) {
|
||||
continue;
|
||||
}
|
||||
$alerts_fired[$alert['id_aam']] = $fires;
|
||||
}
|
||||
return $alerts_fired;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last time an alert fired during a period.
|
||||
*
|
||||
|
|
|
@ -16,6 +16,17 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
/**
|
||||
* Get SLA of a module.
|
||||
*
|
||||
* @param id_agent_module Agent module to calculate SLA
|
||||
* @param period Period to check the SLA compliance.
|
||||
* @param min_value Minimum data value the module in the right interval
|
||||
* @param max_value Maximum data value the module in the right interval
|
||||
* @param date Beginning date of the report in UNIX time (current date by default).
|
||||
*
|
||||
* @return SLA percentage of the requested module.
|
||||
*/
|
||||
function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value, $date = 0) {
|
||||
require("config.php");
|
||||
if (! $date)
|
||||
|
@ -76,7 +87,15 @@ function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value
|
|||
return max ($result, 0);
|
||||
}
|
||||
|
||||
function general_stats ( $id_user, $id_group = 0) {
|
||||
/**
|
||||
* Get a general stats info.
|
||||
*
|
||||
* @param id_user
|
||||
* @param id_group
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
function general_stats ($id_user, $id_group = 0) {
|
||||
if ($id_group <= 0)
|
||||
// Get group list that user has access
|
||||
$mis_grupos = list_group2 ($id_user);
|
||||
|
@ -190,6 +209,19 @@ function general_stats ( $id_user, $id_group = 0) {
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an event reporting table.
|
||||
*
|
||||
* It construct a table object with all the events happened in a group
|
||||
* during a period of time.
|
||||
*
|
||||
* @param id_group Group id to get the report.
|
||||
* @param period Period of time to get the report.
|
||||
* @param date Beginning date of the report in UNIX time (current date by default).
|
||||
* @param return Flag to return or echo the report table (echo by default).
|
||||
*
|
||||
* @return A table object if return variable is true.
|
||||
*/
|
||||
function event_reporting ($id_group, $period, $date = 0, $return = false) {
|
||||
global $config;
|
||||
|
||||
|
@ -228,35 +260,14 @@ function event_reporting ($id_group, $period, $date = 0, $return = false) {
|
|||
return $table;
|
||||
}
|
||||
|
||||
function get_alerts_in_group ($id_group) {
|
||||
$alerts = array ();
|
||||
$agents = get_agents_in_group ($id_group);
|
||||
foreach ($agents as $agent) {
|
||||
$agent_alerts = get_alerts_in_agent ($agent['id_agente']);
|
||||
$alerts = array_merge ($alerts, $agent_alerts);
|
||||
}
|
||||
|
||||
return $alerts;
|
||||
}
|
||||
|
||||
function get_alerts_fired ($alerts, $period = 0, $date = 0) {
|
||||
if (! $date)
|
||||
$date = time ();
|
||||
$datelimit = $date - $period;
|
||||
|
||||
$alerts_fired = array ();
|
||||
$agents = array ();
|
||||
foreach ($alerts as $alert) {
|
||||
$fires = get_alert_fires_in_period ($alert['id_agente_modulo'], $period, $date);
|
||||
if (! $fires) {
|
||||
continue;
|
||||
}
|
||||
$alerts_fired[$alert['id_aam']] = $fires;
|
||||
}
|
||||
return $alerts_fired;
|
||||
}
|
||||
|
||||
function get_fired_alerts_reporting_table ($alerts_fired, $return = false) {
|
||||
/**
|
||||
* Get a table report from a alerts fired array.
|
||||
*
|
||||
* @param alerts_fired Alerts fired array. See get_alerts_fired()
|
||||
*
|
||||
* @return A table object with a report of the fired alerts.
|
||||
*/
|
||||
function get_fired_alerts_reporting_table ($alerts_fired) {
|
||||
$agents = array ();
|
||||
|
||||
foreach (array_keys ($alerts_fired) as $id_alert) {
|
||||
|
@ -291,8 +302,6 @@ function get_fired_alerts_reporting_table ($alerts_fired, $return = false) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$return)
|
||||
print_table ($table);
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
@ -305,14 +314,16 @@ function get_fired_alerts_reporting_table ($alerts_fired, $return = false) {
|
|||
* @param $id_group Group to get info of the alerts.
|
||||
* @param $period Period of time of the desired alert report.
|
||||
* @param $date Beggining date of the report (current date by default).
|
||||
* @param $return Flag to return or echo the report (by default).
|
||||
* @param $return Flag to return or echo the report (echo by default).
|
||||
*/
|
||||
function alert_reporting ($id_group, $period = 0, $date = 0, $return = false) {
|
||||
$output = '';
|
||||
$alerts = get_alerts_in_group ($id_group);
|
||||
$alerts_fired = get_alerts_fired ($alerts, $period, $date);
|
||||
|
||||
$fired_percentage = round (sizeof ($alerts_fired) / sizeof ($alerts) * 100, 2);
|
||||
$fired_percentage = 0;
|
||||
if (sizeof ($alerts) > 0)
|
||||
$fired_percentage = round (sizeof ($alerts_fired) / sizeof ($alerts) * 100, 2);
|
||||
$not_fired_percentage = 100 - $fired_percentage;
|
||||
$output .= '<img src="reporting/fgraph.php?tipo=alerts_fired_pipe&height=150&width=280&fired='.
|
||||
$fired_percentage.'¬_fired='.$not_fired_percentage.'" style="float: right; border: 1px solid black">';
|
||||
|
@ -325,7 +336,7 @@ function alert_reporting ($id_group, $period = 0, $date = 0, $return = false) {
|
|||
echo $output;
|
||||
return $output;
|
||||
}
|
||||
$table = get_fired_alerts_reporting_table ($alerts_fired, true);
|
||||
$table = get_fired_alerts_reporting_table ($alerts_fired);
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox';
|
||||
$table->size = array ();
|
||||
|
@ -334,6 +345,7 @@ function alert_reporting ($id_group, $period = 0, $date = 0, $return = false) {
|
|||
$table->style[0] = 'font-weight: bold';
|
||||
|
||||
$output .= print_table ($table, true);
|
||||
|
||||
if (!$return)
|
||||
echo $output;
|
||||
return $output;
|
||||
|
@ -347,7 +359,7 @@ function alert_reporting ($id_group, $period = 0, $date = 0, $return = false) {
|
|||
*
|
||||
* @param $id_group Group to get info of the monitors.
|
||||
* @param $period Period of time of the desired monitor report.
|
||||
* @param $date Beggining date of the report (current date by default).
|
||||
* @param $date Beginning date of the report in UNIX time (current date by default).
|
||||
* @param $return Flag to return or echo the report (by default).
|
||||
*/
|
||||
function monitor_health_reporting ($id_group, $period = 0, $date = 0, $return = false) {
|
||||
|
@ -368,7 +380,7 @@ function monitor_health_reporting ($id_group, $period = 0, $date = 0, $return =
|
|||
$output .= '<strong>'.lang_string ('total_monitors').': '.sizeof ($monitors).'</strong><br />';
|
||||
$output .= '<strong>'.lang_string ('monitors_down_on_period').': '.sizeof ($monitors_down).'</strong><br />';
|
||||
|
||||
$table = get_monitors_down_reporting_table ($monitors_down, true);
|
||||
$table = get_monitors_down_reporting_table ($monitors_down);
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox';
|
||||
$table->size = array ();
|
||||
|
@ -386,17 +398,15 @@ function monitor_health_reporting ($id_group, $period = 0, $date = 0, $return =
|
|||
return $output;
|
||||
}
|
||||
|
||||
function get_monitors_down ($monitors, $period = 0, $date = 0) {
|
||||
$monitors_down = array ();
|
||||
foreach ($monitors as $monitor) {
|
||||
$down = get_monitor_downs_in_period ($monitor['id_agente_modulo'], $period, $date);
|
||||
if ($down)
|
||||
array_push ($monitors_down, $monitor);
|
||||
}
|
||||
return $monitors_down;
|
||||
}
|
||||
|
||||
function get_monitors_down_reporting_table ($monitors_down, $return = false) {
|
||||
/**
|
||||
* Get a report table with all the monitors down.
|
||||
*
|
||||
* @param monitors_down An array with all the monitors down. See
|
||||
* get_monitors_down()
|
||||
*
|
||||
* @return A table object with a monitors down report.
|
||||
*/
|
||||
function get_monitors_down_reporting_table ($monitors_down) {
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->head[0] = lang_string ('agent');
|
||||
|
@ -429,8 +439,6 @@ function get_monitors_down_reporting_table ($monitors_down, $return = false) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$return)
|
||||
print_table ($table);
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
@ -452,27 +460,16 @@ function general_group_reporting ($id_group, $return = false) {
|
|||
return $output;
|
||||
}
|
||||
|
||||
function get_monitors_in_group ($id_group) {
|
||||
$sql = sprintf ('SELECT tagente_modulo.*
|
||||
FROM tagente_modulo, ttipo_modulo, tagente
|
||||
WHERE id_tipo_modulo = id_tipo
|
||||
AND tagente.id_agente = tagente_modulo.id_agente
|
||||
AND ttipo_modulo.nombre like "%%_proc"
|
||||
AND tagente.id_grupo = %d', $id_group);
|
||||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
||||
function get_monitors_in_agent ($id_agent) {
|
||||
$sql = sprintf ('SELECT tagente_modulo.*
|
||||
FROM tagente_modulo, ttipo_modulo, tagente
|
||||
WHERE id_tipo_modulo = id_tipo
|
||||
AND tagente.id_agente = tagente_modulo.id_agente
|
||||
AND ttipo_modulo.nombre like "%%_proc"
|
||||
AND tagente.id_agente = %d', $id_agent);
|
||||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
||||
function get_agent_alerts_reporting_table ($id_agent, $period = 0, $date = 0, $return = false) {
|
||||
/**
|
||||
* Get a report table of the fired alerts group by agents.
|
||||
*
|
||||
* @param id_agent Agent id to generate the report.
|
||||
* @param period Period of time of the report.
|
||||
* @param date Beginning date of the report in UNIX time (current date by default).
|
||||
*
|
||||
* @return A table object with the alert reporting..
|
||||
*/
|
||||
function get_agent_alerts_reporting_table ($id_agent, $period = 0, $date = 0) {
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->head[0] = lang_string ('type');
|
||||
|
@ -501,12 +498,19 @@ function get_agent_alerts_reporting_table ($id_agent, $period = 0, $date = 0, $r
|
|||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
if (!$return)
|
||||
print_table ($table);
|
||||
return $table;
|
||||
}
|
||||
|
||||
function get_agent_monitors_reporting_table ($id_agent, $period = 0, $date = 0, $return = false) {
|
||||
/**
|
||||
* Get a report of monitors in an agent.
|
||||
*
|
||||
* @param id_agent Agent id to get the report
|
||||
* @param period Period of time of the report.
|
||||
* @param date Beginning date of the report in UNIX time (current date by default).
|
||||
*
|
||||
* @return A table object with the report.
|
||||
*/
|
||||
function get_agent_monitors_reporting_table ($id_agent, $period = 0, $date = 0) {
|
||||
$n_a_string = lang_string ('N/A').'(*)';
|
||||
$table->head = array ();
|
||||
$table->head[0] = lang_string ('monitor');
|
||||
|
@ -527,12 +531,20 @@ function get_agent_monitors_reporting_table ($id_agent, $period = 0, $date = 0,
|
|||
$data[1] = get_monitor_last_down_timestamp_in_period ($monitor['id_agente_modulo'], $period, $date);
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
if (!$return)
|
||||
print_table ($table);
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
function get_agent_modules_reporting_table ($id_agent, $period = 0, $date = 0, $return = false) {
|
||||
/**
|
||||
* Get a report of all the modules in an agent.
|
||||
*
|
||||
* @param id_agent Agent id to get the report.
|
||||
* @param period Period of time of the report
|
||||
* @param date Beginning date of the report in UNIX time (current date by default).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
function get_agent_modules_reporting_table ($id_agent, $period = 0, $date = 0) {
|
||||
$table->data = array ();
|
||||
$n_a_string = lang_string ('N/A').'(*)';
|
||||
$modules = get_modules_in_agent ($id_agent);
|
||||
|
@ -545,8 +557,7 @@ function get_agent_modules_reporting_table ($id_agent, $period = 0, $date = 0, $
|
|||
$data[0] = $module['nombre'];
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
if (!$return)
|
||||
print_table ($table);
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
@ -555,7 +566,7 @@ function get_agent_modules_reporting_table ($id_agent, $period = 0, $date = 0, $
|
|||
*
|
||||
* @param $id_agent Agent to get the report.
|
||||
* @param $period Period of time of the desired report.
|
||||
* @param $date Beggining date of the report (current date by default).
|
||||
* @param $date Beginning date of the report in UNIX time (current date by default).
|
||||
* @param $return Flag to return or echo the report (by default).
|
||||
*/
|
||||
function get_agent_detailed_reporting ($id_agent, $period = 0, $date = 0, $return = false) {
|
||||
|
@ -566,12 +577,12 @@ function get_agent_detailed_reporting ($id_agent, $period = 0, $date = 0, $retur
|
|||
$output .= '<div class="agent_reporting">';
|
||||
$output .= '<h3 style="text-decoration: underline">'.lang_string ('agent').' - '.dame_nombre_agente ($id_agent).'</h3>';
|
||||
$output .= '<h4>'.lang_string ('modules').'</h3>';
|
||||
$table_modules = get_agent_modules_reporting_table ($id_agent, $period, $date, true);
|
||||
$table_modules = get_agent_modules_reporting_table ($id_agent, $period, $date);
|
||||
$table_modules->width = '99%';
|
||||
$output .= print_table ($table_modules, true);
|
||||
|
||||
/* Show alerts in agent */
|
||||
$table_alerts = get_agent_alerts_reporting_table ($id_agent, $period, $date, true);
|
||||
$table_alerts = get_agent_alerts_reporting_table ($id_agent, $period, $date);
|
||||
$table_alerts->width = '99%';
|
||||
if (sizeof ($table_alerts->data)) {
|
||||
$output .= '<h4>'.lang_string ('alerts').'</h4>';
|
||||
|
@ -579,7 +590,7 @@ function get_agent_detailed_reporting ($id_agent, $period = 0, $date = 0, $retur
|
|||
}
|
||||
|
||||
/* Show monitor status in agent (if any) */
|
||||
$table_monitors = get_agent_monitors_reporting_table ($id_agent, $period, $date, true);
|
||||
$table_monitors = get_agent_monitors_reporting_table ($id_agent, $period, $date);
|
||||
if (sizeof ($table_monitors->data) == 0) {
|
||||
$output .= '</div>';
|
||||
if (! $return)
|
||||
|
|
|
@ -234,7 +234,7 @@ function get_pdf_report ($report) {
|
|||
$pdf->ezText ('<b>'.lang_string ('total_alerts_monitored').': '.sizeof ($alerts).'</b>', 8);
|
||||
$pdf->ezText ("\n", 8);
|
||||
|
||||
$table_alerts = get_fired_alerts_reporting_table ($alerts_fired, true);
|
||||
$table_alerts = get_fired_alerts_reporting_table ($alerts_fired);
|
||||
$pdf->ezTable ($table_alerts->data, $table_alerts->head,
|
||||
"", $table_options);
|
||||
unset ($alerts);
|
||||
|
@ -310,7 +310,7 @@ function get_pdf_report ($report) {
|
|||
$pdf->ezText ('<b>'.lang_string ('monitors_down_on_period').': '.sizeof ($monitors_down).'</b>', 8);
|
||||
$pdf->ezText ("\n", 8);
|
||||
|
||||
$table_monitors = get_monitors_down_reporting_table ($monitors_down, true);
|
||||
$table_monitors = get_monitors_down_reporting_table ($monitors_down);
|
||||
$pdf->ezTable ($table_monitors->data, $table_monitors->head,
|
||||
"", $table_options);
|
||||
unset ($monitors);
|
||||
|
@ -323,19 +323,19 @@ function get_pdf_report ($report) {
|
|||
$group_name.' '.lang_string ('group'));
|
||||
foreach ($agents as $agent) {
|
||||
$pdf->ezText ("<b>".$agent['nombre']."</b>", 18);
|
||||
$table = get_agent_modules_reporting_table ($agent['id_agente'], $content['period'], 0, true);
|
||||
$table = get_agent_modules_reporting_table ($agent['id_agente'], $content['period']);
|
||||
$pdf->ezText ("<b>".lang_string ('modules')."</b>", 12);
|
||||
$pdf->ezText ("\n", 3);
|
||||
$pdf->ezTable ($table->data, array (lang_string ('name')), "", $table_options);
|
||||
|
||||
$table = get_agent_alerts_reporting_table ($agent['id_agente'], $content['period'], 0, true);
|
||||
$table = get_agent_alerts_reporting_table ($agent['id_agente'], $content['period']);
|
||||
if (sizeof ($table->data)) {
|
||||
$pdf->ezText ("<b>".lang_string ('alerts')."</b>", 12);
|
||||
$pdf->ezText ("\n", 3);
|
||||
$pdf->ezTable ($table->data, $table->head, "", $table_options);
|
||||
}
|
||||
|
||||
$table = get_agent_monitors_reporting_table ($agent['id_agente'], $content['period'], 0, true);
|
||||
$table = get_agent_monitors_reporting_table ($agent['id_agente'], $content['period']);
|
||||
if (sizeof ($table->data)) {
|
||||
$pdf->ezText ("<b>".lang_string ('monitors')."</b>", 12);
|
||||
$pdf->ezText ("\n", 3);
|
||||
|
|
|
@ -202,12 +202,14 @@ foreach ($contents as $content) {
|
|||
$data = array ();
|
||||
|
||||
$table->colspan[$n][0] = 2;
|
||||
$data[0] = '<span style="font-size: 0.6em">';
|
||||
$data[0] .= lang_string ('agent')." : ".dame_nombre_agente_agentemodulo ($sla['id_agent_module'])."<br />";
|
||||
$data[0] .= lang_string ('module')." : ".dame_nombre_modulo_agentemodulo ($sla['id_agent_module'])."<br />";
|
||||
$data[0] .= lang_string ('sla_max')." : ".$sla['sla_max']."<br />";
|
||||
$data[0] .= lang_string ('sla_min')." : ".$sla['sla_min']."<br />";
|
||||
$data[0] .= "</span>";
|
||||
$data[0] = '<strong>'.lang_string ('agent')."</strong> : ";
|
||||
$data[0] .= dame_nombre_agente_agentemodulo ($sla['id_agent_module'])."<br />";
|
||||
$data[0] .= '<strong>'.lang_string ('module')."</strong> : ";
|
||||
$data[0] .= dame_nombre_modulo_agentemodulo ($sla['id_agent_module'])."<br />";
|
||||
$data[0] .= '<strong>'.lang_string ('sla_max')."</strong> : ";
|
||||
$data[0] .= $sla['sla_max']."<br />";
|
||||
$data[0] .= '<strong>'.lang_string ('sla_min')."</strong> : ";
|
||||
$data[0] .= $sla['sla_min']."<br />";
|
||||
|
||||
$sla_value = get_agent_module_sla ($sla['id_agent_module'], $content['period'],
|
||||
$sla['sla_min'], $sla['sla_max'], $datetime);
|
||||
|
|
Loading…
Reference in New Issue