Merge branch 'develop' of https://192.168.50.5:8081/artica/pandorafms into develop

This commit is contained in:
enriquecd 2016-09-28 18:21:28 +02:00
commit 4f8cf57ee1
11 changed files with 370 additions and 183 deletions

View File

@ -5474,15 +5474,15 @@ 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')));
$tdata[0] = html_print_image('images/bell.png', true, array('title' => __('Defined alerts')), false, false, false, true);
$tdata[1] = $data["monitor_alerts"] <= 0 ? '-' : $data["monitor_alerts"];
$tdata[1] = '<a class="big_data" href="' . $urls["monitor_alerts"] . '">' . $tdata[1] . '</a>';
if($data["monitor_alerts"]>$data["total_agents"] && !enterprise_installed()){
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[3] = html_print_image('images/bell_error.png', true, array('title' => __('Fired alerts')), false, false, false, true);
$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[] = '';
@ -5546,29 +5546,29 @@ function reporting_get_stats_modules_status($data, $graph_width = 250, $graph_he
$table_mbs = html_get_predefined_table();
$tdata = array();
$tdata[0] = html_print_image('images/module_critical.png', true, array('title' => __('Monitor critical')));
$tdata[0] = html_print_image('images/module_critical.png', true, array('title' => __('Monitor critical')), false, false, false, true);
$tdata[1] = $data["monitor_critical"] <= 0 ? '-' : $data["monitor_critical"];
$tdata[1] = '<a style="color: ' . COL_CRITICAL . ';" class="big_data" href="' . $urls['monitor_critical'] . '">' . $tdata[1] . '</a>';
$tdata[2] = html_print_image('images/module_warning.png', true, array('title' => __('Monitor warning')));
$tdata[2] = html_print_image('images/module_warning.png', true, array('title' => __('Monitor warning')), false, false, false, true);
$tdata[3] = $data["monitor_warning"] <= 0 ? '-' : $data["monitor_warning"];
$tdata[3] = '<a style="color: ' . COL_WARNING_DARK . ';" class="big_data" href="' . $urls['monitor_warning'] . '">' . $tdata[3] . '</a>';
$table_mbs->rowclass[] = '';
$table_mbs->data[] = $tdata;
$tdata = array();
$tdata[0] = html_print_image('images/module_ok.png', true, array('title' => __('Monitor normal')));
$tdata[0] = html_print_image('images/module_ok.png', true, array('title' => __('Monitor normal')), false, false, false, true);
$tdata[1] = $data["monitor_ok"] <= 0 ? '-' : $data["monitor_ok"];
$tdata[1] = '<a style="color: ' . COL_NORMAL . ';" class="big_data" href="' . $urls["monitor_ok"] . '">' . $tdata[1] . '</a>';
$tdata[2] = html_print_image('images/module_unknown.png', true, array('title' => __('Monitor unknown')));
$tdata[2] = html_print_image('images/module_unknown.png', true, array('title' => __('Monitor unknown')), false, false, false, true);
$tdata[3] = $data["monitor_unknown"] <= 0 ? '-' : $data["monitor_unknown"];
$tdata[3] = '<a style="color: ' . COL_UNKNOWN . ';" class="big_data" href="' . $urls["monitor_unknown"] . '">' . $tdata[3] . '</a>';
$table_mbs->rowclass[] = '';
$table_mbs->data[] = $tdata;
$tdata = array();
$tdata[0] = html_print_image('images/module_notinit.png', true, array('title' => __('Monitor not init')));
$tdata[0] = html_print_image('images/module_notinit.png', true, array('title' => __('Monitor not init')), false, false, false, true);
$tdata[1] = $data["monitor_not_init"] <= 0 ? '-' : $data["monitor_not_init"];
$tdata[1] = '<a style="color: ' . COL_NOTINIT . ';" class="big_data" href="' . $urls["monitor_not_init"] . '">' . $tdata[1] . '</a>';
@ -5588,7 +5588,7 @@ function reporting_get_stats_modules_status($data, $graph_width = 250, $graph_he
$table_mbs->data[] = $tdata;
}
if(!defined("METACONSOLE")) {
if(!is_metaconsole()) {
$output = '
<fieldset class="databox tactical_set">
<legend>' .
@ -5637,19 +5637,19 @@ function reporting_get_stats_agents_monitors($data) {
$table_am = html_get_predefined_table();
$tdata = array();
$tdata[0] = html_print_image('images/agent.png', true, array('title' => __('Total agents')));
$tdata[0] = html_print_image('images/agent.png', true, array('title' => __('Total agents')), false, false, false, true);
$tdata[1] = $data["total_agents"] <= 0 ? '-' : $data["total_agents"];
$tdata[1] = '<a class="big_data" href="' . $urls['total_agents'] . '">' . $tdata[1] . '</a>';
if($data["total_agents"]>500 && !enterprise_installed()){
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[3] = html_print_image('images/module.png', true, array('title' => __('Monitor checks')), false, false, false, true);
$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()){
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>";
}

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)));
true, array("style" => $style, "class" => "bot", "alt" => groups_get_name($id_group, true), "title" => groups_get_name ($id_group, true)), false, false, false, 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);
true, $options, true, $relative, false, true);
}
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);
$output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, true, $relative, false, true);
}
else {
if (!isset($options['title'])) {
$options['title'] = $os_name;
}
$output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, false, $relative);
$output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, false, $relative, false, true);
}
}
else
@ -1835,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)) . ' ';
$output = html_print_image($icon, true, array('title' => $action), false, false, false, true) . ' ';
break;
}
}
@ -2076,7 +2076,7 @@ function ui_print_status_image ($type, $title = "", $return = false, $options =
$options['title'] = $title;
return html_print_image ($imagepath, $return, $options);
return html_print_image ($imagepath, $return, $options, false, false, false, true);
}
/**

View File

@ -104,7 +104,6 @@ tr.group_view_crit, .group_view_crit {
}
.group_view_normal, .group_view_normal *,
.group_view_norm, .group_view_norm * {
background-color: #FFFFFF;
@ -129,7 +128,6 @@ tr.group_view_crit, .group_view_crit {
text-shadow: none;
}
.group_view_ok, .group_view_ok * {
background-color: #00C000;
color: #000000 !important;

View File

@ -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,9 +23,17 @@ class Agent {
$system = System::getInstance();
$this->id = $system->getRequest('id', 0);
$this->agent = agents_get_agents(array(
'disabled' => 0,
'id_agente' => $this->id), array('*'));
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('*'));
}
if (!empty($this->agent)) {
$this->agent = $this->agent[0];
@ -90,7 +98,7 @@ class Agent {
$ui->createPage();
if ($this->id != 0) {
$agent_name = (string) agents_get_name ($this->id);
$agent_name = (string) $this->agent['nombre'];
$ui->createDefaultHeader(
sprintf('%s', $agent_name),
@ -121,8 +129,17 @@ class Agent {
}
$addresses = agents_get_addresses($this->id);
$address = agents_get_address($this->id);
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'];
foreach ($addresses as $k => $add) {
if ($add == $address) {
unset($addresses[$k]);
@ -154,7 +171,9 @@ 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">';
@ -170,26 +189,38 @@ 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();
$filters = array('id_agent' => $this->id, 'all_modules' => true, 'status' => -1);
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);
$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();
$filters = array('id_agent' => $this->id, 'all_alerts' => true);
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);
$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,40 +223,76 @@ class Agents {
OR comentarios LIKE '%" . $this->free_search . "%') ";
}
$total = agents_get_agents(array(
'disabled' => 0,
'id_grupo' => $this->group,
'search' => $search_sql,
'status' => $this->status),
array ('COUNT(*) AS total'), 'AR', false);
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 = isset($total[0]['total']) ? $total[0]['total'] : 0;
$order = array('field' => 'nombre COLLATE utf8_general_ci',
'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
$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 (!$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);
}
if (empty($agents_db))
$agents_db = array();
@ -340,7 +376,7 @@ class Agents {
if ($system->getPageSize() < $listAgents['total']) {
$ui->contentAddHtml('<div id="loading_rows">' .
html_print_image('images/spinner.gif', true) .
html_print_image('images/spinner.gif', true, false, false, false, false, true) .
' ' . __('Loading...') .
'</div>');

View File

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

View File

@ -13,9 +13,11 @@
// 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();
@ -23,7 +25,7 @@ class Groups {
function __construct() {
$system = System::getInstance();
if ($system->checkACL()) {
if ($system->checkACL($this->acl)) {
$this->correct_acl = true;
$this->groups = $this->getListGroups();
@ -71,11 +73,41 @@ 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("' . $group['group_icon'] . '") no-repeat scroll 0 0 #F3F3F3 !important;
background: url("../images/groups_small/'.$group['icon'].'.png") no-repeat scroll 0 0 #F3F3F3 !important;
width: 24px;
height: 24px;
margin-top: -12px !important;
@ -85,47 +117,49 @@ 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="' . $group['status'] . '" data-content-theme="d">');
$ui->contentAddHtml('<h4>' . $group['group_name'] . '</h4>');
'data-collapsed="true" data-theme="' . $color_class . '" data-content-theme="d">');
$ui->contentAddHtml('<h4>' . $group['_name_'] . '</h4>');
$ui->contentAddHtml('<ul data-role="listview" class="groups_sublist">');
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>' .
$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>' .
'</a></li>');
$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>' .
$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>' .
'</a></li>');
$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>' .
$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>' .
'</a></li>');
$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>' .
$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>' .
'</a></li>');
$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>' .
$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>' .
'</a></li>');
$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>' .
$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>' .
'</a></li>');
$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>' .
$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>' .
'</a></li>');
$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>' .
$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>' .
'</a></li>');
$ui->contentAddHtml('</ul>');
$ui->contentAddHtml('</div>');

View File

@ -29,8 +29,10 @@ class Home {
}
protected function loadPagesItems () {
$system = System::getInstance();
$items = array();
// In home
$items['tactical'] = array(
'name' => __('Tactical view'),
@ -50,63 +52,65 @@ class Home {
'menu_item' => true,
'icon' => 'groups'
);
$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' => ''
);
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' => ''
);
}
$this->pagesItems = $items;
}

View File

@ -278,6 +278,7 @@ 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";
@ -405,8 +406,34 @@ class Modules {
$sql_limit = " LIMIT " . (int)($page * $system->getPageSize()) . "," . (int)$system->getPageSize();
}
$total = db_get_value_sql($sql_total. $sql);
$modules_db = db_get_all_rows_sql($sql_select . $sql . $sql_limit);
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);
}
if (empty($modules_db)) {
$modules_db = array();
@ -592,7 +619,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) .
html_print_image('images/spinner.gif', true, false, false, false, false, true) .
' ' . __('Loading...') .
'</div>');

View File

@ -12,16 +12,17 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
include("../include/functions_reporting.php");
include("../include/functions_tactical.php");
include("../include/functions_servers.php");
class Tactical {
private $correct_acl = false;
private $acl = "AR";
function __construct() {
$system = System::getInstance();
if ($system->checkACL()) {
if ($system->checkACL($this->acl)) {
$this->correct_acl = true;
}
else {
@ -40,7 +41,7 @@ class Tactical {
public function ajax($parameter2 = false) {
$system = System::getInstance();
if (!$this->correct_acl) {
return;
}
@ -49,6 +50,8 @@ 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;
@ -87,7 +90,55 @@ class Tactical {
$ui->showFooter(false);
$ui->beginContent();
$ui->contentBeginGrid('responsive');
$data = reporting_get_group_stats();
//~ $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['mobile'] = true;
$formatted_data = reporting_get_stats_indicators($data, 100, 10, false);
@ -124,21 +175,17 @@ 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' => 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;
$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;
$ui->contentGridAddCell($formatted_data, 'tactical2');
$ui->contentEndGrid();
@ -173,8 +220,8 @@ class Tactical {
postvars[\"action\"] = \"ajax\";
postvars[\"parameter1\"] = \"tactical\";
postvars[\"parameter2\"] = \"render_status_pie\";
postvars[\"links\"] = $('#status_pie_links').html();
postvars[\"data\"] = $('#status_pie_data').html();
postvars[\"links\"] = $('#status_pie_links').text();
postvars[\"data\"] = $('#status_pie_data').text();
postvars[\"width\"] = pie_width;
$.post(\"index.php\",
postvars,