Merge branch 'develop' into feature/NewTreeView

Conflicts resolved:
	pandora_console/include/functions_groups.php
This commit is contained in:
Alejandro Gallardo Escobar 2015-01-09 11:41:07 +01:00
commit e1b34840b1
50 changed files with 2545 additions and 678 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 6.0dev-141213 Version: 6.0dev-150108
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="6.0dev-141213" pandora_version="6.0dev-150108"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -220,10 +220,6 @@ module_name Number processes
module_type generic_data module_type generic_data
module_exec ps aux | wc -l module_exec ps aux | wc -l
module_description Total processes module_description Total processes
module_min_warning 150
module_max_warning 249
module_min_critical 250
module_max_critical 300
module_unit processes module_unit processes
module_end module_end

View File

@ -41,7 +41,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '6.0dev'; use constant AGENT_VERSION => '6.0dev';
use constant AGENT_BUILD => '141213'; use constant AGENT_BUILD => '150108';
# Commands to retrieve total memory information in kB # Commands to retrieve total memory information in kB
use constant TOTALMEMORY_CMDS => { use constant TOTALMEMORY_CMDS => {

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 6.0dev %define version 6.0dev
%define release 141213 %define release 150108
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 6.0dev %define version 6.0dev
%define release 141213 %define release 150108
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -15,22 +15,41 @@ my $SFREE=($SUSED/$STOTAL)*100;
$SFREE = floor($SFREE); $SFREE = floor($SFREE);
$FREEP = floor($FREEP); $FREEP = floor($FREEP);
# Added 30/Dec/2014, slerena
# Available memory as FreeMemory + Cached + SwapCached.
my $freemem=`cat /proc/meminfo | grep 'MemFree' | awk '{ print \$2 } '`;
my $cached=`cat /proc/meminfo | grep '^Cached:' | awk '{ print \$2 } '`;
my $cachedswap=`cat /proc/meminfo | grep '^SwapCached:' | awk '{ print \$2 }'`;
my $available=$freemem+$cached+$cachedwap;
my $available_percent = floor(($available / $STOTAL)*100);
print "<module>\n"; print "<module>\n";
print "<name>FreeMemory</name>\n"; print "<name>FreeMemory</name>\n";
print "<type>generic_data</type>\n"; print "<type>generic_data</type>\n";
print "<description>Free memory %</description>\n"; print "<description>Free memory %. Note most linux use 99% of available memory by default, check Availablememory module for more accurate information on available physical memory on system</description>\n";
print "<unit>%</unit>\n"; print "<unit>%</unit>\n";
print "<min_critical>0</min_critical>\n"; print "<min_critical>0</min_critical>\n";
print "<max_critical>5</max_critical>\n"; print "<max_critical>2</max_critical>\n";
print "<data>$FREEP</data>\n"; print "<data>$FREEP</data>\n";
print "</module>\n"; print "</module>\n";
print "<module>\n"; print "<module>\n";
print "<name>FreeSwap</name>\n"; print "<name>FreeSwap</name>\n";
print "<type>generic_data</type>\n"; print "<type>generic_data</type>\n";
print "<description>Free Swapy %</description>\n"; print "<description>Free Swap %</description>\n";
print "<unit>%</unit>\n";
print "<min_critical>0</min_critical>\n";
print "<max_critical>5</max_critical>\n";
print "<data>$SFREE</data>\n";
print "</module>\n";
print "<module>\n";
print "<name>AvailableMemory</name>\n";
print "<type>generic_data</type>\n";
print "<description>Available Physical Memory % (Free+Cached+CachedSwap)</description>\n";
print "<unit>%</unit>\n"; print "<unit>%</unit>\n";
print "<min_critical>0</min_critical>\n"; print "<min_critical>0</min_critical>\n";
print "<max_critical>10</max_critical>\n"; print "<max_critical>10</max_critical>\n";
print "<data>$SFREE</data>\n"; print "<data>$available_percent</data>\n";
print "</module>\n"; print "</module>\n";

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{141213} {150108}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("6.0dev(Build 141213)") #define PANDORA_VERSION ("6.0dev(Build 150108)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(6.0dev(Build 141213))" VALUE "ProductVersion", "(6.0dev(Build 150108))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 6.0dev-141213 Version: 6.0dev-150108
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="6.0dev-141213" pandora_version="6.0dev-150108"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -43,3 +43,13 @@ CREATE TABLE IF NOT EXISTS `tuser_double_auth` (
UNIQUE (`id_user`), UNIQUE (`id_user`),
FOREIGN KEY (`id_user`) REFERENCES tusuario(`id_user`) ON DELETE CASCADE FOREIGN KEY (`id_user`) REFERENCES tusuario(`id_user`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------------------------------------------------
-- Table `ttipo_modulo`
-- ----------------------------------------------------------------------
INSERT INTO `ttipo_modulo` VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png');
-- ---------------------------------------------------------------------
-- Table `tusuario`
-- ---------------------------------------------------------------------
ALTER TABLE `tusuario` ADD COLUMN `strict_acl` tinyint(1) DEFAULT 0;

View File

@ -31,3 +31,13 @@ CREATE TABLE tuser_double_auth (
); );
CREATE SEQUENCE tuser_double_auth_s INCREMENT BY 1 START WITH 1; CREATE SEQUENCE tuser_double_auth_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tuser_double_auth_inc BEFORE INSERT ON tuser_double_auth REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tuser_double_auth_s.nextval INTO :NEW.ID FROM dual; END tuser_double_auth_inc;; CREATE OR REPLACE TRIGGER tuser_double_auth_inc BEFORE INSERT ON tuser_double_auth REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tuser_double_auth_s.nextval INTO :NEW.ID FROM dual; END tuser_double_auth_inc;;
-- ----------------------------------------------------------------------
-- Table `ttipo_modulo`
-- ----------------------------------------------------------------------
INSERT INTO ttipo_modulo VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png');
-- ---------------------------------------------------------------------
-- Table `tusuario`
-- ---------------------------------------------------------------------
ALTER TABLE tusuario ADD COLUMN strict_acl NUMBER(5,0) DEFAULT 0;

View File

@ -29,3 +29,13 @@ CREATE TABLE "tuser_double_auth" (
"id_user" varchar(60) NOT NULL UNIQUE REFERENCES "tusuario"("id_user") ON DELETE CASCADE, "id_user" varchar(60) NOT NULL UNIQUE REFERENCES "tusuario"("id_user") ON DELETE CASCADE,
"secret" varchar(20) NOT NULL "secret" varchar(20) NOT NULL
); );
-- ----------------------------------------------------------------------
-- Table `ttipo_modulo`
-- ----------------------------------------------------------------------
INSERT INTO "ttipo_modulo" VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png');
-- ---------------------------------------------------------------------
-- Table `tusuario`
-- ---------------------------------------------------------------------
ALTER TABLE "tusuario" ADD COLUMN "strict_acl" SMALLINT NOT NULL default 0;

View File

@ -123,6 +123,7 @@ if ($new_user && $config['admin_can_add_user']) {
$user_info['is_admin'] = 0; $user_info['is_admin'] = 0;
$user_info['language'] = 'default'; $user_info['language'] = 'default';
$user_info["not_login"] = false; $user_info["not_login"] = false;
$user_info["strict_acl"] = false;
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
$user_info['id_skin'] = ''; $user_info['id_skin'] = '';
} }
@ -172,6 +173,7 @@ if ($create_user) {
} }
} }
$values["not_login"] = (bool)get_parameter ('not_login', false); $values["not_login"] = (bool)get_parameter ('not_login', false);
$values["strict_acl"] = (bool)get_parameter ('strict_acl', false);
if ($id == '') { if ($id == '') {
ui_print_error_message (__('User ID cannot be empty')); ui_print_error_message (__('User ID cannot be empty'));
@ -235,6 +237,11 @@ if ($create_user) {
$password_confirm = ''; $password_confirm = '';
if($result) { if($result) {
if ($values["strict_acl"]) {
if ($values['is_admin']) {
ui_print_info_message (__('Strict ACL is not recommended for admin users because performance could be affected.'));
}
}
$user_info = get_user_info ($id); $user_info = get_user_info ($id);
$new_user = false; $new_user = false;
} }
@ -269,6 +276,7 @@ if ($update_user) {
$values['metaconsole_access_node'] = get_parameter ('metaconsole_access_node', '0'); $values['metaconsole_access_node'] = get_parameter ('metaconsole_access_node', '0');
} }
$values["not_login"] = (bool)get_parameter ('not_login', false); $values["not_login"] = (bool)get_parameter ('not_login', false);
$values["strict_acl"] = (bool)get_parameter ('strict_acl', false);
$res1 = update_user ($id, $values); $res1 = update_user ($id, $values);
@ -336,6 +344,25 @@ if ($update_user) {
__('Error updating user info (no change?)')); __('Error updating user info (no change?)'));
} }
if ($values['strict_acl']) {
$count_groups = 0;
$count_tags = 0;
$profiles = db_get_all_rows_field_filter ("tusuario_perfil", "id_usuario", $id);
if ($profiles === false) {
$profiles = array ();
}
foreach ($profiles as $profile) {
$count_groups = $count_groups+1;
$arr_tags = explode(',', $profile['tags']);
$count_tags = $count_tags + count($arr_tags);
}
if (($count_groups > 3) && ($count_tags > 10)) {
ui_print_info_message(__('Strict ACL is not recommended for this user. Performance could be affected.'));
}
}
$user_info = $values; $user_info = $values;
} }
@ -496,6 +523,10 @@ $table->data[13][0] = __('Not Login');
$table->data[13][0] .= ui_print_help_tip(__('The user with not login set only can access to API.'), true); $table->data[13][0] .= ui_print_help_tip(__('The user with not login set only can access to API.'), true);
$table->data[13][1] = html_print_checkbox('not_login', 1, $user_info["not_login"], true); $table->data[13][1] = html_print_checkbox('not_login', 1, $user_info["not_login"], true);
$table->data[14][0] = __('Strict ACL');
$table->data[14][0] .= ui_print_help_tip(__('With this option enabled, the user will can access to accurate information. It is not recommended for admin users because performance could be affected'), true);
$table->data[14][1] = html_print_checkbox('strict_acl', 1, $user_info["strict_acl"], true);
if($meta) { if($meta) {
enterprise_include('include/functions_metaconsole.php'); enterprise_include('include/functions_metaconsole.php');
$data = array(); $data = array();

View File

@ -0,0 +1,65 @@
<?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 Lesser General Public License
// as published by the Free Software Foundation; 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_tags.php');
$action = get_parameter('action');
switch($action) {
case 'get_tag_agents':
$id_tag = get_parameter('id_tag');
$id_user = get_parameter('id_user');
$keys_prefix = get_parameter('keys_prefix');
$only_meta = get_parameter('only_meta');
$agent_search = get_parameter('agent_search');
$assigned_server = get_parameter('assigned_server');
$show_void_agents = get_parameter('show_void_agents', false);
$no_filter_tag = get_parameter('no_filter_tag', false);
echo wizard_get_tag_agents($id_tag, $id_user, $keys_prefix, $agent_search, $only_meta, $assigned_server, $show_void_agents, $no_filter_tag);
break;
}
function wizard_get_tag_agents($id_tag, $id_user, $keys_prefix, $agent_search, $only_meta, $assigned_server, $show_void_agents, $no_filter_tag) {
global $config;
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$acltags = tags_get_user_module_and_tags($config['id_user']);
$filter['search'] = $agent_search;
$filter['show_void_agents'] = $show_void_agents;
$fields = array ('tagente.id_agente', 'tagente.nombre');
$agents = tags_get_all_user_agents ($id_tag, $id_user, $acltags, $filter, $fields, false, $strict_user);
// Add keys prefix
if (!empty($agents)) {
if ($keys_prefix !== "") {
foreach($agents as $k => $v) {
$agents_aux[$keys_prefix . $k] = $v;
//unset($agents[$k]);
}
}
$agents = $agents_aux;
}
echo json_encode ($agents);
return;
}
?>

View File

@ -22,7 +22,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC141213'; $build_version = 'PC150108';
$pandora_version = 'v6.0dev'; $pandora_version = 'v6.0dev';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -114,8 +114,7 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
* @return array All simple alerts defined for an agent. Empty array if no * @return array All simple alerts defined for an agent. Empty array if no
* alerts found. * alerts found.
*/ */
function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', $allModules = false, $orderby = false, $idGroup = false, $count = false, $strict_user = false, $tag = false) {
$allModules = false, $orderby = false, $idGroup = false, $count = false) {
global $config; global $config;
if (is_array($filter)) { if (is_array($filter)) {
@ -150,6 +149,9 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
break; break;
} }
if ($tag) {
$filter .= ' AND (id_agent_module IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN ('.$tag.')))';
}
if (is_array ($options)) { if (is_array ($options)) {
$filter .= db_format_array_where_clause_sql ($options); $filter .= db_format_array_where_clause_sql ($options);
} }
@ -157,7 +159,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
if (($id_agent !== false) && ($idGroup !== false)) { if (($id_agent !== false) && ($idGroup !== false)) {
$groups = users_get_groups($config["id_user"]); $groups = users_get_groups($config["id_user"]);
$where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo'); //$where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo');
if ($idGroup != 0) { //All group if ($idGroup != 0) { //All group
$subQuery = 'SELECT id_agente_modulo $subQuery = 'SELECT id_agente_modulo
FROM tagente_modulo FROM tagente_modulo
@ -168,6 +170,8 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
FROM tagente_modulo WHERE delete_pending = 0'; FROM tagente_modulo WHERE delete_pending = 0';
} }
if ($strict_user) {
$where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo');
// If there are any errors add imposible condition // If there are any errors add imposible condition
if(in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { if(in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) {
$subQuery .= ' AND 1 = 0'; $subQuery .= ' AND 1 = 0';
@ -176,6 +180,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
$subQuery .= $where_tags; $subQuery .= $where_tags;
} }
} }
}
else if ($id_agent === false) { else if ($id_agent === false) {
if ($allModules) if ($allModules)
$disabled = ''; $disabled = '';

View File

@ -1521,7 +1521,7 @@ function get_alert_fires_in_period ($id_alert_module, $period, $date = 0) {
*/ */
function get_group_alerts($id_group, $filter = '', $options = false, function get_group_alerts($id_group, $filter = '', $options = false,
$where = '', $allModules = false, $orderby = false, $where = '', $allModules = false, $orderby = false,
$idGroup = false, $count = false) { $idGroup = false, $count = false, $strict_user = false, $tag = false) {
global $config; global $config;
@ -1562,16 +1562,18 @@ function get_group_alerts($id_group, $filter = '', $options = false,
break; break;
} }
if ($tag) {
$filter .= ' AND (id_agent_module IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN ('.$tag.')))';
}
if (is_array ($options)) { if (is_array ($options)) {
$filter .= db_format_array_where_clause_sql ($options); $filter .= db_format_array_where_clause_sql ($options);
} }
if ($id_group !== false) { if ($id_group !== false) {
$groups = users_get_groups($config["id_user"]); $groups = users_get_groups($config["id_user"], "AR");
$where_tags = tags_get_acl_tags($config['id_user'], //$where_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo');
array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo');
if ($id_group != 0) { if ($id_group != 0) {
if (is_array($id_group)) { if (is_array($id_group)) {
@ -1610,6 +1612,15 @@ function get_group_alerts($id_group, $filter = '', $options = false,
FROM tagente_modulo WHERE delete_pending = 0'; FROM tagente_modulo WHERE delete_pending = 0';
} }
if ($strict_user) {
$groups = users_get_groups($config["id_user"]);
if ($idGroup !== 0) {
$where_tags = tags_get_acl_tags($config['id_user'], $idGroup, 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true);
} else {
$where_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true);
}
// If there are any errors add imposible condition // If there are any errors add imposible condition
if (in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { if (in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) {
$subQuery .= ' AND 1 = 0'; $subQuery .= ' AND 1 = 0';
@ -1618,6 +1629,7 @@ function get_group_alerts($id_group, $filter = '', $options = false,
$subQuery .= $where_tags; $subQuery .= $where_tags;
} }
} }
}
else { else {
if ($allModules) if ($allModules)
$disabled = ''; $disabled = '';

709
pandora_console/include/functions_api.php Normal file → Executable file

File diff suppressed because it is too large Load Diff

View File

@ -677,36 +677,125 @@ function events_get_description ($id_event) {
* *
* @return int event id * @return int event id
*/ */
function events_create_event ($event, $id_group, $id_agent, $status = 0, $id_user = "", $event_type = "unknown", $priority = 0, $id_agent_module = 0, $id_aam = 0, $critical_instructions = '', $warning_instructions = '', $unknown_instructions = '', $source="Pandora", $tags="", $custom_data="") { function events_create_event ($event, $id_group, $id_agent, $status = 0,
$id_user = "", $event_type = "unknown", $priority = 0,
$id_agent_module = 0, $id_aam = 0, $critical_instructions = '',
$warning_instructions = '', $unknown_instructions = '',
$source="Pandora", $tags="", $custom_data="", $server_id = 0) {
global $config; global $config;
$table_events = 'tevento';
if (defined ('METACONSOLE')) {
$table_events = 'tmetaconsole_event';
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
$sql = sprintf ('INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, $sql = sprintf ('
estado, utimestamp, id_usuario, event_type, criticity, INSERT INTO ' . $table_events . ' (id_agente, id_grupo, evento,
id_agentmodule, id_alert_am, critical_instructions, warning_instructions, unknown_instructions, source, tags, custom_data) timestamp, estado, utimestamp, id_usuario,
VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()), "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s")', event_type, criticity, id_agentmodule, id_alert_am,
$id_agent, $id_group, $event, $status, $id_user, $event_type, critical_instructions, warning_instructions,
$priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, $unknown_instructions, $source, $tags, $custom_data); unknown_instructions, source, tags, custom_data,
server_id)
VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()),
"%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
"%s", "%s", %d)',
$id_agent, $id_group, $event, $status, $id_user,
$event_type, $priority, $id_agent_module, $id_aam,
$critical_instructions, $warning_instructions,
$unknown_instructions, $source, $tags, $custom_data,
$server_id);
break; break;
case "postgresql": case "postgresql":
$sql = sprintf ('INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, $sql = sprintf ('
estado, utimestamp, id_usuario, event_type, criticity, INSERT INTO ' . $table_events . ' (id_agente, id_grupo, evento,
id_agentmodule, id_alert_am, critical_instructions, warning_instructions, unknown_instructions, source, tags, custom_data) timestamp, estado, utimestamp, id_usuario,
VALUES (%d, %d, "%s", NOW(), %d, ceil(date_part(\'epoch\', CURRENT_TIMESTAMP)), "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s")', event_type, criticity, id_agentmodule, id_alert_am,
$id_agent, $id_group, $event, $status, $id_user, $event_type, critical_instructions, warning_instructions,
$priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, $unknown_instructions, $source, $tags, $custom_data); unknown_instructions, source, tags, custom_data,
server_id)
VALUES (%d, %d, "%s", NOW(), %d,
ceil(date_part(\'epoch\', CURRENT_TIMESTAMP)), "%s",
"%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s",
"%s", %d)',
$id_agent, $id_group, $event, $status, $id_user,
$event_type, $priority, $id_agent_module, $id_aam,
$critical_instructions, $warning_instructions,
$unknown_instructions, $source, $tags, $custom_data,
$server_id);
break; break;
case "oracle": case "oracle":
$sql = sprintf ('INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, $sql = sprintf ('
estado, utimestamp, id_usuario, event_type, criticity, INSERT INTO ' . $table_events . ' (id_agente, id_grupo, evento,
id_agentmodule, id_alert_am, critical_instructions, warning_instructions, unknown_instructions, source, tags, custom_data) timestamp, estado, utimestamp, id_usuario,
VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d, ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)), "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s")', event_type, criticity, id_agentmodule, id_alert_am,
$id_agent, $id_group, $event, $status, $id_user, $event_type, critical_instructions, warning_instructions,
$priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, $unknown_instructions, $source, $tags, $custom_data); unknown_instructions, source, tags, custom_data,
server_id)
VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d,
ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)),
"%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
"%s", "%s", %d)',
$id_agent, $id_group, $event, $status, $id_user,
$event_type, $priority, $id_agent_module, $id_aam,
$critical_instructions, $warning_instructions,
$unknown_instructions, $source, $tags, $custom_data,
$server_id);
break; break;
} }
}
else {
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ('
INSERT INTO ' . $table_events . ' (id_agente, id_grupo, evento,
timestamp, estado, utimestamp, id_usuario,
event_type, criticity, id_agentmodule, id_alert_am,
critical_instructions, warning_instructions,
unknown_instructions, source, tags, custom_data)
VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()),
"%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
"%s", "%s")',
$id_agent, $id_group, $event, $status, $id_user,
$event_type, $priority, $id_agent_module, $id_aam,
$critical_instructions, $warning_instructions,
$unknown_instructions, $source, $tags, $custom_data);
break;
case "postgresql":
$sql = sprintf ('
INSERT INTO ' . $table_events . ' (id_agente, id_grupo, evento,
timestamp, estado, utimestamp, id_usuario,
event_type, criticity, id_agentmodule, id_alert_am,
critical_instructions, warning_instructions,
unknown_instructions, source, tags, custom_data)
VALUES (%d, %d, "%s", NOW(), %d,
ceil(date_part(\'epoch\', CURRENT_TIMESTAMP)), "%s",
"%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s",
"%s")',
$id_agent, $id_group, $event, $status, $id_user,
$event_type, $priority, $id_agent_module, $id_aam,
$critical_instructions, $warning_instructions,
$unknown_instructions, $source, $tags, $custom_data);
break;
case "oracle":
$sql = sprintf ('
INSERT INTO ' . $table_events . ' (id_agente, id_grupo, evento,
timestamp, estado, utimestamp, id_usuario,
event_type, criticity, id_agentmodule, id_alert_am,
critical_instructions, warning_instructions,
unknown_instructions, source, tags, custom_data)
VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d,
ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)),
"%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
"%s", "%s")',
$id_agent, $id_group, $event, $status, $id_user,
$event_type, $priority, $id_agent_module, $id_aam,
$critical_instructions, $warning_instructions,
$unknown_instructions, $source, $tags, $custom_data);
break;
}
}
return (int) db_process_sql ($sql, "insert_id"); return (int) db_process_sql ($sql, "insert_id");
} }

