Revert "Fixed version mobile in metaconsole version"

This reverts commit a5e14a26bb.
This commit is contained in:
m-lopez-f 2016-09-28 16:06:51 +02:00
parent a5e14a26bb
commit 657cd44a30
11 changed files with 296 additions and 418 deletions

View File

@ -93,7 +93,7 @@ function events_get_events ($filter = false, $fields = false) {
*
* @return mixed False in case of error or invalid values passed. Event row otherwise
*/
function events_get_event ($id, $fields = false, $meta = false) {
function events_get_event ($id, $fields = false) {
if (empty ($id))
return false;
global $config;
@ -103,13 +103,7 @@ function events_get_event ($id, $fields = false, $meta = false) {
$fields[] = 'id_grupo';
}
if($meta) {
$event = events_meta_get_event($id, array ('evento', 'id_agentmodule'), $history);
}
else {
$event = events_get_event ($id, array ('evento', 'id_agentmodule'));
}
$event = db_get_row ('tevento', 'id_evento', $id, $fields);
if (! check_acl ($config['id_user'], $event['id_grupo'], 'ER'))
return false;

View File

@ -159,14 +159,22 @@ function reporting_make_reporting_data($report = null, $id_report,
$content);
break;
case 'custom_graph':
case 'automatic_custom_graph':
$report['contents'][] =
reporting_custom_graph(
$report,
$content,
$type,
$force_width_chart,
$force_height_chart);
$force_height_chart, 'custom_graph');
break;
case 'automatic_graph':
$report['contents'][] =
reporting_custom_graph(
$report,
$content,
$type,
$force_width_chart,
$force_height_chart, 'automatic_graph');
break;
case 'text':
$report['contents'][] = reporting_text(
@ -2623,8 +2631,8 @@ function reporting_alert_report_group($report, $content) {
$data_row['fired'] = array();
$firedTimes = get_module_alert_fired(
$content['id_agent_module'],
$alert['id_alert_template'],
$alert['id_agent_module'],
$alert['id'],
(int) $content['period'],
(int) $report["datetime"]);
@ -2731,7 +2739,7 @@ function reporting_alert_report_agent($report, $content) {
$data_row['fired'] = array();
$firedTimes = get_module_alert_fired(
$alert['id_agent_module'],
$alert['id_alert_template'],
$alert['id'],
(int) $content['period'],
(int) $report["datetime"]);
@ -3175,6 +3183,14 @@ function reporting_prediction_date($report, $content) {
$return["date"] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$module_name = io_safe_output(
modules_get_agentmodule_name($content['id_agent_module']));
$agent_name = io_safe_output(
modules_get_agentmodule_agent_name ($content['id_agent_module']));
$return['agent_name'] = $agent_name;
$return['module_name'] = $module_name;
set_time_limit(500);
$intervals_text = $content['text'];
@ -3741,7 +3757,6 @@ function reporting_availability($report, $content) {
else {
$items = $content['subitems'];
}
@ -4255,18 +4270,23 @@ function reporting_general($report, $content) {
}
function reporting_custom_graph($report, $content, $type = 'dinamic',
$force_width_chart = null, $force_height_chart = null) {
$force_width_chart = null, $force_height_chart = null, $type_report = "custom_graph") {
global $config;
require_once ($config["homedir"] . '/include/functions_graph.php');
if ($config['metaconsole']) {
$id_meta = metaconsole_get_id_server($content["server_name"]);
$server = metaconsole_get_connection_by_id ($id_meta);
metaconsole_connect($server);
if ($type_report == 'automatic_graph') {
// Do none
}
else {
if ($config['metaconsole']) {
$id_meta = metaconsole_get_id_server($content["server_name"]);
$server = metaconsole_get_connection_by_id ($id_meta);
metaconsole_connect($server);
}
}
$graph = db_get_row ("tgraph", "id_graph", $content['id_gs']);
@ -4294,7 +4314,15 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
$labels = array();
foreach ($graphs as $graph_item) {
array_push ($modules, $graph_item['id_agent_module']);
if ($type_report == 'automatic_graph') {
array_push ($modules, array(
'module' => $graph_item['id_agent_module'],
'server' => $graph_item['id_server']));
}
else {
array_push ($modules, $graph_item['id_agent_module']);
}
array_push ($weights, $graph_item["weight"]);
if (in_array('label',$content['style'])) {
$item = array('type' => 'custom_graph',
@ -4345,8 +4373,13 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
break;
}
if ($config['metaconsole']) {
metaconsole_restore_db();
if ($type_report == 'automatic_graph') {
// Do none
}
else {
if ($config['metaconsole']) {
metaconsole_restore_db();
}
}
return reporting_check_structure_content($return);
@ -5441,17 +5474,21 @@ function reporting_get_stats_alerts($data, $links = false) {
$table_al = html_get_predefined_table();
$tdata = array();
$tdata[0] = html_print_image('images/bell.png', true, array('title' => __('Defined alerts')), false, false, false, true);
$tdata[0] = html_print_image('images/bell.png', true, array('title' => __('Defined alerts')));
$tdata[1] = $data["monitor_alerts"] <= 0 ? '-' : $data["monitor_alerts"];
$tdata[1] = '<a class="big_data" href="' . $urls["monitor_alerts"] . '">' . $tdata[1] . '</a>';
$tdata[2] = html_print_image('images/bell_error.png', true, array('title' => __('Fired alerts')));
$tdata[3] = $data["monitor_alerts_fired"] <= 0 ? '-' : $data["monitor_alerts_fired"];
$tdata[3] = '<a style="color: ' . COL_ALERTFIRED . ';" class="big_data" href="' . $urls["monitor_alerts_fired"] . '">' . $tdata[3] . '</a>';
if($data["monitor_alerts"]>$data["total_agents"] && !enterprise_installed()){
$tdata[2] = "<div id='alertagentmodal' class='publienterprise' title='Community version' style=''><img data-title='Enterprise version' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>";
}
$tdata[3] = html_print_image('images/bell_error.png', true, array('title' => __('Fired alerts')));
$tdata[4] = $data["monitor_alerts_fired"] <= 0 ? '-' : $data["monitor_alerts_fired"];
$tdata[4] = '<a style="color: ' . COL_ALERTFIRED . ';" class="big_data" href="' . $urls["monitor_alerts_fired"] . '">' . $tdata[4] . '</a>';
$table_al->rowclass[] = '';
$table_al->data[] = $tdata;
if (!is_metaconsole()) {
if (!defined('METACONSOLE')) {
$output = '<fieldset class="databox tactical_set">
<legend>' .
__('Defined and fired alerts') .
@ -5604,9 +5641,18 @@ function reporting_get_stats_agents_monitors($data) {
$tdata[1] = $data["total_agents"] <= 0 ? '-' : $data["total_agents"];
$tdata[1] = '<a class="big_data" href="' . $urls['total_agents'] . '">' . $tdata[1] . '</a>';
$tdata[2] = html_print_image('images/module.png', true, array('title' => __('Monitor checks')));
$tdata[3] = $data["monitor_checks"] <= 0 ? '-' : $data["monitor_checks"];
$tdata[3] = '<a class="big_data" href="' . $urls['monitor_checks'] . '">' . $tdata[3] . '</a>';
if($data["total_agents"]>500 && !enterprise_installed()){
$tdata[2] = "<div id='agentsmodal' class='publienterprise' title='Community version' style=''><img data-title='Enterprise version' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>";
}
$tdata[3] = html_print_image('images/module.png', true, array('title' => __('Monitor checks')));
$tdata[4] = $data["monitor_checks"] <= 0 ? '-' : $data["monitor_checks"];
$tdata[4] = '<a class="big_data" href="' . $urls['monitor_checks'] . '">' . $tdata[4] . '</a>';
if(($data["monitor_checks"]/$data["total_agents"]>100) && !enterprise_installed()){
$tdata[5] = "<div id='monitorcheckmodal' class='publienterprise' title='Community version' style=''><img data-title='Enterprise version' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>";
}
$table_am->rowclass[] = '';
$table_am->data[] = $tdata;
@ -8254,12 +8300,12 @@ function reporting_get_stats_servers($tiny = true) {
$table_srv->style[0] = $table_srv->style[2] = 'text-align: right; padding: 5px;';
$table_srv->style[1] = $table_srv->style[3] = 'text-align: left; padding: 5px;';
$tdata = array();
$tdata = array();'<span class="big_data">' . format_numeric($server_performance ["total_local_modules"]) . '</span>';
$tdata[0] = html_print_image('images/module.png', true, array('title' => __('Total running modules'), 'width' => '25px'));
$tdata[1] = '<span class="big_data">' . format_numeric($server_performance ["total_modules"]) . '</span>';
$tdata[2] = '<span class="med_data">' . format_numeric($server_performance ["total_modules_rate"], 2) . '</span>';
$tdata[3] = html_print_image('images/module.png', true, array('title' => __('Ratio') . ': ' . __('Modules by second'), 'width' => '16px')) . '/sec </span>';
$tdata[2] = '&nbsp;';
$tdata[3] = '<span class="med_data">' . format_numeric($server_performance ["total_modules_rate"], 2) . '</span>';
$tdata[4] = html_print_image('images/module.png', true, array('title' => __('Ratio') . ': ' . __('Modules by second'), 'width' => '16px')) . '/sec </span>';
$table_srv->rowclass[] = '';
$table_srv->data[] = $tdata;
@ -8274,9 +8320,13 @@ function reporting_get_stats_servers($tiny = true) {
$tdata[0] = html_print_image('images/database.png', true, array('title' => __('Local modules'), 'width' => '25px'));
$tdata[1] = '<span class="big_data">' . format_numeric($server_performance ["total_local_modules"]) . '</span>';
$tdata[2] = '<span class="med_data">' .
$tdata[2] = '&nbsp;';
$tdata[3] = '<span class="med_data">' .
format_numeric($server_performance ["local_modules_rate"], 2) . '</span>';
$tdata[3] = html_print_image('images/module.png', true, array('title' => __('Ratio') . ': ' . __('Modules by second'), 'width' => '16px')) . '/sec </span>';
$tdata[4] = html_print_image('images/module.png', true, array('title' => __('Ratio') . ': ' . __('Modules by second'), 'width' => '16px')) . '/sec </span>';
$table_srv->rowclass[] = '';
$table_srv->data[] = $tdata;
@ -8286,8 +8336,16 @@ function reporting_get_stats_servers($tiny = true) {
$tdata[0] = html_print_image('images/network.png', true, array('title' => __('Remote modules'), 'width' => '25px'));
$tdata[1] = '<span class="big_data">' . format_numeric($server_performance ["total_remote_modules"]) . '</span>';
$tdata[2] = '<span class="med_data">' . format_numeric($server_performance ["remote_modules_rate"], 2) . '</span>';
$tdata[3] = html_print_image('images/module.png', true, array('title' => __('Ratio') . ': ' . __('Modules by second'), 'width' => '16px')) . '/sec </span>';
if($server_performance ["total_remote_modules"]>10000 && !enterprise_installed()){
$tdata[2] = "<div id='agentsmodal' class='publienterprise' title='Community version' style='text-align:left;'><img data-title='Enterprise version' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>";
}
else{
$tdata[2] = '&nbsp;';
}
$tdata[3] = '<span class="med_data">' . format_numeric($server_performance ["remote_modules_rate"], 2) . '</span>';
$tdata[4] = html_print_image('images/module.png', true, array('title' => __('Ratio') . ': ' . __('Modules by second'), 'width' => '16px')) . '/sec </span>';
$table_srv->rowclass[] = '';
$table_srv->data[] = $tdata;
@ -8387,8 +8445,15 @@ function reporting_get_stats_servers($tiny = true) {
array('title' => __('Total events'), 'width' => '25px'));
$tdata[1] = '<span class="big_data">' .
format_numeric($system_events) . '</span>';
$table_srv->colspan[count($table_srv->data)][1] = 3;
if($system_events > 50000 && !enterprise_installed()){
$tdata[2] = "<div id='monitoreventsmodal' class='publienterprise' title='Community version' style='text-align:left'><img data-title='Enterprise version' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>";
}
else{
$tdata[3] = "&nbsp;";
}
$table_srv->colspan[count($table_srv->data)][1] = 2;
$table_srv->rowclass[] = '';
$table_srv->data[] = $tdata;
}

View File

@ -554,7 +554,7 @@ function ui_print_group_icon ($id_group, $return = false, $path = "groups_small"
$output .= '<span title="'. groups_get_name($id_group, true).'">&nbsp;&nbsp;</span>';
else {
$output .= html_print_image("images/" . $path . "/" . $icon . ".png",
true, array("style" => $style, "class" => "bot", "alt" => groups_get_name($id_group, true), "title" => groups_get_name ($id_group, true)), false, false, false, true);
true, array("style" => $style, "class" => "bot", "alt" => groups_get_name($id_group, true), "title" => groups_get_name ($id_group, true)));
}
}
@ -629,7 +629,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false,
if (empty ($icon)) {
if ($only_src) {
$output = html_print_image("images/" . $subfolter . "/unknown.png",
true, $options, true, $relative, false, true);
true, $options, true, $relative);
}
else {
return "-";
@ -637,13 +637,13 @@ function ui_print_os_icon ($id_os, $name = true, $return = false,
}
else if ($apply_skin) {
if ($only_src) {
$output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, true, $relative, false, true);
$output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, true, $relative);
}
else {
if (!isset($options['title'])) {
$options['title'] = $os_name;
}
$output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, false, $relative, false, true);
$output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, false, $relative);
}
}
else
@ -1807,8 +1807,6 @@ function ui_pagination ($count, $url = false, $offset = 0,
* @return string HTML code if return parameter is true.
*/
function ui_print_session_action_icon ($action, $return = false) {
global $config;
$key_icon = array(
'acl' => 'images/delete.png',
'agent' => 'images/agent.png',
@ -1837,7 +1835,7 @@ function ui_print_session_action_icon ($action, $return = false) {
$output = '';
foreach($key_icon as $key => $icon) {
if (stristr($action, $key) !== false) {
$output = html_print_image($icon, true, array('title' => $action), false, false, false, true) . ' ';
$output = html_print_image($icon, true, array('title' => $action)) . ' ';
break;
}
}
@ -2078,7 +2076,7 @@ function ui_print_status_image ($type, $title = "", $return = false, $options =
$options['title'] = $title;
return html_print_image ($imagepath, $return, $options, false, false, false, true);
return html_print_image ($imagepath, $return, $options);
}
/**

View File

@ -18,7 +18,7 @@ if (function_exists ('mb_internal_encoding')) {
mb_internal_encoding ("UTF-8");
}
$develop_bypass = 0;
$develop_bypass = 1;
require_once("include/ui.class.php");
require_once("include/system.class.php");
@ -69,8 +69,8 @@ $system = System::getInstance();
//~ In this moment doesn't work the version mobile when have metaconsole version.
//~ In the future versions of pandora maybe is added a mobile version of PandoraFMS Metaconsole version.
//~ if ($system->getConfig('metaconsole'))
//~ header ("Location: " . $system->getConfig('homeurl') . "enterprise/meta");
if ($system->getConfig('metaconsole'))
header ("Location: " . $system->getConfig('homeurl') . "enterprise/meta");
require_once($system->getConfig('homedir').'/include/constants.php');

View File

@ -23,17 +23,9 @@ class Agent {
$system = System::getInstance();
$this->id = $system->getRequest('id', 0);
if (!$system->getConfig('metaconsole')) {
$this->agent = agents_get_agents(array(
'disabled' => 0,
'id_agente' => $this->id), array('*'));
}
else {
$this->agent = agents_get_meta_agents(array(
'disabled' => 0,
'id_agente' => $this->id), array('*'));
}
$this->agent = agents_get_agents(array(
'disabled' => 0,
'id_agente' => $this->id), array('*'));
if (!empty($this->agent)) {
$this->agent = $this->agent[0];
@ -98,7 +90,7 @@ class Agent {
$ui->createPage();
if ($this->id != 0) {
$agent_name = (string) $this->agent['nombre'];
$agent_name = (string) agents_get_name ($this->id);
$ui->createDefaultHeader(
sprintf('%s', $agent_name),
@ -129,17 +121,8 @@ class Agent {
}
if ($system->getConfig('metaconsole')) {
metaconsole_connect(null, $this->agent['id_tmetaconsole_setup']);
$addresses = agents_get_addresses($this->agent['id_tagente']);
}
else
$addresses = agents_get_addresses($this->id);
if ($system->getConfig('metaconsole'))
metaconsole_restore_db();
$address = $this->agent['direccion'];
$addresses = agents_get_addresses($this->id);
$address = agents_get_address($this->id);
foreach ($addresses as $k => $add) {
if ($add == $address) {
unset($addresses[$k]);
@ -171,9 +154,7 @@ class Agent {
$html .= $last_contact;
$html .= $description;
$html .= '</div>';
if ($system->getConfig('metaconsole')) {
metaconsole_connect(null, $this->agent['id_tmetaconsole_setup']);
}
$ui->contentGridAddCell($html, 'agent_details');
ob_start();
$html = '<div class="agent_graphs">';
@ -189,38 +170,26 @@ class Agent {
$html .= '<div id="events_bar"></div>';
$html .= '<br>';
$html .= '</div>';
$ui->contentGridAddCell($html, 'agent_graphs');
$ui->contentEndGrid();
if ($system->getConfig('metaconsole'))
metaconsole_restore_db();
$modules = new Modules();
if ($system->getConfig('metaconsole'))
$filters = array('id_agent' => $this->agent['id_tagente'], 'all_modules' => true, 'status' => -1);
else
$filters = array('id_agent' => $this->id, 'all_modules' => true, 'status' => -1);
$filters = array('id_agent' => $this->id, 'all_modules' => true, 'status' => -1);
$modules->setFilters($filters);
$modules->disabledColumns(array('agent'));
$ui->contentBeginCollapsible(__('Modules'));
$ui->contentCollapsibleAddItem($modules->listModulesHtml(0, true));
$ui->contentEndCollapsible();
if ($system->getConfig('metaconsole')) {
metaconsole_connect(null, $this->agent['id_tmetaconsole_setup']);
}
$alerts = new Alerts();
if ($system->getConfig('metaconsole'))
$filters = array('id_agent' => $this->agent['id_tagente'], 'all_alerts' => true);
else
$filters = array('id_agent' => $this->id, 'all_alerts' => true);
$filters = array('id_agent' => $this->id, 'all_alerts' => true);
$alerts->setFilters($filters);
$alerts->disabledColumns(array('agent'));
$ui->contentBeginCollapsible(__('Alerts'));
$ui->contentCollapsibleAddItem($alerts->listAlertsHtml(true));
$ui->contentEndCollapsible();
if ($system->getConfig('metaconsole'))
metaconsole_restore_db();
$events = new Events();
$events->addJavascriptDialog();

View File

@ -223,76 +223,40 @@ class Agents {
OR comentarios LIKE '%" . $this->free_search . "%') ";
}
if (!$system->getConfig('metaconsole')) {
$total = agents_get_agents(array(
'disabled' => 0,
'id_grupo' => $this->group,
'search' => $search_sql,
'status' => $this->status),
array ('COUNT(*) AS total'), 'AR', false);
}
else {
$total = agents_get_meta_agents(array(
'disabled' => 0,
'id_grupo' => $this->group,
'search' => $search_sql,
'status' => $this->status),
array ('COUNT(*) AS total'), 'AR', false);
}
$total = agents_get_agents(array(
'disabled' => 0,
'id_grupo' => $this->group,
'search' => $search_sql,
'status' => $this->status),
array ('COUNT(*) AS total'), 'AR', false);
$total = isset($total[0]['total']) ? $total[0]['total'] : 0;
$order = array('field' => 'nombre COLLATE utf8_general_ci',
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
if (!$system->getConfig('metaconsole')) {
$agents_db = agents_get_agents(array(
'disabled' => 0,
'id_grupo' => $this->group,
'search' => $search_sql,
'status' => $this->status,
'offset' => (int) $page * $system->getPageSize(),
'limit' => (int) $system->getPageSize()),
array ('id_agente',
'id_grupo',
'id_os',
'nombre',
'ultimo_contacto',
'intervalo',
'comentarios description',
'quiet',
'normal_count',
'warning_count',
'critical_count',
'unknown_count',
'notinit_count',
'total_count',
'fired_count'),
'AR', $order);
}
else {
$agents_db = agents_get_meta_agents(array(
'disabled' => 0,
'id_grupo' => $this->group,
'search' => $search_sql,
'status' => $this->status,
'offset' => (int) $page * $system->getPageSize(),
'limit' => (int) $system->getPageSize()),
array ('id_agente',
'id_grupo',
'id_os',
'nombre',
'ultimo_contacto',
'intervalo',
'comentarios description',
'quiet',
'normal_count',
'warning_count',
'critical_count',
'unknown_count',
'notinit_count',
'total_count',
'fired_count'),
'AR', $order);
}
$agents_db = agents_get_agents(array(
'disabled' => 0,
'id_grupo' => $this->group,
'search' => $search_sql,
'status' => $this->status,
'offset' => (int) $page * $system->getPageSize(),
'limit' => (int) $system->getPageSize()),
array ('id_agente',
'id_grupo',
'id_os',
'nombre',
'ultimo_contacto',
'intervalo',
'comentarios description',
'quiet',
'normal_count',
'warning_count',
'critical_count',
'unknown_count',
'notinit_count',
'total_count',
'fired_count'),
'AR', $order);
if (empty($agents_db))
$agents_db = array();
@ -376,7 +340,7 @@ class Agents {
if ($system->getPageSize() < $listAgents['total']) {
$ui->contentAddHtml('<div id="loading_rows">' .
html_print_image('images/spinner.gif', true, false, false, false, false, true) .
html_print_image('images/spinner.gif', true) .
' ' . __('Loading...') .
'</div>');

View File

@ -80,7 +80,6 @@ class Events {
$events = array();
$end = 1;
foreach ($events_db as $event) {
$end = 0;
@ -102,7 +101,7 @@ class Events {
$img_st = str_replace("white.png", "dark.png", $img_st);
}
$status_icon = html_print_image($img_st, true, false, false, false, false, true);
$status_icon = html_print_image($img_st, true);
$row = array();
$row[] = '<b class="ui-table-cell-label">' . __('Event Name') . '</b><a href="javascript: openDetails(' . $event['id_evento'] . ')"><div class="event_name">' . io_safe_output($event['evento']) . '</div></a>';
@ -131,17 +130,13 @@ class Events {
$id_event = $system->getRequest('id_event', 0);
$meta = false;
if ($system->getConfig('metaconsole'))
$meta = true;
$event = events_get_event($id_event, false, $meta);
$event = events_get_event($id_event);
if ($event) {
//Check if it is a event from module.
if ($event['id_agentmodule'] > 0) {
$event['module_graph_link'] =
'<a data-ajax="false" href="index.php?page=module_graph&id=' . $event['id_agentmodule'] . '">' .
html_print_image('images/chart_curve.png', true, array ("style" => 'vertical-align: middle;'), false, false, false, true) .
html_print_image('images/chart_curve.png', true, array ("style" => 'vertical-align: middle;')) .
'</a>';
}
else {
@ -225,7 +220,7 @@ class Events {
array ("class" => "image_status",
"width" => 12,
"height" => 12,
"title" => $event_criticity), false, false, false, true);
"title" => $event_criticity));
if ($event['estado'] == 1) {
$user_ack = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']);
@ -257,7 +252,7 @@ class Events {
}
$event["status"] = $title_st;
$event["status"] .= ' ';
$event["status"] .= html_print_image($img_st,true, false, false, false, false, true);
$event["status"] .= html_print_image($img_st,true);
$event["group"] = groups_get_name ($event["id_grupo"], true);
$event["group"] .= ui_print_group_icon ($event["id_grupo"], true);
@ -725,7 +720,7 @@ class Events {
}
$system = System::getInstance();
$groups = users_get_groups($system->getConfig('id_user'), 'ER');
$groups = users_get_groups($system->getConfig('id_user'), 'IR');
//Group selection
if ($this->group > 0 && in_array ($this->group, array_keys ($groups))) {
@ -763,18 +758,13 @@ class Events {
$pagination = $system->getPageSize();
}
$meta = false;
if ($system->getConfig('metaconsole'))
$meta = true;
$events_db = events_get_events_grouped($sql_post,
$offset, $pagination, $meta, false);
$offset, $pagination, false, false);
if (empty($events_db)) {
$events_db = array();
}
$total_events = events_get_total_events_grouped($sql_post, $meta);
$total_events = events_get_total_events_grouped($sql_post);
return array('events' => $events_db, 'total' => $total_events);
}
@ -793,7 +783,7 @@ class Events {
$ui->contentAddHtml($table->getHTML());
$ui->contentAddHtml('<div id="loading_rows">' .
html_print_image('images/spinner.gif', true, false, false, false, false, true) .
html_print_image('images/spinner.gif', true) .
' ' . __('Loading...') .
'</div>' . $no_events);

View File

@ -13,11 +13,9 @@
// GNU General Public License for more details.
include_once("../include/functions_users.php");
include_once("../include/functions_groupview.php");
class Groups {
private $correct_acl = false;
private $acl = 'AR';
private $groups = array();
private $status = array();
@ -25,7 +23,7 @@ class Groups {
function __construct() {
$system = System::getInstance();
if ($system->checkACL($this->acl)) {
if ($system->checkACL()) {
$this->correct_acl = true;
$this->groups = $this->getListGroups();
@ -73,41 +71,11 @@ class Groups {
$ui->contentAddHtml('<div class="list_groups" data-role="collapsible-set" data-theme="a" data-content-theme="d">');
$count = 0;
$url_agent = 'index.php?page=agents&group=%s&status=%s';
$url_modules = 'index.php?page=modules&group=%s&status=%s';
foreach ($this->groups as $group) {
// Calculate entire row color
if ($group["_monitors_alerts_fired_"] > 0) {
$color_class = 'group_view_alrm';
$status_image = ui_print_status_image ('agent_alertsfired_ball.png', "", true);
}
elseif ($group["_monitors_critical_"] > 0) {
$color_class = 'group_view_crit';
$status_image = ui_print_status_image ('agent_critical_ball.png', "", true);
}
elseif ($group["_monitors_warning_"] > 0) {
$color_class = 'group_view_warn';
$status_image = ui_print_status_image ('agent_warning_ball.png', "", true);
}
elseif ($group["_monitors_ok_"] > 0) {
$color_class = 'group_view_ok';
$status_image = ui_print_status_image ('agent_ok_ball.png', "", true);
}
elseif (($group["_monitors_unknown_"] > 0) || ($group["_agents_unknown_"] > 0)) {
$color_class = 'group_view_unk';
$status_image = ui_print_status_image ('agent_no_monitors_ball.png', "", true);
}
else {
$color_class = '';
$status_image = ui_print_status_image ('agent_no_data_ball.png', "", true);
}
$group['icon'] = ($group['icon'] == '') ? 'world' : $group['icon'];
$ui->contentAddHtml('
<style type="text/css">
.ui-icon-group_' . $count . ' {
background: url("../images/groups_small/'.$group['icon'].'.png") no-repeat scroll 0 0 #F3F3F3 !important;
background: url("' . $group['group_icon'] . '") no-repeat scroll 0 0 #F3F3F3 !important;
width: 24px;
height: 24px;
margin-top: -12px !important;
@ -117,49 +85,47 @@ class Groups {
$ui->contentAddHtml('<div data-collapsed-icon="group_' . $count . '" ' .
'data-expanded-icon="group_' . $count . '" ' .
'data-iconpos="right" data-role="collapsible" ' .
'data-collapsed="true" data-theme="' . $color_class . '" data-content-theme="d">');
$ui->contentAddHtml('<h4>' . $group['_name_'] . '</h4>');
'data-collapsed="true" data-theme="' . $group['status'] . '" data-content-theme="d">');
$ui->contentAddHtml('<h4>' . $group['group_name'] . '</h4>');
$ui->contentAddHtml('<ul data-role="listview" class="groups_sublist">');
$ui->contentAddHtml('<li data-icon="false"><a href="' . sprintf($url_agent, $group['_id_'], AGENT_STATUS_ALL) . '">' .
'<span class="name_count">' . html_print_image('images/agent.png', true, false,false, false, false, true) . __('Total agents') . '</span>' .
'<span class="number_count">' . $group['_total_agents_'] . '</span>' .
foreach ($group['counts'] as $k => $v) {
if($v == 0) {
$group['counts'][$k] = '-';
}
}
$ui->contentAddHtml('<li data-icon="false"><a href="' . $group['links'][__('Agents')] . '">' .
'<span class="name_count">' . html_print_image('images/agent.png', true) . __('Total agents') . '</span>' .
'<span class="number_count">' . $group['counts'][__('Agents')] . '</span>' .
'</a></li>');
$ui->contentAddHtml('<li data-icon="false"><a href="' . sprintf($url_agent, $group['_id_'], AGENT_STATUS_NOT_INIT) . '">' .
'<span class="name_count">' . html_print_image('images/agent_notinit.png', true, false,false, false, false, true) . __('Agents not init') . '</span>' .
'<span class="number_count">' . $group['_agents_not_init_'] . '</span>' .
$ui->contentAddHtml('<li data-icon="false"><a href="' . $group['links'][__('Agents unknown')] . '">' .
'<span class="name_count">' . html_print_image('images/agent_unknown.png', true) . __('Agents unknown') . '</span>' .
'<span class="number_count">' . $group['counts'][__('Agents unknown')] . '</span>' .
'</a></li>');
$ui->contentAddHtml('<li data-icon="false"><a href="' . sprintf($url_agent, $group['_id_'], AGENT_STATUS_CRITICAL) . '">' .
'<span class="name_count">' . html_print_image('images/agent_critical.png', true, false,false, false, false, true) . __('Agents critical') . '</span>' .
'<span class="number_count">' . $group['_agents_critical_'] . '</span>' .
$ui->contentAddHtml('<li data-icon="false"><a href="' . $group['links'][__('Unknown')] . '">' .
'<span class="name_count">' . html_print_image('images/module_unknown.png', true) . __('Unknown modules') . '</span>' .
'<span class="number_count">' . $group['counts'][__('Unknown')] . '</span>' .
'</a></li>');
$ui->contentAddHtml('<li data-icon="false"><a href="' . sprintf($url_agent, $group['_id_'], AGENT_STATUS_UNKNOWN) . '">' .
'<span class="name_count">' . html_print_image('images/agent_unknown.png', true, false,false, false, false, true) . __('Agents unknown') . '</span>' .
'<span class="number_count">' . $group['_agents_unknown_'] . '</span>' .
$ui->contentAddHtml('<li data-icon="false"><a href="' . $group['links'][__('Not init')] . '">' .
'<span class="name_count">' . html_print_image('images/module_notinit.png', true) . __('Not init modules') . '</span>' .
'<span class="number_count">' . $group['counts'][__('Not init')] . '</span>' .
'</a></li>');
$ui->contentAddHtml('<li data-icon="false"><a href="' . sprintf($url_modules, $group['_id_'], AGENT_MODULE_STATUS_UNKNOWN) . '">' .
'<span class="name_count">' . html_print_image('images/module_unknown.png', true, false,false, false, false, true) . __('Unknown modules') . '</span>' .
'<span class="number_count">' . $group['_monitors_unknown_'] . '</span>' .
$ui->contentAddHtml('<li data-icon="false"><a href="' . $group['links'][__('Normal')] . '">' .
'<span class="name_count">' . html_print_image('images/module_ok.png', true) . __('Normal modules') . '</span>' .
'<span class="number_count">' . $group['counts'][__('Normal')] . '</span>' .
'</a></li>');
$ui->contentAddHtml('<li data-icon="false"><a href="' . sprintf($url_modules, $group['_id_'], AGENT_MODULE_STATUS_NOT_INIT) . '">' .
'<span class="name_count">' . html_print_image('images/module_notinit.png', true, false,false, false, false, true) . __('Not init modules') . '</span>' .
'<span class="number_count">' . $group['_monitors_not_init_'] . '</span>' .
$ui->contentAddHtml('<li data-icon="false"><a href="' . $group['links'][__('Warning')] . '">' .
'<span class="name_count">' . html_print_image('images/module_warning.png', true) . __('Warning modules') . '</span>' .
'<span class="number_count">' . $group['counts'][__('Warning')] . '</span>' .
'</a></li>');
$ui->contentAddHtml('<li data-icon="false"><a href="' . sprintf($url_modules, $group['_id_'], AGENT_MODULE_STATUS_NORMAL) . '">' .
'<span class="name_count">' . html_print_image('images/module_ok.png', true, false,false, false, false, true) . __('Normal modules') . '</span>' .
'<span class="number_count">' . $group['_monitors_ok_'] . '</span>' .
$ui->contentAddHtml('<li data-icon="false"><a href="' . $group['links'][__('Critical')] . '">' .
'<span class="name_count">' . html_print_image('images/module_critical.png', true) . __('Critical modules') . '</span>' .
'<span class="number_count">' . $group['counts'][__('Critical')] . '</span>' .
'</a></li>');
$ui->contentAddHtml('<li data-icon="false"><a href="' . sprintf($url_modules, $group['_id_'], AGENT_MODULE_STATUS_WARNING) . '">' .
'<span class="name_count">' . html_print_image('images/module_warning.png', true, false,false, false, false, true) . __('Warning modules') . '</span>' .
'<span class="number_count">' . $group['_monitors_warning_'] . '</span>' .
'</a></li>');
$ui->contentAddHtml('<li data-icon="false"><a href="' . sprintf($url_modules, $group['_id_'], AGENT_MODULE_STATUS_CRITICAL_BAD) . '">' .
'<span class="name_count">' . html_print_image('images/module_critical.png', true, false,false, false, false, true) . __('Critical modules') . '</span>' .
'<span class="number_count">' . $group['_monitors_critical_'] . '</span>' .
'</a></li>');
$ui->contentAddHtml('<li data-icon="false"><a href="">' .
'<span class="name_count">' . html_print_image('images/bell_error.png', true, false,false, false, false, true) . __('Alerts fired') . '</span>' .
'<span class="number_count">' . $group['_monitors_alerts_fired_'] . '</span>' .
$ui->contentAddHtml('<li data-icon="false"><a href="' . $group['links'][__('Alerts fired')] . '">' .
'<span class="name_count">' . html_print_image('images/bell_error.png', true) . __('Alerts fired') . '</span>' .
'<span class="number_count">' . $group['counts'][__('Alerts fired')] . '</span>' .
'</a></li>');
$ui->contentAddHtml('</ul>');
$ui->contentAddHtml('</div>');
@ -183,25 +149,35 @@ class Groups {
private function getListGroups() {
$return = array();
$system = System::getInstance();
$user = User::getInstance();
$all_data = groupview_status_modules_agents ($system->getConfig('id_user'), false, 'AR', false);
$result_groups = groupview_get_groups_list($system->getConfig('id_user'), false, 'AR', true, true);
foreach ($all_data as $group_all_data) {
$result_groups[0]['_total_agents_'] += $group_all_data["_total_agents_"];
$result_groups[0]['_monitors_ok_'] += $group_all_data["_monitors_ok_"];
$result_groups[0]['_monitors_warning_'] += $group_all_data["_monitors_warning_"];
$result_groups[0]['_monitors_critical_'] += $group_all_data["_monitors_critical_"];
$result_groups[0]['_monitors_unknown_'] += $group_all_data["_monitors_unknown_"];
$result_groups[0]['_monitors_not_init_'] += $group_all_data["_monitors_not_init_"];
$result_groups[0]['_agents_unknown_'] += $group_all_data["_agents_unknown_"];
$result_groups[0]['_agents_not_init_'] += $group_all_data["_agents_not_init_"];
$result_groups[0]['_agents_critical_'] += $group_all_data["_agents_critical_"];
$result_groups[0]['_monitors_alerts_fired_'] += $group_all_data["_monitors_alerts_fired_"];
// Get group list that user has access
$groups_full = users_get_groups($user->getIdUser(), "AR", true, true);
$groups = array();
foreach ($groups_full as $group) {
$groups[$group['id_grupo']]['name'] = $group['nombre'];
if ($group['id_grupo'] != 0) {
$groups[$group['parent']]['childs'][] = $group['id_grupo'];
$groups[$group['id_grupo']]['prefix'] = $groups[$group['parent']]['prefix'].'&nbsp;&nbsp;&nbsp;';
}
else {
$groups[$group['id_grupo']]['prefix'] = '';
}
if (!isset($groups[$group['id_grupo']]['childs'])) {
$groups[$group['id_grupo']]['childs'] = array();
}
}
return $result_groups;
// For each valid group for this user, take data from agent and modules
foreach ($groups as $id_group => $group) {
$rows = groups_get_group_row_data($id_group, $groups, $group, $printed_groups);
if (!empty($rows))
$return = array_merge($return, $rows);
}
return $return;
}
}

View File

@ -29,10 +29,8 @@ class Home {
}
protected function loadPagesItems () {
$system = System::getInstance();
$items = array();
// In home
$items['tactical'] = array(
'name' => __('Tactical view'),
@ -52,65 +50,63 @@ class Home {
'menu_item' => true,
'icon' => 'groups'
);
if (!$system->getConfig('metaconsole')) {
$items['alerts'] = array(
'name' => __('Alerts'),
'filename' => 'alerts.php',
'menu_item' => true,
'icon' => 'alerts'
);
$items['agents'] = array(
'name' => __('Agents'),
'filename' => 'agents.php',
'menu_item' => true,
'icon' => 'agents'
);
$items['modules'] = array(
'name' => __('Modules'),
'filename' => 'modules.php',
'menu_item' => true,
'icon' => 'modules'
);
$items['networkmaps'] = array(
'name' => __('Networkmaps'),
'filename' => 'networkmaps.php',
'menu_item' => true,
'icon' => 'network_maps'
);
$items['visualmaps'] = array(
'name' => __('Visual consoles'),
'filename' => 'visualmaps.php',
'menu_item' => true,
'icon' => 'visual_console'
);
// Not in home
$items['agent'] = array(
'name' => __('Agent'),
'filename' => 'agent.php',
'menu_item' => false,
'icon' => ''
);
$items['module_graph'] = array(
'name' => __('Module graph'),
'filename' => 'module_graph.php',
'menu_item' => false,
'icon' => ''
);
$items['networkmap'] = array(
'name' => __('Networkmap'),
'filename' => 'networkmap.php',
'menu_item' => false,
'icon' => ''
);
$items['visualmap'] = array(
'name' => __('Visualmap'),
'filename' => 'visualmap.php',
'menu_item' => false,
'icon' => ''
);
}
$items['alerts'] = array(
'name' => __('Alerts'),
'filename' => 'alerts.php',
'menu_item' => true,
'icon' => 'alerts'
);
$items['agents'] = array(
'name' => __('Agents'),
'filename' => 'agents.php',
'menu_item' => true,
'icon' => 'agents'
);
$items['modules'] = array(
'name' => __('Modules'),
'filename' => 'modules.php',
'menu_item' => true,
'icon' => 'modules'
);
$items['networkmaps'] = array(
'name' => __('Networkmaps'),
'filename' => 'networkmaps.php',
'menu_item' => true,
'icon' => 'network_maps'
);
$items['visualmaps'] = array(
'name' => __('Visual consoles'),
'filename' => 'visualmaps.php',
'menu_item' => true,
'icon' => 'visual_console'
);
// Not in home
$items['agent'] = array(
'name' => __('Agent'),
'filename' => 'agent.php',
'menu_item' => false,
'icon' => ''
);
$items['module_graph'] = array(
'name' => __('Module graph'),
'filename' => 'module_graph.php',
'menu_item' => false,
'icon' => ''
);
$items['networkmap'] = array(
'name' => __('Networkmap'),
'filename' => 'networkmap.php',
'menu_item' => false,
'icon' => ''
);
$items['visualmap'] = array(
'name' => __('Visualmap'),
'filename' => 'visualmap.php',
'menu_item' => false,
'icon' => ''
);
$this->pagesItems = $items;
}

View File

@ -278,7 +278,6 @@ class Modules {
$total = 0;
$modules = array();
$modules_db = array();
$sql_conditions_base = " WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo";
@ -406,34 +405,8 @@ class Modules {
$sql_limit = " LIMIT " . (int)($page * $system->getPageSize()) . "," . (int)$system->getPageSize();
}
if ($system->getConfig('metaconsole')) {
$servers = db_get_all_rows_sql ('SELECT *
FROM tmetaconsole_setup
WHERE disabled = 0');
if ($servers === false)
$servers = array();
//$modules_db = array();
$total = 0;
foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR)
continue;
$temp_modules = db_get_all_rows_sql($sql_select . $sql . $sql_limit);
html_debug($temp_modules, true);
foreach ($temp_modules as $result_element_key => $result_element_value) {
array_push($modules_db, $result_element_value);
}
$total += db_get_value_sql($sql_total. $sql);
metaconsole_restore_db();
}
}
else {
$total = db_get_value_sql($sql_total. $sql);
$modules_db = db_get_all_rows_sql($sql_select . $sql . $sql_limit);
}
$total = db_get_value_sql($sql_total. $sql);
$modules_db = db_get_all_rows_sql($sql_select . $sql . $sql_limit);
if (empty($modules_db)) {
$modules_db = array();
@ -619,7 +592,7 @@ class Modules {
if (!$this->all_modules) {
if ($system->getPageSize() < $listModules['total']) {
$ui->contentAddHtml('<div id="loading_rows">' .
html_print_image('images/spinner.gif', true, false, false, false, false, true) .
html_print_image('images/spinner.gif', true) .
' ' . __('Loading...') .
'</div>');

View File

@ -12,17 +12,16 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
include("../include/functions_tactical.php");
include("../include/functions_reporting.php");
include("../include/functions_servers.php");
class Tactical {
private $correct_acl = false;
private $acl = "AR";
function __construct() {
$system = System::getInstance();
if ($system->checkACL($this->acl)) {
if ($system->checkACL()) {
$this->correct_acl = true;
}
else {
@ -41,7 +40,7 @@ class Tactical {
public function ajax($parameter2 = false) {
$system = System::getInstance();
if (!$this->correct_acl) {
return;
}
@ -50,8 +49,6 @@ class Tactical {
case 'render_status_pie':
$links = $system->getRequest('links', '');
$data = $system->getRequest('data', '');
$data = str_replace('\\','',$data);
$links = str_replace('\\','',$links);
$width = $system->getRequest('width', 230);
$max_width = 399;
@ -90,55 +87,7 @@ class Tactical {
$ui->showFooter(false);
$ui->beginContent();
$ui->contentBeginGrid('responsive');
//~ $data = reporting_get_group_stats();
$all_data = tactical_status_modules_agents($config['id_user'], $user_strict, 'AR', $user_strict);
$data = array();
$data['monitor_not_init'] = (int) $all_data['_monitors_not_init_'];
$data['monitor_unknown'] = (int) $all_data['_monitors_unknown_'];
$data['monitor_ok'] = (int) $all_data['_monitors_ok_'];
$data['monitor_warning'] = (int) $all_data['_monitors_warning_'];
$data['monitor_critical'] = (int) $all_data['_monitors_critical_'];
$data['monitor_not_normal'] = (int) $all_data['_monitor_not_normal_'];
$data['monitor_alerts'] = (int) $all_data['_monitors_alerts_'];
$data['monitor_alerts_fired'] = (int) $all_data['_monitors_alerts_fired_'];
$data['total_agents'] = (int) $all_data['_total_agents_'];
$data["monitor_checks"] = (int) $all_data['_monitor_checks_'];
// Percentages
if (!empty($all_data)) {
if ($data["monitor_not_normal"] > 0 && $data["monitor_checks"] > 0)
$data['monitor_health'] = format_numeric (100 - ($data["monitor_not_normal"] / ($data["monitor_checks"] / 100)), 1);
else
$data["monitor_health"] = 100;
if ($data["monitor_not_init"] > 0 && $data["monitor_checks"] > 0)
$data["module_sanity"] = format_numeric (100 - ($data["monitor_not_init"] / ($data["monitor_checks"] / 100)), 1);
else
$data["module_sanity"] = 100;
if (isset($data["alerts"])) {
if ($data["monitor_alerts_fired"] > 0 && $data["alerts"] > 0)
$data["alert_level"] = format_numeric (100 - ($data["monitor_alerts_fired"] / ($data["alerts"] / 100)), 1);
else
$data["alert_level"] = 100;
}
else {
$data["alert_level"] = 100;
$data["alerts"] = 0;
}
$data["monitor_bad"] = $data["monitor_critical"] + $data["monitor_warning"];
if ($data["monitor_bad"] > 0 && $data["monitor_checks"] > 0)
$data["global_health"] = format_numeric (100 - ($data["monitor_bad"] / ($data["monitor_checks"] / 100)), 1);
else
$data["global_health"] = 100;
$data["server_sanity"] = format_numeric (100 - $data["module_sanity"], 1);
}
$data = reporting_get_group_stats();
$data['mobile'] = true;
$formatted_data = reporting_get_stats_indicators($data, 100, 10, false);
@ -175,17 +124,21 @@ class Tactical {
$ui->contentGridAddCell($overview, 'tactical1');
ob_start();
$links = array();
$links['monitor_critical'] = "index.php?page=modules&status=1";
$links['monitor_warning'] = "index.php?page=modules&status=2";
$links['monitor_ok'] = "index.php?page=modules&status=0";
$links['monitor_unknown'] = "index.php?page=modules&status=3";
$links['monitor_not_init'] = "index.php?page=modules&status=5";
$modules_status_untiny = reporting_get_stats_modules_status($data, 230, 150, $links);
$modules_status_tiny = reporting_get_stats_modules_status($data, 185, 110, $links);
$formatted_data = "<div id='status_pie'></div>";
$formatted_data .= html_print_div (array('id' => 'status_pie_links','content' => io_safe_input(json_encode($links)), 'hidden' => '1'), true);
$formatted_data .= html_print_div (array('id' => 'status_pie_data','content' => io_safe_input(json_encode($data)), 'hidden' => '1'), true);
$formatted_data = $formatted_data;
$formatted_data .= html_print_div (array('id' => 'status_pie_links','content' => json_encode($links), 'hidden' => '1'), true);
$formatted_data .= html_print_div (array('id' => 'status_pie_data','content' => json_encode($data), 'hidden' => '1'), true);
$graph_js = ob_get_clean();
$formatted_data = $graph_js . $formatted_data;
$ui->contentGridAddCell($formatted_data, 'tactical2');
$ui->contentEndGrid();
@ -220,8 +173,8 @@ class Tactical {
postvars[\"action\"] = \"ajax\";
postvars[\"parameter1\"] = \"tactical\";
postvars[\"parameter2\"] = \"render_status_pie\";
postvars[\"links\"] = $('#status_pie_links').text();
postvars[\"data\"] = $('#status_pie_data').text();
postvars[\"links\"] = $('#status_pie_links').html();
postvars[\"data\"] = $('#status_pie_data').html();
postvars[\"width\"] = pie_width;
$.post(\"index.php\",
postvars,