2013-03-26 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_reporting.php, include/functions_groups.php:
	changes for to use in the calls in mobile version.
	
	* mobile/index.php, mobile/operation/events.php,
	mobile/operation/modules.php, mobile/operation/events,
	mobile/operation/events/events.php, mobile/operation/agents.php,
	mobile/operation/tactical.php, mobile/operation/alerts.php,
	mobile/include/style/main.css, mobile/include/ui.class.php,
	mobile/include/user.class.php: changes and improves in the code
	of mobile.
	
	* mobile/operation/agents/*, mobile/operation/servers/*: removed
	the old files from version pandora mobile 4.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7891 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-03-26 17:24:10 +00:00
parent 1729eee3d7
commit c8cbc5e650
19 changed files with 1105 additions and 1427 deletions

View File

@ -1,3 +1,19 @@
2013-03-26 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_reporting.php, include/functions_groups.php:
changes for to use in the calls in mobile version.
* mobile/index.php, mobile/operation/events.php,
mobile/operation/modules.php, mobile/operation/events,
mobile/operation/events/events.php, mobile/operation/agents.php,
mobile/operation/tactical.php, mobile/operation/alerts.php,
mobile/include/style/main.css, mobile/include/ui.class.php,
mobile/include/user.class.php: changes and improves in the code
of mobile.
* mobile/operation/agents/*, mobile/operation/servers/*: removed
the old files from version pandora mobile 4.
2013-03-26 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_tags.php, include/functions_reporting.php,

View File

@ -712,8 +712,8 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
}
else {
$row[__('Group')] = $group['prefix'];
$row[__('Group')] .= "<a href=''>";
$row[__('Group')] .= ui_print_group_icon ($id_group, true, "groups_small");
$row[__('Group')] .= "<a href='index.php?page=agents&id_group=" . $id_group . "'>";
$row[__('Group')] .= ui_print_group_icon ($id_group, true, "groups_small", '', false);
$row[__('Group')] .= ui_print_truncate_text($group['name']);
$row[__('Group')] .= "</a>";
}
@ -760,7 +760,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
}
else {
if ($data["total_agents"] > 0) {
$row[__('Agents')] = "<a href=''>";
$row[__('Agents')] = "<a href='index.php?page=agents&id_group=" . $id_group . "'>";
$row[__('Agents')] .= $data["total_agents"];
$row[__('Agents')] .= "</a>";
}
@ -788,7 +788,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
}
else {
if ($data["agents_unknown"] > 0) {
$row[__('Agents unknown')] = "<a href=''>";
$row[__('Agents unknown')] = "<a href='index.php?page=agents&id_group=" . $id_group . "&status=3'>";
$row[__('Agents unknown')] .= $data["agents_unknown"];
$row[__('Agents unknown')] .= "</a>";
}
@ -813,7 +813,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
}
else {
if ($data["monitor_unknown"] > 0) {
$row[__('Unknown')] = "<a href=''>";
$row[__('Unknown')] = "<a href='index.php?page=modules&id_group=" . $id_group . "&status=3'>";
$row[__('Unknown')] .= $data["monitor_unknown"];
$row[__('Unknown')] .= "</a>";
}
@ -839,7 +839,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
}
else {
if ($data["monitor_not_init"] > 0) {
$row[__('Not init')] = "<a href=''>";
$row[__('Not init')] = "<a href='index.php?page=modules&id_group=" . $id_group . "&status=5'>";
$row[__('Not init')] .= $data["monitor_not_init"];
$row[__('Not init')] .= "</a>";
}
@ -864,7 +864,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
}
else {
if ($data["monitor_ok"] > 0) {
$row[__('Normal')] = "<a href=''>";
$row[__('Normal')] = "<a href='index.php?page=modules&id_group=" . $id_group . "&status=0'>";
$row[__('Normal')] .= $data["monitor_ok"];
$row[__('Normal')] .= "</a>";
}
@ -890,7 +890,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
}
else {
if ($data["monitor_warning"] > 0) {
$row[__('Warning')] = "<a href=''>";
$row[__('Warning')] = "<a href='index.php?page=modules&id_group=" . $id_group . "&status=1'>";
$row[__('Warning')] .= $data["monitor_warning"];
$row[__('Warning')] .= "</a>";
}
@ -916,7 +916,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
}
else {
if ($data["monitor_critical"] > 0) {
$row[__('Critical')] = "<a href=''>";
$row[__('Critical')] = "<a href='index.php?page=modules&id_group=" . $id_group . "&status=2'>";
$row[__('Critical')] .= $data["monitor_critical"];
$row[__('Critical')] .= "</a>";
}
@ -942,7 +942,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
}
else {
if ($data["monitor_alerts_fired"] > 0) {
$row[__('Alerts fired')] = "<a href=''>";
$row[__('Alerts fired')] = "<a href='index.php?page=alerts&group=" . $id_group . "&status=fired'>";;
$row[__('Alerts fired')] .= $data["monitor_alerts_fired"];
$row[__('Alerts fired')] .= "</a>";
}

View File

@ -1100,9 +1100,23 @@ function reporting_get_stats_alerts($data) {
global $config;
// Link URLS
$urls = array();
$urls['monitor_alerts'] = "index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60";
$urls['monitor_alerts_fired'] = "index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60&filter=fired";
$mobile = false;
if (isset($data['mobile'])) {
if ($data['mobile']) {
$mobile = true;
}
}
if ($mobile) {
$urls = array();
$urls['monitor_alerts'] = "index.php?page=alerts&status=all_enabled";
$urls['monitor_alerts_fired'] = "index.php?page=alerts&status=fired";
}
else {
$urls = array();
$urls['monitor_alerts'] = "index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60";
$urls['monitor_alerts_fired'] = "index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60&filter=fired";
}
// Alerts table
$table_al = html_get_predefined_table();
@ -1164,9 +1178,23 @@ function reporting_get_stats_agents_monitors($data) {
global $config;
// Link URLS
$urls = array();
$urls['total_agents'] = "index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60";
$urls['monitor_checks'] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=-1";
$mobile = false;
if (isset($data['mobile'])) {
if ($data['mobile']) {
$mobile = true;
}
}
if ($mobile) {
$urls = array();
$urls['total_agents'] = "index.php?page=agents";
$urls['monitor_checks'] = "index.php?page=modules";
}
else {
$urls = array();
$urls['total_agents'] = "index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60";
$urls['monitor_checks'] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=-1";
}
// Agents and modules table
$table_am = html_get_predefined_table();

View File

@ -31,7 +31,8 @@ tr.group_view_crit, .group_view_crit {
color: #000000 !important;
}
tr.group_view_norm, .group_view_norm {
.group_view_normal, .group_view_normal *,
.group_view_norm, .group_view_norm * {
background-color: #FFFFFF;
color: #000000 !important;
}
@ -39,7 +40,7 @@ tr.group_view_norm, .group_view_norm {
color: #000000 !important;
}
tr.group_view_ok, .group_view_ok {
.group_view_ok, .group_view_ok * {
background-color: #00C000;
color: #000000 !important;
}
@ -71,21 +72,26 @@ tr.group_view_unk, .group_view_unk {
tr.group_view_data, .group_view_data {
color: #000000 !important;
}
.group_view_data_unk {
.group_view_data_unk * {
color: #303030 !important;
}
.group_view_data_ok {
.group_view_data_ok * {
color: #00C000 !important;
}
.group_view_data_crit {
.group_view_data_crit * {
color: #5C0000 !important;
}
.group_view_data_alrm {
.group_view_data_alrm * {
color: #5C1D00 !important;
}
.group_view_data_warn {
.group_view_data_warn * {
color: #5C5900 !important;
}
.group_view * {
text-shadow: none !important;
font-size: 12px !important;
}
/*END-----------Groups styles-----------------------------------------*/
@ -139,6 +145,20 @@ table#list_events th {
}
/*END-----------Events styles-----------------------------------------*/
/*INIT-----------Agents styles----------------------------------------*/
.red, .redb, .redi, .error {
color: #CC0000;
}
.green {
color: #5A8629;
}
.grey {
color: #808080;
font-weight: bold;
}
/*END-----------Agents styles-----------------------------------------*/
/*INIT---------Fix the square border in search input------------------*/
.ui-input-search {

View File

@ -717,6 +717,15 @@ class Table {
$this->class_table = $class;
}
public function setId($id = false) {
if (empty($id)) {
$this->id = uniqid();
}
else {
$this->id = $id;
}
}
public function setRowClass($class = '', $pos = false) {
if (is_array($class)) {
$this->rowClass = $class;

View File

@ -36,7 +36,16 @@ class User {
public static function getInstance() {
if (!(self::$instance instanceof self)) {
self::$instance = new self;
//Check if in the session
$system = System::getInstance();
$user = $system->getSession('user', null);
if (!empty($user)) {
self::$instance = $user;
}
else {
self::$instance = new self;
}
}
return self::$instance;
@ -182,7 +191,15 @@ class User {
}
public function getIdUser() {
return $this->user;
return $this->user; //Oldies methods
}
public function isInGroup($access = "AR", $id_group = 0, $name_group = false) {
return (bool)check_acl($this->user, $id_group, $access);
}
public function getIdGroups($access = "AR", $all = false) {
return array_keys(users_get_groups($this->user, $access, $all));
}
}
?>

View File

@ -30,17 +30,14 @@ require_once('operation/tactical.php');
require_once('operation/groups.php');
require_once('operation/events.php');
require_once('operation/alerts.php');
require_once('operation/agents.php');
require_once('operation/modules.php');
$enterpriseHook = enterprise_include('mobile/include/enterprise.class.php');
$system = System::getInstance();
$user = $system->getSession('user', null);
if ($user == null) {
$user = User::getInstance();
}
else {
$user->hackInjectConfig();
}
$user = User::getInstance();
$user->hackInjectConfig();
$action = $system->getRequest('action');
if (!$user->isLogged()) {
@ -57,6 +54,14 @@ switch ($action) {
$events = new Events();
$events->ajax($parameter2);
break;
case 'agents':
$agents = new Agents();
$agents->ajax($parameter2);
break;
case 'modules':
$modules = new Modules();
$modules->ajax($parameter2);
break;
}
return;
break;
@ -102,6 +107,14 @@ switch ($action) {
$alerts = new Alerts();
$alerts->show();
break;
case 'agents':
$agents = new Agents();
$agents->show();
break;
case 'modules':
$modules = new Modules();
$modules->show();
break;
}
break;
}

View File

@ -0,0 +1,375 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
class Agents {
private $correct_acl = false;
private $acl = "AR";
private $default = true;
private $group = 0;
private $status = -1;
private $free_search = '';
private $list_status = null;
function __construct() {
$system = System::getInstance();
$this->list_status = array(
-1 => __('All'),
AGENT_MODULE_STATUS_CRITICAL_BAD => __('Critical'),
AGENT_MODULE_STATUS_CRITICAL_ALERT => __('Alert'),
AGENT_MODULE_STATUS_NORMAL => __('Normal'),
AGENT_MODULE_STATUS_WARNING => __('Warning'),
AGENT_MODULE_STATUS_UNKNOW => __('Unknow'));
if ($system->checkACL($this->acl)) {
$this->correct_acl = true;
}
else {
$this->correct_acl = false;
}
}
public function ajax($parameter2 = false) {
$system = System::getInstance();
if (!$this->correct_acl) {
return;
}
else {
switch ($parameter2) {
case 'get_agents':
$this->getFilters();
$page = $system->getRequest('page', 0);
$agents = array();
$end = 1;
$listAgents = $this->getListAgents($page, true);
if (!empty($listAgents['agents'])) {
$end = 0;
$agents = $listAgents['agents'];
}
echo json_encode(array('end' => $end, 'agents' => $agents));
break;
}
}
}
private function getFilters() {
$system = System::getInstance();
$user = User::getInstance();
$this->free_search = $system->getRequest('free_search', '');
if ($this->free_search != '') {
$this->default = false;
}
$this->status = $system->getRequest('status', __("Status"));
if (($this->status === __("Status")) || ($this->status == -1)) {
$this->status = -1;
}
else {
$this->default = false;
}
$this->group = (int)$system->getRequest('group', __("Group"));
if (!$user->isInGroup($this->acl, $this->group)) {
$this->group = 0;
}
if (($this->group === __("Group")) || ($this->group == 0)) {
$this->group = 0;
}
else {
$this->default = false;
}
}
public function show() {
if (!$this->correct_acl) {
$this->show_fail_acl();
}
else {
$this->getFilters();
$this->show_agents();
}
}
private function show_fail_acl() {
$ui = Ui::getInstance();
$ui->createPage();
$options['type'] = 'onStart';
$options['title_text'] = __('You don\'t have access to this page');
$options['content_text'] = __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database');
$ui->addDialog($options);
$ui->showPage();
}
private function show_agents() {
$ui = Ui::getInstance();
$ui->createPage();
$ui->createDefaultHeader(__("PandoraFMS: Agents"));
$ui->showFooter(false);
$ui->beginContent();
$filter_title = sprintf(__('Filter Agents by %s'),
$this->filterEventsGetString());
$ui->contentBeginCollapsible($filter_title);
$ui->beginForm("index.php?page=agents");
$system = System::getInstance();
$groups = users_get_groups_for_select(
$system->getConfig('id_user'), "AR", true, true, false, 'id_grupo');
$options = array(
'name' => 'group',
'title' => __('Group'),
'label' => __('Group'),
'items' => $groups,
'selected' => $this->group
);
$ui->formAddSelectBox($options);
$options = array(
'name' => 'status',
'title' => __('Status'),
'label' => __('Status'),
'items' => $this->list_status,
'selected' => $this->status
);
$ui->formAddSelectBox($options);
$options = array(
'name' => 'free_search',
'value' => $this->free_search,
'placeholder' => __('Free search')
);
$ui->formAddInputSearch($options);
$options = array(
'icon' => 'refresh',
'icon_pos' => 'right',
'text' => __('Apply Filter')
);
$ui->formAddSubmitButton($options);
$html = $ui->getEndForm();
$ui->contentCollapsibleAddItem($html);
$ui->contentEndCollapsible();
$this->listAgentsHtml();
$ui->endContent();
$ui->showPage();
}
private function getListAgents($page = 0, $ajax = false) {
$system = System::getInstance();
$total = 0;
$agents = array();
$search_sql = '';
if (!empty($this->free_search)) {
$search_sql = " AND (
nombre COLLATE utf8_general_ci LIKE '%" . $this->free_search . "%'
OR direccion LIKE '%" . $this->free_search . "%'
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);
$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 (empty($agents_db))
$agents_db = array();
foreach ($agents_db as $agent) {
$row = array();
$row[0] = $row[__('Agent')] = io_safe_output($agent['nombre']);
$row[1] = $row[__('Description')] = ui_print_truncate_text($agent["description"], 'description', false, true);
$row[2] = $row[__('OS')] = ui_print_os_icon ($agent["id_os"], false, true);
$row[3] = $row[__('Interval')] = human_time_description_raw($agent["intervalo"]);
$row[4] = $row[__('Group')] = ui_print_group_icon ($agent["id_grupo"], true);
$row[5] = $row[__('Modules')] = reporting_tiny_stats($agent, true);
$row[6] = $row[__('Status')] = agents_tree_view_status_img ($agent["critical_count"],
$agent["warning_count"], $agent["unknown_count"]);
$row[7] = $row[__('Alerts')] = agents_tree_view_alert_img ($agent["fired_count"]);
$last_time = strtotime ($agent["ultimo_contacto"]);
$now = time ();
$diferencia = $now - $last_time;
$time = ui_print_timestamp ($last_time, true, array('style' => 'font-size:6.5pt'));
$style = '';
if ($diferencia > ($agent["intervalo"] * 2))
$row[8] = $row[__('Last contact')] = '<b><span style="color: #ff0000;">'.$time.'</span></b>';
else
$row[8] = $row[__('Last contact')] = $time;
if (!$ajax) {
unset($row[0]);
unset($row[1]);
unset($row[2]);
unset($row[3]);
unset($row[4]);
unset($row[5]);
unset($row[6]);
unset($row[7]);
unset($row[8]);
}
$agents[$agent['id_agente']] = $row;
}
return array('agents' => $agents, 'total' => $total);
}
private function listAgentsHtml($page = 0) {
$system = System::getInstance();
$ui = Ui::getInstance();
$listAgents = $this->getListAgents($page);
if ($listAgents['total'] == 0) {
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('No agents') . '</p>');
}
else {
$table = new Table();
$table->id = 'list_agents';
$table->importFromHash($listAgents['agents']);
$ui->contentAddHtml($table->getHTML());
if ($system->getPageSize() < $listAgents['total']) {
$ui->contentAddHtml('<div id="loading_rows">' .
html_print_image('images/spinner.gif', true) .
' ' . __('Loading...') .
'</div>');
$this->addJavascriptAddBottom();
}
}
}
private function addJavascriptAddBottom() {
$ui = Ui::getInstance();
$ui->contentAddHtml("<script type=\"text/javascript\">
var load_more_rows = 1;
var page = 1;
$(document).ready(function() {
$(window).bind(\"scroll\", function () {
if (load_more_rows) {
if ($(this).scrollTop() + $(this).height()
>= ($(document).height() - 100)) {
load_more_rows = 0;
postvars = {};
postvars[\"action\"] = \"ajax\";
postvars[\"parameter1\"] = \"agents\";
postvars[\"parameter2\"] = \"get_agents\";
postvars[\"group\"] = $(\"select[name='group']\").val();
postvars[\"status\"] = $(\"select[name='status']\").val();
postvars[\"free_search\"] = $(\"input[name='free_search']\").val();
postvars[\"page\"] = page;
page++;
$.post(\"index.php\",
postvars,
function (data) {
if (data.end) {
$(\"#loading_rows\").hide();
}
else {
$.each(data.agents, function(key, agent) {
$(\"table#list_agents tbody\")
.append(\"<tr>\" +
\"<th></th>\" +
\"<td>\" + agent[0] + \"</td>\" +
\"<td>\" + agent[1] + \"</td>\" +
\"<td>\" + agent[2] + \"</td>\" +
\"<td>\" + agent[3] + \"</td>\" +
\"<td>\" + agent[4] + \"</td>\" +
\"<td>\" + agent[5] + \"</td>\" +
\"<td>\" + agent[6] + \"</td>\" +
\"<td>\" + agent[7] + \"</td>\" +
\"<td>\" + agent[8] + \"</td>\" +
\"</tr>\");
});
load_more_rows = 1;
}
},
\"json\");
}
}
});
});
</script>");
}
private function filterEventsGetString() {
if ($this->default) {
return __("(Default)");
}
else {
$status = $this->list_status[$this->status];
$group = groups_get_name($this->group, true);
$string = sprintf(
__("(Status: %s - Group: %s - Free Search: %s)"),
$status, $group, $this->free_search);
return $string;
}
}
}
?>

View File

@ -1,86 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
require_once ($config['homedir'].'/include/functions_users.php');
require_once ($config['homedir'] . '/include/functions_groups.php');
class GroupView {
private $system;
public function __construct() {
global $system;
$this->system = $system;
}
public function show() {
$groups = users_get_groups ($this->system->getConfig('id_user'));
$table = null;
$table->width = '100%';
$table->align = array();
for($i = 0; $i <= 8; $i++) {
$table->align[$i] = 'center';
}
$table->head = array();
$table->head[0] = '&nbsp;';
// $table->head[1] = '<span title="' . __('Total Agents') . '" alt="' . __('Total Agents') . '">' . __('T') . '</span>';
// $table->head[2] = '<span title="' . __('Agent unknown') . '" alt="' . __('Agent unknown') . '">' . __('A') . '</span>';
$table->head[3] = '<span title="' . __('Unknown') . '" alt="' . __('Unknown') . '">' . __('Unk') . '</span>';
// $table->head[4] = '<span title="' . __('Not Init') . '" alt="' . __('Not Init') . '">' . __('N') . '</span>';
$table->head[5] = '<span title="' . __('Normal') . '" alt="' . __('Normal') . '">' . __('Nor') . '</span>';
// $table->head[6] = '<span title="' . __('Warning') . '" alt="' . __('Warning') . '">' . __('W') . '</span>';
// $table->head[7] = '<span title="' . __('Critical') . '" alt="' . __('Critical') . '">' . __('C') . '</span>';
$table->head[8] = '<span title="' . __('Alert fired') . '" alt="' . __('Alert fired') . '">' . __('Aler') . '</span>';
$rowPair = false;
$iterator = 0;
foreach ($groups as $idGroup => $group) {
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
$iterator++;
if ($idGroup == 0) continue; //avoid the all group
$groupData = reporting_get_group_stats($idGroup);
if ($groupData['total_agents'] == 0) continue; //avoid the empty groups
$data = array();
$groupName = groups_get_name($idGroup);
$data[] = '<a href="index.php?page=agents&filter_group=' . $idGroup . '">' . $groupName . '</a>';
// $data[] = $groupData['total_agents'];
// $data[] = $groupData['agents_unknown'];
$data[] = $groupData['monitor_unknown'];
// $data[] = $groupData['monitor_not_init'];
$data[] = $groupData["monitor_ok"];
// $data[] = $groupData["monitor_warning"];
// $data[] = $groupData["monitor_critical"];
$data[] = $groupData["monitor_alerts_fired"];
$table->data[] = $data;
}
html_print_table($table);
}
}
?>

View File

@ -1,249 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
class MonitorStatus {
private $system;
private $user;
private $offset;
public function __construct($user) {
global $system;
$this->system = $system;
$this->user = $user;
$this->offset = $this->system->getRequest("offset", 0);
}
public function show() {
global $config;
require_once ($config['homedir'].'/include/functions_users.php');
require_once ($config['homedir'].'/include/functions_modules.php');
$config['text_char_long'] = 12;
$group = $this->system->getRequest("group", 0); //0 = all
$modulegroup = $this->system->getRequest("modulegroup", 0); //0 = all
$status = $this->system->getRequest("status", -1); //-1 = all
$search = $this->system->getRequest('filter_text', '');
$table = null;
$table->width = '100%';
$table->colspan[1][2] = 2;
$table->data[0][0] = '<span alt="' . __('Group') . '" title="' . __('Group') . '"><b>' . __('G') . '</b></span>';
$table->data[0][1] = html_print_select_groups($this->system->getConfig("id_user"), "IR", true, 'group', $group, '', '', 0, true, false, false, 'w130');
$table->data[0][2] = '<span alt="' . __('Monitor status') . '" title="' . __('Monitor Status') . '"><b>' . __('M') . '</b></span>';
$fields = array ();
$fields[-1] = __('All');
$fields[0] = __('Normal');
$fields[1] = __('Warning');
$fields[2] = __('Critical');
$fields[3] = __('Unknown');
$fields[4] = __('Not normal'); //default
$fields[5] = __('Not init');
foreach ($fields as $key => $field) {
$fields[$key] = ui_print_truncate_text($field, GENERIC_SIZE_TEXT, false, true, false);
}
$table->data[0][3] = html_print_select ($fields, "status", $status, '', '', -1, true);
$table->data[1][0] = '<span alt="' . __('Module group') . '" title="' . __('Module group') . '"><b>' . __('M') . '</b></span>';
$table->data[1][1] = html_print_select_from_sql ("SELECT * FROM tmodule_group ORDER BY name",
'module_group', $modulegroup, '',__('All'), 0, true);
$table->data[1][2] = html_print_input_text('search', $search, '', 5, 20, true);
$table->data[1][2] .= "<input type='submit' class='button_filter' name='submit_button' value='' alt='" . __('Filter') . "' title='" . __('Filter') . "' />";
echo "<form method='post'>";
html_print_table($table);
echo "</form>";
// Agent group selector
if (($group > 0) && (check_acl($system->getConfig('id_user'), $group, "AR"))) {
$sqlGroup = sprintf (" AND tagente.id_grupo = %d", $ag_group);
}
else {
$user_groups_all = users_get_groups ($this->user->getIdUser(), "AR");
$user_groups = array_keys ($user_groups_all);
$user_groupsText = implode(',', $user_groups);
// User has explicit permission on group 1 ?
$sqlGroup = " AND tagente.id_grupo IN (" . $user_groupsText . ")";
}
// Status selector
$sqlStatus = '';
if ($status == 0) { //Normal
$sqlStatus = " AND tagente_estado.estado = 0
AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100))) ";
}
elseif ($status == 2) { //Critical
$sqlStatus = " AND tagente_estado.estado = 1 AND utimestamp > 0";
}
elseif ($status == 1) { //Warning
$sqlStatus = " AND tagente_estado.estado = 2 AND utimestamp > 0";
}
elseif ($status == 4) { //Not normal
$sqlStatus = " AND tagente_estado.estado <> 0";
}
elseif ($status == 3) { //Unknown
$sqlStatus = " AND tagente_estado.estado = 3";
}
elseif ($status == 5) { //Not init
$sqlStatus = " AND tagente_estado.utimestamp = 0
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)";
}
// Module group
$sqlModuleGroup = '';
if ($modulegroup > 0) {
$sqlModuleGroup = sprintf (" AND tagente_modulo.id_module_group = '%d'", $modulegroup);
}
// Freestring selector
$sqlFreeSearch = '';
if ($search != "") {
$sqlFreeSearch = sprintf (" AND (tagente.nombre LIKE '%%%s%%' OR tagente_modulo.nombre LIKE '%%%s%%' OR tagente_modulo.descripcion LIKE '%%%s%%')", $search, $search, $search);
}
$selectSQL = 'SELECT tagente_modulo.id_agente_modulo,
tagente.intervalo AS agent_interval, tagente.nombre AS agent_name,
tagente_modulo.nombre AS module_name,
tagente_modulo.id_agente_modulo, tagente_modulo.history_data,
tagente_modulo.flag AS flag, tagente.id_grupo AS id_group,
tagente.id_agente AS id_agent,
tagente_modulo.id_tipo_modulo AS module_type,
tagente_modulo.module_interval, tagente_estado.datos,
tagente_estado.estado, tagente_estado.utimestamp AS utimestamp';
$sql = ' FROM tagente, tagente_modulo, tagente_estado
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.disabled = 0
AND tagente.disabled = 0
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
' . $sqlGroup . '
' . $sqlStatus . '
' . $sqlModuleGroup . '
' . $sqlFreeSearch . '
ORDER BY tagente.id_grupo, tagente.nombre';
$total = db_get_value_sql('SELECT COUNT(*) ' . $sql);
switch ($config["dbtype"]) {
case "mysql":
$rows = db_get_all_rows_sql($selectSQL . $sql . ' LIMIT ' . $this->offset . ', ' . $this->system->getPageSize());
break;
case "postgresql":
$rows = db_get_all_rows_sql($selectSQL . $sql . ' LIMIT ' . $this->system->getPageSize() . ' OFFSET ' . $this->offset);
break;
case "oracle":
$set = array();
$set['limit'] = $this->system->getPageSize();
$set['offset'] = $this->offset;
$rows = oracle_recode_query ($selectSQL . $sql, $set, 'AND', true);
break;
}
if ($rows === false) $rows = array();
if ($config["dbtype"] == 'oracle') {
for ($i=0; $i < count($rows); $i++) {
unset($rows[$i]['rnum']);
}
}
$table = null;
$table->width = '100%';
$table->data = array();
$rowPair = false;
$iterator = 0;
foreach ($rows as $row) {
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
$iterator++;
$data = array();
if($row['utimestamp'] == 0 && (($row['module_type'] < 21 || $row['module_type'] > 23) && $row['module_type'] != 100)) {
$statusImg = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true);
}
elseif ($row["estado"] == 0) {
$statusImg = ui_print_status_image(STATUS_MODULE_OK, __('NORMAL').": ".$row["datos"], true);
}
elseif ($row["estado"] == 1) {
$statusImg = ui_print_status_image(STATUS_MODULE_CRITICAL, __('CRITICAL').": ".$row["datos"], true);
}
elseif ($row["estado"] == 2) {
$statusImg = ui_print_status_image(STATUS_MODULE_WARNING, __('WARNING').": ".$row["datos"], true);
}
else {
$last_status = modules_get_agentmodule_last_status($row['id_agente_modulo']);
switch($last_status) {
case 0:
$statusImg = ui_print_status_image(STATUS_MODULE_OK, __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL').": ".$row["datos"], true);
break;
case 1:
$statusImg = ui_print_status_image(STATUS_MODULE_CRITICAL, __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL').": ".$row["datos"], true);
break;
case 2:
$statusImg = ui_print_status_image(STATUS_MODULE_WARNING, __('UNKNOWN')." - ".__('Last status')." ".__('WARNING').": ".$row["datos"], true);
break;
}
}
$data[] = str_replace('<img src="' , '<img width="15" height="15" src="../../', $statusImg);
$data[] = '<a href="index.php?page=agent&id=' . $row['id_agent'] . '">' .
ui_print_truncate_text($row['agent_name'], 'agent_small', true, true) . '</a>';
$data[] = '<a href="index.php?page=agent&action=view_module_graph&id=' . $row['id_agente_modulo'] . '">' .
ui_print_truncate_text($row['module_name'], 'module_small', true, true) . '</a>';
if (is_numeric($row["datos"]))
$data[] = format_numeric($row["datos"]);
else
$data[] = "<span title='".$row['datos']."' style='white-space: nowrap;'>" .
substr(io_safe_output($row["datos"]),0,12)."</span>";
$data[] = ui_print_timestamp ($row["utimestamp"], true, array('units' => 'tiny'));
$table->data[] = $data;
}
html_print_table($table);
$pagination = pagination ($total,
ui_get_url_refresh (array ()),
0, 0, true);
$pagination = str_replace('images/go_first.png', '../images/go_first.png', $pagination);
$pagination = str_replace('images/go_previous.png', '../images/go_previous.png', $pagination);
$pagination = str_replace('images/go_next.png', '../images/go_next.png', $pagination);
$pagination = str_replace('images/go_last.png', '../images/go_last.png', $pagination);
echo $pagination;
}
}
?>

View File

@ -1,119 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
class Tactical {
private $system;
function __construct() {
global $system;
$this->system = $system;
}
function show() {
global $config;
require_once ($config["homedir"] . '/include/functions_graph.php');
$data = reporting_get_group_stats();
$table = null;
//$table->width = '100%';
$table->size[0] = '10px';
$table->align[0] = 'center';
$table->align[3] = 'right';
$table->colspan = array();
$table->colspan[0][0] = 2;
$table->colspan[0][1] = 2;
$table->data[0][0] = "<h3 class='title_h3_server'>" . __('Status') . "</h3>" ;
$table->data[1][0] = '<span title="' . __('Global health') . '" alt="' . __('Global health') . '">' . __('G') . '</span> ';
$table->data[1][1] =
str_replace('include', '../include', progress_bar($data["global_health"], 70, 8, '', 0));
$table->data[2][0] = '<span title="' . __('Monitor health') . '" alt="' . __('Monitor health') . '">' . __('M') . '</span> ';
$table->data[2][1] =
str_replace('include', '../include', progress_bar($data["monitor_health"], 70, 8, '', 0));
$table->data[3][0] = '<span title="' . __('Module sanity') . '" alt="' . __('Module sanity') . '">' . __('M') . '</span> ';
$table->data[3][1] =
str_replace('include', '../include', progress_bar($data["module_sanity"], 70, 8, '', 0));
$table->data[4][0] = '<span title="' . __('Alert level') . '" alt="' . __('Alert level') . '">' . __('A') . '</span> ';
$table->data[4][1] =
str_replace('include', '../include', progress_bar($data["alert_level"], 70, 8, '', 0));
$table->data[5][0] = $table->data[5][1] = '';
$table->data[6][0] = $table->data[6][1] = '';
$table->data[7][0] = $table->data[7][1] = '';
$table->data[8][0] = $table->data[8][1] = '';
$table->data[0][1] = "<h3 class='title_h3_server'>" . __('Monitor checks') . "</h3>";
$table->data[1][2] = '<a href="index.php?page=monitor" class="tactical_link" style="color: #000;">' . __('Monitor checks') . '</a>';
$table->data[1][3] = '<a href="index.php?page=monitor" class="tactical_link" style="color: #000;">' . $data["monitor_checks"] . '</a>';
$table->data[2][2] = '<a href="index.php?page=monitor&status=2" class="tactical_link" style="color: #c00;">' . __('Monitors critical') . '</a>';
$table->data[2][3] = '<a href="index.php?page=monitor&status=2" class="tactical_link" style="color: #c00;">' . $data["monitor_critical"] . '</a>';
$table->data[3][2] = '<a href="index.php?page=monitor&status=1" class="tactical_link" style="color: #ffcc00;">' . __('Monitors warning') .'</a>';
$table->data[3][3] = '<a href="index.php?page=monitor&status=1" class="tactical_link" style="color: #ffcc00;">' . $data["monitor_warning"] . '</a>';
$table->data[4][2] = '<a href="index.php?page=monitor&status=0" class="tactical_link" style="color: #8ae234;">' . __('Monitors normal') . '</a>';
$table->data[4][3] = '<a href="index.php?page=monitor&status=0" class="tactical_link" style="color: #8ae234;">' . $data["monitor_ok"] . '</a>';
$table->data[5][2] = '<a href="index.php?page=monitor&status=3" class="tactical_link" style="color: #aaa;">' . __('Monitors unknown') . '</a>';
$table->data[5][3] = '<a href="index.php?page=monitor&status=3" class="tactical_link" style="color: #aaa;">' . $data["monitor_unknown"] . '</a>';
$table->data[6][2] = '<a href="index.php?page=monitor&status=5" class="tactical_link" style="color: #ef2929;">' . __('Monitors not init') . '</a>';
$table->data[6][3] = '<a href="index.php?page=monitor&status=5" class="tactical_link" style="color: #ef2929;">' . $data["monitor_not_init"] . '</a>';
$table->data[7][2] = '<a href="index.php?page=alerts" class="tactical_link" style="color: #000;">' . __('Alerts defined') . '</a>';
$table->data[7][3] = '<a href="index.php?page=alerts" class="tactical_link" style="color: #000;">' . $data["monitor_alerts"] . '</a>';
$table->data[8][2] = '<a href="index.php?page=events&event_type=alert_fired" class="tactical_link" style="color: #ff8800;">' . __('Alerts fired') . '</a>';
$table->data[8][3] = '<a href="index.php?page=events&event_type=alert_fired" class="tactical_link" style="color: #ff8800;">' . $data["monitor_alerts_fired"] . '</a>';
html_print_table($table);
echo "<h3 class='title_h3_server'>" . __('Server performance') . "</h3>";
$server_performance = servers_get_performance();
$table = null;
//$table->width = '100%';
$table->align = array();
$table->align[1] = 'right';
$table->data[0][0] = '<span style="color: #729fcf;">' . __('Local modules rate') . '</span>';
$table->data[0][1] = '<span style="color: #729fcf;">' . format_numeric($server_performance ["local_modules_rate"]) . '</span>';
$table->data[1][0] = '<span style="color: #729fcf;">' . __('Remote modules rate') . '</span>';
$table->data[1][1] = '<span style="color: #729fcf;">' . format_numeric($server_performance ["remote_modules_rate"]) . '</span>';
$table->data[2][0] = '<span style="color: #3465a4;">' . __('Local modules') . '</span>';
$table->data[2][1] = '<span style="color: #3465a4;">' . format_numeric($server_performance ["total_local_modules"]) . '</span>';
$table->data[3][0] = '<span style="color: #3465a4;">' . __('Remote modules') . '</span>';
$table->data[3][1] = '<span style="color: #3465a4;">' . format_numeric($server_performance ["total_remote_modules"]) . '</span>';
$table->data[4][0] = '<span style="color: #000;">' . __('Total running modules') . '</span>';
$table->data[4][1] = '<span style="color: #000;">' . format_numeric($server_performance ["total_modules"]) . '</span>';
html_print_table($table);
echo "<h3 class='title_h3_server'>" . __('Summary') . "</h3>";
$table = null;
//$table->width = '100%';
$table->align[1] = 'right';
$table->data[0][0] = '<a href="index.php?page=agents" class="tactical_link" style="color: #000;">' . __('Total agents') . '</span>';
$table->data[0][1] = '<a href="index.php?page=agents" class="tactical_link" style="color: #000;">' . $data["total_agents"] . '</span>';
$table->data[1][0] = '<span style="color: #ef2929;">' . __('Uninitialized modules') . '</span>';
$table->data[1][1] = '<span style="color: #ef2929;">' . $data["server_sanity"] . '</span>';
$table->data[2][0] = '<span style="color: #aaa;">' . __('Agents unknown') . '</span>';
$table->data[2][1] = '<span style="color: #aaa;">' . $data["agents_unknown"] . '</span>';
html_print_table($table);
}
}
?>

View File

@ -1,554 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once("../include/functions_agents.php");
require_once("../include/functions_reporting.php");
require_once("../include/functions_alerts.php");
require_once("../include/functions_modules.php");
require_once('../include/functions_users.php');
class ViewAgents {
private $user;
private $system;
private $filter;
private $filterGroup;
public function __construct() {
global $system;
global $user;
$this->user = $user;
$this->system = $system;
$this->filterText = $this->system->getRequest('filter_text', '');
$this->filterGroup = $this->system->getRequest('filter_group', 0);
}
private function showForm() {
echo "<form>";
html_print_input_hidden('page', 'agents');
global $config;
$config['text_char_long'] = 12;
html_print_select_groups($this->user->getIdUser(), "AR", true, 'filter_group', $this->filterGroup);
html_print_input_text('filter_text', $this->filterText, __('Free text search'), 5, 20);
echo "<input type='submit' class='button_filter' name='submit_button' value='' alt='" . __('Filter') . "' title='" . __('Filter') . "' />";
echo "<form>";
}
public function show() {
$this->showForm();
// Show only selected groups
if ($this->filterGroup > 0) {
$groups = $this->filterGroup;
$agent_names = agents_get_group_agents ($this->filterGroup, array('string' => $this->filterText), "upper");
// Not selected any specific group
}
else {
$user_group = users_get_groups ($this->user->getIdUser(), "AR");
$groups = array_keys ($user_group);
$agent_names = agents_get_group_agents (array_keys ($user_group), array('string' => $this->filterText), "upper");
}
$total_agents = agents_get_agents (array('id_agente' => array_keys ($agent_names),
'order' => 'nombre ASC',
'disabled' => 0,
'id_grupo' => $groups),
array ('COUNT(*) as total'));
$total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0;
$agents = agents_get_agents(array('id_agente' => array_keys ($agent_names),
'order' => 'nombre ASC',
'id_grupo' => $groups,
'offset' => (int) get_parameter ('offset'),
'limit' => (int) $this->system->getPageSize()), array('id_agente', 'nombre', 'id_grupo'));
$table = null;
$table->width = '100%';
$table->align = array();
$table->align[0] = 'center';
$table->align[2] = 'center';
$table->align[3] = 'center';
$table->align[4] = 'center';
$table->head = array();
$table->head[0] = '<span title="' . __('Group') . '" alt="' . __('Group') . '">' . __('G') . '</span>';
$table->head[1] = __('Name');
$table->head[2] = '<span title="' . __('Modules') . '" alt="' . __('Modules') . '">' . __('M') . '</span>';
$table->head[3] = '<span title="' . __('Status') . '" alt="' . __('Status') . '">' . __('S') . '</span>';
$table->head[4] = '<span title="' . __('Alert') . '" alt="' . __('Alert') . '">' . __('A') . '</span>';
$table->data = array();
if ($agents === false) $agents = array();
$iterator = 0;
$rowPair = false;
foreach ($agents as $agent) {
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
$iterator++;
$agent_info = reporting_get_agent_module_info ($agent["id_agente"]); //$this->system->debug($agent_info);
$data = array();
$truncName = ui_print_truncate_text($agent['nombre'], 'agent_small', true, true);
$data[] = ui_print_group_icon_path($agent["id_grupo"], true, "../images/groups_small", '', false);
$data[] = '<a href="index.php?page=agent&id=' . $agent['id_agente'] . '">' . $truncName . '</a>';
$moduleInfo = '<b>';
$moduleInfo .= $agent_info["modules"];
if ($agent_info["monitor_alertsfired"] > 0)
$moduleInfo .= ' : <span class="orange">'.$agent_info["monitor_alertsfired"].'</span>';
if ($agent_info["monitor_critical"] > 0)
$moduleInfo .= ' : <span class="red">'.$agent_info["monitor_critical"].'</span>';
if ($agent_info["monitor_warning"] > 0)
$moduleInfo .= ' : <span class="yellow">'.$agent_info["monitor_warning"].'</span>';
if ($agent_info["monitor_unknown"] > 0)
$moduleInfo .= ' : <span class="grey">'.$agent_info["monitor_unknown"].'</span>';
if ($agent_info["monitor_normal"] > 0)
$moduleInfo .= ' : <span class="green">'.$agent_info["monitor_normal"].'</span>';
$moduleInfo .= '</b>';
$data[] = $moduleInfo;
$data[] = '<img width="12" height="12" src="../images/status_sets/default/' . $agent_info['status'] . '" />';
$data[] = '<img width="12" height="12" src="../images/status_sets/default/' . $agent_info['alert_value'] . '" />';
$table->data[] = $data;
}
html_print_table($table);
$pagination = pagination ($total_agents,
ui_get_url_refresh (array ('filter_group' => $this->filterGroup, 'filter_group' => $this->filterGroup)),
0, 0, true);
$pagination = str_replace('images/go_first.png', '../images/go_first.png', $pagination);
$pagination = str_replace('images/go_previous.png', '../images/go_previous.png', $pagination);
$pagination = str_replace('images/go_next.png', '../images/go_next.png', $pagination);
$pagination = str_replace('images/go_last.png', '../images/go_last.png', $pagination);
echo $pagination;
}
}
class ViewAgent {
private $idAgent;
private $sytem;
private $agent;
private $name;
private $os;
private $ips;
private $modules;
public function __construct() {
global $system;
$this->system = $system;
$this->idAgent = $this->system->getRequest('id', 0);
$this->agent = db_get_row_filter('tagente', array('id_agente' => $this->idAgent));
$this->ips = agents_get_addresses($this->idAgent);
}
public function show() {
$idGroup = $this->agent['id_grupo'];
if (! check_acl ($this->system->getConfig('id_user'), $idGroup, "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access (read) to agent ".agents_get_name($this->idAgent));
include ("../general/noaccess.php");
return;
}
$table = null;
$table->width = '100%';
$table->style[0] = 'font-weight: bolder;';
$table->data[0][0] = __('Name:');
$table->data[0][1] = $this->agent['nombre'];
$table->data[1][0] = __('IP:');
$table->data[1][1] = implode(',', $this->ips);
$table->data[2][0] = __('OS:');
$table->data[2][1] = str_replace('images/os_icons/', '../images/os_icons/', ui_print_os_icon($this->agent['id_os'], true, true));
$table->data[3][0] = __('Last contact');
$table->data[3][1] = $this->agent['ultimo_contacto'];
html_print_table($table);
$sql = sprintf ("
SELECT *
FROM tagente_estado, tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.id_agente = %d
AND tagente_modulo.disabled = 0
AND tagente_modulo.delete_pending = 0
AND tagente_estado.utimestamp != 0
ORDER BY tagente_modulo.id_module_group , tagente_modulo.nombre ASC
", $this->idAgent);
$modules = db_get_all_rows_sql ($sql);
if (empty ($modules)) {
$modules = array ();
}
echo "<h3 class='title_h3'>" . __('Modules') . "</h3>";
$table = null;
//$table->width = '100%';
$table->head = array();
$table->head[0] = __('Module');
$table->head[1] = '<span title="' . __('Status') . '" alt="' . __('Status') . '">' . __('S') . '</span>';
$table->head[2] = __('Data');
$table->head[3] = '<span title="' . __('Last contact') . '" alt="' . __('Last contact') . '">' . __('L') . '</span>';
$table->data = array();
$iterator = 0;
$rowPair = false;
foreach ($modules as $module) {
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
$iterator++;
$data = array();
$data[] = '<a href="index.php?page=agent&action=view_module_graph&id=' . $module['id_agente_modulo'] . '">' .
ui_print_truncate_text($module["nombre"], 'module_small', true, true) . '</a>';
$status = STATUS_MODULE_WARNING;
$title = "";
if ($module["estado"] == 1) {
$status = STATUS_MODULE_CRITICAL;
$title = __('CRITICAL');
}
elseif ($module["estado"] == 2) {
$status = STATUS_MODULE_WARNING;
$title = __('WARNING');
}
elseif ($module["estado"] == 0) {
$status = STATUS_MODULE_OK;
$title = __('NORMAL');
}
elseif ($module["estado"] == 3) {
$last_status = modules_get_agentmodule_last_status($module['id_agente_modulo']);
switch($last_status) {
case 0:
$status = STATUS_MODULE_OK;
$title = __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL');
break;
case 1:
$status = STATUS_MODULE_CRITICAL;
$title = __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL');
break;
case 2:
$status = STATUS_MODULE_WARNING;
$title = __('UNKNOWN')." - ".__('Last status')." ".__('WARNING');
break;
}
}
if (is_numeric($module["datos"])) {
$title .= ": " . format_for_graph($module["datos"]);
}
else {
$title .= ": " . substr(io_safe_output($module["datos"]),0,42);
}
$data[] = str_replace(array('images/status_sets', '<img'),
array('/images/status_sets', '<img height="15" width="15"') , ui_print_status_image($status, $title, true));
if ($module["id_tipo_modulo"] == 24) { // log4x
switch($module["datos"]) {
case 10:
$salida = "TRACE";
$style="font-weight:bold; color:darkgreen;";
break;
case 20:
$salida = "DEBUG";
$style="font-weight:bold; color:darkgreen;";
break;
case 30:
$salida = "INFO";
$style="font-weight:bold; color:darkgreen;";
break;
case 40:
$salida = "WARN";
$style="font-weight:bold; color:darkorange;";
break;
case 50:
$salida = "ERROR";
$style="font-weight:bold; color:red;";
break;
case 60:
$salida = "FATAL";
$style="font-weight:bold; color:red;";
break;
}
$salida = "<span style='$style'>$salida</span>";
}
else {
if (is_numeric($module["datos"])) {
$salida = format_numeric($module["datos"]);
}
else {
$salida = "<span title='".$module['datos']."' style='white-space: nowrap;'>".substr(io_safe_output($module["datos"]),0,12)."</span>";
}
}
$data[] = $salida;
if ($module['estado'] == 3) {
$lastTime = '<span class="redb">';
}
else {
$lastTime = '<span>';
}
$lastTime .= ui_print_timestamp ($module["utimestamp"], true, array('units' => 'tiny'));
$lastTime .= '</span>';
$data[] = $lastTime;
$table->data[] = $data;
}
html_print_table($table);
$table->head = array();
$table->head[0] = __('Module');
$table->head[1] = __('Template');
$table->head[2] = '<span title="' . __('Last fired') . '" alt="' . __('Last fired') . '">' . __('Last') . '</span>';
$table->head[3] = '<span title="' . __('Status') . '" alt="' . __('Status') . '">' . __('S') . '</span>';
$table->align = array();
$table->align[3] = 'right';
$table->align[2] = 'center';
$table->data = array();
$table->rowclass = array();
echo "<h3 class='title_h3'>" . __('Alerts') . "</h3>";
$alertsSimple = agents_get_alerts_simple (array($this->idAgent));
$rowPair = false;
$iterator = 0;
foreach ($alertsSimple as $alert) {
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
$iterator++;
$data = array();
$data[] = ui_print_truncate_text(modules_get_agentmodule_name($alert["id_agent_module"]), 'module_small', true, true);
$template = io_safe_output(alerts_get_alert_template ($alert['id_alert_template']));
$data[] = ui_print_truncate_text(io_safe_output($template['name']), GENERIC_SIZE_TEXT, true, true);
$data[] = ui_print_timestamp ($alert["last_fired"], true, array('units' => 'tiny'));
$status = STATUS_ALERT_NOT_FIRED;
$title = "";
if ($alert["times_fired"] > 0) {
$status = STATUS_ALERT_FIRED;
$title = __('Alert fired').' '.$alert["times_fired"].' '.__('times');
}
elseif ($alert["disabled"] > 0) {
$status = STATUS_ALERT_DISABLED;
$title = __('Alert disabled');
}
else {
$status = STATUS_ALERT_NOT_FIRED;
$title = __('Alert not fired');
}
$data[] = str_replace(array('images/status_sets', '<img'),
array('/images/status_sets', '<img width="15" height="15"'), ui_print_status_image($status, $title, true));
$table->data[] = $data;
}
html_print_table($table);
}
}
class viewGraph {
private $system;
private $idAgentModule;
function __construct($idAgentModule = 0) {
global $system;
$this->system = $system;
$this->idAgentModule = $idAgentModule;
$this->agentModule = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $this->idAgentModule));
$this->period = $this->system->getRequest('period', 86400);
$this->offset = $this->system->getRequest("offset", 0);
$this->agent = db_get_row_filter('tagente', array('id_agente' => $this->agentModule['id_agente']));
}
function show() {
$idGroup = $this->agent['id_grupo'];
if (! check_acl ($this->system->getConfig('id_user'), $idGroup, "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access (read) to agent ".agents_get_name($this->idAgent));
include ("../general/noaccess.php");
return;
}
echo "<h3 class='title_h3'><a href='index.php?page=agent&id=" . $this->agentModule['id_agente'] . "'>" . modules_get_agentmodule_agent_name($this->idAgentModule)."</a> / ".io_safe_output($this->agentModule['nombre']) . "</h3>";
echo "<h3 class='title_h3'>" . __('Graph') . "</h3>";
echo grafico_modulo_sparse($this->idAgentModule, $this->period, 0, 240,
200, io_safe_output($this->agentModule['nombre']), null, false,
false, true, 0, '', true, false, true, true, '../');
echo "<h3 class='title_h3'>" . __('Data') . "</h3>";
echo "<form method='post' action='index.php?page=agent&action=view_module_graph&id=" . $this->idAgentModule . "'>";
echo __("Choose period:");
echo html_print_extended_select_for_time ('period', $this->period, 'this.form.submit();', '', '0', 5);
echo "</form><br />";
$moduletype_name = modules_get_moduletype_name (modules_get_agentmodule_type ($this->idAgentModule));
if ($moduletype_name == "log4x") {
$sql_body = sprintf ("FROM tagente_datos_log4x
WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $this->idAgentModule, (get_system_time () - $this->period));
$columns = array(
//"Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "center" ),
"Sev" => array("severity", "format_data", "align" => "center", "width" => "70px"),
"Message" => array("message", "modules_format_verbatim", "align" => "left", "width" => "45%"),
"StackTrace" => array("stacktrace", "modules_format_verbatim", "align" => "left", "width" => "50%")
);
}
else if (preg_match ("/string/", $moduletype_name)) {
$sql_body = sprintf (" FROM tagente_datos_string
WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $this->idAgentModule, (get_system_time () - $this->period));
$columns = array(
//"Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "center"),
"Data" => array("datos", "format_data", "align" => "center"),
"Time" => array("utimestamp", "modules_format_time", "align" => "center")
);
}
else {
$sql_body = sprintf (" FROM tagente_datos
WHERE id_agente_modulo = %d AND utimestamp > %d
ORDER BY utimestamp DESC", $this->idAgentModule, (get_system_time () - $this->period));
$columns = array(
"Data" => array("datos", "format_data", "align" => "center"),
"Time" => array("utimestamp", "modules_format_time", "align" => "center")
);
}
$sql_count = 'SELECT COUNT(*) ' . $sql_body;
$count = db_get_value_sql($sql_count);
switch ($config["dbtype"]) {
case "mysql":
$sql = 'SELECT * ' . $sql_body . ' LIMIT ' . $this->offset . ',' . $this->system->getPageSize();
break;
case "postgresql":
$sql = 'SELECT * ' . $sql_body . ' LIMIT ' . $this->system->getPageSize() . ' OFFSET ' . $this->offset;
break;
case "oracle":
$set = array();
$set['limit'] = $this->system->getPageSize();
$set['offset'] = $this->offset;
$sql = oracle_recode_query ('SELECT * ' . $sql_body, $set);
break;
}
$result = db_get_all_rows_sql ($sql);
if (($config["dbtype"] == 'oracle') && ($result !== false)) {
// Delete rnum row generated by oracle_recode_query() function
for ($i=0; $i < count($result); $i++) {
unset($result[$i]['rnum']);
}
}
$table = null;
$table->width = '100%';
$table->head = array();
$index = 0;
foreach($columns as $col => $attr) {
$table->head[$index] = $col;
if (isset($attr["align"]))
$table->align[$index] = $attr["align"];
if (isset($attr["width"]))
$table->size[$index] = $attr["width"];
$index++;
}
$table->data = array(); //$this->system->debug($result);
$rowPair = false;
$iterator = 0;
foreach ($result as $row) {
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
$iterator++;
$data = array ();
foreach($columns as $col => $attr) {
$data[] = $attr[1] ($row[$attr[0]]);
}
array_push ($table->data, $data);
}
html_print_table($table);
$pagination = ui_pagination ($count,
ui_get_url_refresh (array ('period' => $this->period)),
0, 0, true);
$pagination = str_replace('images/go_first.png', '../images/go_first.png', $pagination);
$pagination = str_replace('images/go_previous.png', '../images/go_previous.png', $pagination);
$pagination = str_replace('images/go_next.png', '../images/go_next.png', $pagination);
$pagination = str_replace('images/go_last.png', '../images/go_last.png', $pagination);
echo $pagination;
}
}
?>

View File

@ -1,99 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
include_once ($config['homedir'] . "/include/functions_agents.php");
include_once ($config['homedir'].'/include/functions_modules.php');
include_once ($config['homedir'].'/include/functions_users.php');
class ViewAlerts {
private $system;
public function __construct() {
global $system;
$this->system = $system;
}
public function show() {
$table = null;
//$table->width = '100%';
$table->head = array();
$table->head[0] = __('Module');
$table->head[1] = __('Template');
$table->head[2] = __('Action');
$table->head[2] = '<span title="' . __('Last fired') . '" alt="' . __('Last fired') . '">' . __('Last') . '</span>';
$table->head[3] = '<span title="' . __('Status') . '" alt="' . __('Status') . '">' . __('S') . '</span>';
$table->align = array();
$table->align[3] = 'right';
$table->align[2] = 'center';
$table->data = array();
$table->rowclass = array();
$groups = users_get_groups($this->system->getConfig('id_user'));
$idGroups = array_keys($groups);
$agents = agents_get_group_agents($idGroups);
$idAgents = array_keys($agents);
$alertsSimple = agents_get_alerts_simple($idAgents);
$rowPair = false;
$iterator = 0;
foreach ($alertsSimple as $alert) {
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
$iterator++;
$data = array();
$idAgent = modules_get_agentmodule_agent($alert["id_agent_module"]);
$data[] = '<a href="index.php?page=agent&id=' . $idAgent . '">' .
ui_print_truncate_text(modules_get_agentmodule_name($alert["id_agent_module"]), 'module_small', true, true) . '</a>';
$template = io_safe_output(alerts_get_alert_template ($alert['id_alert_template']));
$data[] = ui_print_truncate_text(io_safe_output($template['name']), GENERIC_SIZE_TEXT, true, true);
$data[] = ui_print_timestamp ($alert["last_fired"], true, array('units' => 'tiny'));
$status = STATUS_ALERT_NOT_FIRED;
$title = "";
if ($alert["times_fired"] > 0) {
$status = STATUS_ALERT_FIRED;
$title = __('Alert fired').' '.$alert["times_fired"].' '.__('times');
}
elseif ($alert["disabled"] > 0) {
$status = STATUS_ALERT_DISABLED;
$title = __('Alert disabled');
}
else {
$status = STATUS_ALERT_NOT_FIRED;
$title = __('Alert not fired');
}
$data[] = str_replace(array('images/status_sets', '<img'),
array('images/status_sets', '<img width="15" height="15"'), ui_print_status_image($status, $title, true));
$table->data[] = $data;
}
html_print_table($table);
}
}
?>

View File

@ -14,6 +14,7 @@
class Alerts {
private $correct_acl = false;
private $acl = "LM";
private $default = true;
@ -40,7 +41,7 @@ class Alerts {
$system = System::getInstance();
if ($system->checkACL("LM")) {
if ($system->checkACL($this->acl)) {
$this->correct_acl = true;
}
else {
@ -50,6 +51,7 @@ class Alerts {
private function alertsGetFilters() {
$system = System::getInstance();
$user = User::getInstance();
$this->free_search = $system->getRequest('free_search', '');
if ($this->free_search != '') {
@ -65,7 +67,10 @@ class Alerts {
}
$this->group = $system->getRequest('group', __("Group"));
if ($this->group === __("Group")) {
if (!$user->isInGroup($this->acl, $this->group)) {
$this->group = 0;
}
if (($this->group === __("Group")) || ($this->group == 0)) {
$this->group = 0;
}
else {
@ -195,6 +200,8 @@ class Alerts {
$alerts = alerts_get_alerts($this->group,
$this->free_search, $this->status, $this->standby, "LM");
if (empty($alerts))
$alerts = array();
$table = array();
foreach ($alerts as $alert) {
@ -220,7 +227,7 @@ class Alerts {
$row = array();
$row[__('Agent')] = sprintf($disabled_style,
'<a href="">' . io_safe_output($alert['agent_name'])) . '</a>';
'<a href="index.php?page=agent&id_agente=' . $alert['id_agente'] . '">' . io_safe_output($alert['agent_name'])) . '</a>';
$row[__('Module')] = sprintf($disabled_style,
io_safe_output($alert['module_name']));
$row[__('Template')] = sprintf($disabled_style,

View File

@ -14,6 +14,7 @@
class Events {
private $correct_acl = false;
private $acl = "ER";
private $default = true;
private $free_search = '';
@ -27,7 +28,7 @@ class Events {
function __construct() {
$system = System::getInstance();
if ($system->checkACL("ER")) {
if ($system->checkACL($this->acl)) {
$this->correct_acl = true;
}
else {
@ -240,6 +241,7 @@ class Events {
private function eventsGetFilters() {
$system = System::getInstance();
$user = User::getInstance();
$this->hours_old = $system->getRequest('hours_old', 8);
if ($this->hours_old != 8) {
@ -268,6 +270,9 @@ class Events {
}
$this->group = $system->getRequest('group', __("Group"));
if (!$user->isInGroup($this->acl, $this->group)) {
$this->group = 0;
}
if (($this->group === __("Group")) || ($this->group == 0)) {
$this->group = 0;
}
@ -390,7 +395,7 @@ class Events {
$ui->beginContent();
$ui->contentAddHtml("<a id='detail_event_dialog_hook' href='#detail_event_dialog' style='display:none;'>detail_event_hook</a>");
$ui->contentAddHtml("<a id='detail_event_dialog_error_hook' href='#detail_event_dialog_error' style='display:none;'>detail_event_dialog_error_hook</a>");
//$test = "javascript: $(\"#test\").click();";
$filter_title = sprintf(__('Filter Events by %s'), $this->filterEventsGetString());
$ui->contentBeginCollapsible($filter_title);
$ui->beginForm("index.php?page=events");
@ -614,7 +619,8 @@ class Events {
$row[$field_status] = '';
}
$row[$field_timestamp] = ui_print_timestamp ($event['timestamp_rep'], true);
$row[$field_agent] = ui_print_agent_name ($event["id_agente"], true);
$row[$field_agent] = '<a href="index.php?page=agent&id_agent=' . $event["id_agente"] . '">' .
(string) agents_get_name($event["id_agente"]) . '</a>';
$events[$event['id_evento']] = $row;
@ -629,7 +635,6 @@ class Events {
$table->id = 'list_events';
$table->setRowClass($row_class);
$table->importFromHash($events);
$ui->debug($events, true);
$ui->contentAddHtml($table->getHTML());
if ($system->getPageSize() < $total_events) {

View File

@ -1,211 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once('../include/functions_events.php');
require_once('../include/functions_users.php');
class EventsView {
private $system;
function __construct() {
global $system;
$this->system = $system;
}
function show() {
global $config;
require_once ($config['homedir'].'/include/functions_agents.php');
$config['text_char_long'] = 12;
$offset = $this->system->getRequest("offset", 0);
$ev_group = $this->system->getRequest("ev_group", 0); //0 = all
$event_type = get_parameter ("event_type", ''); // 0 all
$severity = $this->system->getRequest("severity", -1); // -1 all
$search = preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "%", rawurldecode ($this->system->getRequest("search", '')));
$event_view_hr = 24; //Last day of events
$types = get_event_types();
// Expand standard array to add not_normal (not exist in the array, used only for searches)
$types["not_normal"] = __("Not normal");
$table = null;
$table->width = '100%';
$table->colspan[1][2] = 2;
$table->data[0][0] = '<span alt="' . __('Group') . '" title="' . __('Group') . '"><b>' . __('G') . '</b></span>';
$table->data[0][1] = html_print_select_groups($this->system->getConfig("id_user"), "IR", true, 'ev_group', $ev_group, '', '', 0, true, false, false, 'w130');
$table->data[0][2] = '<span alt="' . __('Event type') . '" title="' . __('Event type') . '"><b>' . __('E') . '</b></span>';
$table->data[0][3] = html_print_select ($types, 'event_type', $event_type, '', __('All'), '', true);
$table->data[1][0] = '<span alt="' . __('Severity') . '" title="' . __('Severity') . '"><b>' . __('S') . '</b></span>';
$table->data[1][1] = html_print_select (get_priorities (), "severity", $severity, '', __('All'), '-1', true);
$table->data[1][2] = html_print_input_text('search', $search, '', 5, 20, true);
$table->data[1][2] .= "<input type='submit' class='button_filter' name='submit_button' value='' alt='" . __('Filter') . "' title='" . __('Filter') . "' />";
echo "<form method='post'>";
html_print_table($table);
echo "</form>";
$groups = users_get_groups ($this->system->getConfig("id_user"), "IR");
$sqlGroups = '';
//Group selection
if ($ev_group > 0 && in_array ($ev_group, array_keys ($groups))) {
//If a group is selected and it's in the groups allowed
$sqlGroups = " AND id_grupo = $ev_group";
}
else {
if (is_user_admin ($this->system->getConfig("id_user"))) {
//Do nothing if you're admin, you get full access
$sqlGroups = "";
}
else {
//Otherwise select all groups the user has rights to.
$sqlGroups = " AND id_grupo IN (".implode (",", array_keys ($groups)).")";
}
}
$sqlEventType = '';
if ($event_type != "") {
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
// for the user so for him is presented only "warning, critical and normal"
if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
$sqlEventType = " AND event_type LIKE '%$event_type%' ";
}
elseif ($event_type == "not_normal") {
$sqlEventType = " AND event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%' ";
}
else {
$sqlEventType = " AND event_type = '".$event_type."'";
}
}
$sqlSeverity = '';
if ($severity != -1)
$sqlSeverity = " AND criticity >= ".$severity;
$sqlFreeSearch = '';
if ($search != "")
$sqlFreeSearch .= " AND evento LIKE '%".$search."%'";
$unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); //Put hours in seconds
$sqlTimestamp = " AND utimestamp > ".$unixtime;
$sql = 'SELECT *
FROM tevento
WHERE 1=1 ' . $sqlGroups . $sqlEventType . $sqlSeverity .
$sqlFreeSearch . $sqlTimestamp . ' AND estado = 0 ORDER BY utimestamp DESC';
$sql_count = str_replace('*', 'COUNT(*)', $sql);
switch ($config["dbtype"]) {
case "mysql":
$sql = $sql . sprintf(' LIMIT %d,%d', $offset, $this->system->getPageSize());
break;
case "postgresql":
$sql = $sql . sprintf(' LIMIT %d OFFSET %d', $this->system->getPageSize(), $offset);
break;
case "oracle":
$set = array();
$set['limit'] = $this->system->getPageSize();
$set['offset'] = $offset;
$sql = oracle_recode_query ($sql, $set);
break;
}
$count = db_get_value_sql($sql_count);
$rows = db_get_all_rows_sql($sql);
if ($rows === false)
$rows = array();
$table = null;
$table->width = '100%';
$table->head = array();
$table->head[3] = '<span title="' . __('Timestamp') . '" alt="' . __('Timestamp') . '">' . __('T') . '</span>';
$table->head[4] = '<span title="' . __('Description') . '" alt="' . __('Description') . '">' . __('Des.') . '</span>';
$table->head[5] = '<span title="' . __('Agent') . '" alt="' . __('Agent') . '">' . __('Agent') . '</span>';
$table->data = array();
$iterator = 0;
foreach ($rows as $row) {
$data = array();
switch ($row["criticity"]) {
default:
case 0:
$img = "../images/status_sets/default/severity_maintenance_pixel.png";
break;
case 1:
$img = "../images/status_sets/default/severity_informational_pixel.png";
break;
case 2:
$img = "../images/status_sets/default/severity_normal_pixel.png";
break;
case 3:
$img = "../images/status_sets/default/severity_warning_pixel.png";
break;
case 4:
$img = "../images/status_sets/default/severity_critical_pixel.png";
break;
}
$table->rowclass[$iterator] = get_priority_class($row["criticity"]);
$iterator++;
$data[] = ui_print_timestamp($row["timestamp"], true, array('units' => 'tiny'));
$data[] = $row["evento"];
if ($row["event_type"] == "system") {
$data[] = ui_print_truncate_text(__('System'), GENERIC_SIZE_TEXT, true, true);
}
elseif ($row["id_agente"] > 0) {
// Agent name
$data[] = '<a href="index.php?page=agent&id=' . $row["id_agente"] . '">' .
ui_print_truncate_text(agents_get_name($row["id_agente"]), 'agent_small', true, true) . '</a>';
}
else {
$data[] = ui_print_truncate_text(__('Alert SNMP'), GENERIC_SIZE_TEXT, true, true);
}
$table->data[] = $data;
}
html_print_table($table);
$pagination = ui_pagination ($count,
ui_get_url_refresh(array("offset" => $offset, "ev_group" => $ev_group,
"event_type" => $event_type, "severity" => $severity,
"search" => $search)), 0, 0, true);
$pagination = str_replace('images/go_first.png', '../images/go_first.png', $pagination);
$pagination = str_replace('images/go_previous.png', '../images/go_previous.png', $pagination);
$pagination = str_replace('images/go_next.png', '../images/go_next.png', $pagination);
$pagination = str_replace('images/go_last.png', '../images/go_last.png', $pagination);
echo $pagination;
}
}
?>

View File

@ -0,0 +1,574 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
class Modules {
private $correct_acl = false;
private $acl = "AR";
private $default = true;
private $group = 0;
private $status = AGENT_MODULE_STATUS_NOT_NORMAL;
private $free_search = '';
private $module_group = -1;
private $tag = '';
private $list_status = null;
function __construct() {
$system = System::getInstance();
$this->list_status = array(
-1 => __('All'),
AGENT_MODULE_STATUS_NORMAL => __('Normal'),
AGENT_MODULE_STATUS_WARNING => __('Warning'),
AGENT_MODULE_STATUS_CRITICAL_BAD => __('Critical'),
AGENT_MODULE_STATUS_UNKNOW => __('Unknown'),
AGENT_MODULE_STATUS_NOT_NORMAL => __('Not normal'), //default
AGENT_MODULE_STATUS_NOT_INIT => __('Not init'));
if ($system->checkACL($this->acl)) {
$this->correct_acl = true;
}
else {
$this->correct_acl = false;
}
}
public function ajax($parameter2 = false) {
$system = System::getInstance();
if (!$this->correct_acl) {
return;
}
else {
switch ($parameter2) {
case 'get_modules':
$this->getFilters();
$page = $system->getRequest('page', 0);
$modules = array();
$end = 1;
$listModules = $this->getListModules($page, true);
if (!empty($listModules['modules'])) {
$end = 0;
$modules = $listModules['modules'];
}
echo json_encode(array('end' => $end, 'modules' => $modules));
break;
}
}
}
private function getFilters() {
$system = System::getInstance();
$user = User::getInstance();
$this->free_search = $system->getRequest('free_search', '');
if ($this->free_search != '') {
$this->default = false;
}
$this->status = $system->getRequest('status', __("Status"));
if (($this->status === __("Status")) || ($this->status == AGENT_MODULE_STATUS_NOT_NORMAL)) {
$this->status = AGENT_MODULE_STATUS_NOT_NORMAL;
}
else {
$this->default = false;
}
$this->group = (int)$system->getRequest('group', __("Group"));
if (!$user->isInGroup($this->acl, $this->group)) {
$this->group = 0;
}
if (($this->group === __("Group")) || ($this->group == 0)) {
$this->group = 0;
}
else {
$this->default = false;
}
$this->module_group = (int)$system->getRequest('module_group', __("Module group"));
if (($this->module_group === __("Module group")) || ($this->module_group == -1)
|| ($this->module_group == 0)) {
$this->module_group = -1;
}
else {
$this->default = false;
}
$this->tag = (int)$system->getRequest('tag', __("Tag"));
if (($this->tag === __("Tag")) || ($this->tag == 0)) {
$this->tag = 0;
}
else {
$this->default = false;
}
}
public function show() {
if (!$this->correct_acl) {
$this->show_fail_acl();
}
else {
$this->getFilters();
$this->show_modules();
}
}
private function show_fail_acl() {
$ui = Ui::getInstance();
$ui->createPage();
$options['type'] = 'onStart';
$options['title_text'] = __('You don\'t have access to this page');
$options['content_text'] = __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database');
$ui->addDialog($options);
$ui->showPage();
}
private function show_modules() {
$ui = Ui::getInstance();
$ui->createPage();
$ui->createDefaultHeader(__("PandoraFMS: Modules"));
$ui->showFooter(false);
$ui->beginContent();
$filter_title = sprintf(__('Filter Modules by %s'),
$this->filterEventsGetString());
$ui->contentBeginCollapsible($filter_title);
$ui->beginForm("index.php?page=modules");
$system = System::getInstance();
$groups = users_get_groups_for_select(
$system->getConfig('id_user'), "AR", true, true, false, 'id_grupo');
$options = array(
'name' => 'group',
'title' => __('Group'),
'label' => __('Group'),
'items' => $groups,
'selected' => $this->group
);
$ui->formAddSelectBox($options);
$options = array(
'name' => 'status',
'title' => __('Status'),
'label' => __('Status'),
'items' => $this->list_status,
'selected' => $this->status
);
$ui->formAddSelectBox($options);
$module_groups = db_get_all_rows_sql("SELECT *
FROM tmodule_group
ORDER BY name");
$module_groups = io_safe_output($module_groups);
$options = array(
'name' => 'module_group',
'title' => __('Module group'),
'label' => __('Module group'),
'item_id' => 'id_mg',
'item_value' => 'name',
'items' => $module_groups,
'selected' => $this->module_group
);
$ui->formAddSelectBox($options);
$tags = tags_get_user_tags();
$options = array(
'name' => 'tag',
'title' => __('Tag'),
'label' => __('Tag'),
'items' => $tags,
'selected' => $this->tag
);
$ui->formAddSelectBox($options);
$options = array(
'name' => 'free_search',
'value' => $this->free_search,
'placeholder' => __('Free search')
);
$ui->formAddInputSearch($options);
$options = array(
'icon' => 'refresh',
'icon_pos' => 'right',
'text' => __('Apply Filter')
);
$ui->formAddSubmitButton($options);
$html = $ui->getEndForm();
$ui->contentCollapsibleAddItem($html);
$ui->contentEndCollapsible();
$this->listModulesHtml();
$ui->endContent();
$ui->showPage();
}
private function getListModules($page = 0, $ajax = false) {
$system = System::getInstance();
$user = User::getInstance();
$id_type_web_content_string = db_get_value('id_tipo',
'ttipo_modulo', 'nombre', 'web_content_string');
$total = 0;
$modules = array();
$sql_conditions_base = " WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo";
// Part SQL for the Group
if ($this->group != 0) {
$sql_conditions_group = " AND tagente.id_grupo = " . $this->group;
}
else {
$user_groups = implode(',', $user->getIdGroups($this->acl));
$sql_conditions_group = " AND tagente.id_grupo IN (" . $user_groups . ")";
}
// Part SQL for the Tag
$sql_conditions_tags = tags_get_acl_tags($user->getIdUser(),
$this->group, $this->acl, 'module_condition', 'AND', 'tagente_modulo');
$sql_conditions = " AND tagente_modulo.disabled = 0 AND tagente.disabled = 0";
// Part SQL for the module_group
if ($this->module_group > -1) {
$sql_conditions .= sprintf (" AND tagente_modulo.id_module_group = '%d'",
$this->module_group);
}
// Part SQL for the free search
if ($this->free_search != "") {
$sql_conditions .= sprintf (" AND (tagente.nombre LIKE '%%%s%%'
OR tagente_modulo.nombre LIKE '%%%s%%'
OR tagente_modulo.descripcion LIKE '%%%s%%')",
$this->free_search, $this->free_search, $this->free_search);
}
// Part SQL fro Status
if ($this->status == AGENT_MODULE_STATUS_NORMAL) { //Normal
$sql_conditions .= " AND tagente_estado.estado = 0
AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100))) ";
}
elseif ($this->status == AGENT_MODULE_STATUS_CRITICAL_BAD) { //Critical
$sql_conditions .= " AND tagente_estado.estado = 1 AND utimestamp > 0";
}
elseif ($this->status == AGENT_MODULE_STATUS_WARNING) { //Warning
$sql_conditions .= " AND tagente_estado.estado = 2 AND utimestamp > 0";
}
elseif ($this->status == AGENT_MODULE_STATUS_NOT_NORMAL) { //Not normal
$sql_conditions .= " AND tagente_estado.estado <> 0";
}
elseif ($this->status == AGENT_MODULE_STATUS_UNKNOW) { //Unknown
$sql_conditions .= " AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0";
}
elseif ($this->status == AGENT_MODULE_STATUS_NOT_INIT) { //Not init
$sql_conditions .= " AND tagente_estado.utimestamp = 0
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)";
}
if ($this->tag > 0) {
$sql_conditions .= " AND tagente_modulo.id_agente_modulo IN (
SELECT ttag_module.id_agente_modulo
FROM ttag_module
WHERE ttag_module.id_tag = " . $this->tag . ")";
}
$sql_conditions_all = $sql_conditions_base . $sql_conditions .
$sql_conditions_group . $sql_conditions_tags;
$sql_select = "SELECT
(SELECT GROUP_CONCAT(ttag.name SEPARATOR ',')
FROM ttag
WHERE ttag.id_tag IN (
SELECT ttag_module.id_tag
FROM ttag_module
WHERE ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo))
AS tags,
tagente_modulo.id_agente_modulo,
tagente.intervalo AS agent_interval,
tagente.nombre AS agent_name,
tagente_modulo.nombre AS module_name,
tagente_modulo.history_data,
tagente_modulo.flag AS flag,
tagente.id_grupo AS id_group,
tagente.id_agente AS id_agent,
tagente_modulo.id_tipo_modulo AS module_type,
tagente_modulo.module_interval,
tagente_estado.datos,
tagente_estado.estado,
tagente_modulo.min_warning,
tagente_modulo.max_warning,
tagente_modulo.str_warning,
tagente_modulo.unit,
tagente_modulo.min_critical,
tagente_modulo.max_critical,
tagente_modulo.str_critical,
tagente_modulo.extended_info,
tagente_modulo.critical_inverse,
tagente_modulo.warning_inverse,
tagente_modulo.critical_instructions,
tagente_modulo.warning_instructions,
tagente_modulo.unknown_instructions,
tagente_estado.utimestamp AS utimestamp";
$sql_total = "SELECT count(*)";
$sql = " FROM tagente, tagente_modulo, tagente_estado" .
$sql_conditions_all;
$sql_limit = "ORDER BY tagente.nombre ASC
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 (empty($modules_db)) {
$modules_db = array();
}
else {
$modules = array();
foreach ($modules_db as $module) {
$row = array();
$row[0] = $row[__('Agent name')] = $module['agent_name'];
$row[1] = $row[__('Type')] = html_print_image("images/" .
modules_show_icon_type($module["module_type"]), true);
$row[2] = $row[__('Module name')] = $module['module_name'];
$row[3] = $row[__('Tags')] = $module['tags'];
$row[4] = $row[__('Interval')] = ($module['module_interval'] == 0) ? human_time_description_raw($module['agent_interval']) : human_time_description_raw($module['module_interval']);
if ($module['utimestamp'] == 0 && (($module['module_type'] < 21 ||
$module['module_type'] > 23) && $module['module_type'] != 100)) {
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_NO_DATA,
__('NOT INIT'), true);
}
elseif ($module["estado"] == 0) {
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_OK,
__('NORMAL') . ": " . $module["datos"], true);
}
elseif ($module["estado"] == 1) {
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_CRITICAL,
__('CRITICAL') . ": " . $module["datos"], true);
}
elseif ($module["estado"] == 2) {
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_WARNING,
__('WARNING') . ": " . $module["datos"], true);
}
else {
$last_status = modules_get_agentmodule_last_status(
$module['id_agente_modulo']);
switch($last_status) {
case 0:
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_UNKNOWN,
__('UNKNOWN') . " - " . __('Last status') . " " .
__('NORMAL') . ": " . $module["datos"], true);
break;
case 1:
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_UNKNOWN,
__('UNKNOWN') . " - " . __('Last status') ." " .
__('CRITICAL') . ": " . $module["datos"], true);
break;
case 2:
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_UNKNOWN,
__('UNKNOWN') . " - " . __('Last status') . " " .
__('WARNING') . ": " . $module["datos"], true);
break;
}
}
$row[6] = $row[__('Timestamp')] = ui_print_timestamp(
$module["utimestamp"], true);
if (is_numeric($module["datos"])) {
$output = format_numeric($module["datos"]);
// Show units ONLY in numeric data types
if (isset($module["unit"])) {
$output .= "&nbsp;" .
'<i>'. io_safe_output($module["unit"]) . '</i>';
}
}
else {
$is_web_content_string =
(bool)db_get_value_filter('id_agente_modulo',
'tagente_modulo',
array('id_agente_modulo' => $module['id_agente_modulo'],
'id_tipo_modulo' => $id_type_web_content_string));
//Fixed the goliat sends the strings from web
//without HTML entities
if ($is_web_content_string) {
$module['datos'] = io_safe_input($module['datos']);
}
//Fixed the data from Selenium Plugin
if ($module['datos'] != strip_tags($module['datos'])) {
$module['datos'] = io_safe_input($module['datos']);
}
if ($is_web_content_string) {
$module_value = $module["datos"];
}
else {
$module_value = io_safe_output($module["datos"]);
}
$sub_string = substr(io_safe_output($module["datos"]), 0, 12);
if ($module_value == $sub_string) {
$output = $module_value;
}
else {
$output = $sub_string;
}
}
$row[7] = $row[__('Data')] = $output;
if (!$ajax) {
unset($row[0]);
unset($row[1]);
unset($row[2]);
unset($row[3]);
unset($row[4]);
unset($row[5]);
unset($row[6]);
unset($row[7]);
}
$modules[$module['id_agente_modulo']] = $row;
}
}
return array('modules' => $modules, 'total' => $total);
}
private function listModulesHtml($page = 0) {
$system = System::getInstance();
$ui = Ui::getInstance();
$listModules = $this->getListModules($page);
$ui->debug($listModules, true);
if ($listModules['total'] == 0) {
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('No modules') . '</p>');
}
else {
$table = new Table();
$table->id = 'list_Modules';
$table->importFromHash($listModules['modules']);
$ui->contentAddHtml($table->getHTML());
if ($system->getPageSize() < $listModules['total']) {
$ui->contentAddHtml('<div id="loading_rows">' .
html_print_image('images/spinner.gif', true) .
' ' . __('Loading...') .
'</div>');
$this->addJavascriptAddBottom();
}
}
}
private function addJavascriptAddBottom() {
$ui = Ui::getInstance();
$ui->contentAddHtml("<script type=\"text/javascript\">
var load_more_rows = 1;
var page = 1;
$(document).ready(function() {
$(window).bind(\"scroll\", function () {
if (load_more_rows) {
if ($(this).scrollTop() + $(this).height()
>= ($(document).height() - 100)) {
load_more_rows = 0;
postvars = {};
postvars[\"action\"] = \"ajax\";
postvars[\"parameter1\"] = \"modules\";
postvars[\"parameter2\"] = \"get_modules\";
postvars[\"group\"] = $(\"select[name='group']\").val();
postvars[\"status\"] = $(\"select[name='status']\").val();
postvars[\"type\"] = $(\"select[name='module_group']\").val();
postvars[\"severity\"] = $(\"select[name='tag']\").val();
postvars[\"free_search\"] = $(\"input[name='free_search']\").val();
postvars[\"page\"] = page;
page++;
$.post(\"index.php\",
postvars,
function (data) {
if (data.end) {
$(\"#loading_rows\").hide();
}
else {
$.each(data.module, function(key, module) {
$(\"table#list_events tbody\").append(\"<tr>\" +
\"<th></th>\" +
\"<td>\" + module[0] + \"</td>\" +
\"<td>\" + module[1] + \"</td>\" +
\"<td>\" + module[2] + \"</td>\" +
\"<td>\" + module[3] + \"</td>\" +
\"<td>\" + module[4] + \"</td>\" +
\"<td>\" + module[5] + \"</td>\" +
\"<td>\" + module[6] + \"</td>\" +
\"<td>\" + module[7] + \"</td>\" +
\"</tr>\");
});
load_more_rows = 1;
}
},
\"json\");
}
}
});
});
</script>");
}
private function filterEventsGetString() {
if ($this->default) {
return __("(Default)");
}
else {
$status = $this->list_status[$this->status];
$group = groups_get_name($this->group, true);
$module_group = db_get_value('name',
'tmodule_group', 'id_mg', $this->module_group);
$module_groups = io_safe_output($module_groups);
$tag = tags_get_name($this->tag);
$string = sprintf(
__("(Status: %s - Group: %s - Module group: %s - Tag: %s - Free Search: %s)"),
$status, $group, $module_group, $tag, $this->free_search);
return $string;
}
}
}
?>

View File

@ -1,70 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once('../include/functions_servers.php');
class ViewServers {
private $system;
public function __construct() {
global $system;
$this->system = $system;
}
public function show() {
$servers = servers_get_info ();
if ($servers === false) $servers = array();
$table = null;
$table->width = '100%';
$table->align = array();
$table->align[1] = 'center';
$table->align[4] = 'center';
$table->head = array();
$table->head[0] = __('Server');
$table->head[1] = '<span title="' . __('Type') . '" alt="' . __('Type') . '">' . __('T') . '</span>';
$table->head[2] = '<span title="' . __('Started') . '" alt="' . __('Started') . '">' . __('S') . '</span>';
$table->head[3] = '<span title="' . __('Updated') . '" alt="' . __('Updated') . '">' . __('U') . '</span>';
$table->head[4] = '<span title="' . __('Status') . '" alt="' . __('Status') . '">' . __('S') . '</span>';
$table->data = array(); //$this->system->debug($servers);
foreach ($servers as $server) {
$data = array();
if ($server['status'] == 0) {
$server_status = ui_print_status_image(STATUS_SERVER_DOWN, '', true);
}
else {
$server_status = ui_print_status_image(STATUS_SERVER_OK, '', true);
}
$data[] = strip_tags($server["name"]);
$data[] = str_replace('images/', '/images/', $server['img']);
$data[] = human_time_comparation ($server["laststart"], 'tiny');
$data[] = human_time_comparation ($server["keepalive"], 'tiny');
$data[] = str_replace(array('images/status_sets', '<img'),
array('/images/status_sets', '<img width="15" height="15"'), $server_status);
// $this->system->debug($server["name"]);
$table->data[] = $data;
}
html_print_table($table);
}
}
?>

View File

@ -60,6 +60,8 @@ class Tactical {
$ui->beginContent();
$ui->contentBeginGrid('responsive');
$data = reporting_get_group_stats();
$data['mobile'] = true;
$formatted_data = reporting_get_stats_indicators($data, 280, 20, false);
$overview = '<fieldset class="databox" style="width:97%;">
<legend style="text-align:left; color: #666;">' .