View File

@ -401,8 +401,7 @@ function groups_get_icon ($id_group) {
function groups_get_all($groupWithAgents = false) { function groups_get_all($groupWithAgents = false) {
global $config; global $config;
$sql = 'SELECT id_grupo, nombre $sql = 'SELECT id_grupo, nombre FROM tgrupo';
FROM tgrupo';
global $config; global $config;
@ -1133,7 +1132,7 @@ function groups_create_group($group_name, $rest_values){
// Get agents NOT INIT // Get agents NOT INIT
function groups_agent_not_init ($group_array) { function groups_agent_not_init ($group_array, $strict_user = false, $id_group_strict = false) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
@ -1148,6 +1147,19 @@ function groups_agent_not_init ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) {
$tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo
WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))";
$sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0
AND id_grupo=$id_group_strict
AND critical_count = 0
AND warning_count = 0
AND unknown_count = 0
AND (notinit_count > 0 OR total_count = 0)
$tags_clause";
$count = db_get_sql ($sql);
} else {
$count = db_get_sql ("SELECT COUNT(*) $count = db_get_sql ("SELECT COUNT(*)
FROM tagente FROM tagente
WHERE disabled = 0 WHERE disabled = 0
@ -1156,6 +1168,7 @@ function groups_agent_not_init ($group_array) {
AND unknown_count = 0 AND unknown_count = 0
AND (notinit_count > 0 OR total_count = 0) AND (notinit_count > 0 OR total_count = 0)
AND id_grupo IN $group_clause"); AND id_grupo IN $group_clause");
}
return $count > 0 ? $count : 0; return $count > 0 ? $count : 0;
} }
@ -1163,7 +1176,7 @@ function groups_agent_not_init ($group_array) {
// Get unknown agents by using the status code in modules. // Get unknown agents by using the status code in modules.
function groups_agent_unknown ($group_array) { function groups_agent_unknown ($group_array, $strict_user = false, $id_group_strict = false) {
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
@ -1175,12 +1188,24 @@ function groups_agent_unknown ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) {
$tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo
WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))";
$sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0
AND id_grupo=$id_group_strict
AND critical_count=0
AND warning_count=0 AND unknown_count>0
$tags_clause";
$count = db_get_sql ($sql);
} else {
$count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause");
}
return $count > 0 ? $count : 0; return $count > 0 ? $count : 0;
} }
function groups_agent_total($group_array) { function groups_agent_total($group_array, $strict_user = false, $id_group_strict = false) {
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
@ -1192,19 +1217,30 @@ function groups_agent_total($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) {
$tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo
WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))";
$sql = "SELECT COUNT(*) FROM tagente
WHERE tagente.disabled = 0
AND id_grupo = ".$id_group_strict .
$tags_clause;
$count = db_get_sql($sql);
} else {
$count = db_get_sql ("SELECT COUNT(*) $count = db_get_sql ("SELECT COUNT(*)
FROM tagente FROM tagente
WHERE tagente.disabled = 0 WHERE tagente.disabled = 0
AND id_grupo IN $group_clause"); AND id_grupo IN $group_clause");
}
return $count > 0 ? $count : 0; return $count > 0 ? $count : 0;
} }
// Get ok agents by using the status code in modules. // Get ok agents by using the status code in modules.
function groups_agent_ok ($group_array) { function groups_agent_ok ($group_array, $strict_user = false, $id_group_strict = false) {
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
@ -1217,21 +1253,30 @@ function groups_agent_ok ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) {
$tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo
WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))";
$sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0
AND id_grupo=$id_group_strict
AND critical_count=0
AND warning_count=0 AND normal_count = total_count
$tags_clause";
$count = db_get_sql ($sql);
} else {
$count = db_get_sql ("SELECT COUNT(*) $count = db_get_sql ("SELECT COUNT(*)
FROM tagente FROM tagente
WHERE tagente.disabled = 0 WHERE tagente.disabled = 0
AND normal_count = total_count AND normal_count = total_count
AND total_count != 0
AND id_grupo IN $group_clause"); AND id_grupo IN $group_clause");
}
return $count > 0 ? $count : 0; return $count > 0 ? $count : 0;
} }
// Get critical agents by using the status code in modules. // Get critical agents by using the status code in modules.
function groups_agent_critical ($group_array) { function groups_agent_critical ($group_array, $strict_user = false, $id_group_strict = false) {
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
@ -1245,14 +1290,26 @@ function groups_agent_critical ($group_array) {
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
if ($strict_user) {
$tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo
WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))";
$sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0
AND id_grupo=$id_group_strict
AND critical_count>0
$tags_clause";
$count = db_get_sql ($sql);
} else {
$count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo IN $group_clause");
}
return $count > 0 ? $count : 0; return $count > 0 ? $count : 0;
} }
// Get warning agents by using the status code in modules. // Get warning agents by using the status code in modules.
function groups_agent_warning ($group_array) { function groups_agent_warning ($group_array, $strict_user = false, $id_group_strict = false) {
if (empty ($group_array)) { if (empty ($group_array)) {
return 0; return 0;
@ -1265,7 +1322,19 @@ function groups_agent_warning ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) {
$tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo
WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))";
$sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0
AND id_grupo=$id_group_strict
AND critical_count=0
AND warning_count>0
$tags_clause";
$count = db_get_sql ($sql);
} else {
$count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause");
}
return $count > 0 ? $count : 0; return $count > 0 ? $count : 0;
} }
@ -1273,7 +1342,7 @@ function groups_agent_warning ($group_array) {
// Get monitor NOT INIT, except disabled AND async modules // Get monitor NOT INIT, except disabled AND async modules
function groups_monitor_not_init ($group_array) { function groups_monitor_not_init ($group_array, $strict_user = false, $id_group_strict = false) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
@ -1288,15 +1357,29 @@ function groups_monitor_not_init ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
AND tagente_estado.estado = 5
AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente
WHERE disabled = 0
AND tagente.id_grupo = $id_group_strict
) ". $tags_clause);
} else {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
$count = db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
}
return $count > 0 ? $count : 0; return $count > 0 ? $count : 0;
} }
// Get monitor OK, except disabled and non-init // Get monitor OK, except disabled and non-init
function groups_monitor_ok ($group_array) { function groups_monitor_ok ($group_array, $strict_user = false, $id_group_strict = false) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
@ -1311,17 +1394,28 @@ function groups_monitor_ok ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
AND tagente_estado.estado = 0
AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente
WHERE disabled = 0
AND tagente.id_grupo = $id_group_strict
) ". $tags_clause);
} else {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
$count = db_get_sql ("SELECT SUM(normal_count) $count = db_get_sql ("SELECT SUM(normal_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
FROM tagente }
WHERE disabled = 0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0; return $count > 0 ? $count : 0;
} }
// Get monitor CRITICAL, except disabled and non-init // Get monitor CRITICAL, except disabled and non-init
function groups_monitor_critical ($group_array) { function groups_monitor_critical ($group_array, $strict_user = false, $id_group_strict = false) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
@ -1336,17 +1430,28 @@ function groups_monitor_critical ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
AND tagente_estado.estado = 1
AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente
WHERE disabled = 0
AND tagente.id_grupo = $id_group_strict
) ". $tags_clause);
} else {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
$count = db_get_sql ("SELECT SUM(critical_count) $count = db_get_sql ("SELECT SUM(critical_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
FROM tagente }
WHERE disabled = 0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0; return $count > 0 ? $count : 0;
} }
// Get monitor WARNING, except disabled and non-init // Get monitor WARNING, except disabled and non-init
function groups_monitor_warning ($group_array) { function groups_monitor_warning ($group_array, $strict_user = false, $id_group_strict = false) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
@ -1361,15 +1466,27 @@ function groups_monitor_warning ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
AND tagente_estado.estado = 2
AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente
WHERE disabled = 0
AND tagente.id_grupo = $id_group_strict
) ". $tags_clause);
} else {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
$count = db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
}
return $count > 0 ? $count : 0; return $count > 0 ? $count : 0;
} }
// Get monitor UNKNOWN, except disabled and non-init // Get monitor UNKNOWN, except disabled and non-init
function groups_monitor_unknown ($group_array) { function groups_monitor_unknown ($group_array, $strict_user = false, $id_group_strict = false) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
@ -1384,17 +1501,27 @@ function groups_monitor_unknown ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
AND tagente_estado.estado = 3
AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente
WHERE disabled = 0
AND tagente.id_grupo = $id_group_strict
) ". $tags_clause);
} else {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
$count = db_get_sql ("SELECT SUM(unknown_count) $count = db_get_sql ("SELECT SUM(unknown_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
FROM tagente }
WHERE disabled = 0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0; return $count > 0 ? $count : 0;
} }
// Get alerts defined for a given group, except disabled // Get alerts defined for a given group, except disabled
function groups_monitor_alerts ($group_array) { function groups_monitor_alerts ($group_array, $strict_user = false, $id_group_strict = false) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
@ -1409,8 +1536,23 @@ function groups_monitor_alerts ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$sql = "SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
WHERE tagente.id_grupo = $id_group_strict AND tagente_modulo.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
AND talert_template_modules.disabled = 0
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
$tags_clause";
$count = db_get_sql ($sql);
return $count;
} else {
//TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT(talert_template_modules.id) return db_get_sql ("SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente
@ -1418,11 +1560,12 @@ function groups_monitor_alerts ($group_array) {
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
AND talert_template_modules.disabled = 0 AND talert_template_modules.disabled = 0
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"); AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo");
}
} }
// Get alert configured currently FIRED, except disabled // Get alert configured currently FIRED, except disabled
function groups_monitor_fired_alerts ($group_array) { function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_group_strict = false) {
// If there are not groups to query, we jump to nextone // If there are not groups to query, we jump to nextone
@ -1437,8 +1580,23 @@ function groups_monitor_fired_alerts ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$sql = "SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
WHERE tagente.id_grupo = $id_group_strict AND tagente_modulo.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
AND talert_template_modules.disabled = 0
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
AND times_fired > 0 ".$tags_clause;
$count = db_get_sql ($sql);
return $count;
} else {
//TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT(talert_template_modules.id) return db_get_sql ("SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente
@ -1447,6 +1605,8 @@ function groups_monitor_fired_alerts ($group_array) {
AND talert_template_modules.disabled = 0 AND talert_template_modules.disabled = 0
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
AND times_fired > 0"); AND times_fired > 0");
}
} }
/** /**
@ -1645,8 +1805,6 @@ function groups_get_tree(&$groups, $parent = false) {
return $return; return $return;
} }
function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) {
global $config; global $config;
@ -1661,12 +1819,10 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) {
$propagate = db_get_value('propagate','tgrupo','id_grupo',$parent); $propagate = db_get_value('propagate','tgrupo','id_grupo',$parent);
if ($propagate == 1) { if ($propagate == 1) {
//$childrens_ids_parent = array($parent);
$hierarchy[] = $parent; $hierarchy[] = $parent;
$childrens = groups_get_childrens($parent); $childrens = groups_get_childrens($parent);
if (!empty($childrens)) { if (!empty($childrens)) {
foreach ($childrens as $child) { foreach ($childrens as $child) {
//$childrens_ids_parent[] = (int)$child['id_grupo'];
$hierarchy[] = (int)$child['id_grupo']; $hierarchy[] = (int)$child['id_grupo'];
} }
} }
@ -1677,4 +1833,325 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) {
} }
return $hierarchy; return $hierarchy;
} }
function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group') {
global $config;
if ($id_user == false) {
$id_user = $config['id_user'];
}
$user_groups = array();
$user_tags = array();
foreach ($acltags as $group => $tags) {
if ($user_strict) { //Remove groups with tags
if ($tags == '') {
$groups_without_tags[$group] = $group;
}
}
$user_groups[$group] = groups_get_name($group);
if ($tags != '') {
$tags_group = explode(',', $tags);
foreach ($tags_group as $tag) {
$user_tags[$tag] = tags_get_name($tag);
}
}
}
if ($user_strict) {
$user_groups_ids = implode(',',array_keys($groups_without_tags));
} else {
$user_groups_ids = implode(',',array_keys($acltags));
}
if ($user_groups_ids == '') {
$user_groups_ids == -1;
}
switch ($config["dbtype"]) {
case "mysql":
$list_groups = db_get_all_rows_sql("
SELECT *
FROM tgrupo
WHERE id_grupo IN (" . $user_groups_ids . ")
ORDER BY nombre COLLATE utf8_general_ci ASC");
break;
case "postgresql":
$list_groups = db_get_all_rows_sql("
SELECT *
FROM tgrupo
WHERE id_grupo IN (" . $user_groups_ids . ")
ORDER BY nombre ASC");
break;
case "oracle":
$list_groups = db_get_all_rows_sql("
SELECT *
FROM tgrupo
WHERE id_grupo IN (" . $user_groups_ids . ")
ORDER BY nombre COLLATE utf8_general_ci ASC");
break;
}
if ($list_groups == false) {
$list_groups = array();
}
if ($returnAllGroup) {
$i = 1;
$list[0]['_id_'] = 0;
$list[0]['_name_'] = __('All');
} else {
$i = 0;
}
foreach ($list_groups as $key => $item) {
$id = $item['id_grupo'];
if (($config["realtimestats"] == 0) && !$user_strict) {
$group_stat = db_get_all_rows_sql ("SELECT *
FROM tgroup_stat, tgrupo
WHERE tgrupo.id_grupo = tgroup_stat.id_group
AND tgroup_stat.id_group = $id
ORDER BY nombre");
$list[$i]['_id_'] = $id;
$list[$i]['_name_'] = $item['nombre'];
$list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;'));
$list[$i]['_agents_unknown_'] = $group_stat[0]["unknown"];
$list[$i]['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"];
$list[$i]['_total_agents_'] = $group_stat[0]["agents"];
if ($mode == 'tactical') {
$list[$i]['_agents_ok_'] = $group_stat[0]["normal"];
$list[$i]['_agents_warning_'] = $group_stat[0]["warning"];
$list[$i]['_agents_critical_'] = $group_stat[0]["critical"];
$list[$i]['_monitors_alerts_'] = $group_stat[0]["alerts"];
}
// This fields are not in database
$list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id);
$list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id);
$list[$i]['_monitors_warning_'] = groups_monitor_warning($id, $user_strict, $id);
$list[$i]['_monitors_unknown_'] = groups_monitor_unknown($id, $user_strict, $id);
$list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id);
$list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id);
if ($returnAllGroup) {
$list[0]['_agents_unknown_'] += $group_stat[0]["unknown"];
$list[0]['_monitors_alerts_fired_'] += $group_stat[0]["alerts_fired"];
$list[0]['_total_agents_'] += $group_stat[0]["agents"];
$list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_'];
$list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_'];
$list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_'];
$list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_'];
$list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_'];
$list[0]['_agents_not_init'] += $list[$i]['_agents_not_init'];
if ($mode == 'tactical') {
$list[0]['_agents_ok_'] += $group_stat[0]["normal"];
$list[0]['_agents_warning_'] += $group_stat[0]["warning"];
$list[0]['_agents_critical_'] += $group_stat[0]["critical"];
$list[0]['_monitors_alerts_'] += $group_stat[0]["alerts"];
}
}
if ($mode == 'group') {
if (! defined ('METACONSOLE')) {
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
unset($list[$i]);
}
} else {
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) {
unset($list[$i]);
}
}
}
} else {
$list[$i]['_id_'] = $id;
$list[$i]['_name_'] = $item['nombre'];
$list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;'));
$list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id);
$list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id);
$list[$i]['_monitors_warning_'] = groups_monitor_warning($id, $user_strict, $id);
$list[$i]['_agents_unknown_'] = groups_agent_unknown ($id, $user_strict, $id);
$list[$i]['_monitors_alerts_fired_'] = groups_monitor_fired_alerts ($id, $user_strict, $id);
$list[$i]['_total_agents_'] = groups_agent_total ($id, $user_strict, $id);
$list[$i]['_monitors_unknown_'] = groups_monitor_unknown($id, $user_strict, $id);
$list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id);
$list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id);
if ($mode == 'tactical') {
$list[$i]['_agents_ok_'] = groups_agent_ok ($id, $user_strict, $id);
$list[$i]['_agents_warning_'] = groups_agent_warning ($id, $user_strict, $id);
$list[$i]['_agents_critical_'] = groups_agent_critical ($id, $user_strict, $id);
$list[$i]['_monitors_alerts_'] = groups_monitor_alerts ($id, $user_strict, $id);
}
if ($returnAllGroup) {
$list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_'];
$list[0]['_monitors_alerts_fired_'] += $list[$i]['_monitors_alerts_fired_'];
$list[0]['_total_agents_'] += $list[$i]['_total_agents_'];
$list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_'];
$list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_'];
$list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_'];
$list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_'];
$list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_'];
$list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init'];
if ($mode == 'tactical') {
$list[0]['_agents_ok_'] += $list[$i]['_agents_ok_'];
$list[0]['_agents_warning_'] += $list[$i]['_agents_warning_'];
$list[0]['_agents_critical_'] += $list[$i]['_agents_critical_'];
$list[0]['_monitors_alerts_'] += $list[$i]['_monitors_alerts_'];
}
}
if ($mode == 'group') {
if (! defined ('METACONSOLE')) {
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
unset($list[$i]);
}
} else {
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) {
unset($list[$i]);
}
}
}
}
$i++;
}
if ($user_strict) {
foreach ($user_tags as $group_id => $tag_name) {
$id = db_get_value('id_tag', 'ttag', 'name', $tag_name);
$list[$i]['_id_'] = $id;
$list[$i]['_name_'] = $tag_name;
$list[$i]['_iconImg_'] = html_print_image ("images/tag_red.png", true, array ("style" => 'vertical-align: middle;'));
$list[$i]['_is_tag_'] = 1;
$list[$i]['_total_agents_'] = tags_total_agents ($id, $acltags);
$list[$i]['_agents_unknown_'] = tags_get_unknown_agents ($id, $acltags);
$list[$i]['_monitors_ok_'] = tags_monitors_ok ($id, $acltags);
$list[$i]['_monitors_critical_'] = tags_monitors_critical ($id, $acltags);
$list[$i]['_monitors_warning_'] = tags_monitors_warning ($id, $acltags);
$list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags);
if ($mode == 'tactical') {
$list[$i]['_agents_ok_'] = tags_agent_ok ($id, $acltags);
$list[$i]['_agents_warning_'] = tags_agent_warning ($id, $acltags);
$list[$i]['_agents_critical_'] = tags_get_critical_agents ($id, $acltags);
$list[$i]['_monitors_alerts_'] = tags_get_monitors_alerts ($id, $acltags);
}
if ($returnAllGroup) {
$list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_'];
$list[0]['_monitors_alerts_fired_'] += $list[$i]['_monitors_alerts_fired_'];
$list[0]['_total_agents_'] += $list[$i]['_total_agents_'];
$list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_'];
$list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_'];
$list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_'];
$list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_'];
$list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_'];
if ($mode == 'tactical') {
$list[0]['_agents_ok_'] += $list[$i]['_agents_ok_'];
$list[0]['_agents_warning_'] += $list[$i]['_agents_warning_'];
$list[0]['_agents_critical_'] += $list[$i]['_agents_critical_'];
$list[0]['_monitors_alerts_'] += $list[$i]['_monitors_alerts_'];
}
}
if ($mode == 'group') {
if (! defined ('METACONSOLE')) {
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
unset($list[$i]);
}
} else {
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) {
unset($list[$i]);
}
}
}
$i++;
}
}
return $list;
}
function group_get_groups_list($id_user = false, $user_strict = false, $access = 'AR', $force_group_and_tag = true, $returnAllGroup = false, $mode = 'group') {
global $config;
if ($id_user == false) {
$id_user = $config['id_user'];
}
$acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict);
if (! defined ('METACONSOLE')) {
$result_list = group_get_data ($id_user, $user_strict, $acltags, $returnAllGroup, $mode);
return $result_list;
} else {
$servers = db_get_all_rows_sql ("
SELECT *
FROM tmetaconsole_setup
WHERE disabled = 0");
if ($servers === false) {
$servers = array();
}
$result_list = array ();
foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR) {
continue;
}
$server_list = group_get_data ($id_user, $user_strict, $acltags, $returnAllGroup, $mode);
foreach ($server_list as $server_item) {
if (! isset ($result_list[$server_item['_name_']])) {
$result_list[$server_item['_name_']] = $server_item;
}
else {
$result_list[$server_item['_name_']]['_monitors_ok_'] += $server_item['_monitors_ok_'];
$result_list[$server_item['_name_']]['_monitors_critical_'] += $server_item['_monitors_critical_'];
$result_list[$server_item['_name_']]['_monitors_warning_'] += $server_item['_monitors_warning_'];
$result_list[$server_item['_name_']]['_agents_unknown_'] += $server_item['_agents_unknown_'];
$result_list[$server_item['_name_']]['_total_agents_'] += $server_item['_total_agents_'];
$result_list[$server_item['_name_']]['_monitors_alerts_fired_'] += $server_item['_monitors_alerts_fired_'];
if ($mode == 'tactical') {
$result_list[$server_item['_name_']]['_agents_ok_'] += $server_item['_agents_ok_'];
$result_list[$server_item['_name_']]['_agents_critical_'] += $server_item['_agents_critical_'];
$result_list[$server_item['_name_']]['_agents_warning_'] += $server_item['_agents_warning_'];
$result_list[$server_item['_name_']]['_monitors_alerts_'] += $server_item['_monitors_alerts_'];
}
}
}
metaconsole_restore_db();
}
return $result_list;
}
}
function groups_get_group_deep ($id_group) {
global $config;
$parents = groups_get_parents($id_group, false);
if (empty($parents)) {
$deep = "";
} else {
$deep = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;", count($parents));
}
return $deep;
}
?> ?>

View File

@ -368,13 +368,36 @@ function html_print_select_groups($id_user = false, $privilege = "AR",
$nothing = '', $nothing_value = 0, $return = false, $nothing = '', $nothing_value = 0, $return = false,
$multiple = false, $sort = true, $class = '', $disabled = false, $multiple = false, $sort = true, $class = '', $disabled = false,
$style = false, $option_style = false, $id_group = false, $style = false, $option_style = false, $id_group = false,
$keys_field = 'id_grupo') { $keys_field = 'id_grupo', $strict_user = false) {
global $config; global $config;
$fields = users_get_groups_for_select($id_user, $privilege, $fields = users_get_groups_for_select($id_user, $privilege,
$returnAllGroup, true, $id_group, $keys_field); $returnAllGroup, true, $id_group, $keys_field);
if ($strict_user) {
foreach ($fields as $id => $group_name) {
$sql = "SELECT tags FROM tusuario_perfil WHERE id_usuario = '$id_user' AND id_grupo = $id";
$group_has_tag = db_get_value_sql ($sql);
if (!$group_has_tag) {
$sql_parent = "SELECT parent FROM tgrupo WHERE id_grupo = $id AND propagate = 1";
$id_parent = db_get_value_sql($sql_parent);
if ($id_parent) {
$sql_parent_aux = "SELECT tags FROM tusuario_perfil WHERE id_usuario = '$id_user' AND id_grupo = $id_parent";
$parent_has_tag = db_get_value_sql ($sql_parent_aux);
if ($parent_has_tag) {
unset($fields[$id]);
}
}
} else {
unset($fields[$id]);
}
}
}
$output = html_print_select ($fields, $name, $selected, $script, $output = html_print_select ($fields, $name, $selected, $script,
$nothing, $nothing_value, $return, $multiple, false, $class, $nothing, $nothing_value, $return, $multiple, false, $class,
$disabled, $style, $option_style); $disabled, $style, $option_style);
@ -1467,21 +1490,12 @@ function html_print_table (&$table, $return = false) {
$style[$key] = ''; $style[$key] = '';
} }
$output .= '<td ' . $output .= '<td id="'.$tableid.'-'.$keyrow.'-'.$key.'" style="'. $cellstyle[$keyrow][$key].$style[$key].$valign[$key].$align[$key].$size[$key].$wrap[$key] .'" '.$colspan[$keyrow][$key].' '.$rowspan[$keyrow][$key].' class="' . $class . ' ' . $cellclass[$keyrow][$key] . '">'. $item .'</td>'."\n";
'id="' . $tableid . '-' . $keyrow . '-' . $key . '" ' .
'style="' . $cellstyle[$keyrow][$key] .
$style[$key] . $valign[$key] . $align[$key] .
$size[$key] . $wrap[$key] . '" ' .
$colspan[$keyrow][$key] . ' ' .
$rowspan[$keyrow][$key] . ' ' .
'class="' . $class . ' ' .
$cellclass[$keyrow][$key] . '">' .
$item . '</td>' . "\n";
} }
$output .= '</tr>' . "\n"; $output .= '</tr>'."\n";
} }
} }
$output .= '</tbody></table>' . "\n"; $output .= '</tbody></table>'."\n";
if ($return) if ($return)
return $output; return $output;

View File

@ -62,17 +62,39 @@ function tags_agent_unknown ($id_tag) {
* *
* @return mixed Returns count of agents with this tag or false if they aren't. * @return mixed Returns count of agents with this tag or false if they aren't.
*/ */
function tags_total_agents ($id_tag) { function tags_total_agents ($id_tag, $groups_and_tags = array()) {
// Avoid mysql error // Avoid mysql error
if (empty($id_tag)) if (empty($id_tag))
return; return;
$groups_clause = "";
if (!empty($groups_and_tags)) {
$i = 0;
foreach ($groups_and_tags as $group_id => $tags) {
if ($tags != "") {
$tags_arr = explode(',', $tags);
foreach ($tags_arr as $tag) {
if ($tag == $id_tag) {
if ($i == 0) {
$groups_id = $group_id;
} else {
$groups_id .= ','.$group_id;
}
$i++;
}
}
}
}
$groups_clause = " AND tagente.id_grupo IN ($groups_id)";
}
$total_agents = "SELECT COUNT(DISTINCT tagente.id_agente) $total_agents = "SELECT COUNT(DISTINCT tagente.id_agente)
FROM tagente, tagente_modulo, ttag_module FROM tagente, tagente_modulo, ttag_module
WHERE tagente.id_agente = tagente_modulo.id_agente WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo
AND ttag_module.id_tag = " . $id_tag; AND ttag_module.id_tag = " . $id_tag .
$groups_clause;
return db_get_sql ($total_agents); return db_get_sql ($total_agents);
} }
@ -84,7 +106,28 @@ function tags_total_agents ($id_tag) {
* *
* @return mixed Returns count of agents in normal status or false if they aren't. * @return mixed Returns count of agents in normal status or false if they aren't.
*/ */
function tags_agent_ok ($id_tag) { function tags_agent_ok ($id_tag, $groups_and_tags = array()) {
$groups_clause = "";
if (!empty($groups_and_tags)) {
$i = 0;
foreach ($groups_and_tags as $group_id => $tags) {
if ($tags != "") {
$tags_arr = explode(',', $tags);
foreach ($tags_arr as $tag) {
if ($tag == $id_tag) {
if ($i == 0) {
$groups_id = $group_id;
} else {
$groups_id .= ','.$group_id;
}
$i++;
}
}
}
}
$groups_clause = " AND tagente.id_grupo IN ($groups_id)";
}
return db_get_sql ("SELECT COUNT(*) return db_get_sql ("SELECT COUNT(*)
FROM tagente, tagente_modulo, ttag_module FROM tagente, tagente_modulo, ttag_module
@ -92,7 +135,8 @@ function tags_agent_ok ($id_tag) {
AND tagente.disabled=0 AND tagente.disabled=0
AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo
AND ttag_module.id_tag = $id_tag AND ttag_module.id_tag = $id_tag
AND normal_count=total_count"); AND normal_count=total_count
$groups_clause");
} }
/** /**
@ -102,7 +146,7 @@ function tags_agent_ok ($id_tag) {
* *
* @return mixed Returns count of agents in warning status or false if they aren't. * @return mixed Returns count of agents in warning status or false if they aren't.
*/ */
function tags_agent_warning ($id_tag) { function tags_agent_warning ($id_tag, $groups_and_tags = array()) {
return db_get_sql ("SELECT COUNT(*) return db_get_sql ("SELECT COUNT(*)
FROM tagente, tagente_modulo, ttag_module FROM tagente, tagente_modulo, ttag_module
@ -203,7 +247,7 @@ function tags_create_tag($values) {
return false; return false;
} }
return db_process_sql_insert('ttag', $values); return db_process_sql_insert('ttag',$values);
} }
/** /**
@ -657,10 +701,7 @@ function tags_get_tags_formatted ($tags_array, $get_url = true) {
* @return mixed/string Tag ids * @return mixed/string Tag ids
*/ */
function tags_get_acl_tags($id_user, $id_group, $access = 'AR', function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = 'module_condition', $query_prefix = '', $query_table = '', $meta = false, $childrens_ids = array(), $force_group_and_tag = false) {
$return_mode = 'module_condition', $query_prefix = '',
$query_table = '', $meta = false, $childrens_ids = array(),
$force_group_and_tag = false) {
global $config; global $config;
@ -680,6 +721,10 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR',
} }
} }
if ($id_group[0] != 0) {
$id_group = groups_get_all_hierarchy_group ($id_group[0]);
}
if ((string)$id_group === "0") { if ((string)$id_group === "0") {
$id_group = array_keys(users_get_groups($id_user, $access, false)); $id_group = array_keys(users_get_groups($id_user, $access, false));
@ -694,10 +739,6 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR',
$id_group = (array) $id_group; $id_group = (array) $id_group;
} }
if ($id_group[0] != 0) {
$id_group = groups_get_all_hierarchy_group ($id_group[0]);
}
$acl_column = get_acl_column($access); $acl_column = get_acl_column($access);
if (empty($acl_column)) { if (empty($acl_column)) {
@ -777,7 +818,7 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR',
break; break;
case 'module_condition': case 'module_condition':
// Return the condition of the tags for tagente_modulo table // Return the condition of the tags for tagente_modulo table
$condition = tags_get_acl_tags_module_condition($acltags, $query_table); $condition = tags_get_acl_tags_module_condition($acltags, $query_table, true);
if (!empty($condition)) { if (!empty($condition)) {
return " $query_prefix " . $condition; return " $query_prefix " . $condition;
} }
@ -820,10 +861,6 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
if ($i == 0) if ($i == 0)
$condition .= ' ( '; $condition .= ' ( ';
// Group condition (The module belongs to an agent of the group X) // Group condition (The module belongs to an agent of the group X)
// Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition // Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition
if (!array_key_exists(0, $acltags)) { if (!array_key_exists(0, $acltags)) {
@ -835,20 +872,21 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
$group_condition = " 1 = 1 "; $group_condition = " 1 = 1 ";
} }
//When the acl is only group without tags //When the acl is only group without tags
if (empty($group_tags)) { if (empty($group_tags)) {
$condition .= "($group_condition)\n"; $condition .= "($group_condition)\n";
} }
else { else {
if (is_array($group_tags)) {
$group_tags_query = implode(',',$group_tags);
} else {
$group_tags_query = $group_tags;
}
// Tags condition (The module has at least one of the restricted tags) // Tags condition (The module has at least one of the restricted tags)
$tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, implode(',',$group_tags)); $tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, $group_tags_query);
$condition .= "($group_condition AND \n$tags_condition)\n"; $condition .= "($group_condition AND \n$tags_condition)\n";
} }
$i++; $i++;
} }
@ -896,6 +934,10 @@ function tags_get_acl_tags_event_condition($acltags, $meta = false, $force_group
if (empty($group_tags)) { if (empty($group_tags)) {
$tags_condition = "id_grupo = ".$group_id; $tags_condition = "id_grupo = ".$group_id;
} else { } else {
if (!is_array($group_tags)) {
$group_tags = explode(',', $group_tags);
}
foreach ($group_tags as $tag) { foreach ($group_tags as $tag) {
// If the tag ID doesnt exist, ignore // If the tag ID doesnt exist, ignore
if (!isset($all_tags[$tag])) { if (!isset($all_tags[$tag])) {
@ -1021,17 +1063,17 @@ function tags_get_user_tags($id_user = false, $access = 'AR') {
FROM tusuario_perfil, tperfil FROM tusuario_perfil, tperfil
WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND
tusuario_perfil.id_usuario = '%s' AND tusuario_perfil.id_usuario = '%s' AND
tperfil.%s = 1 AND tags = ''", tperfil.%s = 1 AND tags <> ''",
$id_user, $acl_column); $id_user, $acl_column);
$profiles_without_tags = db_get_value_sql($query); $profiles_without_tags = db_get_value_sql($query);
if ($profiles_without_tags > 0) { if ($profiles_without_tags == 0) {
return $all_tags; return $all_tags;
} }
// Get the tags of the required access flag for each group // Get the tags of the required access flag for each group
$tags = tags_get_acl_tags($id_user, 0, $access, 'data'); $tags = tags_get_acl_tags($id_user, 0, $access, 'data','','', true, array(), true);
// Merge the tags to get an array with all of them // Merge the tags to get an array with all of them
$user_tags_id = array(); $user_tags_id = array();
@ -1054,7 +1096,6 @@ function tags_get_user_tags($id_user = false, $access = 'AR') {
$user_tags[$id] = $all_tags[$id]; $user_tags[$id] = $all_tags[$id];
} }
return $user_tags; return $user_tags;
} }
@ -1351,4 +1392,430 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags = array(), $c
return false; return false;
} }
/**
* Get unknown agents filtering by id_tag.
*
* @param int $id_tag Id of the tag to search unknown agents
*
* @return mixed Returns count of unknown agents with this tag or false if they aren't.
*/
function tags_get_unknown_agents ($id_tag, $groups_and_tags = array()) {
// Avoid mysql error
if (empty($id_tag))
return;
$groups_clause = "";
if (!empty($groups_and_tags)) {
$i = 0;
foreach ($groups_and_tags as $group_id => $tags) {
if ($tags != "") {
$tags_arr = explode(',', $tags);
foreach ($tags_arr as $tag) {
if ($tag == $id_tag) {
if ($i == 0) {
$groups_id = $group_id;
} else {
$groups_id .= ','.$group_id;
}
$i++;
}
}
}
}
$groups_clause = " AND tagente.id_grupo IN ($groups_id)";
}
$total_agents = "SELECT COUNT(DISTINCT tagente.id_agente)
FROM tagente, tagente_modulo, ttag_module
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo
AND ttag_module.id_tag = " . $id_tag . "
AND tagente.critical_count=0
AND tagente.warning_count=0
AND tagente.unknown_count>0
$groups_clause";
return db_get_sql ($total_agents);
}
function tags_monitors_ok ($id_tag, $groups_and_tags = array()) {
// Avoid mysql error
if (empty($id_tag))
return;
$groups_clause = "";
if (!empty($groups_and_tags)) {
$i = 0;
foreach ($groups_and_tags as $group_id => $tags) {
if ($tags != "") {
$tags_arr = explode(',', $tags);
foreach ($tags_arr as $tag) {
if ($tag == $id_tag) {
if ($i == 0) {
$groups_id = $group_id;
} else {
$groups_id .= ','.$group_id;
}
$i++;
}
}
}
}
$groups_clause = " AND id_grupo IN ($groups_id)";
}
$sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
AND tagente_estado.estado = 0
AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente
WHERE disabled = 0
$groups_clause)
AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module
WHERE ttag_module.id_tag = " . $id_tag .")";
$count = db_get_sql ($sql);
return $count;
}
function tags_monitors_critical ($id_tag, $groups_and_tags = array()) {
// Avoid mysql error
if (empty($id_tag))
return;
$groups_clause = "";
if (!empty($groups_and_tags)) {
$i = 0;
foreach ($groups_and_tags as $group_id => $tags) {
if ($tags != "") {
$tags_arr = explode(',', $tags);
foreach ($tags_arr as $tag) {
if ($tag == $id_tag) {
if ($i == 0) {
$groups_id = $group_id;
} else {
$groups_id .= ','.$group_id;
}
$i++;
}
}
}
}
$groups_clause = " AND id_grupo IN ($groups_id)";
}
$sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
AND tagente_estado.estado = 1
AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente
WHERE disabled = 0
$groups_clause)
AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module
WHERE ttag_module.id_tag = " . $id_tag .")";
$count = db_get_sql ($sql);
return $count;
}
function tags_monitors_warning ($id_tag, $groups_and_tags = array()) {
// Avoid mysql error
if (empty($id_tag))
return;
$groups_clause = "";
if (!empty($groups_and_tags)) {
$i = 0;
foreach ($groups_and_tags as $group_id => $tags) {
if ($tags != "") {
$tags_arr = explode(',', $tags);
foreach ($tags_arr as $tag) {
if ($tag == $id_tag) {
if ($i == 0) {
$groups_id = $group_id;
} else {
$groups_id .= ','.$group_id;
}
$i++;
}
}
}
}
$groups_clause = " AND id_grupo IN ($groups_id)";
}
$sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
AND tagente_estado.estado = 2
AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente
WHERE disabled = 0
$groups_clause)
AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module
WHERE ttag_module.id_tag = " . $id_tag .")";
$count = db_get_sql ($sql);
return $count;
}
function tags_monitors_fired_alerts ($id_tag, $groups_and_tags = array()) {
// Avoid mysql error
if (empty($id_tag))
return;
$groups_clause = "";
if (!empty($groups_and_tags)) {
$i = 0;
foreach ($groups_and_tags as $group_id => $tags) {
if ($tags != "") {
$tags_arr = explode(',', $tags);
foreach ($tags_arr as $tag) {
if ($tag == $id_tag) {
if ($i == 0) {
$groups_id = $group_id;
} else {
$groups_id .= ','.$group_id;
}
$i++;
}
}
}
}
$groups_clause = " AND tagente.id_grupo IN ($groups_id)";
}
$sql = "SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
WHERE tagente_modulo.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
AND talert_template_modules.disabled = 0
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
AND times_fired > 0
AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag)
$groups_clause";
$count = db_get_sql ($sql);
return $count;
}
/* Return array with groups and their tags */
function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $strict_user = false) {
global $config;
if ($id_user == false) {
$id_user = $config['id_user'];
}
$acl_column = get_acl_column($access);
$query = sprintf("SELECT tags, id_grupo
FROM tusuario_perfil, tperfil
WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND
tusuario_perfil.id_usuario = '%s' AND
tperfil.%s = 1
ORDER BY id_grupo", $id_user, $acl_column);
$tags_and_groups = db_get_all_rows_sql($query);
if ($tags_and_groups == false) {
$tags_and_groups = array();
}
$acltags = array();
if ((count($tags_and_groups) == 1) && ($tags_and_groups[0]['id_grupo'] == 0) && ($tags_and_groups[0]['tags'] == '')){ //user with all groups without tags
$all_groups = groups_get_all();
foreach ($all_groups as $id => $name) {
$acltags[$id] = '';
}
} else {
foreach ($tags_and_groups as $group_tag) {
$acltags[$group_tag['id_grupo']] = $group_tag['tags'];
$propagate = db_get_value('propagate', 'tgrupo', 'id_grupo', $group_tag['id_grupo']);
if ($propagate) {
$sql = "SELECT id_grupo FROM tgrupo WHERE parent = " .$group_tag['id_grupo'];
$children = db_get_all_rows_sql($sql);
if ($children == false) {
$children = array();
}
foreach ($children as $group) {
$acltags[$group['id_grupo']] = $group_tag['tags'];
}
}
}
}
return $acltags;
}
/**
* Get unknown agents filtering by id_tag.
*
* @param int $id_tag Id of the tag to search unknown agents
*
* @return mixed Returns count of unknown agents with this tag or false if they aren't.
*/
function tags_get_critical_agents ($id_tag, $groups_and_tags = array()) {
// Avoid mysql error
if (empty($id_tag))
return;
$groups_clause = "";
if (!empty($groups_and_tags)) {
$i = 0;
foreach ($groups_and_tags as $group_id => $tags) {
if ($tags != "") {
$tags_arr = explode(',', $tags);
foreach ($tags_arr as $tag) {
if ($tag == $id_tag) {
if ($i == 0) {
$groups_id = $group_id;
} else {
$groups_id .= ','.$group_id;
}
$i++;
}
}
}
}
$groups_clause = " AND tagente.id_grupo IN ($groups_id)";
}
$total_agents = "SELECT COUNT(DISTINCT tagente.id_agente)
FROM tagente, tagente_modulo, ttag_module
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo
AND ttag_module.id_tag = " . $id_tag . "
AND tagente.critical_count>0
$groups_clause";
return db_get_sql ($total_agents);
}
function tags_get_monitors_alerts ($id_tag, $groups_and_tags = array()) {
// Avoid mysql error
if (empty($id_tag))
return;
$groups_clause = "";
if (!empty($groups_and_tags)) {
$i = 0;
foreach ($groups_and_tags as $group_id => $tags) {
if ($tags != "") {
$tags_arr = explode(',', $tags);
foreach ($tags_arr as $tag) {
if ($tag == $id_tag) {
if ($i == 0) {
$groups_id = $group_id;
} else {
$groups_id .= ','.$group_id;
}
$i++;
}
}
}
}
$groups_clause = " AND tagente.id_grupo IN ($groups_id)";
}
$sql = "SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
WHERE tagente_modulo.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND tagente.disabled = 0
AND talert_template_modules.disabled = 0
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag)
$groups_clause";
$count = db_get_sql ($sql);
return $count;
}
/**
* Get agents filtering by id_tag.
*
* @param int $id_tag Id of the tag to search total agents
*
* @return mixed Returns count of agents with this tag or false if they aren't.
*/
function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags = array(), $filter = false, $fields = false, $meta = true, $strict_user = true) {
global $config;
// Avoid mysql error
if (empty($id_tag))
return;
if (empty($id_user)) {
$id_user = $config['id_user'];
}
if (!is_array ($fields)) {
$fields = array ();
$fields[0] = "id_agente";
$fields[1] = "nombre";
}
$select_fields = implode(',',$fields);
$groups_clause = "";
if ($strict_user) {
if (!empty($groups_and_tags)) {
$groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo");
}
} else {
$groups_clause = " AND tagente.id_grupo IN (".implode(',',$groups_and_tags).")";
}
$search_sql = "";
$void_agents = "";
if ($filter) {
if (($filter['search']) != "") {
$string = io_safe_input ($filter['search']);
$search_sql = ' AND (tagente.nombre COLLATE utf8_general_ci LIKE "%'.$string.'%")';
}
if (isset($filter['show_void_agents'])) {
if (!$filter['show_void_agents']) {
$void_agents = " AND tagente_modulo.delete_pending = 0";
}
}
}
$user_agents_sql = "SELECT ".$select_fields ."
FROM tagente, tagente_modulo, ttag_module
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo
AND ttag_module.id_tag = " . $id_tag .
$groups_clause . $search_sql . $void_agents .
" ORDER BY tagente.nombre ASC";
$user_agents = db_get_all_rows_sql($user_agents_sql);
if (!$meta){
$user_agents_aux = array();
if ($user_agents === false) {
$user_agents = array();
}
foreach ($user_agents as $ua) {
$user_agents_aux[$ua['id_agente']] = $ua['nombre'];
}
return $user_agents_aux;
}
return $user_agents;
}
?> ?>

