Moved some the functions to 'functions_reporting.php'
This commit is contained in:
parent
2b665f8117
commit
f0d30f1057
|
@ -2918,4 +2918,240 @@ function reporting_get_agentmodule_ttr ($id_agent_module, $period = 0, $date = 0
|
||||||
|
|
||||||
return $critical_period;
|
return $critical_period;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a detailed report of the modules of the agent
|
||||||
|
*
|
||||||
|
* @param int $id_agent Agent id to get the report for.
|
||||||
|
* @param string $filter filter for get partial modules.
|
||||||
|
*
|
||||||
|
* @return array An array
|
||||||
|
*/
|
||||||
|
function reporting_get_agent_module_info ($id_agent, $filter = false) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$return = array ();
|
||||||
|
$return["last_contact"] = 0; //Last agent contact
|
||||||
|
$return["status"] = STATUS_AGENT_NO_DATA;
|
||||||
|
$return["status_img"] = ui_print_status_image (STATUS_AGENT_NO_DATA, __('Agent without data'), true);
|
||||||
|
$return["alert_status"] = "notfired";
|
||||||
|
$return["alert_value"] = STATUS_ALERT_NOT_FIRED;
|
||||||
|
$return["alert_img"] = ui_print_status_image (STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true);
|
||||||
|
$return["agent_group"] = agents_get_agent_group ($id_agent);
|
||||||
|
|
||||||
|
if (!check_acl ($config["id_user"], $return["agent_group"], "AR")) {
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filter != '') {
|
||||||
|
$filter = 'AND ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter = 'disabled = 0';
|
||||||
|
|
||||||
|
$modules = agents_get_modules($id_agent, false, $filter, true, false);
|
||||||
|
|
||||||
|
if ($modules === false) {
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$now = get_system_time ();
|
||||||
|
|
||||||
|
// Get modules status for this agent
|
||||||
|
|
||||||
|
$agent = db_get_row ("tagente", "id_agente", $id_agent);
|
||||||
|
|
||||||
|
$return["total_count"] = $agent["total_count"];
|
||||||
|
$return["normal_count"] = $agent["normal_count"];
|
||||||
|
$return["warning_count"] = $agent["warning_count"];
|
||||||
|
$return["critical_count"] = $agent["critical_count"];
|
||||||
|
$return["unknown_count"] = $agent["unknown_count"];
|
||||||
|
$return["fired_count"] = $agent["fired_count"];
|
||||||
|
$return["notinit_count"] = $agent["notinit_count"];
|
||||||
|
|
||||||
|
if ($return["total_count"] > 0) {
|
||||||
|
if ($return["critical_count"] > 0) {
|
||||||
|
$return["status"] = STATUS_AGENT_CRITICAL;
|
||||||
|
$return["status_img"] = ui_print_status_image (STATUS_AGENT_CRITICAL, __('At least one module in CRITICAL status'), true);
|
||||||
|
}
|
||||||
|
else if ($return["warning_count"] > 0) {
|
||||||
|
$return["status"] = STATUS_AGENT_WARNING;
|
||||||
|
$return["status_img"] = ui_print_status_image (STATUS_AGENT_WARNING, __('At least one module in WARNING status'), true);
|
||||||
|
}
|
||||||
|
else if ($return["unknown_count"] > 0) {
|
||||||
|
$return["status"] = STATUS_AGENT_DOWN;
|
||||||
|
$return["status_img"] = ui_print_status_image (STATUS_AGENT_DOWN, __('At least one module is in UKNOWN status'), true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$return["status"] = STATUS_AGENT_OK;
|
||||||
|
$return["status_img"] = ui_print_status_image (STATUS_AGENT_OK, __('All Monitors OK'), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Alert not fired is by default
|
||||||
|
if ($return["fired_count"] > 0) {
|
||||||
|
$return["alert_status"] = "fired";
|
||||||
|
$return["alert_img"] = ui_print_status_image (STATUS_ALERT_FIRED, __('Alert fired'), true);
|
||||||
|
$return["alert_value"] = STATUS_ALERT_FIRED;
|
||||||
|
}
|
||||||
|
elseif (groups_give_disabled_group ($return["agent_group"])) {
|
||||||
|
$return["alert_status"] = "disabled";
|
||||||
|
$return["alert_value"] = STATUS_ALERT_DISABLED;
|
||||||
|
$return["alert_img"] = ui_print_status_image (STATUS_ALERT_DISABLED, __('Alert disabled'), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print tiny statistics of the status of one agent, group, etc.
|
||||||
|
*
|
||||||
|
* @param mixed Array with the counts of the total modules, normal modules, critical modules, warning modules, unknown modules and fired alerts
|
||||||
|
* @param bool return or echo flag
|
||||||
|
*
|
||||||
|
* @return string html formatted tiny stats of modules/alerts of an agent
|
||||||
|
*/
|
||||||
|
function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent', $separator = ':', $strict_user = false) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$out = '';
|
||||||
|
|
||||||
|
// Depend the type of object, the stats will refer agents, modules...
|
||||||
|
switch ($type) {
|
||||||
|
case 'modules':
|
||||||
|
$template_title['total_count'] = __('%d Total modules');
|
||||||
|
$template_title['normal_count'] = __('%d Normal modules');
|
||||||
|
$template_title['critical_count'] = __('%d Critical modules');
|
||||||
|
$template_title['warning_count'] = __('%d Warning modules');
|
||||||
|
$template_title['unknown_count'] = __('%d Unknown modules');
|
||||||
|
break;
|
||||||
|
case 'agent':
|
||||||
|
$template_title['total_count'] = __('%d Total modules');
|
||||||
|
$template_title['normal_count'] = __('%d Normal modules');
|
||||||
|
$template_title['critical_count'] = __('%d Critical modules');
|
||||||
|
$template_title['warning_count'] = __('%d Warning modules');
|
||||||
|
$template_title['unknown_count'] = __('%d Unknown modules');
|
||||||
|
$template_title['fired_count'] = __('%d Fired alerts');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$template_title['total_count'] = __('%d Total agents');
|
||||||
|
$template_title['normal_count'] = __('%d Normal agents');
|
||||||
|
$template_title['critical_count'] = __('%d Critical agents');
|
||||||
|
$template_title['warning_count'] = __('%d Warning agents');
|
||||||
|
$template_title['unknown_count'] = __('%d Unknown agents');
|
||||||
|
$template_title['not_init_count'] = __('%d not init agents');
|
||||||
|
$template_title['fired_count'] = __('%d Fired alerts');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($strict_user && $type == 'agent') {
|
||||||
|
|
||||||
|
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
|
||||||
|
$filter['disabled'] = 0;
|
||||||
|
$id_agent = $counts_info['id_agente'];
|
||||||
|
|
||||||
|
$counts_info = array();
|
||||||
|
$counts_info['normal_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NORMAL));
|
||||||
|
$counts_info['warning_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_WARNING));
|
||||||
|
$counts_info['critical_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_CRITICAL_BAD));
|
||||||
|
$counts_info['notinit_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NOT_INIT));
|
||||||
|
$counts_info['unknown_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_UNKNOWN));
|
||||||
|
$counts_info['total_count'] = $counts_info['normal_count'] + $counts_info['warning_count'] + $counts_info['critical_count'] + $counts_info['unknown_count'] + $counts_info['notinit_count'];
|
||||||
|
|
||||||
|
$all_agent_modules = tags_get_agent_modules ($id_agent, false, $acltags, false, $filter);
|
||||||
|
if (!empty($all_agent_modules)) {
|
||||||
|
$mod_clause = "(".implode(',', array_keys($all_agent_modules)).")";
|
||||||
|
|
||||||
|
$counts_info['fired_count'] = (int) db_get_sql ("SELECT COUNT(times_fired)
|
||||||
|
FROM talert_template_modules
|
||||||
|
WHERE times_fired != 0 AND id_agent_module IN ".$mod_clause);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$counts_info['fired_count'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the counts in a data structure to print hidden divs with titles
|
||||||
|
$stats = array();
|
||||||
|
|
||||||
|
if (isset($counts_info['total_count'])) {
|
||||||
|
$not_init = isset($counts_info['notinit_count']) ? $counts_info['notinit_count'] : 0;
|
||||||
|
$total_count = $counts_info['total_count'] - $not_init;
|
||||||
|
$stats[] = array('name' => 'total_count', 'count' => $total_count, 'title' => sprintf($template_title['total_count'], $total_count));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($counts_info['normal_count'])) {
|
||||||
|
$normal_count = $counts_info['normal_count'];
|
||||||
|
$stats[] = array('name' => 'normal_count', 'count' => $normal_count, 'title' => sprintf($template_title['normal_count'], $normal_count));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($counts_info['critical_count'])) {
|
||||||
|
$critical_count = $counts_info['critical_count'];
|
||||||
|
$stats[] = array('name' => 'critical_count', 'count' => $critical_count, 'title' => sprintf($template_title['critical_count'], $critical_count));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($counts_info['warning_count'])) {
|
||||||
|
$warning_count = $counts_info['warning_count'];
|
||||||
|
$stats[] = array('name' => 'warning_count', 'count' => $warning_count, 'title' => sprintf($template_title['warning_count'], $warning_count));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($counts_info['unknown_count'])) {
|
||||||
|
$unknown_count = $counts_info['unknown_count'];
|
||||||
|
$stats[] = array('name' => 'unknown_count', 'count' => $unknown_count, 'title' => sprintf($template_title['unknown_count'], $unknown_count));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($counts_info['not_init_count'])) {
|
||||||
|
$not_init_count = $counts_info['not_init_count'];
|
||||||
|
$stats[] = array('name' => 'not_init_count',
|
||||||
|
'count' => $not_init_count,
|
||||||
|
'title' => sprintf($template_title['not_init_count'], $not_init_count));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($template_title['fired_count'])) {
|
||||||
|
if (isset($counts_info['fired_count'])) {
|
||||||
|
$fired_count = $counts_info['fired_count'];
|
||||||
|
$stats[] = array('name' => 'fired_count', 'count' => $fired_count, 'title' => sprintf($template_title['fired_count'], $fired_count));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$uniq_id = uniqid();
|
||||||
|
|
||||||
|
foreach ($stats as $stat) {
|
||||||
|
$params = array('id' => 'forced_title_' . $stat['name'] . '_' . $uniq_id,
|
||||||
|
'class' => 'forced_title_layer',
|
||||||
|
'content' => $stat['title'],
|
||||||
|
'hidden' => true);
|
||||||
|
$out .= html_print_div($params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If total count is less than 0, is an error. Never show negative numbers
|
||||||
|
if ($total_count < 0) {
|
||||||
|
$total_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$out .= '<b>' . '<span id="total_count_' . $uniq_id . '" class="forced_title" style="font-size: 7pt">' . $total_count . '</span>';
|
||||||
|
if (isset($fired_count) && $fired_count > 0)
|
||||||
|
$out .= ' ' . $separator . ' <span class="orange forced_title" id="fired_count_' . $uniq_id . '" style="font-size: 7pt">' . $fired_count . '</span>';
|
||||||
|
if (isset($critical_count) && $critical_count > 0)
|
||||||
|
$out .= ' ' . $separator . ' <span class="red forced_title" id="critical_count_' . $uniq_id . '" style="font-size: 7pt">' . $critical_count . '</span>';
|
||||||
|
if (isset($warning_count) && $warning_count > 0)
|
||||||
|
$out .= ' ' . $separator . ' <span class="yellow forced_title" id="warning_count_' . $uniq_id . '" style="font-size: 7pt">' . $warning_count . '</span>';
|
||||||
|
if (isset($unknown_count) && $unknown_count > 0)
|
||||||
|
$out .= ' ' . $separator . ' <span class="grey forced_title" id="unknown_count_' . $uniq_id . '" style="font-size: 7pt">' . $unknown_count . '</span>';
|
||||||
|
if (isset($not_init_count) && $not_init_count > 0)
|
||||||
|
$out .= ' ' . $separator . ' <span class="blue forced_title" id="not_init_count_' . $uniq_id . '" style="font-size: 7pt">' . $not_init_count . '</span>';
|
||||||
|
if (isset($normal_count) && $normal_count > 0)
|
||||||
|
$out .= ' ' . $separator . ' <span class="green forced_title" id="normal_count_' . $uniq_id . '" style="font-size: 7pt">' . $normal_count . '</span>';
|
||||||
|
|
||||||
|
$out .= '</b>';
|
||||||
|
|
||||||
|
if ($return) {
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo $out;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
|
@ -3191,89 +3191,6 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, $date =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a detailed report of the modules of the agent
|
|
||||||
*
|
|
||||||
* @param int $id_agent Agent id to get the report for.
|
|
||||||
* @param string $filter filter for get partial modules.
|
|
||||||
*
|
|
||||||
* @return array An array
|
|
||||||
*/
|
|
||||||
function reporting_get_agent_module_info ($id_agent, $filter = false) {
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
$return = array ();
|
|
||||||
$return["last_contact"] = 0; //Last agent contact
|
|
||||||
$return["status"] = STATUS_AGENT_NO_DATA;
|
|
||||||
$return["status_img"] = ui_print_status_image (STATUS_AGENT_NO_DATA, __('Agent without data'), true);
|
|
||||||
$return["alert_status"] = "notfired";
|
|
||||||
$return["alert_value"] = STATUS_ALERT_NOT_FIRED;
|
|
||||||
$return["alert_img"] = ui_print_status_image (STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true);
|
|
||||||
$return["agent_group"] = agents_get_agent_group ($id_agent);
|
|
||||||
|
|
||||||
if (!check_acl ($config["id_user"], $return["agent_group"], "AR")) {
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($filter != '') {
|
|
||||||
$filter = 'AND ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$filter = 'disabled = 0';
|
|
||||||
|
|
||||||
$modules = agents_get_modules($id_agent, false, $filter, true, false);
|
|
||||||
|
|
||||||
if ($modules === false) {
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$now = get_system_time ();
|
|
||||||
|
|
||||||
// Get modules status for this agent
|
|
||||||
|
|
||||||
$agent = db_get_row ("tagente", "id_agente", $id_agent);
|
|
||||||
|
|
||||||
$return["total_count"] = $agent["total_count"];
|
|
||||||
$return["normal_count"] = $agent["normal_count"];
|
|
||||||
$return["warning_count"] = $agent["warning_count"];
|
|
||||||
$return["critical_count"] = $agent["critical_count"];
|
|
||||||
$return["unknown_count"] = $agent["unknown_count"];
|
|
||||||
$return["fired_count"] = $agent["fired_count"];
|
|
||||||
$return["notinit_count"] = $agent["notinit_count"];
|
|
||||||
|
|
||||||
if ($return["total_count"] > 0) {
|
|
||||||
if ($return["critical_count"] > 0) {
|
|
||||||
$return["status"] = STATUS_AGENT_CRITICAL;
|
|
||||||
$return["status_img"] = ui_print_status_image (STATUS_AGENT_CRITICAL, __('At least one module in CRITICAL status'), true);
|
|
||||||
}
|
|
||||||
else if ($return["warning_count"] > 0) {
|
|
||||||
$return["status"] = STATUS_AGENT_WARNING;
|
|
||||||
$return["status_img"] = ui_print_status_image (STATUS_AGENT_WARNING, __('At least one module in WARNING status'), true);
|
|
||||||
}
|
|
||||||
else if ($return["unknown_count"] > 0) {
|
|
||||||
$return["status"] = STATUS_AGENT_DOWN;
|
|
||||||
$return["status_img"] = ui_print_status_image (STATUS_AGENT_DOWN, __('At least one module is in UKNOWN status'), true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$return["status"] = STATUS_AGENT_OK;
|
|
||||||
$return["status_img"] = ui_print_status_image (STATUS_AGENT_OK, __('All Monitors OK'), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Alert not fired is by default
|
|
||||||
if ($return["fired_count"] > 0) {
|
|
||||||
$return["alert_status"] = "fired";
|
|
||||||
$return["alert_img"] = ui_print_status_image (STATUS_ALERT_FIRED, __('Alert fired'), true);
|
|
||||||
$return["alert_value"] = STATUS_ALERT_FIRED;
|
|
||||||
}
|
|
||||||
elseif (groups_give_disabled_group ($return["agent_group"])) {
|
|
||||||
$return["alert_status"] = "disabled";
|
|
||||||
$return["alert_value"] = STATUS_ALERT_DISABLED;
|
|
||||||
$return["alert_img"] = ui_print_status_image (STATUS_ALERT_DISABLED, __('Alert disabled'), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the callback sorting function for SLA values descending
|
* This is the callback sorting function for SLA values descending
|
||||||
|
@ -5870,155 +5787,6 @@ function reporting_get_count_events_validated ($filter, $period = 0,
|
||||||
$filter_event_warning, $filter_event_no_validated);
|
$filter_event_warning, $filter_event_no_validated);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Print tiny statistics of the status of one agent, group, etc.
|
|
||||||
*
|
|
||||||
* @param mixed Array with the counts of the total modules, normal modules, critical modules, warning modules, unknown modules and fired alerts
|
|
||||||
* @param bool return or echo flag
|
|
||||||
*
|
|
||||||
* @return string html formatted tiny stats of modules/alerts of an agent
|
|
||||||
*/
|
|
||||||
function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent', $separator = ':', $strict_user = false) {
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
$out = '';
|
|
||||||
|
|
||||||
// Depend the type of object, the stats will refer agents, modules...
|
|
||||||
switch ($type) {
|
|
||||||
case 'modules':
|
|
||||||
$template_title['total_count'] = __('%d Total modules');
|
|
||||||
$template_title['normal_count'] = __('%d Normal modules');
|
|
||||||
$template_title['critical_count'] = __('%d Critical modules');
|
|
||||||
$template_title['warning_count'] = __('%d Warning modules');
|
|
||||||
$template_title['unknown_count'] = __('%d Unknown modules');
|
|
||||||
break;
|
|
||||||
case 'agent':
|
|
||||||
$template_title['total_count'] = __('%d Total modules');
|
|
||||||
$template_title['normal_count'] = __('%d Normal modules');
|
|
||||||
$template_title['critical_count'] = __('%d Critical modules');
|
|
||||||
$template_title['warning_count'] = __('%d Warning modules');
|
|
||||||
$template_title['unknown_count'] = __('%d Unknown modules');
|
|
||||||
$template_title['fired_count'] = __('%d Fired alerts');
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$template_title['total_count'] = __('%d Total agents');
|
|
||||||
$template_title['normal_count'] = __('%d Normal agents');
|
|
||||||
$template_title['critical_count'] = __('%d Critical agents');
|
|
||||||
$template_title['warning_count'] = __('%d Warning agents');
|
|
||||||
$template_title['unknown_count'] = __('%d Unknown agents');
|
|
||||||
$template_title['not_init_count'] = __('%d not init agents');
|
|
||||||
$template_title['fired_count'] = __('%d Fired alerts');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($strict_user && $type == 'agent') {
|
|
||||||
|
|
||||||
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
|
|
||||||
$filter['disabled'] = 0;
|
|
||||||
$id_agent = $counts_info['id_agente'];
|
|
||||||
|
|
||||||
$counts_info = array();
|
|
||||||
$counts_info['normal_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NORMAL));
|
|
||||||
$counts_info['warning_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_WARNING));
|
|
||||||
$counts_info['critical_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_CRITICAL_BAD));
|
|
||||||
$counts_info['notinit_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NOT_INIT));
|
|
||||||
$counts_info['unknown_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_UNKNOWN));
|
|
||||||
$counts_info['total_count'] = $counts_info['normal_count'] + $counts_info['warning_count'] + $counts_info['critical_count'] + $counts_info['unknown_count'] + $counts_info['notinit_count'];
|
|
||||||
|
|
||||||
$all_agent_modules = tags_get_agent_modules ($id_agent, false, $acltags, false, $filter);
|
|
||||||
if (!empty($all_agent_modules)) {
|
|
||||||
$mod_clause = "(".implode(',', array_keys($all_agent_modules)).")";
|
|
||||||
|
|
||||||
$counts_info['fired_count'] = (int) db_get_sql ("SELECT COUNT(times_fired)
|
|
||||||
FROM talert_template_modules
|
|
||||||
WHERE times_fired != 0 AND id_agent_module IN ".$mod_clause);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$counts_info['fired_count'] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store the counts in a data structure to print hidden divs with titles
|
|
||||||
$stats = array();
|
|
||||||
|
|
||||||
if (isset($counts_info['total_count'])) {
|
|
||||||
$not_init = isset($counts_info['notinit_count']) ? $counts_info['notinit_count'] : 0;
|
|
||||||
$total_count = $counts_info['total_count'] - $not_init;
|
|
||||||
$stats[] = array('name' => 'total_count', 'count' => $total_count, 'title' => sprintf($template_title['total_count'], $total_count));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($counts_info['normal_count'])) {
|
|
||||||
$normal_count = $counts_info['normal_count'];
|
|
||||||
$stats[] = array('name' => 'normal_count', 'count' => $normal_count, 'title' => sprintf($template_title['normal_count'], $normal_count));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($counts_info['critical_count'])) {
|
|
||||||
$critical_count = $counts_info['critical_count'];
|
|
||||||
$stats[] = array('name' => 'critical_count', 'count' => $critical_count, 'title' => sprintf($template_title['critical_count'], $critical_count));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($counts_info['warning_count'])) {
|
|
||||||
$warning_count = $counts_info['warning_count'];
|
|
||||||
$stats[] = array('name' => 'warning_count', 'count' => $warning_count, 'title' => sprintf($template_title['warning_count'], $warning_count));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($counts_info['unknown_count'])) {
|
|
||||||
$unknown_count = $counts_info['unknown_count'];
|
|
||||||
$stats[] = array('name' => 'unknown_count', 'count' => $unknown_count, 'title' => sprintf($template_title['unknown_count'], $unknown_count));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($counts_info['not_init_count'])) {
|
|
||||||
$not_init_count = $counts_info['not_init_count'];
|
|
||||||
$stats[] = array('name' => 'not_init_count',
|
|
||||||
'count' => $not_init_count,
|
|
||||||
'title' => sprintf($template_title['not_init_count'], $not_init_count));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($template_title['fired_count'])) {
|
|
||||||
if (isset($counts_info['fired_count'])) {
|
|
||||||
$fired_count = $counts_info['fired_count'];
|
|
||||||
$stats[] = array('name' => 'fired_count', 'count' => $fired_count, 'title' => sprintf($template_title['fired_count'], $fired_count));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$uniq_id = uniqid();
|
|
||||||
|
|
||||||
foreach ($stats as $stat) {
|
|
||||||
$params = array('id' => 'forced_title_' . $stat['name'] . '_' . $uniq_id,
|
|
||||||
'class' => 'forced_title_layer',
|
|
||||||
'content' => $stat['title'],
|
|
||||||
'hidden' => true);
|
|
||||||
$out .= html_print_div($params, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If total count is less than 0, is an error. Never show negative numbers
|
|
||||||
if ($total_count < 0) {
|
|
||||||
$total_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$out .= '<b>' . '<span id="total_count_' . $uniq_id . '" class="forced_title" style="font-size: 7pt">' . $total_count . '</span>';
|
|
||||||
if (isset($fired_count) && $fired_count > 0)
|
|
||||||
$out .= ' ' . $separator . ' <span class="orange forced_title" id="fired_count_' . $uniq_id . '" style="font-size: 7pt">' . $fired_count . '</span>';
|
|
||||||
if (isset($critical_count) && $critical_count > 0)
|
|
||||||
$out .= ' ' . $separator . ' <span class="red forced_title" id="critical_count_' . $uniq_id . '" style="font-size: 7pt">' . $critical_count . '</span>';
|
|
||||||
if (isset($warning_count) && $warning_count > 0)
|
|
||||||
$out .= ' ' . $separator . ' <span class="yellow forced_title" id="warning_count_' . $uniq_id . '" style="font-size: 7pt">' . $warning_count . '</span>';
|
|
||||||
if (isset($unknown_count) && $unknown_count > 0)
|
|
||||||
$out .= ' ' . $separator . ' <span class="grey forced_title" id="unknown_count_' . $uniq_id . '" style="font-size: 7pt">' . $unknown_count . '</span>';
|
|
||||||
if (isset($not_init_count) && $not_init_count > 0)
|
|
||||||
$out .= ' ' . $separator . ' <span class="blue forced_title" id="not_init_count_' . $uniq_id . '" style="font-size: 7pt">' . $not_init_count . '</span>';
|
|
||||||
if (isset($normal_count) && $normal_count > 0)
|
|
||||||
$out .= ' ' . $separator . ' <span class="green forced_title" id="normal_count_' . $uniq_id . '" style="font-size: 7pt">' . $normal_count . '</span>';
|
|
||||||
|
|
||||||
$out .= '</b>';
|
|
||||||
|
|
||||||
if ($return) {
|
|
||||||
return $out;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
echo $out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function reporting_network_interfaces_table ($content, $report, $mini, $item_title = "", &$table = null, &$pdf = null) {
|
function reporting_network_interfaces_table ($content, $report, $mini, $item_title = "", &$table = null, &$pdf = null) {
|
||||||
|
|
Loading…
Reference in New Issue