View File

@ -164,8 +164,9 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup
$user_groups = array (); $user_groups = array ();
if (!$groups) if (!$groups) {
return $user_groups; return $user_groups;
}
if ($returnAllGroup) { //All group if ($returnAllGroup) { //All group
if ($returnAllColumns) { if ($returnAllColumns) {

View File

@ -465,10 +465,10 @@ function event_comment() {
var params = []; var params = [];
params.push("page=include/ajax/events"); params.push("page=include/ajax/events");
params.push("add_comment=1"); params.push("add_comment=1");
params.push("event_id="+event_id); params.push("event_id=" + event_id);
params.push("comment="+comment); params.push("comment=" + comment);
params.push("meta="+meta); params.push("meta=" + meta);
params.push("history="+history); params.push("history=" + history);
$('#button-comment_button').attr('disabled','disabled'); $('#button-comment_button').attr('disabled','disabled');
$('#response_loading').show(); $('#response_loading').show();

View File

@ -63,7 +63,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '6.0dev'; $version = '6.0dev';
$build = '141213'; $build = '150108';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -34,13 +34,17 @@ function validateAlert() {
} }
} }
function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby = false, $return = false) { function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby = false, $tag_filter = false, $return = false, $strict_user = false) {
global $config;
require_once ($config['homedir'] . "/include/functions_tags.php");
$table->width = '100%'; $table->width = '100%';
$table->data = array (); $table->data = array ();
$table->style = array (); $table->style = array ();
$table->data[0][0] = __('Group'); $table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(false, "AR", true, "ag_group", $id_group, '', '', '', true); $table->data[0][1] = html_print_select_groups($config['id_user'], "AR", true, "ag_group", $id_group, '', '', '', true, false, false, '', false, '', false, false, 'id_grupo', $strict_user);
$alert_status_filter = array(); $alert_status_filter = array();
$alert_status_filter['all_enabled'] = __('All (Enabled)'); $alert_status_filter['all_enabled'] = __('All (Enabled)');
@ -56,7 +60,18 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
$table->data[0][2] = __('Status'); $table->data[0][2] = __('Status');
$table->data[0][3] = html_print_select ($alert_status_filter, "filter", $filter, '', '', '', true); $table->data[0][3] = html_print_select ($alert_status_filter, "filter", $filter, '', '', '', true);
$table->data[0][4] = '';
$table->data[0][4] = __('Tags') . ui_print_help_tip(__('Only it is show tags in use.'), true);
$tags = tags_get_user_tags();
if (empty($tags)) {
$table->data[0][4] .= __('No tags');
}
else {
$table->data[0][4] .= html_print_select ($tags, "tag_filter", $tag_filter, '', __('All'), '', true, false, true, '', false, 'width: 150px;');
}
$table->data[1][0] = __('Free text for search') . $table->data[1][0] = __('Free text for search') .
ui_print_help_tip( ui_print_help_tip(
__("Filter by agent name, module name, template name or action name"), __("Filter by agent name, module name, template name or action name"),

View File

@ -38,11 +38,19 @@ require_once ($config['homedir'] . '/include/functions_users.php');
$isFunctionPolicies = enterprise_include_once ('include/functions_policies.php'); $isFunctionPolicies = enterprise_include_once ('include/functions_policies.php');
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$filter = get_parameter ("filter", "all_enabled"); $filter = get_parameter ("filter", "all_enabled");
$filter_standby = get_parameter ("filter_standby", "all"); $filter_standby = get_parameter ("filter_standby", "all");
$offset_simple = (int) get_parameter_get ("offset_simple", 0); $offset_simple = (int) get_parameter_get ("offset_simple", 0);
$id_group = (int) get_parameter ("ag_group", 0); //0 is the All group (selects all groups) $id_group = (int) get_parameter ("ag_group", 0); //0 is the All group (selects all groups)
$free_search = get_parameter("free_search", ''); $free_search = get_parameter("free_search", '');
$tag_filter = get_parameter("tag_filter", 0);
if ($tag_filter) {
if ($id_group && $strict_user) {
$tag_filter = 0;
}
}
$sec2 = get_parameter_get ('sec2'); $sec2 = get_parameter_get ('sec2');
$sec2 = safe_url_extraclean ($sec2); $sec2 = safe_url_extraclean ($sec2);
@ -58,7 +66,7 @@ $refr = (int)get_parameter('refr', 0);
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
$url = 'index.php?sec=' . $sec . '&sec2=' . $sec2 . '&refr=' . $refr . $url = 'index.php?sec=' . $sec . '&sec2=' . $sec2 . '&refr=' . $refr .
'&filter=' . $filter . '&filter_standby=' . $filter_standby . '&filter=' . $filter . '&filter_standby=' . $filter_standby .
'&ag_group=' . $id_group; '&ag_group=' . $id_group .'&tag_filter=' .$tag_filter;
if ($flag_alert == 1 && check_acl($config['id_user'], $id_group, "AW")) { if ($flag_alert == 1 && check_acl($config['id_user'], $id_group, "AW")) {
forceExecution($id_group); forceExecution($id_group);
@ -325,48 +333,33 @@ else {
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
require_once ($config['homedir'] . '/enterprise/meta/include/functions_alerts_meta.php'); require_once ($config['homedir'] . '/enterprise/meta/include/functions_alerts_meta.php');
if ($idAgent != 0) { if ($idAgent != 0) {
$alerts['alerts_simple'] = alerts_meta_get_alerts ($agents, $alerts['alerts_simple'] = alerts_meta_get_alerts ($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user);
$filter_alert, $options_simple, $whereAlertSimple, false, false,
$idGroup);
$countAlertsSimple = alerts_meta_get_alerts ($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user);
$countAlertsSimple = alerts_meta_get_alerts ($agents, $filter_alert,
false, $whereAlertSimple, false, false, $idGroup, true);
} }
else { else {
$id_groups = array_keys( $id_groups = array_keys(
users_get_groups($config["id_user"], 'AR', false)); users_get_groups($config["id_user"], 'AR', false));
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter);
$filter_alert, $options_simple, $whereAlertSimple, false,
false, $idGroup);
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter);
$filter_alert, false, $whereAlertSimple, false, false,
$idGroup, true);
} }
} }
else { else {
if ($idAgent != 0) { if ($idAgent != 0) {
$alerts['alerts_simple'] = agents_get_alerts_simple ($idAgent, $alerts['alerts_simple'] = agents_get_alerts_simple ($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter);
$filter_alert, $options_simple, $whereAlertSimple, false, false,
$idGroup);
$countAlertsSimple = agents_get_alerts_simple ($idAgent, $countAlertsSimple = agents_get_alerts_simple ($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter);
$filter_alert, false, $whereAlertSimple, false, false,
$idGroup, true);
} }
else { else {
$id_groups = array_keys( $id_groups = array_keys(
users_get_groups($config["id_user"], 'AR', false)); users_get_groups($config["id_user"], 'AR', false));
$alerts['alerts_simple'] = get_group_alerts($id_groups, $alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter);
$filter_alert, $options_simple, $whereAlertSimple, false,
false, $idGroup);
$countAlertsSimple = get_group_alerts($id_groups, $countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter);
$filter_alert, false, $whereAlertSimple, false, false,
$idGroup, true);
} }
} }
@ -381,10 +374,7 @@ if ($pure) {
// Filter form // Filter form
if ($print_agent) { if ($print_agent) {
echo '<br>'; echo '<br>';
ui_toggle( ui_toggle(printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby, $tag_filter, true, $strict_user),__('Alert control filter'), __('Toggle filter(s)'));
printFormFilterAlert(
$id_group, $filter, $free_search, $url, $filter_standby, true),
__('Alert control filter'), __('Toggle filter(s)'));
} }
$table->width = '100%'; $table->width = '100%';
@ -428,26 +418,14 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
// Sort buttons are only for normal console // Sort buttons are only for normal console
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
$table->head[3] .= ' ' . $table->head[3] .= ' ' .
'<a href="' . $url . '&sort_field=agent&sort=up">' . '<a href="' . $url . '&sort_field=agent&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectAgentUp)) . '</a>' .
html_print_image("images/sort_up.png", true, '<a href="' . $url . '&sort_field=agent&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectAgentDown)) . '</a>';
array("style" => $selectAgentUp)) . '</a>' .
'<a href="' . $url . '&sort_field=agent&sort=down">' .
html_print_image("images/sort_down.png", true,
array("style" => $selectAgentDown)) . '</a>';
$table->head[4] .= ' ' . $table->head[4] .= ' ' .
'<a href="' . $url . '&sort_field=module&sort=up">' . '<a href="' . $url . '&sort_field=module&sort=up">' . html_print_image("images/sort_up.png", true, array("style" =>$selectModuleUp)) . '</a>' .
html_print_image("images/sort_up.png", true, '<a href="' . $url . '&sort_field=module&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleDown)) . '</a>';
array("style" =>$selectModuleUp)) . '</a>' .
'<a href="' . $url . '&sort_field=module&sort=down">' .
html_print_image("images/sort_down.png", true,
array("style" => $selectModuleDown)) . '</a>';
$table->head[5] .= ' ' . $table->head[5] .= ' ' .
'<a href="' . $url . '&sort_field=template&sort=up">' . '<a href="' . $url . '&sort_field=template&sort=up">' . html_print_image("images/sort_up.png", true, array("style" =>$selectTemplateUp)) . '</a>' .
html_print_image("images/sort_up.png", true, '<a href="' . $url . '&sort_field=template&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectTemplateDown)) . '</a>';
array("style" =>$selectTemplateUp)) . '</a>' .
'<a href="' . $url . '&sort_field=template&sort=down">' .
html_print_image("images/sort_down.png", true,
array("style" => $selectTemplateDown)) . '</a>';
} }
} }
else { else {
@ -477,19 +455,11 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
// Sort buttons are only for normal console // Sort buttons are only for normal console
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
$table->head[3] .= ' ' . $table->head[3] .= ' ' .
'<a href="' . $url . '&sort_field=module&sort=up">' . '<a href="' . $url . '&sort_field=module&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectModuleUp)) . '</a>' .
html_print_image("images/sort_up.png", true, '<a href="' . $url . '&sort_field=module&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleDown)) . '</a>';
array("style" => $selectModuleUp)) . '</a>' .
'<a href="' . $url . '&sort_field=module&sort=down">' .
html_print_image("images/sort_down.png", true,
array("style" => $selectModuleDown)) . '</a>';
$table->head[4] .= ' ' . $table->head[4] .= ' ' .
'<a href="' . $url . '&sort_field=template&sort=up">' . '<a href="' . $url . '&sort_field=template&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectTemplateUp)) . '</a>' .
html_print_image("images/sort_up.png", true, '<a href="' . $url . '&sort_field=template&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectTemplateDown)) . '</a>';
array("style" => $selectTemplateUp)) . '</a>' .
'<a href="' . $url . '&sort_field=template&sort=down">' .
html_print_image("images/sort_down.png", true,
array("style" => $selectTemplateDown)) . '</a>';
} }
} }
} }
@ -599,6 +569,17 @@ else {
echo '<div class="nf">'.__('No alerts found').'</div>'; echo '<div class="nf">'.__('No alerts found').'</div>';
} }
//strict user hidden
echo '<div id="strict_hidden" style="display:none;">';
html_print_input_text('strict_user_hidden', $strict_user);
if (defined('METACONSOLE')) {
$is_meta = true;
} else {
$is_meta = false;
}
html_print_input_text('is_meta_hidden', $is_meta);
echo '</div>';
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');
@ -615,5 +596,32 @@ $(document).ready (function () {
}).click (function () { }).click (function () {
return false; return false;
}); });
if ($('#ag_group').val() != 0) {
$("#tag_filter").css('display', 'none');
$("#table2-0-4").css('display', 'none');
}
});
$('#ag_group').change (function (){
strict_user = $("#text-strict_user_hidden").val();
is_meta = $("#text-is_meta_hidden").val();
if (($("#ag_group").val() != 0) && (strict_user != 0)) {
$("#tag_filter").css('display', 'none');
if (is_meta) {
$("#table1-0-4").css('display', 'none');
} else {
$("#table2-0-4").css('display', 'none');
}
} else {
$("#tag_filter").css('display', '');
if (is_meta) {
$("#table1-0-4").css('display', '');
} else {
$("#table2-0-4").css('display', '');
}
}
}); });
</script> </script>

View File

@ -34,6 +34,8 @@ enterprise_include_once ('include/functions_metaconsole.php');
$isFunctionPolicies = enterprise_include_once ('include/functions_policies.php'); $isFunctionPolicies = enterprise_include_once ('include/functions_policies.php');
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
//Header //Header
ui_print_page_header (__("Monitor detail"), "images/brick.png", false); ui_print_page_header (__("Monitor detail"), "images/brick.png", false);
@ -43,8 +45,6 @@ else {
ui_meta_print_header(__("Monitor view")); ui_meta_print_header(__("Monitor view"));
} }
$ag_freestring = get_parameter ('ag_freestring'); $ag_freestring = get_parameter ('ag_freestring');
$ag_modulename = (string) get_parameter ('ag_modulename'); $ag_modulename = (string) get_parameter ('ag_modulename');
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
@ -68,6 +68,11 @@ $offset = (int) get_parameter ('offset', 0);
$status = (int) get_parameter ('status', 4); $status = (int) get_parameter ('status', 4);
$modulegroup = get_parameter ('modulegroup', -1); $modulegroup = get_parameter ('modulegroup', -1);
$tag_filter = get_parameter('tag_filter', 0); $tag_filter = get_parameter('tag_filter', 0);
if ($tag_filter) {
if ($ag_group && $strict_user) {
$tag_filter = 0;
}
}
$refr = get_parameter('refr', 0); $refr = get_parameter('refr', 0);
// Sort functionality // Sort functionality
@ -108,6 +113,7 @@ else {
$id_ag_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $ag_group); $id_ag_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $ag_group);
} }
// Agent group selector // Agent group selector
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
if ($ag_group > 0 && check_acl ($config["id_user"], $ag_group, "AR")) { if ($ag_group > 0 && check_acl ($config["id_user"], $ag_group, "AR")) {
@ -119,8 +125,9 @@ if (!defined('METACONSOLE')) {
} }
} }
else { else {
if ($ag_group != "0" && check_acl ($config["id_user"], $id_ag_group, "AR")) { if ($ag_group != "0" && check_acl ($config["id_user"], $id_ag_group, "AR")) {
$sql_conditions_group = sprintf (" AND tagente.id_grupo IN ( SELECT id_grupo FROM tgrupo where nombre = '%s') ", $ag_group); $sql_conditions_group = sprintf (" AND tagente.id_grupo IN (%s) ", $ag_group);
} }
elseif ($user_groups != '') { elseif ($user_groups != '') {
// User has explicit permission on group 1 ? // User has explicit permission on group 1 ?
@ -200,7 +207,7 @@ if ($tag_filter !== 0) {
$sql_conditions .= " AND tagente_modulo.id_agente_modulo IN ( $sql_conditions .= " AND tagente_modulo.id_agente_modulo IN (
SELECT ttag_module.id_agente_modulo SELECT ttag_module.id_agente_modulo
FROM ttag_module FROM ttag_module
WHERE ttag_module.id_tag IN (SELECT id_tag FROM ttag where name LIKE '%" . $tag_filter . "%') WHERE ttag_module.id_tag IN ($tag_filter)
)"; )";
} }
else { else {
@ -213,14 +220,13 @@ if ($tag_filter !== 0) {
} }
} }
if (defined('METACONSOLE') && $ag_group !== 0) {
$ag_group = groups_get_id($ag_group);
}
// Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!) // Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!)
$groups = users_get_groups($config["id_user"]); $groups = users_get_groups($config["id_user"]);
if ($ag_group !== 0) {
$sql_conditions_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo'); $sql_conditions_tags = tags_get_acl_tags($config['id_user'], $ag_group, 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true);
} else {
$sql_conditions_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true);
}
if (is_numeric($sql_conditions_tags)) { if (is_numeric($sql_conditions_tags)) {
$sql_conditions_tags = ' AND 1 = 0'; $sql_conditions_tags = ' AND 1 = 0';
@ -230,6 +236,11 @@ if (is_numeric($sql_conditions_tags)) {
$sql_conditions_all = $sql_conditions_base . $sql_conditions . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields; $sql_conditions_all = $sql_conditions_base . $sql_conditions . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields;
$sql_conditions_acl = $sql_conditions_base . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields; $sql_conditions_acl = $sql_conditions_base . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields;
if (!$strict_user) {
$sql_conditions_all = $sql_conditions_base . $sql_conditions . $sql_conditions_group . $sql_conditions_custom_fields;
$sql_conditions_acl = $sql_conditions_base . $sql_conditions_group . $sql_conditions_custom_fields;
}
// Get count to paginate // Get count to paginate
if (!defined('METACONSOLE')) if (!defined('METACONSOLE'))
$count = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) " . $sql_from . $sql_conditions_all); $count = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) " . $sql_from . $sql_conditions_all);
@ -335,21 +346,6 @@ if (defined('METACONSOLE')) {
// Get all info for filters of all nodes // Get all info for filters of all nodes
$modules_temp = db_get_all_rows_sql($sql); $modules_temp = db_get_all_rows_sql($sql);
# Fix : only user tags have to be shown in these component
$_tags = tags_get_user_tags();
if (!empty($_tags)) {
foreach ($_tags as $_tag) {
$tags_temp[]['name'] = $_tag;
}
}
$rows_temp = db_get_all_rows_sql("SELECT distinct name $rows_temp = db_get_all_rows_sql("SELECT distinct name
FROM tmodule_group FROM tmodule_group
ORDER BY name"); ORDER BY name");
@ -377,8 +373,6 @@ if (defined('METACONSOLE')) {
if (!empty($modules_temp)) if (!empty($modules_temp))
$modules = array_merge($modules, $modules_temp); $modules = array_merge($modules, $modules_temp);
if (!empty($tags_temp))
$tags = array_merge($tags, $tags_temp);
metaconsole_restore_db(); metaconsole_restore_db();
} }
@ -388,28 +382,17 @@ if (defined('METACONSOLE')) {
unset($groups_select[$key_group_all]); unset($groups_select[$key_group_all]);
} }
if (!defined('METACONSOLE')) { echo '
echo ' <td valign="middle">' . __('Group') . '</td>
<td valign="middle">' . __('Group') . '</td> <td valign="middle">' .
<td valign="middle">' . html_print_select_groups($config['id_user'], "AR", true, "ag_group",
html_print_select_groups(false, "AR", true, "ag_group",
$ag_group, '', '', '0', true, false, false, 'w130', $ag_group, '', '', '0', true, false, false, 'w130',
false, 'width:150px;') . ' false, 'width:150px;', false, false,
</td>'; 'id_grupo', $strict_user) . '
} </td>';
else {
echo '
<td valign="middle">' . __('Group') . '</td>
<td valign="middle">' .
html_print_select($groups_select, "ag_group",
io_safe_output($ag_group_metaconsole), '', __('All'), '0', true, false, false, 'w130',
false, 'width:150px;') . '
</td>';
}
echo '<td>' . __('Monitor status') . "</td>"; echo '<td>' . __('Monitor status') . "</td>";
echo "<td>"; echo "<td>";
$fields = array (); $fields = array ();
@ -421,11 +404,9 @@ $fields[AGENT_MODULE_STATUS_NOT_NORMAL] = __('Not normal'); //default
$fields[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init'); $fields[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init');
html_print_select ($fields, "status", $status, '', __('All'), -1, html_print_select ($fields, "status", $status, '', __('All'), -1,
false, false, true, '', false, 'width: 125px;'); false, false, true, '', false, 'width: 150px;');
echo '</td>'; echo '</td>';
echo '<td valign="middle">' . __('Module group') . '</td>'; echo '<td valign="middle">' . __('Module group') . '</td>';
echo '<td valign="middle">'; echo '<td valign="middle">';
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
@ -440,17 +421,13 @@ if (!defined('METACONSOLE')) {
$rows_select[0] = __('Not assigned'); $rows_select[0] = __('Not assigned');
html_print_select($rows_select, 'modulegroup', $modulegroup, '', __('All'), -1); html_print_select($rows_select, 'modulegroup', $modulegroup, '', __('All'),-1,false, false, true, '', false, 'width: 120px;');
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
echo '<tr>'; echo '<tr>';
echo '<td valign="middle">' . __('Module name') . '</td>'; echo '<td valign="middle">' . __('Module name') . '</td>';
echo '<td valign="middle">'; echo '<td valign="middle">';
@ -463,32 +440,6 @@ html_print_select (index_array ($modules, 'nombre', 'nombre'), "ag_modulename",
echo '</td>'; echo '</td>';
echo '<td valign="middle" align="right">' .
__('Tags') .
ui_print_help_tip(__('Only it is show tags in use.'), true) .
'</td>';
echo '<td>';
if (!defined('METACONSOLE')) {
$tags = tags_get_user_tags();
}
if (empty($tags)) {
echo __('No tags');
}
else {
if (!defined('METACONSOLE'))
html_print_select ($tags, "tag_filter",
$tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;');
else
html_print_select (index_array($tags, 'name', 'name'), "tag_filter",
$tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;');
}
echo '</td>';
echo '<td valign="middle" align="right">' . echo '<td valign="middle" align="right">' .
__('Search') . __('Search') .
'</td>'; '</td>';
@ -496,7 +447,21 @@ echo '<td valign="middle">';
html_print_input_text ("ag_freestring", $ag_freestring, '', 20,30, false); html_print_input_text ("ag_freestring", $ag_freestring, '', 20,30, false);
echo '</td>'; echo '</td>';
echo '<td valign="middle" align="right" id="tag_td">' .
__('Tags') .
ui_print_help_tip(__('Only it is show tags in use.'), true);
echo '<td>';
$tags = tags_get_user_tags();
if (empty($tags)) {
echo __('No tags');
}
else {
html_print_select ($tags, "tag_filter", $tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;');
}
echo '</td>';
echo '<td valign="middle">'; echo '<td valign="middle">';
html_print_submit_button (__('Show'), "uptbutton", false, 'class="sub search"'); html_print_submit_button (__('Show'), "uptbutton", false, 'class="sub search"');
@ -732,6 +697,7 @@ switch ($config["dbtype"]) {
$sql_from . $sql_conditions_all . " $sql_from . $sql_conditions_all . "
ORDER BY " . $order['field'] . " " . $order['order'] . " ORDER BY " . $order['field'] . " " . $order['order'] . "
LIMIT ".$offset.",".$limit_sql; LIMIT ".$offset.",".$limit_sql;
break; break;
case "postgresql": case "postgresql":
if (strstr($config['dbversion'], "8.4") !== false) { if (strstr($config['dbversion'], "8.4") !== false) {
@ -941,10 +907,6 @@ if (! defined ('METACONSOLE')) {
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=module_name&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleNameDown, "alt" => "down")) . '</a>'; '<a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=module_name&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleNameDown, "alt" => "down")) . '</a>';
} }
/*
$table->head[4] = __('Tags');
*/
$table->head[5] = __('Interval'); $table->head[5] = __('Interval');
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
$table->head[5] .= ' <a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=interval&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '</a>' . $table->head[5] .= ' <a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=interval&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '</a>' .
@ -1188,7 +1150,6 @@ foreach ($result as $row) {
$data[7] = '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a>'; $data[7] = '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a>';
if (defined('METACONSOLE')) if (defined('METACONSOLE'))
//$data[7] .= "&nbsp;<a href='" . $row['server_url'] . "index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=".$row["id_agent"]."&amp;tab=data_view&period=86400&loginhash=auto&loginhash_data=" . $row["hashdata"] . "&loginhash_user=" . $row["user"] . "&amp;id=".$row["id_agente_modulo"]."'>" . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . "</a>";
$data[7] .= "<a href='javascript: show_module_detail_dialog(" . $row["id_agente_modulo"] . ", ". $row['id_agent'].", \"" . $row['server_name'] . "\", 0, 86400)'>". html_print_image ("images/binary.png", true, array ("border" => "0", "alt" => "")) . "</a>"; $data[7] .= "<a href='javascript: show_module_detail_dialog(" . $row["id_agente_modulo"] . ", ". $row['id_agent'].", \"" . $row['server_name'] . "\", 0, 86400)'>". html_print_image ("images/binary.png", true, array ("border" => "0", "alt" => "")) . "</a>";
else else
$data[7] .= "&nbsp;<a href='index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=".$row["id_agent"]."&amp;tab=data_view&period=86400&amp;id=".$row["id_agente_modulo"]."'>" . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . "</a>"; $data[7] .= "&nbsp;<a href='index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=".$row["id_agent"]."&amp;tab=data_view&period=86400&amp;id=".$row["id_agente_modulo"]."'>" . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . "</a>";
@ -1257,8 +1218,6 @@ foreach ($result as $row) {
} }
} }
if ($module_value == $sub_string) { if ($module_value == $sub_string) {
$salida = $module_value; $salida = $module_value;
} }
@ -1307,12 +1266,37 @@ else {
echo "<div id='monitor_details_window'></div>"; echo "<div id='monitor_details_window'></div>";
//strict user hidden
echo '<div id="strict_hidden" style="display:none;">';
html_print_input_text('strict_user_hidden', $strict_user);
echo '</div>';
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');
ui_require_javascript_file('pandora_modules'); ui_require_javascript_file('pandora_modules');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready (function () {
if ($('#ag_group').val() != 0) {
$("#tag_filter").css('display', 'none');
$("#tag_td").css('display', 'none');
}
});
$('#ag_group').change (function (){
strict_user = $("#text-strict_user_hidden").val();
if (($("#ag_group").val() != 0) && (strict_user != 0)) {
$("#tag_filter").css('display', 'none');
$("#tag_td").css('display', 'none');
} else {
$("#tag_filter").css('display', '');
$("#tag_td").css('display', '');
}
});
function toggle_full_value(id) { function toggle_full_value(id) {
text = $("#hidden_value_module_" + id).html(); text = $("#hidden_value_module_" + id).html();
old_text = $("#value_module_text_" + id).html(); old_text = $("#value_module_text_" + id).html();

View File

@ -163,10 +163,10 @@ if ($update_pressed || $open_filter) {
$table = html_get_predefined_table('transparent', 2); $table = html_get_predefined_table('transparent', 2);
$table->styleTable = 'width: 23px; float: right; background: #ECECEC;'; $table->styleTable = 'width: 23px; float: right; background: #ECECEC;';
$table->width = '98%'; $table->width = '98%';
$table->style[0] = 'text-align:left;'; $table->style[0] = 'text-align: left;';
$table->style[1] = 'text-align:right;'; $table->style[1] = 'text-align: right;';
$table->data[0][1] = '<a id="events_graph_link" href="javascript:show_events_graph_dialog()">' . html_print_image('images/chart_curve.png', true, array('title' => __('Show events graph'))) . '</a>'; $table->data[0][1] = '<a id="events_graph_link" href="javascript: show_events_graph_dialog()">' . html_print_image('images/chart_curve.png', true, array('title' => __('Show events graph'))) . '</a>';
$table->cellstyle[0][1] = 'background: #ECECEC;'; $table->cellstyle[0][1] = 'background: #ECECEC;';
html_print_table($table); html_print_table($table);
@ -610,7 +610,8 @@ enterprise_hook('close_meta_frame');
unset($table); unset($table);
// Values to be used from javascript library // Values to be used from javascript library
html_print_input_hidden('ajax_file', ui_get_full_url("ajax.php", false, false, false)); html_print_input_hidden('ajax_file',
ui_get_full_url("ajax.php", false, false, false));
html_print_input_hidden('meta', (int)$meta); html_print_input_hidden('meta', (int)$meta);
html_print_input_hidden('history', (int)$history); html_print_input_hidden('history', (int)$history);

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 6.0dev %define version 6.0dev
%define release 141213 %define release 150108
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 6.0dev %define version 6.0dev
%define release 141213 %define release 150108
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -269,7 +269,7 @@ INSERT INTO ttipo_modulo VALUES (1,'generic_data',0,'Generic data','mod_data.png
INSERT INTO ttipo_modulo VALUES (2,'generic_proc',1,'Generic boolean','mod_proc.png'); INSERT INTO ttipo_modulo VALUES (2,'generic_proc',1,'Generic boolean','mod_proc.png');
INSERT INTO ttipo_modulo VALUES (3,'generic_data_string',2,'Generic string','mod_string.png'); INSERT INTO ttipo_modulo VALUES (3,'generic_data_string',2,'Generic string','mod_string.png');
INSERT INTO ttipo_modulo VALUES (4,'generic_data_inc',0,'Generic data incremental','mod_data_inc.png'); INSERT INTO ttipo_modulo VALUES (4,'generic_data_inc',0,'Generic data incremental','mod_data_inc.png');
INSERT INTO ttipo_modulo VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png');
INSERT INTO ttipo_modulo VALUES (6,'remote_icmp_proc',4,'Remote ICMP network agent, boolean data','mod_icmp_proc.png'); INSERT INTO ttipo_modulo VALUES (6,'remote_icmp_proc',4,'Remote ICMP network agent, boolean data','mod_icmp_proc.png');
INSERT INTO ttipo_modulo VALUES (7,'remote_icmp',3,'Remote ICMP network agent (latency)','mod_icmp_data.png'); INSERT INTO ttipo_modulo VALUES (7,'remote_icmp',3,'Remote ICMP network agent (latency)','mod_icmp_data.png');
INSERT INTO ttipo_modulo VALUES (8,'remote_tcp',3,'Remote TCP network agent, numeric data','mod_tcp_data.png'); INSERT INTO ttipo_modulo VALUES (8,'remote_tcp',3,'Remote TCP network agent, numeric data','mod_tcp_data.png');

View File

@ -251,7 +251,7 @@ INSERT INTO "ttipo_modulo" VALUES
(2,'generic_proc',1,'Generic boolean','mod_proc.png'), (2,'generic_proc',1,'Generic boolean','mod_proc.png'),
(3,'generic_data_string',2,'Generic string','mod_string.png'), (3,'generic_data_string',2,'Generic string','mod_string.png'),
(4,'generic_data_inc',0,'Generic data incremental','mod_data_inc.png'), (4,'generic_data_inc',0,'Generic data incremental','mod_data_inc.png'),
(5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png'),
(6,'remote_icmp_proc',4,'Remote ICMP network agent, boolean data','mod_icmp_proc.png'), (6,'remote_icmp_proc',4,'Remote ICMP network agent, boolean data','mod_icmp_proc.png'),
(7,'remote_icmp',3,'Remote ICMP network agent (latency)','mod_icmp_data.png'), (7,'remote_icmp',3,'Remote ICMP network agent (latency)','mod_icmp_data.png'),
(8,'remote_tcp',3,'Remote TCP network agent, numeric data','mod_tcp_data.png'), (8,'remote_tcp',3,'Remote TCP network agent, numeric data','mod_tcp_data.png'),

View File

@ -1029,6 +1029,7 @@ CREATE TABLE tusuario (
metaconsole_agents_manager NUMBER(10, 0) default 0 NOT NULL, metaconsole_agents_manager NUMBER(10, 0) default 0 NOT NULL,
metaconsole_assigned_server NUMBER(10, 0) default 0 NOT NULL, metaconsole_assigned_server NUMBER(10, 0) default 0 NOT NULL,
metaconsole_access_node NUMBER(10, 0) default 0 NOT NULL, metaconsole_access_node NUMBER(10, 0) default 0 NOT NULL,
strict_acl NUMBER(5,0) unsigned NOT NULL DEFAULT 0,
CONSTRAINT t_usuario_metaconsole_access_cons CHECK (metaconsole_access IN ('basic','advanced')) CONSTRAINT t_usuario_metaconsole_access_cons CHECK (metaconsole_access IN ('basic','advanced'))
); );

View File

@ -910,7 +910,8 @@ CREATE TABLE "tusuario" (
"metaconsole_agents_manager" SMALLINT DEFAULT 0, "metaconsole_agents_manager" SMALLINT DEFAULT 0,
"metaconsole_assigned_server" INTEGER NOT NULL default 0, "metaconsole_assigned_server" INTEGER NOT NULL default 0,
"metaconsole_access_node" SMALLINT DEFAULT 0, "metaconsole_access_node" SMALLINT DEFAULT 0,
"metaconsole_access" type_tusuario_metaconsole_access default 'basic' "metaconsole_access" type_tusuario_metaconsole_access default 'basic',
"strict_acl" SMALLINT NOT NULL default 0
); );
-- ----------------------------------------------------- -- -----------------------------------------------------

View File

@ -982,6 +982,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` (
`metaconsole_agents_manager` tinyint(1) unsigned NOT NULL default 0, `metaconsole_agents_manager` tinyint(1) unsigned NOT NULL default 0,
`metaconsole_assigned_server` int(10) unsigned NOT NULL default 0, `metaconsole_assigned_server` int(10) unsigned NOT NULL default 0,
`metaconsole_access_node` tinyint(1) unsigned NOT NULL default 0, `metaconsole_access_node` tinyint(1) unsigned NOT NULL default 0,
`strict_acl` tinyint(1) unsigned NOT NULL DEFAULT 0,
UNIQUE KEY `id_user` (`id_user`) UNIQUE KEY `id_user` (`id_user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -38,7 +38,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('graph_res','5'), ('graph_res','5'),
('step_compact','1'), ('step_compact','1'),
('db_scheme_version','6.0dev'), ('db_scheme_version','6.0dev'),
('db_scheme_build','PD141213'), ('db_scheme_build','PD150108'),
('show_unknown','0'), ('show_unknown','0'),
('show_lastalerts','1'), ('show_lastalerts','1'),
('style','pandora'), ('style','pandora'),
@ -133,7 +133,7 @@ INSERT INTO `tconfig_os` (`id_os`, `name`, `description`, `icon_name`) VALUES
(16, 'VMware', 'VMware Architecture', 'so_vmware.png'), (16, 'VMware', 'VMware Architecture', 'so_vmware.png'),
(17, 'Router', 'Generic router', 'so_router.png'), (17, 'Router', 'Generic router', 'so_router.png'),
(18, 'Switch', 'Generic switch', 'so_switch.png'), (18, 'Switch', 'Generic switch', 'so_switch.png'),
(19, 'Satellite', 'Satellite agent', 'satellite.png'); (19, 'Satellite', 'Satellite agent', 'satellite.png'),
(20, 'Mainframe', 'Mainframe agent', 'so_mainframe.png'); (20, 'Mainframe', 'Mainframe agent', 'so_mainframe.png');
UNLOCK TABLES; UNLOCK TABLES;
@ -241,7 +241,7 @@ INSERT INTO `ttipo_modulo` VALUES
(2,'generic_proc',1,'Generic boolean','mod_proc.png'), (2,'generic_proc',1,'Generic boolean','mod_proc.png'),
(3,'generic_data_string',2,'Generic string','mod_string.png'), (3,'generic_data_string',2,'Generic string','mod_string.png'),
(4,'generic_data_inc',0,'Generic numeric incremental','mod_data_inc.png'), (4,'generic_data_inc',0,'Generic numeric incremental','mod_data_inc.png'),
(5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png'),
(6,'remote_icmp_proc',4,'Remote ICMP network agent, boolean data','mod_icmp_proc.png'), (6,'remote_icmp_proc',4,'Remote ICMP network agent, boolean data','mod_icmp_proc.png'),
(7,'remote_icmp',3,'Remote ICMP network agent (latency)','mod_icmp_data.png'), (7,'remote_icmp',3,'Remote ICMP network agent (latency)','mod_icmp_data.png'),
(8,'remote_tcp',3,'Remote TCP network agent, numeric data','mod_tcp_data.png'), (8,'remote_tcp',3,'Remote TCP network agent, numeric data','mod_tcp_data.png'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 6.0dev-141213 Version: 6.0dev-150108
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="6.0dev-141213" pandora_version="6.0dev-150108"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -43,7 +43,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "6.0dev"; my $pandora_version = "6.0dev";
my $pandora_build = "141213"; my $pandora_build = "150108";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -1114,9 +1114,8 @@ sub pandora_process_module ($$$$$$$$$;$) {
} }
# Process data # Process data
my $processed_data = process_data ($pa_config, $data_object, $module, $module_type, $utimestamp, $dbh); my $processed_data = process_data ($pa_config, $data_object, $agent, $module, $module_type, $utimestamp, $dbh);
if (! defined ($processed_data)) { if (! defined ($processed_data)) {
logger($pa_config, "Received invalid data '" . $data_object->{'data'} . "' from agent '" . $agent->{'nombre'} . "' module '" . $module->{'nombre'} . "' agent " . (defined ($agent) ? "'" . $agent->{'nombre'} . "'" : 'ID ' . $module->{'id_agente'}) . ".", 3);
pandora_update_module_on_error ($pa_config, $module, $dbh); pandora_update_module_on_error ($pa_config, $module, $dbh);
return; return;
} }
@ -3267,8 +3266,9 @@ sub on_demand_macro($$$$$$) {
########################################################################## ##########################################################################
# Process module data. # Process module data.
########################################################################## ##########################################################################
sub process_data ($$$$$$) { sub process_data ($$$$$$$) {
my ($pa_config, $data_object, $module, $module_type, $utimestamp, $dbh) = @_; my ($pa_config, $data_object, $agent, $module,
$module_type, $utimestamp, $dbh) = @_;
if ($module_type eq "log4x") { if ($module_type eq "log4x") {
return log4x_get_severity_num($data_object); return log4x_get_severity_num($data_object);
@ -3280,13 +3280,17 @@ sub process_data ($$$$$$) {
if ($module_type =~ m/_string$/) { if ($module_type =~ m/_string$/) {
# Empty strings are not allowed # Empty strings are not allowed
return undef if ($data eq ''); if ($data eq '') {
logger($pa_config, "Received invalid data '" . $data_object->{'data'} . "' from agent '" . $agent->{'nombre'} . "' module '" . $module->{'nombre'} . "' agent " . (defined ($agent) ? "'" . $agent->{'nombre'} . "'" : 'ID ' . $module->{'id_agente'}) . ".", 3);
return undef;
}
return $data; return $data;
} }
# Not a number # Not a number
if (! is_numeric ($data)) { if (! is_numeric ($data)) {
logger($pa_config, "Received invalid data '" . $data_object->{'data'} . "' from agent '" . $agent->{'nombre'} . "' module '" . $module->{'nombre'} . "' agent " . (defined ($agent) ? "'" . $agent->{'nombre'} . "'" : 'ID ' . $module->{'id_agente'}) . ".", 3);
return undef; return undef;
} }
@ -3294,8 +3298,10 @@ sub process_data ($$$$$$) {
$data =~ s/\,/\./; $data =~ s/\,/\./;
# Out of bounds # Out of bounds
return undef if (($module->{'max'} != $module->{'min'}) && if (($module->{'max'} != $module->{'min'}) && ($data > $module->{'max'} || $data < $module->{'min'})) {
($data > $module->{'max'} || $data < $module->{'min'})); logger($pa_config, "Received invalid data '" . $data_object->{'data'} . "' from agent '" . $agent->{'nombre'} . "' module '" . $module->{'nombre'} . "' agent " . (defined ($agent) ? "'" . $agent->{'nombre'} . "'" : 'ID ' . $module->{'id_agente'}) . ".", 3);
return undef;
}
# Process INC modules # Process INC modules
if ($module_type =~ m/_inc$/) { if ($module_type =~ m/_inc$/) {
@ -3304,6 +3310,13 @@ sub process_data ($$$$$$) {
# No previous data or error. # No previous data or error.
return undef unless defined ($data); return undef unless defined ($data);
} }
# Process absolute INC modules
elsif ($module_type =~ m/_inc_abs$/) {
$data = process_inc_abs_data ($pa_config, $data, $module, $utimestamp, $dbh);
# No previous data or error.
return undef unless defined ($data);
}
# Post process # Post process
if (is_numeric ($module->{'post_process'}) && $module->{'post_process'} != 0) { if (is_numeric ($module->{'post_process'}) && $module->{'post_process'} != 0) {
@ -3348,7 +3361,10 @@ sub process_inc_data ($$$$$) {
} }
# Should not happen # Should not happen
return undef if ($utimestamp == $data_inc->{'utimestamp'}); if ($utimestamp == $data_inc->{'utimestamp'}) {
logger($pa_config, "Duplicate timestamp for incremental module " . $module->{'nombre'} . "(module id " . $module->{'id_agente_modulo'} . ").", 10);
return undef;
}
# Update inc data # Update inc data
db_do ($dbh, 'UPDATE tagente_datos_inc SET datos = ?, utimestamp = ? WHERE id_agente_modulo = ?', $data, $utimestamp, $module->{'id_agente_modulo'}); db_do ($dbh, 'UPDATE tagente_datos_inc SET datos = ?, utimestamp = ? WHERE id_agente_modulo = ?', $data, $utimestamp, $module->{'id_agente_modulo'});
@ -3356,6 +3372,46 @@ sub process_inc_data ($$$$$) {
return ($data - $data_inc->{'datos'}) / ($utimestamp - $data_inc->{'utimestamp'}); return ($data - $data_inc->{'datos'}) / ($utimestamp - $data_inc->{'utimestamp'});
} }
##########################################################################
# Process data of type *_inc_abs.
##########################################################################
sub process_inc_abs_data ($$$$$) {
my ($pa_config, $data, $module, $utimestamp, $dbh) = @_;
my $data_inc = get_db_single_row ($dbh, 'SELECT * FROM tagente_datos_inc WHERE id_agente_modulo = ?', $module->{'id_agente_modulo'});
# No previous data
if (! defined ($data_inc)) {
db_do ($dbh, 'INSERT INTO tagente_datos_inc
(id_agente_modulo, datos, utimestamp)
VALUES (?, ?, ?)', $module->{'id_agente_modulo'}, $data, $utimestamp);
logger($pa_config, "Discarding first data for incremental module " . $module->{'nombre'} . "(module id " . $module->{'id_agente_modulo'} . ").", 10);
return undef;
}
# Negative increment, reset inc data
if ($data < $data_inc->{'datos'}) {
db_do ($dbh, 'UPDATE tagente_datos_inc SET datos = ?, utimestamp = ? WHERE id_agente_modulo = ?', $data, $utimestamp, $module->{'id_agente_modulo'});
logger($pa_config, "Discarding data and resetting counter for incremental module " . $module->{'nombre'} . "(module id " . $module->{'id_agente_modulo'} . ").", 10);
# Prevent the module from becoming unknown!
db_do ($dbh, 'UPDATE tagente_estado SET utimestamp = ? WHERE id_agente_modulo = ?', time(), $module->{'id_agente_modulo'});
return undef;
}
# Should not happen
if ($utimestamp == $data_inc->{'utimestamp'}) {
logger($pa_config, "Duplicate timestamp for incremental module " . $module->{'nombre'} . "(module id " . $module->{'id_agente_modulo'} . ").", 10);
return undef;
}
# Update inc data
db_do ($dbh, 'UPDATE tagente_datos_inc SET datos = ?, utimestamp = ? WHERE id_agente_modulo = ?', $data, $utimestamp, $module->{'id_agente_modulo'});
return ($data - $data_inc->{'datos'});
}
sub log4x_get_severity_num($) { sub log4x_get_severity_num($) {
my ($data_object) = @_; my ($data_object) = @_;
my $data = $data_object->{'severity'}; my $data = $data_object->{'severity'};

View File

@ -102,7 +102,7 @@ sub data_producer ($) {
WHERE server_name = ? WHERE server_name = ?
AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0 AND tagente.disabled = 0
AND tagente_modulo.id_tipo_modulo > 4 AND tagente_modulo.id_tipo_modulo > 5
AND tagente_modulo.id_tipo_modulo < 19 ' AND tagente_modulo.id_tipo_modulo < 19 '
. (defined ($network_filter) ? $network_filter : ' ') . . (defined ($network_filter) ? $network_filter : ' ') .
'AND tagente_modulo.disabled = 0 'AND tagente_modulo.disabled = 0
@ -116,7 +116,7 @@ sub data_producer ($) {
AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0 AND tagente.disabled = 0
AND tagente_modulo.disabled = 0 AND tagente_modulo.disabled = 0
AND tagente_modulo.id_tipo_modulo > 4 AND tagente_modulo.id_tipo_modulo > 5
AND tagente_modulo.id_tipo_modulo < 19 ' AND tagente_modulo.id_tipo_modulo < 19 '
. (defined ($network_filter) ? $network_filter : ' ') . . (defined ($network_filter) ? $network_filter : ' ') .
'AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo 'AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 6.0dev %define version 6.0dev
%define release 141213 %define release 150108
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 6.0dev %define version 6.0dev
%define release 141213 %define release 150108
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -33,7 +33,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "6.0dev PS141213"; my $version = "6.0dev PS150108";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;
@ -79,6 +79,20 @@ sub pandora_purgedb ($$) {
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime()); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime());
my $ulimit_access_timestamp = time() - 86400; my $ulimit_access_timestamp = time() - 86400;
my $ulimit_timestamp = time() - (86400 * $conf->{'_days_purge'}); my $ulimit_timestamp = time() - (86400 * $conf->{'_days_purge'});
my $first_mark;
my $total_time;
my $purge_steps;
my $purge_count;
# Delete extended session data
if (enterprise_load (\%conf) != 0) {
db_do ($dbh, "DELETE FROM tsesion_extended
WHERE id_sesion NOT IN ( SELECT id_sesion FROM tsesion );");
log_message ('PURGE', 'Deleting old extended session data.');
}
# Delete old data
if ($conf->{'_days_purge'} > 0) {
# Delete old numeric data # Delete old numeric data
pandora_delete_old_module_data ($dbh, 'tagente_datos', $ulimit_access_timestamp, $ulimit_timestamp); pandora_delete_old_module_data ($dbh, 'tagente_datos', $ulimit_access_timestamp, $ulimit_timestamp);
@ -86,21 +100,7 @@ sub pandora_purgedb ($$) {
# Delete old export data # Delete old export data
pandora_delete_old_export_data ($dbh, $ulimit_timestamp); pandora_delete_old_export_data ($dbh, $ulimit_timestamp);
# Delete extended session data # Delete old inventory data
if (enterprise_load (\%conf) != 0) {
db_do ($dbh, "DELETE FROM tsesion_extended
WHERE id_sesion NOT IN ( SELECT id_sesion FROM tsesion );");
log_message ('PURGE', 'Deleting old extended session data.');
}
# Delete inventory data, only if enterprise is enabled
# We use the same value than regular data purge interval
my $first_mark;
my $total_time;
my $purge_steps;
my $purge_count;
if (enterprise_load (\%conf) != 0) { if (enterprise_load (\%conf) != 0) {
log_message ('PURGE', 'Deleting old inventory data.'); log_message ('PURGE', 'Deleting old inventory data.');
@ -153,20 +153,29 @@ sub pandora_purgedb ($$) {
else { else {
log_message ('PURGE', 'No data in tagente_datos_log4x.'); log_message ('PURGE', 'No data in tagente_datos_log4x.');
} }
}
else {
log_message ('PURGE', 'days_purge is set to 0. Old data will not be deleted.');
}
# String data deletion # String data deletion
if (!defined($conf->{'_string_purge'})){ if (!defined($conf->{'_string_purge'})){
$conf->{'_string_purge'} = 7; $conf->{'_string_purge'} = 7;
} }
if ($conf->{'_string_purge'} > 0) {
$ulimit_access_timestamp = time() - 86400; $ulimit_access_timestamp = time() - 86400;
$ulimit_timestamp = time() - (86400 * $conf->{'_days_purge'}); $ulimit_timestamp = time() - (86400 * $conf->{'_days_purge'});
pandora_delete_old_module_data ($dbh, 'tagente_datos_string', $ulimit_access_timestamp, $ulimit_timestamp); pandora_delete_old_module_data ($dbh, 'tagente_datos_string', $ulimit_access_timestamp, $ulimit_timestamp);
}
else {
log_message ('PURGE', 'string_purge is set to 0. Old string data will not be deleted.');
}
# Delete event data # Delete event data
if (!defined($conf->{'_event_purge'})){ if (!defined($conf->{'_event_purge'})){
$conf->{'_event_purge'}= 10; $conf->{'_event_purge'}= 10;
} }
if ($conf->{'_event_purge'} > 0) {
my $event_limit = time() - 86400 * $conf->{'_event_purge'}; my $event_limit = time() - 86400 * $conf->{'_event_purge'};
my $events_table = 'tevento'; my $events_table = 'tevento';
@ -204,20 +213,33 @@ sub pandora_purgedb ($$) {
usleep (10000); usleep (10000);
} }
log_message ('', "\n"); log_message ('', "\n");
}
else {
log_message ('PURGE', 'event_purge is set to 0. Old events will not be deleted.');
}
# Delete audit data # Delete audit data
$conf->{'_audit_purge'}= 7 if (!defined($conf->{'_audit_purge'})); $conf->{'_audit_purge'}= 7 if (!defined($conf->{'_audit_purge'}));
if ($conf->{'_audit_purge'} > 0) {
log_message ('PURGE', "Deleting old audit data (More than " . $conf->{'_audit_purge'} . " days)."); log_message ('PURGE', "Deleting old audit data (More than " . $conf->{'_audit_purge'} . " days).");
my $audit_limit = time() - 86400 * $conf->{'_audit_purge'}; my $audit_limit = time() - 86400 * $conf->{'_audit_purge'};
db_do($dbh, "DELETE FROM tsesion WHERE utimestamp < $audit_limit"); db_do($dbh, "DELETE FROM tsesion WHERE utimestamp < $audit_limit");
}
else {
log_message ('PURGE', 'audit_purge is set to 0. Old audit data will not be deleted.');
}
# Delete SNMP trap data # Delete SNMP trap data
$conf->{'_trap_purge'}= 7 if (!defined($conf->{'_trap_purge'})); $conf->{'_trap_purge'}= 7 if (!defined($conf->{'_trap_purge'}));
log_message ('PURGE', "Deleting old SNMP traps data (More than " . $conf->{'_trap_purge'} . " days)."); if ($conf->{'_trap_purge'} > 0) {
log_message ('PURGE', "Deleting old SNMP traps (More than " . $conf->{'_trap_purge'} . " days).");
my $trap_limit = strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - 86400 * $conf->{'_trap_purge'})); my $trap_limit = strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - 86400 * $conf->{'_trap_purge'}));
db_do($dbh, "DELETE FROM ttrap WHERE timestamp < '$trap_limit'"); db_do($dbh, "DELETE FROM ttrap WHERE timestamp < '$trap_limit'");
}
else {
log_message ('PURGE', 'trap_purge is set to 0. Old SNMP traps will not be deleted.');
}
# Delete policy queue data # Delete policy queue data
enterprise_hook("pandora_purge_policy_queue", [$dbh, $conf]); enterprise_hook("pandora_purge_policy_queue", [$dbh, $conf]);
@ -227,10 +249,14 @@ sub pandora_purgedb ($$) {
# Delete GIS data # Delete GIS data
$conf->{'_gis_purge'}= 15 if (!defined($conf->{'_gis_purge'})); $conf->{'_gis_purge'}= 15 if (!defined($conf->{'_gis_purge'}));
if ($conf->{'_gis_purge'} > 0) {
log_message ('PURGE', "Deleting old GIS data (More than " . $conf->{'_gis_purge'} . " days)."); log_message ('PURGE', "Deleting old GIS data (More than " . $conf->{'_gis_purge'} . " days).");
my $gis_limit = strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - 86400 * $conf->{'_gis_purge'})); my $gis_limit = strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - 86400 * $conf->{'_gis_purge'}));
db_do($dbh, "DELETE FROM tgis_data_history WHERE end_timestamp < '$gis_limit'"); db_do($dbh, "DELETE FROM tgis_data_history WHERE end_timestamp < '$gis_limit'");
}
else {
log_message ('PURGE', 'gis_purge is set to 0. Old GIS data will not be deleted.');
}
# Delete pending modules # Delete pending modules
log_message ('PURGE', "Deleting pending delete modules (data table).", ''); log_message ('PURGE', "Deleting pending delete modules (data table).", '');
@ -323,6 +349,7 @@ sub pandora_purgedb ($$) {
# Delete old netflow data # Delete old netflow data
if ($conf->{'_netflow_max_lifetime'} > 0) {
log_message ('PURGE', "Deleting old netflow data."); log_message ('PURGE', "Deleting old netflow data.");
if (! defined ($conf->{'_netflow_path'}) || ! -d $conf->{'_netflow_path'}) { if (! defined ($conf->{'_netflow_path'}) || ! -d $conf->{'_netflow_path'}) {
log_message ('!', "Netflow data directory does not exist, skipping."); log_message ('!', "Netflow data directory does not exist, skipping.");
@ -333,6 +360,10 @@ sub pandora_purgedb ($$) {
else { else {
`yes 2>/dev/null | $conf->{'_netflow_nfexpire'} -e "$conf->{'_netflow_path'}" -t $conf->{'_netflow_max_lifetime'}d`; `yes 2>/dev/null | $conf->{'_netflow_nfexpire'} -e "$conf->{'_netflow_path'}" -t $conf->{'_netflow_max_lifetime'}d`;
} }
}
else {
log_message ('PURGE', 'netflow_max_lifetime is set to 0. Old netflow data will not be deleted.');
}
@ -341,7 +372,8 @@ sub pandora_purgedb ($$) {
if (! defined ($conf->{'_log_dir'}) || ! -d $conf->{'_log_dir'}) { if (! defined ($conf->{'_log_dir'}) || ! -d $conf->{'_log_dir'}) {
log_message ('!', "Log data directory does not exist, skipping."); log_message ('!', "Log data directory does not exist, skipping.");
} }
elsif ($conf->{'_log_max_lifetime'} != 0) { elsif ($conf->{'_log_max_lifetime'} > 0) {
log_message ('PURGE', 'Deleting log data older than ' . $conf->{'_log_max_lifetime'} . ' days.');
# Calculate the limit date # Calculate the limit date
my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time() - $conf->{'_log_max_lifetime'} * 86400); my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time() - $conf->{'_log_max_lifetime'} * 86400);
@ -365,6 +397,9 @@ sub pandora_purgedb ($$) {
# Purge the log dir # Purge the log dir
pandora_purge_log_dir ($conf->{'_log_dir'}, $limits); pandora_purge_log_dir ($conf->{'_log_dir'}, $limits);
} }
else {
log_message ('PURGE', 'log_max_lifetime is set to 0. Old log data will not be deleted.');
}
} }
######################################################################## ########################################################################

View File

@ -34,7 +34,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "6.0dev PS141213"; my $version = "6.0dev PS150108";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);

View File

@ -33,18 +33,23 @@ Where options:\n
-create_event -create_event
-name <event_name> : Free text -name <event_name> : Free text
-group <id_group> : Group ID (use 0 for 'all') -group <id_group> : Group ID (use 0 for 'all')
-agent :Agent ID -agent : Agent ID
Optional parameters: Optional parameters:
[-status <status>] : 0 New, 1 Validated, 2 In process [-status <status>] : 0 New, 1 Validated, 2 In process
[-user <id_user>] : User comment (use in combination with -comment option) [-user <id_user>] : User comment (use in combination with -comment option)
[type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased [-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased
alert_manual_validation, system, error, new_agent alert_manual_validation, system, error, new_agent
configuration_change, going_unknown, going_down_critical, configuration_change, going_unknown, going_down_critical,
going_down_warning, going_up_normal going_down_warning, going_up_normal
[-criticity <criticity>] : 0 Maintance, 1 Informative, 2 Normal, [-criticity <criticity>] : 0 Maintance,
3 Warning, 4 Crit, 5 Minor, 6 Major 1 Informative,
2 Normal,
3 Warning,
4 Crit,
5 Minor,
6 Major
[-am <id_agent_module>] : ID Agent Module linked to event [-am <id_agent_module>] : ID Agent Module linked to event
[-alert <id_alert_am>] : ID Alert Module linked to event [-alert <id_alert_am>] : ID Alert Module linked to event
[-c_instructions <critical_instructions>] [-c_instructions <critical_instructions>]
@ -53,19 +58,15 @@ Optional parameters:
[-user_comment <comment>] [-user_comment <comment>]
[-owner_user <user for the event>] [-owner_user <user for the event>]
[-source <source>] : (By default 'Pandora') [-source <source>] : (By default 'Pandora')
[-tag <tags>] : Tag (must exist in the system to be imported)"; [-tag <tags>] : Tag (must exist in the system to be imported)
[-custom_data <custom_data>]: Custom data should be a base 64 encoded JSON document
[-server_id <server_id>] : The pandora node server_id";
print "Credential/API syntax: \n\n\t"; print "Credential/API syntax: \n\n\t";
print "<credentials>: API credentials separated by comma: <api_pass>,<user>,<pass>\n\n"; print "<credentials>: API credentials separated by comma: <api_pass>,<user>,<pass>\n\n";
print "Example of event generation:\n\n"; print "Example of event generation:\n\n";
#~ print "\t./pandora_revent.pl -p http://192.168.70.160/pandora_console/include/api.php -u pot12,admin,pandora \
#~ \t-create_event -name \"Sample event executed from commandline\" -group 2 -type \"system\" -agent 2 \
#~ \t-user \"admin\" -status 0 -am 0 -alert 9 -criticity 3 -comment \"User comments\" -tag \"tags\" \
#~ \t-source \"Commandline\" -extra 3 -c_instructions \"Critical instructions\" \
#~ \t-w_instructions \"Warning instructions\" -u_instructions \"Unknown instructions\" -owner \"other\" ";
print "\t./pandora_revent.pl -p http://localhost/pandora_console/include/api.php -u 1234,admin,pandora \ print "\t./pandora_revent.pl -p http://localhost/pandora_console/include/api.php -u 1234,admin,pandora \
\t-create_event -name \"SampleEvent\" -group 2 -agent 189 -status 0 -user \"admin\" -type \"system\" \ \t-create_event -name \"SampleEvent\" -group 2 -agent 189 -status 0 -user \"admin\" -type \"system\" \
\t-criticity 3 -am 0 -alert 9 -c_instructions \"Critical instructions\" -w_instructions \"Warning instructions\" \ \t-criticity 3 -am 0 -alert 9 -c_instructions \"Critical instructions\" -w_instructions \"Warning instructions\" \
@ -136,6 +137,8 @@ sub tool_api_main () {
my $id_event; my $id_event;
my $option = $ARGV[4]; my $option = $ARGV[4];
my $call_api; my $call_api;
my $custom_data = "";
my $server_id = 0;
#~ help or api path (required) #~ help or api path (required)
if ($ARGV[0] eq '-h') { if ($ARGV[0] eq '-h') {
@ -232,6 +235,12 @@ sub tool_api_main () {
if ($line eq '-owner_user') { if ($line eq '-owner_user') {
$owner_user = $ARGV[$i + 1]; $owner_user = $ARGV[$i + 1];
} }
if ($line eq '-custom_data') {
$custom_data = $ARGV[$i + 1];
}
if ($line eq '-server_id') {
$server_id = $ARGV[$i + 1];
}
$i++; $i++;
} }
@ -264,7 +273,10 @@ sub tool_api_main () {
"|" . $user_comment . "|" . $user_comment .
"|" . $owner_user . "|" . $owner_user .
"|" . $source . "|" . $source .
"|" . $tags; "|" . $tags .
"|" . $custom_data .
"|" . $server_id;
$call_api = $api_path . '?' . $call_api = $api_path . '?' .
'op=set&' . 'op=set&' .
'op2=create_event&' . 'op2=create_event&' .