mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
Merge branch 'develop' into ent-3773-fallo-paginacion-templates-alerts
This commit is contained in:
commit
610e0dabbf
@ -1,5 +1,5 @@
|
||||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.734-190429
|
||||
Version: 7.0NG.734-190508
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -14,7 +14,7 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.734-190429"
|
||||
pandora_version="7.0NG.734-190508"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
@ -42,7 +42,7 @@ my $Sem = undef;
|
||||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.734';
|
||||
use constant AGENT_BUILD => '190429';
|
||||
use constant AGENT_BUILD => '190508';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.734
|
||||
%define release 190429
|
||||
%define release 190508
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.734
|
||||
%define release 190429
|
||||
%define release 190508
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -10,7 +10,7 @@
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.734"
|
||||
PI_BUILD="190429"
|
||||
PI_BUILD="190508"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
@ -4,23 +4,44 @@
|
||||
# Copyright (c) 2009 Artica Soluciones Tecnologicas S.L.
|
||||
#
|
||||
# inventory Generate a hardware/software inventory.
|
||||
#
|
||||
#
|
||||
# Sample usage: ./inventory <interval in days> [cpu] [ram] [video] [nic] [hd] [cdrom] [software] [init_services] [filesystem] [process] [users]
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; version 2 of the License.
|
||||
#
|
||||
#
|
||||
# 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.
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
use strict;
|
||||
use constant TSTAMP_FILE => '/tmp/pandora_inventory.tstamp';
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
use Data::Dumper;
|
||||
|
||||
# Set environment language to English
|
||||
$ENV{"LANG"} = "en_US";
|
||||
|
||||
# Check AIX system
|
||||
my $AIX=0;
|
||||
my $system = `uname -a | awk '{print $1}'`;
|
||||
if ($system =~ 'AIX') {
|
||||
$AIX=1;
|
||||
}
|
||||
|
||||
sub is_enabled {
|
||||
my $value = shift;
|
||||
if ((defined ($value)) && looks_like_number($value) && ($value > 0)){
|
||||
# return true
|
||||
return 1;
|
||||
}
|
||||
#return false
|
||||
return 0;
|
||||
}
|
||||
# Operation mode (LSHW or HWINFO)
|
||||
my $Mode;
|
||||
|
||||
@ -31,12 +52,12 @@ my $Separator;
|
||||
sub get_module_data ($$$$) {
|
||||
my ($name, $hwinfo, $keys, $modules) = @_;
|
||||
my %module;
|
||||
|
||||
# Store keys
|
||||
$Separator='\s+\*\-';
|
||||
# Store keys
|
||||
foreach my $key (@{$keys}) {
|
||||
push (@{$module{'_keys'}}, $key);
|
||||
}
|
||||
|
||||
|
||||
# Parse module data
|
||||
while (my $line = shift (@{$hwinfo})) {
|
||||
if ($line =~ /$Separator/) {
|
||||
@ -46,7 +67,7 @@ sub get_module_data ($$$$) {
|
||||
foreach my $key (@{$keys}) {
|
||||
if ($line =~ /$key:\s+(.+)/) {
|
||||
$module{$key} = $1;
|
||||
# Replace semicolon by comma to avoid parse errors
|
||||
# Replace semicolon by comma to avoid parse errors
|
||||
$module{$key} =~ s/;/,/g;
|
||||
}
|
||||
}
|
||||
@ -58,12 +79,65 @@ sub get_module_data ($$$$) {
|
||||
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
}
|
||||
sub test_contain ($$) {
|
||||
my ($value, $array)=@_;
|
||||
if ( grep( /$value/, @{$array} ) ) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
sub get_module_data_aix_ram_cpu ($$$$) {
|
||||
my ($name, $hwinfo, $keys, $modules) = @_;
|
||||
my %module;
|
||||
# Store keys
|
||||
foreach my $key (@{$keys}) {
|
||||
push (@{$module{'_keys'}}, $key);
|
||||
}
|
||||
# Parse module data
|
||||
foreach my $line (@{$hwinfo}) {
|
||||
foreach my $key (@{$keys}) {
|
||||
if ($line =~ /$key:\s+(.+)/) {
|
||||
$module{$key} = $1;
|
||||
$module{$key} =~ s/,/ /g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# No data found
|
||||
#my @data = keys (%module);
|
||||
#return unless ($#data >= 0);
|
||||
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
}
|
||||
sub get_module_data_aix ($$$$) {
|
||||
my ($name,$hwinfo,$regex,$modules) = @_;
|
||||
my %module;
|
||||
foreach my $line (@{$hwinfo}) {
|
||||
$line =~ s/\s{2,}/;/g;
|
||||
$line =~ s/\+ //g;
|
||||
$line =~ s/\* //g;
|
||||
}
|
||||
foreach my $line (@{$hwinfo}) {
|
||||
if ($line =~ /$regex/){
|
||||
my ($var1, $var2, $var3) = split /;/, $line;
|
||||
my %module;
|
||||
$module{'device'} = $var1;
|
||||
$module{'serial'} = $var2;
|
||||
$module{'description'}=$var3;
|
||||
$module{'_keys'} = ['device','serial','description'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Get a list of information file system in machine
|
||||
sub get_file_system($$) {
|
||||
my ($name, $modules) = @_;
|
||||
|
||||
my @fileSystems = `df -hP | tail -n +2`; #remove the titles of columns
|
||||
my @fileSystems;
|
||||
if (is_enabled $AIX){
|
||||
@fileSystems = `df -gP | tail -n +2`;
|
||||
} else {
|
||||
@fileSystems = `df -hP | tail -n +2`; #remove the titles of columns
|
||||
}
|
||||
|
||||
foreach my $row (@fileSystems) {
|
||||
next unless ($row =~ /^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+\S+\s+(\S+)/);
|
||||
@ -73,94 +147,110 @@ sub get_file_system($$) {
|
||||
$module{'used'} = $2;
|
||||
$module{'avail'} = $3;
|
||||
$module{'mount'} = $4;
|
||||
$module{'_keys'} = ['filesystem', 'used','avail', 'mount'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
}
|
||||
$module{'_keys'} = ['filesystem', 'used','avail', 'mount'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
}
|
||||
}
|
||||
|
||||
# Get a list of services init in machine
|
||||
sub get_servicies_init_machine($$) {
|
||||
my ($name, $modules) = @_;
|
||||
my $runlevel = `who -r | awk '{print \$2}'`;
|
||||
my $runlevel;
|
||||
if (is_enabled $AIX) {
|
||||
$runlevel = `who -r | awk '{print \$3}'`;
|
||||
} else {
|
||||
$runlevel = `who -r | awk '{print \$2}'`;
|
||||
}
|
||||
|
||||
#ini trim($runlevel)
|
||||
$runlevel =~ s/^\s*//; #ltrim
|
||||
$runlevel =~ s/\s*$//; #rtrim
|
||||
#end trim($runlevel)
|
||||
|
||||
my $script = "";
|
||||
|
||||
my $script;
|
||||
|
||||
if (-e "/etc/rc" . $runlevel .".d/") {
|
||||
$script = "ls /etc/rc" . $runlevel .".d/ -l | grep \"^l.*\" | awk \"{print \\\$NF}\" | sed -e \"s/\\.\\.\\///g\" | sed -e \"s/.*init\\.d\\///g\"";
|
||||
$script = "ls -l /etc/rc" . $runlevel .".d/ | grep \"^l.*\" | awk \"{print \\\$NF}\" | sed -e \"s/\\.\\.\\///g\" | sed -e \"s/.*init\\.d\\///g\"";
|
||||
}
|
||||
else {
|
||||
$script = "ls /etc/rc.d/rc" . $runlevel .".d/ -l | grep \"^l.*\" | grep \" S.* \" | awk \"{print \\\$NF}\" | sed -e \"s/\\.\\.\\///g\" | sed -e \"s/.*init\\.d\\///g\"";
|
||||
|
||||
$script = "ls -l /etc/rc.d/rc" . $runlevel .".d/ | grep \"^l.*\" | grep \" S.* \" | awk \"{print \\\$NF}\" | sed -e \"s/\\.\\.\\///g\" | sed -e \"s/.*init\\.d\\///g\"";
|
||||
}
|
||||
|
||||
|
||||
my @services = `$script`;
|
||||
foreach my $row (@services) {
|
||||
|
||||
my %module;
|
||||
$row =~ s/\n//;
|
||||
$module{'service'} = $row;
|
||||
$module{'_keys'} = ['service'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
$row =~ s/\n//;
|
||||
$module{'service'} = $row;
|
||||
$module{'_keys'} = ['service'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
}
|
||||
}
|
||||
|
||||
# Get a list of running processes
|
||||
sub get_processes ($$) {
|
||||
my ($name, $modules) = @_;
|
||||
my $script;
|
||||
if (is_enabled $AIX) {
|
||||
$script = "ps -eo args | tail -n +2";
|
||||
} else {
|
||||
$script = "ps -eo command | tail -n +2";
|
||||
}
|
||||
|
||||
my $script = "ps -eo command";
|
||||
|
||||
my @services = `$script`;
|
||||
foreach my $row (@services) {
|
||||
my %module;
|
||||
# Remove carriage returns
|
||||
$row =~ s/[\n\l\f]//g;
|
||||
# Replace semicolon by comma to avoid parse errors
|
||||
$row =~ s/;/,/g;
|
||||
$module{'service'} = $row;
|
||||
$module{'_keys'} = ['service'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
}
|
||||
my @services = `$script`;
|
||||
foreach my $row (@services) {
|
||||
my %module;
|
||||
# Remove carriage returns
|
||||
$row =~ s/[\n\l\f]//g;
|
||||
# Replace semicolon by comma to avoid parse errors
|
||||
$row =~ s/;/,/g;
|
||||
$module{'service'} = $row;
|
||||
$module{'_keys'} = ['service'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
}
|
||||
}
|
||||
|
||||
# Get a list of valid users in the system
|
||||
sub get_users ($$) {
|
||||
my ($name, $modules) = @_;
|
||||
|
||||
my $script = "cat /etc/passwd";
|
||||
my ($name, $modules) = @_;
|
||||
my $script = "cat /etc/passwd";
|
||||
my $user = "";
|
||||
my $estado = "";
|
||||
|
||||
my @services = `$script`;
|
||||
foreach my $row (@services) {
|
||||
my %module;
|
||||
my @services = `$script`;
|
||||
foreach my $row (@services) {
|
||||
my %module;
|
||||
|
||||
next unless ($row =~ /^([A-Za-z0-9\-\_]*)/);
|
||||
|
||||
$user = $1;
|
||||
$script = `passwd -S $user`;
|
||||
if ( $script =~ /^(\S+)\sP./){
|
||||
$module{'user'} = $user;
|
||||
$module{'_keys'} = ['user'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
next unless ($row =~ /^([A-Za-z0-9\-\_]*)/);
|
||||
if (is_enabled $AIX) {
|
||||
$user = $1;
|
||||
$script = `lsuser $user`;
|
||||
if ( $script =~ /^(\S+)\sid./){
|
||||
$module{'user'} = $user;
|
||||
$module{'_keys'} = ['user'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
}
|
||||
} else {
|
||||
$user = $1;
|
||||
$script = `passwd -S $user`;
|
||||
if ( $script =~ /^(\S+)\sP./){
|
||||
$module{'user'} = $user;
|
||||
$module{'_keys'} = ['user'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
# Show Kernel Information
|
||||
sub get_kernel_info ($$) {
|
||||
my ($name, $modules) = @_;
|
||||
my $script = `uname -a | tr -d \";\"`;
|
||||
my %module;
|
||||
my ($name, $modules) = @_;
|
||||
my $script = `uname -a | tr -d \";\"`;
|
||||
my %module;
|
||||
|
||||
$module{'Kernel'} = $script;
|
||||
$module{'_keys'} = ['Kernel'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
$module{'Kernel'} = $script;
|
||||
$module{'_keys'} = ['Kernel'];
|
||||
push (@{$modules->{$name}}, \%module);
|
||||
}
|
||||
|
||||
|
||||
@ -171,11 +261,13 @@ sub get_software_module_data ($$) {
|
||||
# Guess the current distribution
|
||||
my $distrib_id = "";
|
||||
|
||||
if ( -e "/etc/SuSE-release"){
|
||||
if (is_enabled $AIX) {
|
||||
$distrib_id = "AIX";
|
||||
}elsif ( -e "/etc/SuSE-release"){
|
||||
$distrib_id = "SUSE";
|
||||
} elsif ( -e "/etc/redhat-release"){
|
||||
}elsif ( -e "/etc/redhat-release"){
|
||||
$distrib_id = "REDHAT";
|
||||
} else {
|
||||
}else {
|
||||
$distrib_id = "DEBIAN";
|
||||
}
|
||||
|
||||
@ -183,7 +275,9 @@ sub get_software_module_data ($$) {
|
||||
my @soft;
|
||||
if ($distrib_id eq 'DEBIAN') {
|
||||
@soft = `dpkg -l | grep ii`;
|
||||
} else {
|
||||
}elsif ($distrib_id eq 'AIX') {
|
||||
@soft = `lslpp -Lcq | awk -F: '{print "ii "\$1" "\$3" "\$8}'`;
|
||||
}else {
|
||||
# Sometimes rpm return data splitted in two lines, and with dupes. Thats bad for our inventory system
|
||||
@soft = `rpm -q -a --qf "ii %{NAME} %{VERSION} %{SUMMARY}\n" | grep "^ii" | sort -u`;
|
||||
}
|
||||
@ -197,7 +291,7 @@ sub get_software_module_data ($$) {
|
||||
$module{'program'} = $1;
|
||||
$module{'version'} = $2;
|
||||
$module{'description'} = $3;
|
||||
# Replace semicolon by comma to avoid parse errors
|
||||
# Replace semicolon by comma to avoid parse errors
|
||||
$module{'program'} =~ s/;/,/g;
|
||||
$module{'version'} =~ s/;/,/g;
|
||||
$module{'description'} =~ s/;/,/g;
|
||||
@ -211,67 +305,95 @@ sub get_software_module_data ($$) {
|
||||
#Get the list of interfaces with the ip assigned
|
||||
sub get_ips ($$) {
|
||||
my ($name, $modules) = @_;
|
||||
my @interfaces;
|
||||
my $ifconfig;
|
||||
if (is_enabled $AIX) {
|
||||
$ifconfig = `ifconfig -a`;
|
||||
} else {
|
||||
$ifconfig = `ifconfig`;
|
||||
}
|
||||
|
||||
my $ifconfig = `ifconfig`;
|
||||
|
||||
my @ifconfig_array = split("\n", $ifconfig);
|
||||
|
||||
for(my $i = 0; $i<$#ifconfig_array; $i++) {
|
||||
|
||||
#Check for an interface
|
||||
if ($ifconfig_array[$i] =~ /Link/) {
|
||||
my %info;
|
||||
|
||||
my @line_split = split(" ", $ifconfig_array[$i]);
|
||||
|
||||
#Get interface name
|
||||
$info{'interface'} = $line_split[0];
|
||||
|
||||
#Get IP address
|
||||
my $line = $ifconfig_array[$i+1];
|
||||
|
||||
$line =~ s/\s+//g;
|
||||
my @ifconfig_array = split("\n", $ifconfig);
|
||||
|
||||
@line_split = split(":", $line);
|
||||
|
||||
if($line_split[1] =~ /(\d+\.\d+\.\d+\.\d+).+/) {
|
||||
$info{'ip'} = $1;
|
||||
}
|
||||
|
||||
$info{'_keys'} = ['interface', 'ip'];
|
||||
push (@{$modules->{$name}}, \%info);
|
||||
|
||||
}
|
||||
foreach (@ifconfig_array){
|
||||
if ($_=~/(.*)flags/){
|
||||
my $match;
|
||||
($match)=$_=~/^(.*?)\: flags/;
|
||||
$match=~s/://;
|
||||
push @interfaces,$match;
|
||||
}
|
||||
}
|
||||
foreach (@interfaces) {
|
||||
my $ifconfig_item=`ifconfig $_`;
|
||||
my $interface=$_;
|
||||
my @ip_array = split("\n", $ifconfig_item);
|
||||
foreach (@ip_array) {
|
||||
if ($_=~/(?<=inet )(.*)(?= netmask)/){
|
||||
my $ip;
|
||||
($ip)=$_=~/inet (.*) netmask/;
|
||||
my %info;
|
||||
$info{'interface'} = $interface;
|
||||
$info{'ip'} = $ip;
|
||||
$info{'_keys'} = ['interface','ip'];
|
||||
push (@{$modules->{$name}}, \%info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Get route table
|
||||
sub get_route_table ($$) {
|
||||
my ($name, $modules) = @_;
|
||||
|
||||
my $route_table = `route`;
|
||||
|
||||
my @table_split = split("\n", $route_table);
|
||||
|
||||
for (my $i=2; $i<=$#table_split; $i++) {
|
||||
|
||||
my @split = split(" ", $table_split[$i]);
|
||||
|
||||
my %info;
|
||||
|
||||
$info{'destination'} = $split[0];
|
||||
$info{'gateway'} = $split[1];
|
||||
$info{'mask'} = $split[2];
|
||||
$info{'flags'} = $split[3];
|
||||
$info{'metric'} = $split[4];
|
||||
$info{'ref'} = $split[5];
|
||||
$info{'use'} = $split[6];
|
||||
$info{'interface'} = $split[7];
|
||||
|
||||
$info{'_keys'} = ['destination', 'gateway', 'mask', 'flags', 'metric', 'use', 'interface'];
|
||||
|
||||
push (@{$modules->{$name}}, \%info);
|
||||
}
|
||||
my ($name, $modules) = @_;
|
||||
my $route_table;
|
||||
my @table_split;
|
||||
if (is_enabled $AIX) {
|
||||
$route_table = `netstat -rn`;
|
||||
@table_split = split("\n", $route_table);
|
||||
my $length=scalar @table_split;
|
||||
for (my $i=4; $i<=$length-4; $i++) {
|
||||
|
||||
my @split = split(" ", $table_split[$i]);
|
||||
|
||||
my %info;
|
||||
|
||||
$info{'destination'} = $split[0];
|
||||
$info{'gateway'} = $split[1];
|
||||
$info{'mask'} = $split[2];
|
||||
$info{'flags'} = $split[3];
|
||||
$info{'metric'} = $split[4];
|
||||
$info{'ref'} = $split[5];
|
||||
$info{'use'} = $split[6];
|
||||
$info{'interface'} = $split[7];
|
||||
|
||||
$info{'_keys'} = ['destination', 'gateway', 'mask', 'flags', 'metric', 'use', 'interface'];
|
||||
|
||||
push (@{$modules->{$name}}, \%info);
|
||||
}
|
||||
} else {
|
||||
$route_table = `route`;
|
||||
my @table_split = split("\n", $route_table);
|
||||
|
||||
for (my $i=2; $i<=$#table_split; $i++) {
|
||||
|
||||
my @split = split(" ", $table_split[$i]);
|
||||
|
||||
my %info;
|
||||
|
||||
$info{'destination'} = $split[0];
|
||||
$info{'gateway'} = $split[1];
|
||||
$info{'mask'} = $split[2];
|
||||
$info{'flags'} = $split[3];
|
||||
$info{'metric'} = $split[4];
|
||||
$info{'ref'} = $split[5];
|
||||
$info{'use'} = $split[6];
|
||||
$info{'interface'} = $split[7];
|
||||
|
||||
$info{'_keys'} = ['destination', 'gateway', 'mask', 'flags', 'metric', 'use', 'interface'];
|
||||
|
||||
push (@{$modules->{$name}}, \%info);
|
||||
}
|
||||
}
|
||||
}
|
||||
# Print module data
|
||||
sub print_module ($$) {
|
||||
@ -309,14 +431,18 @@ my $enable_all = 0;
|
||||
|
||||
$interval = $ARGV[0];
|
||||
if ($#ARGV == 0){
|
||||
$enable_all = 1;
|
||||
$enable_all = 1;
|
||||
}
|
||||
if ($interval!=/[:alpha:]/){
|
||||
splice @ARGV,0,1;
|
||||
}
|
||||
|
||||
foreach my $module (@ARGV) {
|
||||
foreach my $module (@ARGV) {
|
||||
if ($module eq "all"){
|
||||
$enable_all = 1;
|
||||
}
|
||||
$enabled{$module} = 1;
|
||||
$enable_all = 1;
|
||||
}else {
|
||||
$enabled{$module} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
# Check execution interval
|
||||
@ -333,76 +459,107 @@ close (FILE);
|
||||
# Retrieve hardware information
|
||||
$Mode = 'LSHW';
|
||||
$Separator = '\s+\*\-';
|
||||
my @hwinfo = `lshw 2>/dev/null`;
|
||||
if ($? != 0) {
|
||||
$Mode = 'HWINFO';
|
||||
$Separator = 'Hardware Class:';
|
||||
@hwinfo = `hwinfo --cpu --memory --gfxcard --netcard --cdrom --disk 2>/dev/null`;
|
||||
my @hwinfo;
|
||||
if (is_enabled $AIX) {
|
||||
$Separator = '^\s*$';
|
||||
@hwinfo=`prtconf 2>/dev/null`;
|
||||
} else {
|
||||
@hwinfo = `lshw 2>/dev/null`;
|
||||
if ($? != 0) {
|
||||
$Mode = 'HWINFO';
|
||||
$Separator = 'Hardware Class:';
|
||||
@hwinfo = `hwinfo --cpu --memory --gfxcard --netcard --cdrom --disk 2>/dev/null`;
|
||||
}
|
||||
}
|
||||
|
||||
# Parse hardware information
|
||||
my %modules;
|
||||
while (my $line = shift (@hwinfo)) {
|
||||
|
||||
if (is_enabled $AIX) {
|
||||
#CPU
|
||||
# VIDEO
|
||||
### Not avilable in AIX ###
|
||||
# NIC
|
||||
### Not relevant in AIX ###
|
||||
if ((test_contain('ent',\@hwinfo)) && ($enable_all == 1 || $enabled{'nic'} == 1)) {
|
||||
get_module_data_aix ('NIC',\@hwinfo,'^ent',\%modules);
|
||||
}
|
||||
if ((test_contain('hdisk',\@hwinfo)) && ($enable_all == 1 || $enabled{'hd'} == 1)) {
|
||||
get_module_data_aix ('HD',\@hwinfo,'^hdisk',\%modules);
|
||||
}
|
||||
|
||||
foreach my $line (@hwinfo) {
|
||||
chomp ($line);
|
||||
#CPU
|
||||
if (($line =~ /^Memory Size:/) && ($enable_all == 1 || $enabled{'ram'} == 1)) {
|
||||
get_module_data_aix_ram_cpu ('RAM', \@hwinfo, ['Memory Size','Good Memory Size'], \%modules);
|
||||
}
|
||||
|
||||
if (($line =~ /^System Model/) && ($enable_all == 1 || $enabled{'cpu'} == 1)) {
|
||||
get_module_data_aix_ram_cpu ('CPU', \@hwinfo, ['System Model', 'Processor Implementation Mode', 'Number Of Processors'], \%modules);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# Parse hardware information
|
||||
while (my $line= shift (@hwinfo)) {
|
||||
chomp ($line);
|
||||
# CPU
|
||||
if (($line =~ /\*\-cpu/ || $line =~ /Hardware Class: cpu/) && ($enable_all == 1 || $enabled{'cpu'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('CPU', \@hwinfo, ['product', 'vendor', 'capacity'], \%modules);
|
||||
} else {
|
||||
get_module_data ('CPU', \@hwinfo, ['Model', 'Vendor', 'Clock'], \%modules);
|
||||
}
|
||||
}
|
||||
|
||||
# CPU
|
||||
if (($line =~ /\*\-cpu/ || $line =~ /Hardware Class: cpu/) && ($enable_all == 1 || $enabled{'cpu'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('CPU', \@hwinfo, ['product', 'vendor', 'capacity'], \%modules);
|
||||
} else {
|
||||
get_module_data ('CPU', \@hwinfo, ['Model', 'Vendor', 'Clock'], \%modules);
|
||||
}
|
||||
}
|
||||
# RAM
|
||||
if (($line =~ /\*\-bank/ || $line =~ /\*\-memory/ || $line =~ /Hardware Class: memory/) && ($enable_all == 1 || $enabled{'ram'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('RAM', \@hwinfo, ['description', 'size'], \%modules);
|
||||
} else {
|
||||
get_module_data ('RAM', \@hwinfo, ['Model', 'Memory Size'], \%modules);
|
||||
}
|
||||
}
|
||||
|
||||
# RAM
|
||||
if (($line =~ /\*\-bank/ || $line =~ /Hardware Class: memory/) && ($enable_all == 1 || $enabled{'ram'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('RAM', \@hwinfo, ['description', 'size'], \%modules);
|
||||
} else {
|
||||
get_module_data ('RAM', \@hwinfo, ['Model', 'Memory Size'], \%modules);
|
||||
}
|
||||
}
|
||||
# VIDEO
|
||||
if (($line =~ /\*\-display/ || $line =~ /Hardware Class: graphics card/) && ($enable_all == 1 || $enabled{'video'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('VIDEO', \@hwinfo, ['product', 'description', 'vendor'], \%modules);
|
||||
} else {
|
||||
# Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor
|
||||
get_module_data ('VIDEO', \@hwinfo, ['Model', ' Device', ' Vendor'], \%modules);
|
||||
}
|
||||
}
|
||||
|
||||
# VIDEO
|
||||
if (($line =~ /\*\-display/ || $line =~ /Hardware Class: graphics card/) && ($enable_all == 1 || $enabled{'video'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('VIDEO', \@hwinfo, ['product', 'description', 'vendor'], \%modules);
|
||||
} else {
|
||||
# Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor
|
||||
get_module_data ('VIDEO', \@hwinfo, ['Model', ' Device', ' Vendor'], \%modules);
|
||||
}
|
||||
}
|
||||
# NIC
|
||||
if (($line =~ /\*\-network/ || $line =~ /Hardware Class: network/) && ($enable_all == 1 || $enabled{'nic'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('NIC', \@hwinfo, ['product', 'description', 'vendor', 'serial'], \%modules);
|
||||
} else {
|
||||
# Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor
|
||||
get_module_data ('NIC', \@hwinfo, ['Model', ' Device', ' Vendor', 'HW Address'], \%modules);
|
||||
}
|
||||
}
|
||||
|
||||
# NIC
|
||||
if (($line =~ /\*\-network/ || $line =~ /Hardware Class: network/) && ($enable_all == 1 || $enabled{'nic'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('NIC', \@hwinfo, ['product', 'description', 'vendor', 'serial'], \%modules);
|
||||
} else {
|
||||
# Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor
|
||||
get_module_data ('NIC', \@hwinfo, ['Model', ' Device', ' Vendor', 'HW Address'], \%modules);
|
||||
}
|
||||
}
|
||||
|
||||
# CDROM
|
||||
if (($line =~ /\*\-cdrom/ || $line =~ /Hardware Class: cdrom/) && ($enable_all == 1 || $enabled{'cdrom'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('CDROM', \@hwinfo, ['product', 'description', 'vendor'], \%modules);
|
||||
} else {
|
||||
# Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor
|
||||
get_module_data ('CDROM', \@hwinfo, ['Model', ' Device', ' Vendor'], \%modules);
|
||||
}
|
||||
}
|
||||
# CDROM
|
||||
if (($line =~ /\*\-cdrom/ || $line =~ /Hardware Class: cdrom/) && ($enable_all == 1 || $enabled{'cdrom'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('CDROM', \@hwinfo, ['product', 'description', 'vendor'], \%modules);
|
||||
} else {
|
||||
# Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor
|
||||
get_module_data ('CDROM', \@hwinfo, ['Model', ' Device', ' Vendor'], \%modules);
|
||||
}
|
||||
}
|
||||
|
||||
# HD
|
||||
if (($line =~ /\*\-disk/ || $line =~ /Hardware Class: disk/) && ($enable_all == 1 || $enabled{'hd'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('HD', \@hwinfo, ['product', 'description', 'size'], \%modules);
|
||||
} else {
|
||||
get_module_data ('HD', \@hwinfo, ['Model', 'Serial ID', 'Size'], \%modules);
|
||||
}
|
||||
}
|
||||
# HD
|
||||
if (($line =~ /\*\-disk/ || $line =~ /Hardware Class: disk/) && ($enable_all == 1 || $enabled{'hd'} == 1)) {
|
||||
if ($Mode eq 'LSHW') {
|
||||
get_module_data ('HD', \@hwinfo, ['product', 'description', 'size'], \%modules);
|
||||
} else {
|
||||
get_module_data ('HD', \@hwinfo, ['Model', 'Serial ID', 'Size'], \%modules);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Software
|
||||
if ($enable_all == 1 || $enabled{'software'} == 1) {
|
||||
get_software_module_data ('Software', \%modules);
|
||||
@ -410,12 +567,12 @@ if ($enable_all == 1 || $enabled{'software'} == 1) {
|
||||
|
||||
#init_services
|
||||
if ($enable_all == 1 || $enabled{'init_services'} == 1) {
|
||||
get_servicies_init_machine ('Init services', \%modules);
|
||||
get_servicies_init_machine ('Init_services', \%modules);
|
||||
}
|
||||
|
||||
#filesystem
|
||||
if ($enable_all == 1 || $enabled{'filesystem'} == 1) {
|
||||
get_file_system('File system', \%modules);
|
||||
get_file_system('Filesystem', \%modules);
|
||||
}
|
||||
|
||||
#processes
|
||||
@ -442,7 +599,6 @@ if ($enable_all == 1 || $enabled{'route'} == 1) {
|
||||
if ($enable_all == 1 || $enabled{'kernel'} == 1){
|
||||
get_kernel_info ('Kernel', \%modules);
|
||||
}
|
||||
|
||||
# Print module data
|
||||
print "<inventory>\n";
|
||||
while (my ($name, $module) = each (%modules)) {
|
||||
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
||||
{}
|
||||
|
||||
Version
|
||||
{190429}
|
||||
{190508}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
||||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.734(Build 190429)")
|
||||
#define PANDORA_VERSION ("7.0NG.734(Build 190508)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
@ -11,7 +11,7 @@ BEGIN
|
||||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.734(Build 190429))"
|
||||
VALUE "ProductVersion", "(7.0NG.734(Build 190508))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-console
|
||||
Version: 7.0NG.734-190429
|
||||
Version: 7.0NG.734-190508
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -14,7 +14,7 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.734-190429"
|
||||
pandora_version="7.0NG.734-190508"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// Load global vars
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
enterprise_include('godmode/agentes/configurar_agente.php');
|
||||
@ -23,10 +23,10 @@ ui_require_javascript_file('encode_decode_base64');
|
||||
|
||||
check_login();
|
||||
|
||||
// Get tab parameter to check ACL in each tabs
|
||||
// Get tab parameter to check ACL in each tabs.
|
||||
$tab = get_parameter('tab', 'main');
|
||||
|
||||
// See if id_agente is set (either POST or GET, otherwise -1
|
||||
// See if id_agente is set (either POST or GET, otherwise -1.
|
||||
$id_agente = (int) get_parameter('id_agente');
|
||||
$group = 0;
|
||||
$all_groups = [$group];
|
||||
@ -46,6 +46,7 @@ if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
@ -63,11 +64,11 @@ require_once 'include/functions_modules.php';
|
||||
require_once 'include/functions_alerts.php';
|
||||
require_once 'include/functions_reporting.php';
|
||||
|
||||
// Get passed variables
|
||||
// Get passed variables.
|
||||
$alerttype = get_parameter('alerttype');
|
||||
$id_agent_module = (int) get_parameter('id_agent_module');
|
||||
|
||||
// Init vars
|
||||
// Init vars.
|
||||
$descripcion = '';
|
||||
$comentarios = '';
|
||||
$campo_1 = '';
|
||||
@ -137,7 +138,7 @@ $alert_priority = 0;
|
||||
$server_name = '';
|
||||
$grupo = 0;
|
||||
$id_os = 9;
|
||||
// Windows
|
||||
// Windows.
|
||||
$custom_id = '';
|
||||
$cascade_protection = 0;
|
||||
$cascade_protection_modules = 0;
|
||||
@ -156,7 +157,7 @@ $cps = 0;
|
||||
$create_agent = (bool) get_parameter('create_agent');
|
||||
$module_macros = [];
|
||||
|
||||
// Create agent
|
||||
// Create agent.
|
||||
if ($create_agent) {
|
||||
$mssg_warning = 0;
|
||||
$alias_safe_output = io_safe_output(get_parameter('alias', ''));
|
||||
@ -165,14 +166,14 @@ if ($create_agent) {
|
||||
$direccion_agente = (string) get_parameter_post('direccion', '');
|
||||
$unique_ip = (int) get_parameter_post('unique_ip', 0);
|
||||
|
||||
// safe_output only validate ip
|
||||
// Safe_output only validate ip.
|
||||
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||
|
||||
if (!validate_address($direccion_agente)) {
|
||||
$mssg_warning = 1;
|
||||
}
|
||||
|
||||
// safe-input before validate ip
|
||||
// Safe-input before validate ip.
|
||||
$direccion_agente = io_safe_input($direccion_agente);
|
||||
|
||||
$nombre_agente = hash('sha256', $alias.'|'.$direccion_agente.'|'.time().'|'.sprintf('%04d', rand(0, 10000)));
|
||||
@ -208,7 +209,7 @@ if ($create_agent) {
|
||||
$field_values[$field['id_field']] = (string) get_parameter_post('customvalue_'.$field['id_field'], '');
|
||||
}
|
||||
|
||||
// Check if agent exists (BUG WC-50518-2)
|
||||
// Check if agent exists (BUG WC-50518-2).
|
||||
if ($alias == '') {
|
||||
$agent_creation_error = __('No agent alias specified');
|
||||
$agent_created_ok = 0;
|
||||
@ -256,7 +257,7 @@ if ($create_agent) {
|
||||
}
|
||||
|
||||
if ($id_agente !== false) {
|
||||
// Create custom fields for this agent
|
||||
// Create custom fields for this agent.
|
||||
foreach ($field_values as $key => $value) {
|
||||
$update_custom = db_process_sql_insert(
|
||||
'tagent_custom_data',
|
||||
@ -268,7 +269,7 @@ if ($create_agent) {
|
||||
);
|
||||
}
|
||||
|
||||
// Create address for this agent in taddress
|
||||
// Create address for this agent in taddress.
|
||||
if ($direccion_agente != '') {
|
||||
agents_add_address($id_agente, $direccion_agente);
|
||||
}
|
||||
@ -311,7 +312,7 @@ if ($create_agent) {
|
||||
"Quiet":"'.(int) $quiet.'",
|
||||
"Cps":"'.(int) $cps.'"}';
|
||||
|
||||
// Create the secondary groups
|
||||
// Create the secondary groups.
|
||||
enterprise_hook(
|
||||
'agents_update_secondary_groups',
|
||||
[
|
||||
@ -341,14 +342,14 @@ if ($create_agent) {
|
||||
}
|
||||
}
|
||||
|
||||
// Show tabs
|
||||
// Show tabs.
|
||||
$img_style = [
|
||||
'class' => 'top',
|
||||
'width' => 16,
|
||||
];
|
||||
|
||||
if ($id_agente) {
|
||||
// View tab
|
||||
// View tab.
|
||||
$viewtab['text'] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'">'.html_print_image('images/operation.png', true, ['title' => __('View')]).'</a>';
|
||||
|
||||
if ($tab == 'view') {
|
||||
@ -359,7 +360,7 @@ if ($id_agente) {
|
||||
|
||||
$viewtab['operation'] = 1;
|
||||
|
||||
// Main tab
|
||||
// Main tab.
|
||||
$maintab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$id_agente.'">'.html_print_image('images/gm_setup.png', true, ['title' => __('Setup')]).'</a>';
|
||||
if ($tab == 'main') {
|
||||
$maintab['active'] = true;
|
||||
@ -367,7 +368,7 @@ if ($id_agente) {
|
||||
$maintab['active'] = false;
|
||||
}
|
||||
|
||||
// Module tab
|
||||
// Module tab.
|
||||
$moduletab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente.'">'.html_print_image('images/gm_modules.png', true, ['title' => __('Modules')]).'</a>';
|
||||
|
||||
if ($tab == 'module') {
|
||||
@ -376,7 +377,7 @@ if ($id_agente) {
|
||||
$moduletab['active'] = false;
|
||||
}
|
||||
|
||||
// Alert tab
|
||||
// Alert tab.
|
||||
$alerttab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente.'">'.html_print_image('images/gm_alerts.png', true, ['title' => __('Alerts')]).'</a>';
|
||||
|
||||
if ($tab == 'alert') {
|
||||
@ -385,7 +386,7 @@ if ($id_agente) {
|
||||
$alerttab['active'] = false;
|
||||
}
|
||||
|
||||
// Template tab
|
||||
// Template tab.
|
||||
$templatetab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=template&id_agente='.$id_agente.'">'.html_print_image('images/templates.png', true, ['title' => __('Module templates')]).'</a>';
|
||||
|
||||
if ($tab == 'template') {
|
||||
@ -395,7 +396,7 @@ if ($id_agente) {
|
||||
}
|
||||
|
||||
|
||||
// Inventory
|
||||
// Inventory.
|
||||
$inventorytab = enterprise_hook('inventory_tab');
|
||||
|
||||
if ($inventorytab == -1) {
|
||||
@ -412,7 +413,7 @@ if ($id_agente) {
|
||||
}
|
||||
|
||||
if ($has_remote_conf === true) {
|
||||
// Plugins
|
||||
// Plugins.
|
||||
$pluginstab = enterprise_hook('plugins_tab');
|
||||
if ($pluginstab == -1) {
|
||||
$pluginstab = '';
|
||||
@ -421,21 +422,21 @@ if ($id_agente) {
|
||||
$pluginstab = '';
|
||||
}
|
||||
|
||||
// Collection
|
||||
// Collection.
|
||||
$collectiontab = enterprise_hook('collection_tab');
|
||||
|
||||
if ($collectiontab == -1) {
|
||||
$collectiontab = '';
|
||||
}
|
||||
|
||||
// Group tab
|
||||
// Group tab.
|
||||
$grouptab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&ag_group='.$group.'">'.html_print_image('images/group.png', true, [ 'title' => __('Group')]).'</a>';
|
||||
|
||||
$grouptab['active'] = false;
|
||||
|
||||
$gistab = [];
|
||||
|
||||
// GIS tab
|
||||
// GIS tab.
|
||||
if ($config['activate_gis']) {
|
||||
$gistab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=gis&id_agente='.$id_agente.'">'.html_print_image('images/gm_gis.png', true, [ 'title' => __('GIS data')]).'</a>';
|
||||
|
||||
@ -446,10 +447,10 @@ if ($id_agente) {
|
||||
}
|
||||
}
|
||||
|
||||
// Agent wizard tab
|
||||
// Agent wizard tab.
|
||||
$agent_wizard['text'] = '<a href="javascript:" class="agent_wizard_tab">'.html_print_image('images/wand_agent.png', true, [ 'title' => __('Agent wizard')]).'</a>';
|
||||
|
||||
// Hidden subtab layer
|
||||
// Hidden subtab layer.
|
||||
$agent_wizard['sub_menu'] = '<ul class="mn subsubmenu" style="display:none; float:none;">';
|
||||
$agent_wizard['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">';
|
||||
$agent_wizard['sub_menu'] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=snmp_explorer&id_agente='.$id_agente.'">'.html_print_image('images/wand_snmp.png', true, [ 'title' => __('SNMP Wizard')]).'</a>';
|
||||
@ -471,7 +472,7 @@ if ($id_agente) {
|
||||
|
||||
$total_incidents = agents_get_count_incidents($id_agente);
|
||||
|
||||
// Incident tab
|
||||
// Incident tab.
|
||||
if ($total_incidents > 0) {
|
||||
$incidenttab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=incident&id_agente='.$id_agente.'">'.html_print_image('images/book_edit.png', true, ['title' => __('Incidents')]).'</a>';
|
||||
|
||||
@ -532,7 +533,7 @@ if ($id_agente) {
|
||||
];
|
||||
}
|
||||
|
||||
// Only if the agent has incidents associated show incidents tab
|
||||
// Only if the agent has incidents associated show incidents tab.
|
||||
if ($total_incidents) {
|
||||
$onheader['incident'] = $incidenttab;
|
||||
}
|
||||
@ -545,7 +546,7 @@ if ($id_agente) {
|
||||
];
|
||||
}
|
||||
|
||||
// Extensions tabs
|
||||
// Extensions tabs.
|
||||
foreach ($config['extensions'] as $extension) {
|
||||
if (isset($extension['extension_god_tab'])) {
|
||||
if (check_acl($config['id_user'], $group, $extension['extension_god_tab']['acl'])) {
|
||||
@ -574,7 +575,7 @@ if ($id_agente) {
|
||||
}
|
||||
|
||||
$help_header = '';
|
||||
// This add information to the header
|
||||
// This add information to the header.
|
||||
switch ($tab) {
|
||||
case 'main':
|
||||
$tab_description = '- '.__('Setup');
|
||||
@ -639,6 +640,10 @@ if ($id_agente) {
|
||||
case 'wmi_explorer':
|
||||
$tab_description = '- '.__('WMI Wizard');
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -649,10 +654,15 @@ if ($id_agente) {
|
||||
$tab_description = '- '.__('SNMP explorer');
|
||||
$help_header = 'snmp_explorer';
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
@ -668,7 +678,7 @@ if ($id_agente) {
|
||||
$config['item_title_size_text']
|
||||
);
|
||||
} else {
|
||||
// Create agent
|
||||
// Create agent.
|
||||
ui_print_page_header(
|
||||
__('Agent manager'),
|
||||
'images/bricks.png',
|
||||
@ -682,12 +692,12 @@ $delete_conf_file = (bool) get_parameter('delete_conf_file');
|
||||
|
||||
if ($delete_conf_file) {
|
||||
$correct = false;
|
||||
// Delete remote configuration
|
||||
// Delete remote configuration.
|
||||
if (isset($config['remote_config'])) {
|
||||
$agent_md5 = md5(io_safe_output(agents_get_name($id_agente, 'none')), false);
|
||||
|
||||
if (file_exists($config['remote_config'].'/md5/'.$agent_md5.'.md5')) {
|
||||
// Agent remote configuration editor
|
||||
// Agent remote configuration editor.
|
||||
$file_name = $config['remote_config'].'/conf/'.$agent_md5.'.conf';
|
||||
$correct = @unlink($file_name);
|
||||
|
||||
@ -703,7 +713,7 @@ if ($delete_conf_file) {
|
||||
);
|
||||
}
|
||||
|
||||
// Show agent creation results
|
||||
// Show agent creation results.
|
||||
if ($create_agent) {
|
||||
if (!isset($agent_creation_error)) {
|
||||
$agent_creation_error = __('Could not be created');
|
||||
@ -720,17 +730,17 @@ if ($create_agent) {
|
||||
}
|
||||
}
|
||||
|
||||
// Fix / Normalize module data
|
||||
// Fix / Normalize module data.
|
||||
if (isset($_GET['fix_module'])) {
|
||||
$id_module = get_parameter_get('fix_module', 0);
|
||||
// get info about this module
|
||||
// Get info about this module.
|
||||
$media = reporting_get_agentmodule_data_average($id_module, 30758400);
|
||||
// Get average over the year
|
||||
// Get average over the year.
|
||||
$media *= 1.3;
|
||||
$error = '';
|
||||
$result = true;
|
||||
|
||||
// If the value of media is 0 or something went wrong, don't delete
|
||||
// If the value of media is 0 or something went wrong, don't delete.
|
||||
if (!empty($media)) {
|
||||
$where = [
|
||||
'datos' => '>'.$media,
|
||||
@ -759,9 +769,9 @@ if (isset($_GET['fix_module'])) {
|
||||
|
||||
$update_agent = (bool) get_parameter('update_agent');
|
||||
|
||||
// Update AGENT
|
||||
// Update AGENT.
|
||||
if ($update_agent) {
|
||||
// if modified some agent paramenter
|
||||
// If modified some agent paramenter.
|
||||
$mssg_warning = 0;
|
||||
$id_agente = (int) get_parameter_post('id_agente');
|
||||
$nombre_agente = str_replace('`', '‘', (string) get_parameter_post('agente', ''));
|
||||
@ -770,14 +780,14 @@ if ($update_agent) {
|
||||
$alias_as_name = (int) get_parameter_post('alias_as_name', 0);
|
||||
$direccion_agente = (string) get_parameter_post('direccion', '');
|
||||
$unique_ip = (int) get_parameter_post('unique_ip', 0);
|
||||
// safe_output only validate ip
|
||||
// Safe_output only validate ip.
|
||||
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||
|
||||
if (!validate_address($direccion_agente)) {
|
||||
$mssg_warning = 1;
|
||||
}
|
||||
|
||||
// safe-input before validate ip
|
||||
// Safe-input before validate ip.
|
||||
$direccion_agente = io_safe_input($direccion_agente);
|
||||
|
||||
$address_list = (string) get_parameter_post('address_list', '');
|
||||
@ -786,10 +796,13 @@ if ($update_agent) {
|
||||
&& $direccion_agente == agents_get_address($id_agente)
|
||||
&& $address_list != agents_get_address($id_agente)
|
||||
) {
|
||||
// If we selected another IP in the drop down list to be 'primary':
|
||||
// a) field is not the same as selectbox
|
||||
// b) field has not changed from current IP
|
||||
// c) selectbox is not the current IP
|
||||
/*
|
||||
* If we selected another IP in the drop down list to be 'primary':
|
||||
* a) field is not the same as selectbox
|
||||
* b) field has not changed from current IP
|
||||
* c) selectbox is not the current IP.
|
||||
*/
|
||||
|
||||
if (!empty($address_list)) {
|
||||
$direccion_agente = $address_list;
|
||||
}
|
||||
@ -799,7 +812,7 @@ if ($update_agent) {
|
||||
$intervalo = (int) get_parameter_post('intervalo', SECONDS_5MINUTES);
|
||||
$comentarios = str_replace('`', '‘', (string) get_parameter_post('comentarios', ''));
|
||||
$modo = (int) get_parameter_post('modo', 0);
|
||||
// Mode: Learning, Normal or Autodisabled
|
||||
// Mode: Learning, Normal or Autodisabled.
|
||||
$id_os = (int) get_parameter_post('id_os');
|
||||
$disabled = (bool) get_parameter_post('disabled');
|
||||
$server_name = (string) get_parameter_post('server_name', '');
|
||||
@ -837,7 +850,7 @@ if ($update_agent) {
|
||||
);
|
||||
|
||||
if ($old_value === false) {
|
||||
// Create custom field if not exist
|
||||
// Create custom field if not exist.
|
||||
$update_custom = db_process_sql_insert(
|
||||
'tagent_custom_data',
|
||||
[
|
||||
@ -866,10 +879,10 @@ if ($update_agent) {
|
||||
ui_print_warning_message(__('The ip or dns name entered cannot be resolved'));
|
||||
}
|
||||
|
||||
// Verify if there is another agent with the same name but different ID
|
||||
// Verify if there is another agent with the same name but different ID.
|
||||
if ($alias == '') {
|
||||
ui_print_error_message(__('No agent alias specified'));
|
||||
// If there is an agent with the same name, but a different ID
|
||||
// If there is an agent with the same name, but a different ID.
|
||||
}
|
||||
|
||||
if ($unique_ip && $direccion_agente != '') {
|
||||
@ -882,7 +895,7 @@ if ($update_agent) {
|
||||
} else if ($exists_ip) {
|
||||
ui_print_error_message(__('Duplicate main IP address'));
|
||||
} else {
|
||||
// If different IP is specified than previous, add the IP
|
||||
// If different IP is specified than previous, add the IP.
|
||||
if ($direccion_agente != ''
|
||||
&& $direccion_agente != agents_get_address($id_agente)
|
||||
) {
|
||||
@ -890,7 +903,7 @@ if ($update_agent) {
|
||||
}
|
||||
|
||||
$action_delete_ip = (bool) get_parameter('delete_ip', false);
|
||||
// If IP is set for deletion, delete first
|
||||
// If IP is set for deletion, delete first.
|
||||
if ($action_delete_ip) {
|
||||
$delete_ip = get_parameter_post('address_list');
|
||||
|
||||
@ -939,11 +952,11 @@ if ($update_agent) {
|
||||
__('There was a problem updating the agent')
|
||||
);
|
||||
} else {
|
||||
// Update the agent from the metaconsole cache
|
||||
// Update the agent from the metaconsole cache.
|
||||
enterprise_include_once('include/functions_agents.php');
|
||||
enterprise_hook('agent_update_from_cache', [$id_agente, $values, $server_name]);
|
||||
|
||||
// Update the configuration files
|
||||
// Update the configuration files.
|
||||
if ($old_values['intervalo'] != $intervalo) {
|
||||
enterprise_hook(
|
||||
'config_agents_update_config_token',
|
||||
@ -1057,9 +1070,9 @@ if ($update_agent) {
|
||||
}
|
||||
|
||||
// Read agent data
|
||||
// This should be at the end of all operation checks, to read the changes - $id_agente doesn't have to be retrieved
|
||||
// This should be at the end of all operation checks, to read the changes - $id_agente doesn't have to be retrieved.
|
||||
if ($id_agente) {
|
||||
// This has been done in the beginning of the page, but if an agent was created, this id might change
|
||||
// This has been done in the beginning of the page, but if an agent was created, this id might change.
|
||||
$id_grupo = agents_get_agent_group($id_agente);
|
||||
if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') && !check_acl_one_of_groups($config['id_user'], $all_groups, 'AD')) {
|
||||
db_pandora_audit('ACL Violation', 'Trying to admin an agent without access');
|
||||
@ -1069,13 +1082,13 @@ if ($id_agente) {
|
||||
|
||||
$agent = db_get_row('tagente', 'id_agente', $id_agente);
|
||||
if (empty($agent)) {
|
||||
// Close out the page
|
||||
// Close out the page.
|
||||
ui_print_error_message(__('There was a problem loading the agent'));
|
||||
return;
|
||||
}
|
||||
|
||||
$intervalo = $agent['intervalo'];
|
||||
// Define interval in seconds
|
||||
// Define interval in seconds.
|
||||
$nombre_agente = $agent['nombre'];
|
||||
if (empty($alias)) {
|
||||
$alias = $agent['alias'];
|
||||
@ -1111,11 +1124,11 @@ $create_module = (bool) get_parameter('create_module');
|
||||
$delete_module = (bool) get_parameter('delete_module');
|
||||
$enable_module = (int) get_parameter('enable_module');
|
||||
$disable_module = (int) get_parameter('disable_module');
|
||||
// It is the id_agent_module to duplicate
|
||||
// It is the id_agent_module to duplicate.
|
||||
$duplicate_module = (int) get_parameter('duplicate_module');
|
||||
$edit_module = (bool) get_parameter('edit_module');
|
||||
|
||||
// GET DATA for MODULE UPDATE OR MODULE INSERT
|
||||
// GET DATA for MODULE UPDATE OR MODULE INSERT.
|
||||
if ($update_module || $create_module) {
|
||||
$id_grupo = agents_get_agent_group($id_agente);
|
||||
$all_groups = agents_get_all_groups_agent($id_agente, $id_grupo);
|
||||
@ -1136,9 +1149,12 @@ if ($update_module || $create_module) {
|
||||
$id_module_group = (int) get_parameter('id_module_group');
|
||||
$flag = (bool) get_parameter('flag');
|
||||
|
||||
// Don't read as (float) because it lost it's decimals when put into MySQL
|
||||
// where are very big and PHP uses scientific notation, p.e:
|
||||
// 1.23E-10 is 0.000000000123
|
||||
/*
|
||||
* Don't read as (float) because it lost it's decimals when put into MySQL
|
||||
* where are very big and PHP uses scientific notation, p.e:
|
||||
* 1.23E-10 is 0.000000000123.
|
||||
*/
|
||||
|
||||
$post_process = (string) get_parameter('post_process', 0.0);
|
||||
if (get_parameter('prediction_module')) {
|
||||
$prediction_module = 1;
|
||||
@ -1160,7 +1176,7 @@ if ($update_module || $create_module) {
|
||||
$tcp_send = (string) get_parameter('tcp_send');
|
||||
$tcp_rcv = (string) get_parameter('tcp_rcv');
|
||||
$tcp_port = (int) get_parameter('tcp_port');
|
||||
// Correction in order to not insert 0 as port
|
||||
// Correction in order to not insert 0 as port.
|
||||
$is_port_empty = get_parameter('tcp_port', '');
|
||||
if ($is_port_empty === '') {
|
||||
$tcp_port = null;
|
||||
@ -1186,7 +1202,7 @@ if ($update_module || $create_module) {
|
||||
}
|
||||
|
||||
if ($id_module_type == 25) {
|
||||
// web analysis, from MODULE_WUX
|
||||
// web analysis, from MODULE_WUX.
|
||||
$custom_string_1 = base64_encode((string) get_parameter('custom_string_1', $custom_string_1_default));
|
||||
$custom_integer_1 = (int) get_parameter('custom_integer_1', $custom_integer_1_default);
|
||||
} else {
|
||||
@ -1198,7 +1214,7 @@ if ($update_module || $create_module) {
|
||||
$custom_string_3 = (string) get_parameter('custom_string_3', $custom_string_3_default);
|
||||
$custom_integer_2 = (int) get_parameter('custom_integer_2', 0);
|
||||
|
||||
// Get macros
|
||||
// Get macros.
|
||||
$macros = (string) get_parameter('macros');
|
||||
|
||||
if (!empty($macros)) {
|
||||
@ -1225,7 +1241,8 @@ if ($update_module || $create_module) {
|
||||
if (preg_match('/^module_name\s*(.*)/', $line, $match)) {
|
||||
$new_configuration_data .= 'module_name '.io_safe_output($name)."\n";
|
||||
}
|
||||
// We delete from conf all the module macros starting with _field
|
||||
|
||||
// We delete from conf all the module macros starting with _field.
|
||||
else if (!preg_match('/^module_macro_field.*/', $line, $match)) {
|
||||
$new_configuration_data .= "$line\n";
|
||||
}
|
||||
@ -1243,14 +1260,6 @@ if ($update_module || $create_module) {
|
||||
$new_configuration_data = str_replace('module_end', $macros_for_data.'module_end', $new_configuration_data);
|
||||
}
|
||||
|
||||
/*
|
||||
$macros_for_data = enterprise_hook('config_agents_get_macros_data_conf', array($_POST));
|
||||
|
||||
if ($macros_for_data !== ENTERPRISE_NOT_HOOK && $macros_for_data != '') {
|
||||
// Add macros to configuration file
|
||||
$new_configuration_data = str_replace('module_end', $macros_for_data."module_end", $new_configuration_data);
|
||||
}
|
||||
*/
|
||||
$configuration_data = str_replace(
|
||||
'\\',
|
||||
'\',
|
||||
@ -1269,16 +1278,16 @@ if ($update_module || $create_module) {
|
||||
|
||||
$snmp_community = (string) get_parameter('snmp_community');
|
||||
$snmp_oid = (string) get_parameter('snmp_oid');
|
||||
// Change double quotes by single
|
||||
// Change double quotes by single.
|
||||
$snmp_oid = preg_replace('/"/', ''', $snmp_oid);
|
||||
|
||||
if (empty($snmp_oid)) {
|
||||
// The user did not set any OID manually but did a SNMP walk
|
||||
// The user did not set any OID manually but did a SNMP walk.
|
||||
$snmp_oid = (string) get_parameter('select_snmp_oid');
|
||||
}
|
||||
|
||||
if ($id_module_type >= 15 && $id_module_type <= 18) {
|
||||
// New support for snmp v3
|
||||
// New support for snmp v3.
|
||||
$tcp_send = (string) get_parameter('snmp_version');
|
||||
$plugin_user = (string) get_parameter('snmp3_auth_user');
|
||||
$plugin_pass = io_input_password((string) get_parameter('snmp3_auth_pass'));
|
||||
@ -1410,15 +1419,25 @@ if ($update_module || $create_module) {
|
||||
$module_macro_values = (array) get_parameter('module_macro_values', []);
|
||||
$module_macros = modules_get_module_macros_json($module_macro_names, $module_macro_values);
|
||||
|
||||
// Make changes in the conf file if necessary
|
||||
// Make changes in the conf file if necessary.
|
||||
enterprise_include_once('include/functions_config_agents.php');
|
||||
|
||||
$module_in_policy = enterprise_hook('policies_is_module_in_policy', [$id_agent_module]);
|
||||
$module_linked = enterprise_hook('policies_is_module_linked', [$id_agent_module]);
|
||||
|
||||
if ((!$module_in_policy && !$module_linked )
|
||||
|| ( $module_in_policy && !$module_linked )
|
||||
if ((!$module_in_policy && !$module_linked && $update_module)
|
||||
|| ( $module_in_policy && !$module_linked && $update_module)
|
||||
) {
|
||||
enterprise_hook(
|
||||
'config_agents_update_module_in_conf',
|
||||
[
|
||||
$id_agente,
|
||||
io_safe_output($old_configuration_data),
|
||||
io_safe_output($configuration_data),
|
||||
$disabled,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
enterprise_hook(
|
||||
'config_agents_write_module_in_conf',
|
||||
[
|
||||
@ -1431,7 +1450,7 @@ if ($update_module || $create_module) {
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE UPDATE
|
||||
// MODULE UPDATE.
|
||||
if ($update_module) {
|
||||
$id_agent_module = (int) get_parameter('id_agent_module');
|
||||
|
||||
@ -1517,7 +1536,7 @@ if ($update_module) {
|
||||
}
|
||||
}
|
||||
|
||||
// In local modules, the interval is updated by agent
|
||||
// In local modules, the interval is updated by agent.
|
||||
$module_kind = (int) get_parameter('moduletype');
|
||||
if ($module_kind == MODULE_DATA) {
|
||||
unset($values['module_interval']);
|
||||
@ -1586,7 +1605,7 @@ if ($update_module) {
|
||||
);
|
||||
}
|
||||
|
||||
// Update the module interval
|
||||
// Update the module interval.
|
||||
cron_update_module_interval($id_agent_module, $cron_interval);
|
||||
|
||||
ui_print_success_message(__('Module successfully updated'));
|
||||
@ -1605,8 +1624,7 @@ if ($update_module) {
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE INSERT
|
||||
// =================
|
||||
// MODULE INSERT.
|
||||
if ($create_module) {
|
||||
if (isset($_POST['combo_snmp_oid'])) {
|
||||
$combo_snmp_oid = get_parameter_post('combo_snmp_oid');
|
||||
@ -1630,6 +1648,10 @@ if ($create_module) {
|
||||
$description = ' ';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
$values = [
|
||||
@ -1755,7 +1777,7 @@ if ($create_module) {
|
||||
enterprise_hook('modules_create_synthetic_operations', [$id_agent_module, $serialize_ops]);
|
||||
}
|
||||
|
||||
// Update the module interval
|
||||
// Update the module interval.
|
||||
cron_update_module_interval($id_agent_module, $cron_interval);
|
||||
|
||||
ui_print_success_message(__('Module added successfully'));
|
||||
@ -1776,7 +1798,7 @@ if ($create_module) {
|
||||
}
|
||||
|
||||
// MODULE DELETION
|
||||
// =================
|
||||
// =================.
|
||||
if ($delete_module) {
|
||||
// DELETE agent module !
|
||||
$id_borrar_modulo = (int) get_parameter_get('delete_module', 0);
|
||||
@ -1812,7 +1834,7 @@ if ($delete_module) {
|
||||
enterprise_include_once('include/functions_config_agents.php');
|
||||
enterprise_hook('config_agents_delete_module_in_conf', [modules_get_agentmodule_agent($id_borrar_modulo), modules_get_agentmodule_name($id_borrar_modulo)]);
|
||||
|
||||
// Init transaction
|
||||
// Init transaction.
|
||||
$error = 0;
|
||||
|
||||
// First delete from tagente_modulo -> if not successful, increment
|
||||
@ -1831,7 +1853,7 @@ if ($delete_module) {
|
||||
if ($result === false) {
|
||||
$error++;
|
||||
} else {
|
||||
// Set flag to update module status count
|
||||
// Set flag to update module status count.
|
||||
db_process_sql(
|
||||
'UPDATE tagente
|
||||
SET update_module_count = 1, update_alert_count = 1
|
||||
@ -1873,7 +1895,7 @@ if ($delete_module) {
|
||||
}
|
||||
|
||||
// Trick to detect if we are deleting a synthetic module (avg or arithmetic)
|
||||
// If result is empty then module doesn't have this type of submodules
|
||||
// If result is empty then module doesn't have this type of submodules.
|
||||
$ops_json = enterprise_hook('modules_get_synthetic_operations', [$id_borrar_modulo]);
|
||||
$result_ops_synthetic = json_decode($ops_json);
|
||||
if (!empty($result_ops_synthetic)) {
|
||||
@ -1881,18 +1903,17 @@ if ($delete_module) {
|
||||
if ($result === false) {
|
||||
$error++;
|
||||
}
|
||||
} //end if
|
||||
else {
|
||||
} else {
|
||||
$result_components = enterprise_hook('modules_get_synthetic_components', [$id_borrar_modulo]);
|
||||
$count_components = 1;
|
||||
if (!empty($result_components)) {
|
||||
// Get number of components pending to delete to know when it's needed to update orders
|
||||
// Get number of components pending to delete to know when it's needed to update orders.
|
||||
$num_components = count($result_components);
|
||||
$last_target_module = 0;
|
||||
foreach ($result_components as $id_target_module) {
|
||||
// Detects change of component or last component to update orders
|
||||
// Detects change of component or last component to update orders.
|
||||
if (($count_components == $num_components)
|
||||
or ($last_target_module != $id_target_module)
|
||||
|| ($last_target_module != $id_target_module)
|
||||
) {
|
||||
$update_orders = true;
|
||||
} else {
|
||||
@ -1911,7 +1932,7 @@ if ($delete_module) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check for errors
|
||||
// Check for errors.
|
||||
if ($error != 0) {
|
||||
ui_print_error_message(__('There was a problem deleting the module'));
|
||||
} else {
|
||||
@ -1929,7 +1950,7 @@ if ($delete_module) {
|
||||
}
|
||||
|
||||
// MODULE DUPLICATION
|
||||
// ==================
|
||||
// ==================.
|
||||
if (!empty($duplicate_module)) {
|
||||
// DUPLICATE agent module !
|
||||
$id_duplicate_module = $duplicate_module;
|
||||
@ -1976,7 +1997,7 @@ if (!empty($duplicate_module)) {
|
||||
}
|
||||
|
||||
// MODULE ENABLE/DISABLE
|
||||
// =====================
|
||||
// =====================.
|
||||
if ($enable_module) {
|
||||
$result = modules_change_disabled($enable_module, 0);
|
||||
$modulo_nombre = db_get_row_sql('SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = '.$enable_module.'');
|
||||
@ -2016,7 +2037,7 @@ if ($disable_module) {
|
||||
}
|
||||
|
||||
// UPDATE GIS
|
||||
// ==========
|
||||
// ==========.
|
||||
$updateGIS = get_parameter('update_gis', 0);
|
||||
if ($updateGIS) {
|
||||
$updateGisData = get_parameter('update_gis_data');
|
||||
@ -2104,9 +2125,8 @@ switch ($tab) {
|
||||
break;
|
||||
|
||||
case 'alert':
|
||||
/*
|
||||
Because $id_agente is set, it will show only agent alerts */
|
||||
// This var is for not display create button on alert list
|
||||
// Because $id_agente is set, it will show only agent alerts.
|
||||
// This var is for not display create button on alert list.
|
||||
$dont_display_alert_create_bttn = true;
|
||||
include 'godmode/alerts/alert_list.php';
|
||||
break;
|
||||
@ -2155,7 +2175,7 @@ switch ($tab) {
|
||||
default:
|
||||
if (enterprise_hook('switch_agent_tab', [$tab])) {
|
||||
// This will make sure that blank pages will have at least some
|
||||
// debug info in them - do not translate debug
|
||||
// debug info in them - do not translate debug.
|
||||
ui_print_error_message(__('Invalid tab specified'));
|
||||
}
|
||||
break;
|
||||
|
@ -200,8 +200,8 @@ if ($config['history_db_enabled'] == 1) {
|
||||
);
|
||||
|
||||
$time_pandora_db_history = false;
|
||||
if ($history_connect !== false) {
|
||||
if ($config['history_db_connection'] !== false) {
|
||||
if ($history_connect) {
|
||||
if ($config['history_db_connection']) {
|
||||
$time_pandora_db_history = mysql_db_process_sql(
|
||||
$sql,
|
||||
'insert_id',
|
||||
@ -405,16 +405,16 @@ if ($config['history_db_enabled'] == 1) {
|
||||
);
|
||||
}
|
||||
|
||||
$history_connect = @mysql_db_process_sql(
|
||||
'SELECT 1 FROM tconfig',
|
||||
'affected_rows',
|
||||
$config['history_db_connection'],
|
||||
false
|
||||
);
|
||||
|
||||
$config_history = false;
|
||||
if ($history_connect !== false) {
|
||||
if ($config['history_db_connection'] != false) {
|
||||
if ($config['history_db_connection']) {
|
||||
$history_connect = @mysql_db_process_sql(
|
||||
'SELECT 1 FROM tconfig',
|
||||
'affected_rows',
|
||||
$config['history_db_connection'],
|
||||
false
|
||||
);
|
||||
|
||||
if ($history_connect !== false) {
|
||||
$config_history_array = mysql_db_process_sql(
|
||||
'SELECT * FROM tconfig',
|
||||
'affected_rows',
|
||||
@ -427,11 +427,11 @@ if ($config['history_db_enabled'] == 1) {
|
||||
$config_history[$value['token']] = $value['value'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo ui_print_error_message(
|
||||
__('The tconfig table does not exist in the historical database')
|
||||
);
|
||||
}
|
||||
} else {
|
||||
echo ui_print_error_message(
|
||||
__('The tconfig table does not exist in the historical database')
|
||||
);
|
||||
}
|
||||
|
||||
if ($config_history === false) {
|
||||
|
@ -1,17 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Extension to manage a list of gateways and the node address where they should
|
||||
* point to.
|
||||
*
|
||||
* @category Custom fields View
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
if (check_login()) {
|
||||
// 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;
|
||||
|
||||
include_once $config['homedir'].'/include/functions_agents.php';
|
||||
@ -21,9 +37,18 @@ if (check_login()) {
|
||||
enterprise_include_once('include/functions_metaconsole.php');
|
||||
|
||||
$get_custom_fields_data = (bool) get_parameter('get_custom_fields_data', 0);
|
||||
$build_table_custom_fields = (bool) get_parameter('build_table_custom_fields', 0);
|
||||
$build_table_child_custom_fields = (bool) get_parameter('build_table_child_custom_fields', 0);
|
||||
$build_table_save_filter = (bool) get_parameter('build_table_save_filter', 0);
|
||||
$build_table_custom_fields = (bool) get_parameter(
|
||||
'build_table_custom_fields',
|
||||
0
|
||||
);
|
||||
$build_table_child_custom_fields = (bool) get_parameter(
|
||||
'build_table_child_custom_fields',
|
||||
0
|
||||
);
|
||||
$build_table_save_filter = (bool) get_parameter(
|
||||
'build_table_save_filter',
|
||||
0
|
||||
);
|
||||
$append_tab_filter = (bool) get_parameter('append_tab_filter', 0);
|
||||
$create_filter_cf = (bool) get_parameter('create_filter_cf', 0);
|
||||
$update_filter_cf = (bool) get_parameter('update_filter_cf', 0);
|
||||
@ -43,9 +68,16 @@ if (check_login()) {
|
||||
$start = get_parameter('start', 0);
|
||||
$draw = get_parameter('draw', 0);
|
||||
$search = get_parameter('search', '');
|
||||
$indexed_descriptions = json_decode(io_safe_output(get_parameter('indexed_descriptions', '')), true);
|
||||
$indexed_descriptions = json_decode(
|
||||
io_safe_output(
|
||||
get_parameter('indexed_descriptions', '')
|
||||
),
|
||||
true
|
||||
);
|
||||
$module_status = get_parameter('module_status');
|
||||
$id_status = get_parameter('id_status');
|
||||
|
||||
// order query
|
||||
// Order query.
|
||||
$order_column = $order[0]['column'];
|
||||
$type_order = $order[0]['dir'];
|
||||
switch ($order_column) {
|
||||
@ -66,27 +98,34 @@ if (check_login()) {
|
||||
break;
|
||||
}
|
||||
|
||||
// table temporary for save array in table by order and search custom_field data
|
||||
// Table temporary for save array in table
|
||||
// by order and search custom_field data.
|
||||
$table_temporary = 'CREATE TEMPORARY TABLE temp_custom_fields (
|
||||
id_server int(10),
|
||||
id_agent int(10),
|
||||
name_custom_fields varchar(2048),
|
||||
critical_count int,
|
||||
warning_count int,
|
||||
unknown_count int,
|
||||
notinit_count int,
|
||||
normal_count int,
|
||||
total_count int,
|
||||
`status` int(2),
|
||||
KEY `data_index_temp_1` (`id_server`, `id_agent`)
|
||||
)';
|
||||
db_process_sql($table_temporary);
|
||||
|
||||
// insert values array in table temporary
|
||||
// Insert values array in table temporary.
|
||||
$values_insert = [];
|
||||
foreach ($indexed_descriptions as $key => $value) {
|
||||
$values_insert[] = '('.$value['id_server'].', '.$value['id_agente'].", '".$value['description']."', ".$value['status'].')';
|
||||
$values_insert[] = '('.$value['id_server'].', '.$value['id_agente'].", '".$value['description']."', '".$value['critical_count']."', '".$value['warning_count']."', '".$value['unknown_count']."', '".$value['notinit_count']."', '".$value['normal_count']."', '".$value['total_count']."', ".$value['status'].')';
|
||||
}
|
||||
|
||||
$values_insert_implode = implode(',', $values_insert);
|
||||
$query_insert = 'INSERT INTO temp_custom_fields VALUES '.$values_insert_implode;
|
||||
db_process_sql($query_insert);
|
||||
|
||||
// search table for alias, custom field data, server_name, direction
|
||||
// Search table for alias, custom field data, server_name, direction.
|
||||
$search_query = '';
|
||||
if ($search['value'] != '') {
|
||||
$search_query = ' AND (tma.alias LIKE "%'.$search['value'].'%"';
|
||||
@ -95,7 +134,61 @@ if (check_login()) {
|
||||
$search_query .= ' OR temp.name_custom_fields LIKE "%'.$search['value'].'%" ) ';
|
||||
}
|
||||
|
||||
// query all fields result
|
||||
// Search for status module.
|
||||
$status_agent_search = '';
|
||||
if (isset($id_status) === true && is_array($id_status) === true) {
|
||||
if (in_array(-1, $id_status) === false) {
|
||||
if (in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $id_status) === false) {
|
||||
$status_agent_search = ' AND temp.status IN ('.implode(',', $id_status).')';
|
||||
} else {
|
||||
// Not normal statuses.
|
||||
$status_agent_search = ' AND temp.status IN (1,2,3,4,5)';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Search for status module.
|
||||
$status_module_search = '';
|
||||
if (isset($module_status) === true && is_array($module_status) === true) {
|
||||
if (in_array(-1, $module_status) === false) {
|
||||
if (in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $module_status) === false) {
|
||||
if (count($module_status) > 0) {
|
||||
$status_module_search = ' AND ( ';
|
||||
foreach ($module_status as $key => $value) {
|
||||
$status_module_search .= ($key != 0) ? ' OR (' : ' (';
|
||||
switch ($value) {
|
||||
default:
|
||||
case AGENT_STATUS_NORMAL:
|
||||
$status_module_search .= ' temp.normal_count > 0) ';
|
||||
break;
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
$status_module_search .= ' temp.critical_count > 0) ';
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_WARNING:
|
||||
$status_module_search .= ' temp.warning_count > 0) ';
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_UNKNOWN:
|
||||
$status_module_search .= ' temp.unknown_count > 0) ';
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_NOT_INIT:
|
||||
$status_module_search .= ' temp.notinit_count > 0) ';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$status_module_search .= ' ) ';
|
||||
}
|
||||
} else {
|
||||
// Not normal.
|
||||
$status_module_search = ' AND ( temp.critical_count > 0 OR temp.warning_count > 0 OR temp.unknown_count > 0 AND temp.notinit_count > 0 )';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Query all fields result.
|
||||
$query = sprintf(
|
||||
'SELECT
|
||||
tma.id_agente,
|
||||
@ -112,10 +205,14 @@ if (check_login()) {
|
||||
AND temp.id_server = tma.id_tmetaconsole_setup
|
||||
WHERE tma.disabled = 0
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
LIMIT %d OFFSET %d
|
||||
',
|
||||
$search_query,
|
||||
$status_agent_search,
|
||||
$status_module_search,
|
||||
$order_by,
|
||||
$length,
|
||||
$start
|
||||
@ -123,23 +220,27 @@ if (check_login()) {
|
||||
|
||||
$result = db_get_all_rows_sql($query);
|
||||
|
||||
// query count
|
||||
// Query count.
|
||||
$query_count = sprintf(
|
||||
'SELECT
|
||||
COUNT(tma.id_agente) AS `count`
|
||||
FROM tmetaconsole_agent tma
|
||||
INNER JOIN temp_custom_fields temp
|
||||
ON temp.id_agent = tma.id_tagente
|
||||
AND temp.id_server = tma.id_tmetaconsole_setup
|
||||
WHERE tma.disabled = 0
|
||||
%s
|
||||
',
|
||||
$search_query
|
||||
FROM tmetaconsole_agent tma
|
||||
INNER JOIN temp_custom_fields temp
|
||||
ON temp.id_agent = tma.id_tagente
|
||||
AND temp.id_server = tma.id_tmetaconsole_setup
|
||||
WHERE tma.disabled = 0
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
',
|
||||
$search_query,
|
||||
$status_agent_search,
|
||||
$status_module_search
|
||||
);
|
||||
|
||||
$count = db_get_sql($query_count);
|
||||
|
||||
// for link nodes.
|
||||
// For link nodes.
|
||||
$array_nodes = metaconsole_get_connections();
|
||||
if (isset($array_nodes) && is_array($array_nodes)) {
|
||||
$hash_array_nodes = [];
|
||||
@ -158,20 +259,20 @@ if (check_login()) {
|
||||
$user_rot13 = str_rot13($config['id_user']);
|
||||
$hashdata = $user.$pwd;
|
||||
$hashdata = md5($hashdata);
|
||||
$url_hash = '&'.'loginhash=auto&'.'loginhash_data='.$hashdata.'&'.'loginhash_user='.$user_rot13;
|
||||
$url_hash = '&loginhash=auto&loginhash_data='.$hashdata.'&loginhash_user='.$user_rot13;
|
||||
|
||||
$hash_array_nodes[$server['id']]['hashurl'] = $url_hash;
|
||||
$hash_array_nodes[$server['id']]['server_url'] = $server['server_url'];
|
||||
}
|
||||
}
|
||||
|
||||
// prepare rows for table dinamic
|
||||
// Prepare rows for table dinamic.
|
||||
$data = [];
|
||||
foreach ($result as $values) {
|
||||
$image_status = agents_get_image_status($values['status']);
|
||||
|
||||
// link nodes
|
||||
$agent_link = '<a href="'.$hash_array_nodes[$values['id_tmetaconsole_setup']]['server_url'].'/'.'index.php?'.'sec=estado&'.'sec2=operation/agentes/ver_agente&'.'id_agente='.$values['id_tagente'].$hash_array_nodes[$values['id_tmetaconsole_setup']]['hashurl'].'">';
|
||||
// Link nodes.
|
||||
$agent_link = '<a href="'.$hash_array_nodes[$values['id_tmetaconsole_setup']]['server_url'].'/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$values['id_tagente'].$hash_array_nodes[$values['id_tmetaconsole_setup']]['hashurl'].'">';
|
||||
|
||||
$agent_alias = ui_print_truncate_text(
|
||||
$values['alias'],
|
||||
@ -225,7 +326,7 @@ if (check_login()) {
|
||||
$name_where = " AND tam.nombre LIKE '%".$module_search."%'";
|
||||
}
|
||||
|
||||
// filter by status module
|
||||
// Filter by status module.
|
||||
$and_module_status = '';
|
||||
if (is_array($module_status)) {
|
||||
if (!in_array(-1, $module_status)) {
|
||||
@ -260,7 +361,7 @@ if (check_login()) {
|
||||
$and_module_status .= ' ) ';
|
||||
}
|
||||
} else {
|
||||
// not normal
|
||||
// Not normal.
|
||||
$and_module_status = 'AND tae.estado <> 0 AND tae.estado <> 300 ';
|
||||
}
|
||||
}
|
||||
@ -314,7 +415,12 @@ if (check_login()) {
|
||||
&& $value['id_tipo_modulo'] != 23
|
||||
&& $value['id_tipo_modulo'] != 33
|
||||
) {
|
||||
$table_modules->data[$key][1] = remove_right_zeros(number_format($value['datos'], $config['graph_precision']));
|
||||
$table_modules->data[$key][1] = remove_right_zeros(
|
||||
number_format(
|
||||
$value['datos'],
|
||||
$config['graph_precision']
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$table_modules->data[$key][1] = $value['datos'];
|
||||
}
|
||||
@ -329,7 +435,10 @@ if (check_login()) {
|
||||
);
|
||||
|
||||
$table_modules->data[$key][3] = $value['current_interval'];
|
||||
$table_modules->data[$key][4] = ui_print_timestamp($value['utimestamp'], true);
|
||||
$table_modules->data[$key][4] = ui_print_timestamp(
|
||||
$value['utimestamp'],
|
||||
true
|
||||
);
|
||||
switch ($value['estado']) {
|
||||
case 0:
|
||||
case 300:
|
||||
@ -398,7 +507,7 @@ if (check_login()) {
|
||||
}
|
||||
}
|
||||
|
||||
// status agents from tagente
|
||||
// Status agents from tagente.
|
||||
$sql_info_agents = 'SELECT * fROM tagente WHERE id_agente ='.$id_agent;
|
||||
$info_agents = db_get_row_sql($sql_info_agents);
|
||||
$status_agent = agents_get_status_from_counts($info_agents);
|
||||
@ -463,7 +572,13 @@ if (check_login()) {
|
||||
false
|
||||
);
|
||||
|
||||
$table->data[0][3] = html_print_submit_button(__('Load filter'), 'load_filter', false, 'class="sub upd"', true);
|
||||
$table->data[0][3] = html_print_submit_button(
|
||||
__('Load filter'),
|
||||
'load_filter',
|
||||
false,
|
||||
'class="sub upd"',
|
||||
true
|
||||
);
|
||||
|
||||
echo "<form action='' method='post'>";
|
||||
html_print_table($table);
|
||||
@ -474,7 +589,12 @@ if (check_login()) {
|
||||
}
|
||||
|
||||
if ($append_tab_filter) {
|
||||
$filters = json_decode(io_safe_output(get_parameter('filters', '')), true);
|
||||
$filters = json_decode(
|
||||
io_safe_output(
|
||||
get_parameter('filters', '')
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$table = new StdClass;
|
||||
$table->id = 'save_filter_form';
|
||||
@ -485,7 +605,14 @@ if (check_login()) {
|
||||
if ($filters['id'] == 'extended_create_filter') {
|
||||
echo "<div id='msg_error_create'></div>";
|
||||
$table->data[0][0] = __('Filter name');
|
||||
$table->data[0][1] = html_print_input_text('id_name', '', '', 15, 255, true);
|
||||
$table->data[0][1] = html_print_input_text(
|
||||
'id_name',
|
||||
'',
|
||||
'',
|
||||
15,
|
||||
255,
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[1][0] = __('Group');
|
||||
$table->data[1][1] = html_print_select_groups(
|
||||
@ -510,7 +637,13 @@ if (check_login()) {
|
||||
);
|
||||
|
||||
$table->rowspan[0][2] = 2;
|
||||
$table->data[0][2] = html_print_submit_button(__('Create filter'), 'create_filter', false, 'class="sub upd"', true);
|
||||
$table->data[0][2] = html_print_submit_button(
|
||||
__('Create filter'),
|
||||
'create_filter',
|
||||
false,
|
||||
'class="sub upd"',
|
||||
true
|
||||
);
|
||||
} else {
|
||||
echo "<div id='msg_error_update'></div>";
|
||||
echo "<div id='msg_error_delete'></div>";
|
||||
@ -552,8 +685,20 @@ if (check_login()) {
|
||||
false
|
||||
);
|
||||
|
||||
$table->data[0][2] = html_print_submit_button(__('Delete filter'), 'delete_filter', false, 'class="sub upd"', true);
|
||||
$table->data[1][2] = html_print_submit_button(__('Update filter'), 'update_filter', false, 'class="sub upd"', true);
|
||||
$table->data[0][2] = html_print_submit_button(
|
||||
__('Delete filter'),
|
||||
'delete_filter',
|
||||
false,
|
||||
'class="sub upd"',
|
||||
true
|
||||
);
|
||||
$table->data[1][2] = html_print_submit_button(
|
||||
__('Update filter'),
|
||||
'update_filter',
|
||||
false,
|
||||
'class="sub upd"',
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
@ -561,17 +706,20 @@ if (check_login()) {
|
||||
}
|
||||
|
||||
if ($create_filter_cf) {
|
||||
// initialize result
|
||||
// Initialize result.
|
||||
$result_array = [];
|
||||
$result_array['error'] = 0;
|
||||
$result_array['msg'] = '';
|
||||
|
||||
// initialize vars
|
||||
$filters = json_decode(io_safe_output(get_parameter('filters', '')), true);
|
||||
// Initialize vars.
|
||||
$filters = json_decode(
|
||||
io_safe_output(get_parameter('filters', '')),
|
||||
true
|
||||
);
|
||||
$name_filter = get_parameter('name_filter', '');
|
||||
$group_search = get_parameter('group_search', 0);
|
||||
|
||||
// check that the name is not empty
|
||||
// Check that the name is not empty.
|
||||
if ($name_filter == '') {
|
||||
$result_array['error'] = 1;
|
||||
$result_array['msg'] = ui_print_error_message(
|
||||
@ -596,7 +744,7 @@ if (check_login()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check custom field is not empty
|
||||
// Check custom field is not empty.
|
||||
if ($filters['id_custom_fields'] == '') {
|
||||
$result_array['error'] = 1;
|
||||
$result_array['msg'] = ui_print_error_message(
|
||||
@ -608,13 +756,15 @@ if (check_login()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// insert
|
||||
// Insert.
|
||||
$values = [];
|
||||
$values['name'] = $name_filter;
|
||||
$values['group_search'] = $group_search;
|
||||
$values['id_group'] = $filters['group'];
|
||||
$values['id_custom_field'] = $filters['id_custom_fields'];
|
||||
$values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']);
|
||||
$values['id_custom_fields_data'] = json_encode(
|
||||
$filters['id_custom_fields_data']
|
||||
);
|
||||
$values['id_status'] = json_encode($filters['id_status']);
|
||||
$values['module_search'] = $filters['module_search'];
|
||||
$values['module_status'] = json_encode($filters['module_status']);
|
||||
@ -622,7 +772,7 @@ if (check_login()) {
|
||||
|
||||
$insert = db_process_sql_insert('tagent_custom_fields_filter', $values);
|
||||
|
||||
// check error insert
|
||||
// Check error insert.
|
||||
if ($insert) {
|
||||
$result_array['error'] = 0;
|
||||
$result_array['msg'] = ui_print_success_message(
|
||||
@ -644,17 +794,17 @@ if (check_login()) {
|
||||
}
|
||||
|
||||
if ($update_filter_cf) {
|
||||
// initialize result
|
||||
// Initialize result.
|
||||
$result_array = [];
|
||||
$result_array['error'] = 0;
|
||||
$result_array['msg'] = '';
|
||||
|
||||
// initialize vars
|
||||
// Initialize vars.
|
||||
$filters = json_decode(io_safe_output(get_parameter('filters', '')), true);
|
||||
$id_filter = get_parameter('id_filter', '');
|
||||
$group_search = get_parameter('group_search', 0);
|
||||
|
||||
// check selected filter
|
||||
// Check selected filter.
|
||||
if ($id_filter == -1) {
|
||||
$result_array['error'] = 1;
|
||||
$result_array['msg'] = ui_print_error_message(
|
||||
@ -666,11 +816,11 @@ if (check_login()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// array condition update
|
||||
// Array condition update.
|
||||
$condition = [];
|
||||
$condition['id'] = $id_filter;
|
||||
|
||||
// check selected custom fields
|
||||
// Check selected custom fields.
|
||||
if ($filters['id_custom_fields'] == '') {
|
||||
$result_array['error'] = 1;
|
||||
$result_array['msg'] = ui_print_error_message(
|
||||
@ -682,7 +832,7 @@ if (check_login()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// array values update
|
||||
// Array values update.
|
||||
$values = [];
|
||||
$values['id_group'] = $filters['group'];
|
||||
$values['group_search'] = $group_search;
|
||||
@ -693,10 +843,10 @@ if (check_login()) {
|
||||
$values['module_status'] = json_encode($filters['module_status']);
|
||||
$values['recursion'] = $filters['recursion'];
|
||||
|
||||
// update
|
||||
// Update.
|
||||
$update = db_process_sql_update('tagent_custom_fields_filter', $values, $condition);
|
||||
|
||||
// check error insert
|
||||
// Check error insert.
|
||||
if ($update) {
|
||||
$result_array['error'] = 0;
|
||||
$result_array['msg'] = ui_print_success_message(
|
||||
@ -718,16 +868,16 @@ if (check_login()) {
|
||||
}
|
||||
|
||||
if ($delete_filter_cf) {
|
||||
// Initialize result
|
||||
// Initialize result.
|
||||
$result_array = [];
|
||||
$result_array['error'] = 0;
|
||||
$result_array['msg'] = '';
|
||||
|
||||
// Initialize vars
|
||||
// Initialize vars.
|
||||
$filters = json_decode(io_safe_output(get_parameter('filters', '')), true);
|
||||
$id_filter = get_parameter('id_filter', '');
|
||||
|
||||
// Check selected filter
|
||||
// Check selected filter.
|
||||
if ($id_filter == -1) {
|
||||
$result_array['error'] = 1;
|
||||
$result_array['msg'] = ui_print_error_message(
|
||||
@ -739,14 +889,14 @@ if (check_login()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Array condition update
|
||||
// Array condition update.
|
||||
$condition = [];
|
||||
$condition['id'] = $id_filter;
|
||||
|
||||
// Delete
|
||||
// Delete.
|
||||
$delete = db_process_sql_delete('tagent_custom_fields_filter', $condition);
|
||||
|
||||
// Check error insert
|
||||
// Check error insert.
|
||||
if ($delete) {
|
||||
$result_array['error'] = 0;
|
||||
$result_array['msg'] = ui_print_success_message(
|
||||
|
@ -1684,7 +1684,12 @@ class NetworkMap
|
||||
$node[$k] = $v;
|
||||
}
|
||||
|
||||
$node['style']['label'] = $node['label'];
|
||||
if (!empty($node['text'])) {
|
||||
$node['style']['label'] = $node['text'];
|
||||
} else {
|
||||
$node['style']['label'] = $node['name'];
|
||||
}
|
||||
|
||||
$node['style']['shape'] = 'circle';
|
||||
if (isset($source_data['color'])) {
|
||||
$item['color'] = $source_data['color'];
|
||||
|
@ -20,7 +20,7 @@
|
||||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC190429';
|
||||
$build_version = 'PC190508';
|
||||
$pandora_version = 'v7.0NG.734';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
@ -4613,7 +4613,7 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2)
|
||||
return;
|
||||
}
|
||||
|
||||
$id = network_components_create_network_component($id, $other['data'][0], $other['data'][25], $values);
|
||||
$id = network_components_create_network_component($id, $other['data'][0], $other['data'][26], $values);
|
||||
|
||||
if (!$id) {
|
||||
returnError('error_set_new_snmp_component', 'Error creating SNMP component.');
|
||||
|
@ -1,16 +1,31 @@
|
||||
<?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.
|
||||
/**
|
||||
* Extension to manage a list of gateways and the node address where they should
|
||||
* point to.
|
||||
*
|
||||
* @category Custom fields View
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@ -56,14 +71,14 @@ function get_custom_fields($custom_field_id=false, $select=true, $display_on_fro
|
||||
}
|
||||
} else {
|
||||
$metaconsole_connections = metaconsole_get_connection_names();
|
||||
// For all nodes
|
||||
// For all nodes.
|
||||
if (isset($metaconsole_connections) && is_array($metaconsole_connections)) {
|
||||
$result_meta = [];
|
||||
foreach ($metaconsole_connections as $metaconsole) {
|
||||
// Get server connection data
|
||||
// Get server connection data.
|
||||
$server_data = metaconsole_get_connection($metaconsole);
|
||||
|
||||
// Establishes connection
|
||||
// Establishes connection.
|
||||
if (metaconsole_load_external_db($server_data) !== NOERR) {
|
||||
continue;
|
||||
}
|
||||
@ -82,7 +97,7 @@ function get_custom_fields($custom_field_id=false, $select=true, $display_on_fro
|
||||
|
||||
$result[] = db_get_all_rows_sql($sql);
|
||||
|
||||
// Restore connection to root node
|
||||
// Restore connection to root node.
|
||||
metaconsole_restore_db();
|
||||
|
||||
if (isset($result) && is_array($result)) {
|
||||
@ -109,7 +124,7 @@ function get_custom_fields($custom_field_id=false, $select=true, $display_on_fro
|
||||
/**
|
||||
* Returns custom field data.
|
||||
*
|
||||
* @param integer custom_field_id id.
|
||||
* @param integer $custom_field_name Custom_field_id id.
|
||||
*
|
||||
* @return array custom fields data.
|
||||
*/
|
||||
@ -141,14 +156,14 @@ function get_custom_fields_data($custom_field_name)
|
||||
}
|
||||
} else {
|
||||
$metaconsole_connections = metaconsole_get_connection_names();
|
||||
// For all nodes
|
||||
// For all nodes.
|
||||
if (isset($metaconsole_connections) && is_array($metaconsole_connections)) {
|
||||
$result_meta = [];
|
||||
foreach ($metaconsole_connections as $metaconsole) {
|
||||
// Get server connection data
|
||||
// Get server connection data.
|
||||
$server_data = metaconsole_get_connection($metaconsole);
|
||||
|
||||
// Establishes connection
|
||||
// Establishes connection.
|
||||
if (metaconsole_load_external_db($server_data) !== NOERR) {
|
||||
continue;
|
||||
}
|
||||
@ -168,7 +183,7 @@ function get_custom_fields_data($custom_field_name)
|
||||
|
||||
$result_meta[] = db_get_all_rows_sql($sql);
|
||||
|
||||
// Restore connection to root node
|
||||
// Restore connection to root node.
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
@ -189,9 +204,15 @@ function get_custom_fields_data($custom_field_name)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function for custom field view return all conter for agents
|
||||
*
|
||||
* @param array $filters Params for search.
|
||||
* @return void False or array.
|
||||
*/
|
||||
function agent_counters_custom_fields($filters)
|
||||
{
|
||||
// filter by status agent
|
||||
// Filter by status agent.
|
||||
$and_status = '';
|
||||
|
||||
$agent_state_normal = 0;
|
||||
@ -262,7 +283,7 @@ function agent_counters_custom_fields($filters)
|
||||
}
|
||||
}
|
||||
|
||||
// filter by status module
|
||||
// Filter by status module.
|
||||
$empty_agents_count = "UNION ALL
|
||||
SELECT ta.id_agente,
|
||||
0 AS c_m_total,
|
||||
@ -314,20 +335,20 @@ function agent_counters_custom_fields($filters)
|
||||
$and_module_status .= ' ) ';
|
||||
}
|
||||
} else {
|
||||
// not normal
|
||||
// Not normal.
|
||||
$and_module_status = 'AND tae.estado <> 0 AND tae.estado <> 300 ';
|
||||
$empty_agents_count = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// filters module
|
||||
// Filters module.
|
||||
if ($filters['module_search']) {
|
||||
$and_module_search = 'AND tam.nombre LIKE "%'.$filters['module_search'].'%"';
|
||||
$empty_agents_count = '';
|
||||
}
|
||||
|
||||
// filter group and check ACL groups
|
||||
// Filter group and check ACL groups.
|
||||
$groups_and = '';
|
||||
if (!users_can_manage_group_all('AR')) {
|
||||
if ($filters['group']) {
|
||||
@ -338,7 +359,7 @@ function agent_counters_custom_fields($filters)
|
||||
}
|
||||
|
||||
if ($filters['group']) {
|
||||
// recursion check acl
|
||||
// Recursion check acl.
|
||||
if ($filters['recursion']) {
|
||||
$recursion_groups = groups_get_id_recursive($filters['group'], true);
|
||||
if (!users_can_manage_group_all('AR')) {
|
||||
@ -362,26 +383,26 @@ function agent_counters_custom_fields($filters)
|
||||
}
|
||||
}
|
||||
|
||||
// filter custom data
|
||||
// Filter custom data.
|
||||
$custom_data_and = '';
|
||||
if (!in_array(-1, $filters['id_custom_fields_data'])) {
|
||||
$custom_data_array = implode("', '", $filters['id_custom_fields_data']);
|
||||
$custom_data_and = "AND tcd.description IN ('".$custom_data_array."')";
|
||||
}
|
||||
|
||||
// filter custom name
|
||||
// Filter custom name.
|
||||
$custom_field_name = $filters['id_custom_fields'];
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$metaconsole_connections = metaconsole_get_connection_names();
|
||||
// For all nodes
|
||||
// For all nodes.
|
||||
if (isset($metaconsole_connections) && is_array($metaconsole_connections)) {
|
||||
$result_meta = [];
|
||||
$data = [];
|
||||
foreach ($metaconsole_connections as $metaconsole) {
|
||||
// Get server connection data
|
||||
// Get server connection data.
|
||||
$server_data = metaconsole_get_connection($metaconsole);
|
||||
// Establishes connection
|
||||
// Establishes connection.
|
||||
if (metaconsole_load_external_db($server_data) !== NOERR) {
|
||||
continue;
|
||||
}
|
||||
@ -470,7 +491,13 @@ function agent_counters_custom_fields($filters)
|
||||
WHEN ta.total_count = ta.notinit_count
|
||||
THEN 5
|
||||
ELSE 0
|
||||
END) AS `status`
|
||||
END) AS `status`,
|
||||
ta.critical_count,
|
||||
ta.warning_count,
|
||||
ta.unknown_count,
|
||||
ta.notinit_count,
|
||||
ta.normal_count,
|
||||
ta.total_count
|
||||
FROM tagente ta
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
@ -510,7 +537,7 @@ function agent_counters_custom_fields($filters)
|
||||
}
|
||||
|
||||
$data = array_merge($data, $node_result);
|
||||
// Restore connection to root node
|
||||
// Restore connection to root node.
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
}
|
||||
@ -519,7 +546,7 @@ function agent_counters_custom_fields($filters)
|
||||
$array_data = [];
|
||||
|
||||
if (isset($result_meta) && is_array($result_meta)) {
|
||||
// initialize counters
|
||||
// Initialize counters.
|
||||
$final_result['counters_total'] = [
|
||||
't_m_normal' => 0,
|
||||
't_m_critical' => 0,
|
||||
@ -538,7 +565,7 @@ function agent_counters_custom_fields($filters)
|
||||
foreach ($result_meta as $k => $nodo) {
|
||||
if (isset($nodo) && is_array($nodo)) {
|
||||
foreach ($nodo as $key => $value) {
|
||||
// Sum counters total
|
||||
// Sum counters total.
|
||||
$final_result['counters_total']['t_m_normal'] += $value['m_normal'];
|
||||
$final_result['counters_total']['t_m_critical'] += $value['m_critical'];
|
||||
$final_result['counters_total']['t_m_warning'] += $value['m_warning'];
|
||||
@ -553,7 +580,7 @@ function agent_counters_custom_fields($filters)
|
||||
$final_result['counters_total']['t_a_not_init'] += $value['a_not_init'];
|
||||
$final_result['counters_total']['t_a_agents'] += $value['a_agents'];
|
||||
|
||||
// Sum counters for data
|
||||
// Sum counters for data.
|
||||
$array_data[$value['name_data']]['m_normal'] += $value['m_normal'];
|
||||
$array_data[$value['name_data']]['m_critical'] += $value['m_critical'];
|
||||
$array_data[$value['name_data']]['m_warning'] += $value['m_warning'];
|
||||
@ -576,7 +603,7 @@ function agent_counters_custom_fields($filters)
|
||||
|
||||
$final_result['indexed_descriptions'] = $data;
|
||||
} else {
|
||||
// TODO
|
||||
// TODO.
|
||||
$final_result = false;
|
||||
}
|
||||
|
||||
@ -586,7 +613,7 @@ function agent_counters_custom_fields($filters)
|
||||
|
||||
function get_filters_custom_fields_view($id=0, $for_select=false, $name='')
|
||||
{
|
||||
// filter group and check ACL groups
|
||||
// Filter group and check ACL groups.
|
||||
$groups_and = '';
|
||||
if (!users_can_manage_group_all()) {
|
||||
$user_groups = array_keys(users_get_groups(false, 'AR', false));
|
||||
@ -631,3 +658,38 @@ function get_group_filter_custom_field_view($id)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function for print counters agents or modules.
|
||||
*
|
||||
* @param array $status_array Array need value, image, title, color, counter.
|
||||
* @param string $id_form Id form default value ''.
|
||||
* @param string $id_input Id input default value ''.
|
||||
*
|
||||
* @return array Return html print div container counters.
|
||||
*/
|
||||
function print_counters_cfv(
|
||||
array $status_array,
|
||||
string $id_form='',
|
||||
string $id_input=''
|
||||
) {
|
||||
$html_result = '<form class = "cfv_status_agent" id="'.$id_form.'">';
|
||||
foreach ($status_array as $key => $value) {
|
||||
$checked = ($value['checked'] === 1) ? 'checked=true' : '';
|
||||
$disabled = ($value['counter'] === 0) ? 'disabled=true' : '';
|
||||
|
||||
$html_result .= '<input id="lists_'.$id_input.'['.$key.']" '.$checked.' '.$disabled.' type="checkbox" name="lists_'.$id_input.'['.$key.']" />';
|
||||
$html_result .= '<label for="lists_'.$id_input.'['.$key.']" style="background-color:'.$value['color'].';">';
|
||||
$html_result .= html_print_image(
|
||||
$value['image'],
|
||||
true,
|
||||
['title' => $value['title']]
|
||||
);
|
||||
$html_result .= $value['counter'];
|
||||
$html_result .= '</label>';
|
||||
}
|
||||
|
||||
$html_result .= '</form>';
|
||||
return $html_result;
|
||||
}
|
||||
|
@ -9340,15 +9340,34 @@ function reporting_get_agent_module_info($id_agent)
|
||||
|
||||
$return = [];
|
||||
$return['last_contact'] = 0;
|
||||
// Last agent contact
|
||||
// Last agent contact.
|
||||
$return['status'] = STATUS_AGENT_NO_DATA;
|
||||
$return['status_img'] = ui_print_status_image(STATUS_AGENT_NO_DATA, __('Agent without data'), true);
|
||||
$return['status_img'] = ui_print_status_image(
|
||||
STATUS_AGENT_NO_DATA,
|
||||
__('Agent without data'),
|
||||
true
|
||||
);
|
||||
$return['alert_status'] = 'notfired';
|
||||
$return['alert_value'] = STATUS_ALERT_NOT_FIRED;
|
||||
$return['alert_img'] = ui_print_status_image(STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true);
|
||||
$return['agent_group'] = agents_get_agent_group($id_agent);
|
||||
$return['alert_img'] = ui_print_status_image(
|
||||
STATUS_ALERT_NOT_FIRED,
|
||||
__('Alert not fired'),
|
||||
true
|
||||
);
|
||||
|
||||
if (!check_acl($config['id_user'], $return['agent_group'], 'AR')) {
|
||||
$return['agent_group'] = '';
|
||||
// Important agents_get_all_groups_agent check secondary groups.
|
||||
$id_all_groups = agents_get_all_groups_agent($id_agent);
|
||||
if (isset($id_all_groups) && is_array($id_all_groups)) {
|
||||
foreach ($id_all_groups as $value) {
|
||||
if (check_acl($config['id_user'], $value, 'AR')) {
|
||||
$return['agent_group'] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If $return['agent_group'] is empty no access.
|
||||
if ($return['agent_group'] == '') {
|
||||
return $return;
|
||||
}
|
||||
|
||||
@ -9361,7 +9380,7 @@ function reporting_get_agent_module_info($id_agent)
|
||||
|
||||
$now = get_system_time();
|
||||
|
||||
// Get modules status for this agent
|
||||
// Get modules status for this agent.
|
||||
$agent = db_get_row('tagente', 'id_agente', $id_agent);
|
||||
|
||||
$return['total_count'] = $agent['total_count'];
|
||||
@ -9375,28 +9394,52 @@ function reporting_get_agent_module_info($id_agent)
|
||||
if ($return['total_count'] > 0) {
|
||||
if ($return['critical_count'] > 0) {
|
||||
$return['status'] = STATUS_AGENT_CRITICAL;
|
||||
$return['status_img'] = ui_print_status_image(STATUS_AGENT_CRITICAL, __('At least one module in CRITICAL status'), true);
|
||||
$return['status_img'] = ui_print_status_image(
|
||||
STATUS_AGENT_CRITICAL,
|
||||
__('At least one module in CRITICAL status'),
|
||||
true
|
||||
);
|
||||
} else if ($return['warning_count'] > 0) {
|
||||
$return['status'] = STATUS_AGENT_WARNING;
|
||||
$return['status_img'] = ui_print_status_image(STATUS_AGENT_WARNING, __('At least one module in WARNING status'), true);
|
||||
$return['status_img'] = ui_print_status_image(
|
||||
STATUS_AGENT_WARNING,
|
||||
__('At least one module in WARNING status'),
|
||||
true
|
||||
);
|
||||
} else if ($return['unknown_count'] > 0) {
|
||||
$return['status'] = STATUS_AGENT_DOWN;
|
||||
$return['status_img'] = ui_print_status_image(STATUS_AGENT_DOWN, __('At least one module is in UKNOWN status'), true);
|
||||
$return['status_img'] = ui_print_status_image(
|
||||
STATUS_AGENT_DOWN,
|
||||
__('At least one module is in UKNOWN status'),
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$return['status'] = STATUS_AGENT_OK;
|
||||
$return['status_img'] = ui_print_status_image(STATUS_AGENT_OK, __('All Monitors OK'), true);
|
||||
$return['status_img'] = ui_print_status_image(
|
||||
STATUS_AGENT_OK,
|
||||
__('All Monitors OK'),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Alert not fired is by default
|
||||
// Alert not fired is by default.
|
||||
if ($return['fired_count'] > 0) {
|
||||
$return['alert_status'] = 'fired';
|
||||
$return['alert_img'] = ui_print_status_image(STATUS_ALERT_FIRED, __('Alert fired'), true);
|
||||
$return['alert_img'] = ui_print_status_image(
|
||||
STATUS_ALERT_FIRED,
|
||||
__('Alert fired'),
|
||||
true
|
||||
);
|
||||
$return['alert_value'] = STATUS_ALERT_FIRED;
|
||||
} else if (groups_give_disabled_group($return['agent_group'])) {
|
||||
$return['alert_status'] = 'disabled';
|
||||
$return['alert_value'] = STATUS_ALERT_DISABLED;
|
||||
$return['alert_img'] = ui_print_status_image(STATUS_ALERT_DISABLED, __('Alert disabled'), true);
|
||||
$return['alert_img'] = ui_print_status_image(
|
||||
STATUS_ALERT_DISABLED,
|
||||
__('Alert disabled'),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
@ -61,10 +61,14 @@ function tags_search_tag($tag_name_description=false, $filter=false, $only_names
|
||||
$filter[] = '(UPPER(name) LIKE UPPER (\'%'.$tag_name_description.'%\') OR
|
||||
UPPER(dbms_lob.substr(description, 4000, 1)) LIKE UPPER (\'%'.$tag_name_description.'%\'))';
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Default order
|
||||
// Default order.
|
||||
set_unless_defined($filter['order'], 'name');
|
||||
|
||||
$fields = '*';
|
||||
@ -75,7 +79,7 @@ function tags_search_tag($tag_name_description=false, $filter=false, $only_names
|
||||
];
|
||||
}
|
||||
|
||||
// It will return the count
|
||||
// It will return the count.
|
||||
if ($count) {
|
||||
unset($filter['order']);
|
||||
unset($filter['limit']);
|
||||
@ -120,7 +124,7 @@ function tags_create_tag($values)
|
||||
return false;
|
||||
}
|
||||
|
||||
// No create tag if the tag exists
|
||||
// No create tag if the tag exists.
|
||||
if (tags_get_id($values['name'])) {
|
||||
return false;
|
||||
}
|
||||
@ -365,7 +369,7 @@ function tags_insert_module_tag($id_agent_module, $tags)
|
||||
}
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
// Protect against default insert
|
||||
// Protect against default insert.
|
||||
if (empty($tag)) {
|
||||
continue;
|
||||
}
|
||||
@ -396,7 +400,7 @@ function tags_insert_policy_module_tag($id_agent_module, $tags)
|
||||
|
||||
$values = [];
|
||||
foreach ($tags as $tag) {
|
||||
// Protect against default insert
|
||||
// Protect against default insert.
|
||||
if (empty($tag)) {
|
||||
continue;
|
||||
}
|
||||
@ -439,7 +443,7 @@ function tags_update_module_tag(
|
||||
}
|
||||
|
||||
if ($update_policy_tags) {
|
||||
// First delete module tag entries
|
||||
// First delete module tag entries.
|
||||
$result_tag = db_process_sql_delete(
|
||||
'ttag_module',
|
||||
['id_agente_modulo' => $id_agent_module]
|
||||
@ -456,7 +460,7 @@ function tags_update_module_tag(
|
||||
|
||||
$values = [];
|
||||
foreach ($tags as $tag) {
|
||||
// Protect against default insert
|
||||
// Protect against default insert.
|
||||
if (empty($tag)) {
|
||||
continue;
|
||||
}
|
||||
@ -494,7 +498,7 @@ function tags_update_policy_module_tag($id_policy_module, $tags, $autocommit=fal
|
||||
|
||||
$values = [];
|
||||
foreach ($tags as $tag) {
|
||||
// Protect against default insert
|
||||
// Protect against default insert.
|
||||
if (empty($tag)) {
|
||||
continue;
|
||||
}
|
||||
@ -759,11 +763,14 @@ function tags_get_acl_tags(
|
||||
return '';
|
||||
|
||||
break;
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($id_group == 0) {
|
||||
// Don't filter
|
||||
// Don't filter.
|
||||
$id_group = [];
|
||||
} else if (empty($id_group)) {
|
||||
return ERR_WRONG_PARAMETERS;
|
||||
@ -789,12 +796,12 @@ function tags_get_acl_tags(
|
||||
|
||||
switch ($return_mode) {
|
||||
case 'data':
|
||||
// Stop here and return the array
|
||||
// Stop here and return the array.
|
||||
return $acltags;
|
||||
|
||||
break;
|
||||
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,
|
||||
@ -806,13 +813,17 @@ function tags_get_acl_tags(
|
||||
break;
|
||||
|
||||
case 'event_condition':
|
||||
// Return the condition of the tags for tevento table
|
||||
// Return the condition of the tags for tevento table.
|
||||
$condition = tags_get_acl_tags_event_condition($acltags, $meta, $force_group_and_tag);
|
||||
|
||||
if (!empty($condition)) {
|
||||
return " $query_prefix ".'('.$condition.')';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -847,7 +858,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table='', $force_
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($group_tags)) {
|
||||
if (!empty($group_tags) && !empty($force_tags)) {
|
||||
$group_tags = array_intersect($force_tags, $group_tags);
|
||||
}
|
||||
|
||||
@ -899,27 +910,27 @@ function tags_get_acl_tags_event_condition($acltags, $meta=false, $force_group_a
|
||||
global $config;
|
||||
$condition = [];
|
||||
|
||||
// Get all tags of the system
|
||||
// Get all tags of the system.
|
||||
$all_tags = tags_get_all_tags(false);
|
||||
|
||||
$without_tags = [];
|
||||
foreach ($acltags as $group_id => $group_tags) {
|
||||
// NO check if there is not tag associated with groups
|
||||
// NO check if there is not tag associated with groups.
|
||||
if (empty($group_tags)) {
|
||||
$without_tags[] = $group_id;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Group condition (The module belongs to an agent of the group X)
|
||||
// $group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_id_recursive($group_id, true))));
|
||||
// $group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_id_recursive($group_id, true))));.
|
||||
$group_condition = "(id_grupo = $group_id OR id_group = $group_id)";
|
||||
|
||||
// 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 = '';
|
||||
$tags_condition_array = [];
|
||||
|
||||
foreach ($group_tags as $tag) {
|
||||
// If the tag ID doesnt exist, ignore
|
||||
// If the tag ID doesnt exist, ignore.
|
||||
if (!isset($all_tags[$tag])) {
|
||||
continue;
|
||||
}
|
||||
@ -927,7 +938,7 @@ function tags_get_acl_tags_event_condition($acltags, $meta=false, $force_group_a
|
||||
$tags_condition_array[] = $force_equal ? sprintf('tags = "%s"', io_safe_input($all_tags[$tag])) : "tags LIKE '%".io_safe_input($all_tags[$tag])."%'";
|
||||
}
|
||||
|
||||
// If there is not tag currently in Pandora, block the group info
|
||||
// If there is not tag currently in Pandora, block the group info.
|
||||
if (empty($tags_condition_array)) {
|
||||
$tags_condition_array[] = '1=0';
|
||||
}
|
||||
@ -1000,16 +1011,16 @@ function tags_get_user_tags($id_user=false, $access='AR', $return_tag_any=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// users_is_strict_acl
|
||||
// users_is_strict_acl.
|
||||
if ($id_user === false) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
// Get all tags to have the name of all of them
|
||||
// Get all tags to have the name of all of them.
|
||||
$all_tags = tags_get_all_tags();
|
||||
|
||||
// If at least one of the profiles of this access flag hasent
|
||||
// tags restrictions, the user can see all tags
|
||||
// tags restrictions, the user can see all tags.
|
||||
$acl_column = get_acl_column($access);
|
||||
|
||||
if (empty($acl_column)) {
|
||||
@ -1045,6 +1056,10 @@ function tags_get_user_tags($id_user=false, $access='AR', $return_tag_any=false)
|
||||
$acl_column
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
$profiles_without_tags = db_get_value_sql($query);
|
||||
@ -1068,14 +1083,14 @@ function tags_get_user_tags($id_user=false, $access='AR', $return_tag_any=false)
|
||||
}
|
||||
}
|
||||
|
||||
// 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');
|
||||
// If there are wrong parameters or fail ACL check, return false
|
||||
// If there are wrong parameters or fail ACL check, return false.
|
||||
if ($tags_user === ERR_WRONG_PARAMETERS || $tags_user === ERR_ACL) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 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 = [];
|
||||
|
||||
foreach ($tags as $t) {
|
||||
@ -1086,7 +1101,7 @@ function tags_get_user_tags($id_user=false, $access='AR', $return_tag_any=false)
|
||||
}
|
||||
}
|
||||
|
||||
// Set the format id=>name to tags
|
||||
// Set the format id=>name to tags.
|
||||
$user_tags = [];
|
||||
foreach ($user_tags_id as $id) {
|
||||
if (!isset($all_tags[$id])) {
|
||||
@ -1104,16 +1119,16 @@ function tags_get_tags_for_module_search($id_user=false, $access='AR')
|
||||
{
|
||||
global $config;
|
||||
|
||||
// users_is_strict_acl
|
||||
// users_is_strict_acl.
|
||||
if ($id_user === false) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
// Get all tags to have the name of all of them
|
||||
// Get all tags to have the name of all of them.
|
||||
$all_tags = tags_get_all_tags();
|
||||
|
||||
// If at least one of the profiles of this access flag hasent
|
||||
// tags restrictions, the user can see all tags
|
||||
// tags restrictions, the user can see all tags.
|
||||
$acl_column = get_acl_column($access);
|
||||
|
||||
if (empty($acl_column)) {
|
||||
@ -1149,6 +1164,10 @@ function tags_get_tags_for_module_search($id_user=false, $access='AR')
|
||||
$acl_column
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
$profiles_without_tags = db_get_value_sql($query);
|
||||
@ -1164,14 +1183,14 @@ function tags_get_tags_for_module_search($id_user=false, $access='AR')
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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');
|
||||
// If there are wrong parameters or fail ACL check, return false
|
||||
// If there are wrong parameters or fail ACL check, return false.
|
||||
if ($tags_user === ERR_WRONG_PARAMETERS || $tags_user === ERR_ACL) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 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 = [];
|
||||
|
||||
foreach ($tags as $t) {
|
||||
@ -1182,7 +1201,7 @@ function tags_get_tags_for_module_search($id_user=false, $access='AR')
|
||||
}
|
||||
}
|
||||
|
||||
// Set the format id=>name to tags
|
||||
// Set the format id=>name to tags.
|
||||
$user_tags = [];
|
||||
foreach ($user_tags_id as $id) {
|
||||
if (!isset($all_tags[$id])) {
|
||||
@ -1217,12 +1236,12 @@ function tags_check_acl_by_module(
|
||||
|
||||
$acl_column = get_acl_column($access);
|
||||
foreach ($groups as $group) {
|
||||
// If user has not permission for this group,go to next group
|
||||
// If user has not permission for this group,go to next group.
|
||||
if (!isset($user_groups[$group])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// No tags means user can see all tags for this group
|
||||
// No tags means user can see all tags for this group.
|
||||
if (empty($user_groups[$group]['tags'][$acl_column])) {
|
||||
return true;
|
||||
}
|
||||
@ -1238,7 +1257,7 @@ function tags_check_acl_by_module(
|
||||
}
|
||||
|
||||
|
||||
// This function checks event ACLs
|
||||
// This function checks event ACLs.
|
||||
function tags_checks_event_acl($id_user, $id_group, $access, $tags=[], $childrens_ids=[])
|
||||
{
|
||||
global $config;
|
||||
@ -1252,12 +1271,12 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags=[], $children
|
||||
}
|
||||
|
||||
$tags_user = tags_get_acl_tags($id_user, $id_group, $access, 'data', '', '', true, $childrens_ids, true);
|
||||
// If there are wrong parameters or fail ACL check, return false
|
||||
// If there are wrong parameters or fail ACL check, return false.
|
||||
if ($tags_user === ERR_WRONG_PARAMETERS || $tags_user === ERR_ACL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check user without tags
|
||||
// check user without tags.
|
||||
$sql = "SELECT id_usuario FROM tusuario_perfil
|
||||
WHERE id_usuario = '".$config['id_user']."' AND tags = ''
|
||||
AND id_perfil IN (
|
||||
@ -1362,7 +1381,7 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags=[], $children
|
||||
*/
|
||||
function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[], $realtime=true)
|
||||
{
|
||||
// Avoid mysql error
|
||||
// Avoid mysql error.
|
||||
if (empty($id_tag)) {
|
||||
return false;
|
||||
}
|
||||
@ -1392,12 +1411,12 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
$agent_name_filter = '';
|
||||
$agent_status = AGENT_STATUS_ALL;
|
||||
if (!empty($agent_filter)) {
|
||||
// Name
|
||||
// Name.
|
||||
if (isset($agent_filter['name']) && !empty($agent_filter['name'])) {
|
||||
$agent_name_filter = "AND ta.nombre LIKE '%".$agent_filter['name']."%'";
|
||||
}
|
||||
|
||||
// Status
|
||||
// Status.
|
||||
if (isset($agent_filter['status'])) {
|
||||
if (is_array($agent_filter['status'])) {
|
||||
$agent_status = array_unique($agent_filter['status']);
|
||||
@ -1411,15 +1430,15 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
$module_status_filter = '';
|
||||
$module_status_array = [];
|
||||
if (!empty($module_filter)) {
|
||||
// IMPORTANT: The module filters will force the realtime search
|
||||
// IMPORTANT: The module filters will force the realtime search.
|
||||
$realtime = true;
|
||||
|
||||
// Name
|
||||
// Name.
|
||||
if (isset($module_filter['name']) && !empty($module_filter['name'])) {
|
||||
$module_name_filter = "AND tam.nombre LIKE '%".$module_filter['name']."%'";
|
||||
}
|
||||
|
||||
// Status
|
||||
// Status.
|
||||
if (isset($module_filter['status'])) {
|
||||
$module_status = $module_filter['status'];
|
||||
if (is_array($module_status)) {
|
||||
@ -1469,6 +1488,10 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
$module_status_array[] = AGENT_MODULE_STATUS_NORMAL_ALERT;
|
||||
$module_status_array[] = AGENT_MODULE_STATUS_NORMAL;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1517,7 +1540,7 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
$unknown = 0;
|
||||
$not_init = 0;
|
||||
$normal = 0;
|
||||
// Without module filter
|
||||
// Without module filter.
|
||||
if (empty($module_status_array)) {
|
||||
$total = (int) tags_get_total_monitors($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||
$critical = (int) tags_get_critical_monitors($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||
@ -1526,7 +1549,8 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
$not_init = (int) tags_get_not_init_monitors($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||
$normal = (int) tags_get_normal_monitors($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||
}
|
||||
// With module filter
|
||||
|
||||
// With module filter.
|
||||
else {
|
||||
foreach ($module_status_array as $status) {
|
||||
switch ($status) {
|
||||
@ -1553,6 +1577,10 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
case AGENT_MODULE_STATUS_NORMAL:
|
||||
$normal = (int) tags_get_normal_monitors($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1592,7 +1620,7 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
break;
|
||||
|
||||
default:
|
||||
// The status doesn't exist
|
||||
// The status doesn't exist.
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@ -1617,7 +1645,7 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
$count ++;
|
||||
}
|
||||
}
|
||||
// Invalid status
|
||||
// Invalid status.
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
@ -1625,12 +1653,12 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
}
|
||||
} else {
|
||||
$status_filter = '';
|
||||
// Transform the element into a one element array
|
||||
// Transform the element into a one element array.
|
||||
if (!is_array($agent_status)) {
|
||||
$agent_status = [$agent_status];
|
||||
}
|
||||
|
||||
// Support for multiple status. It counts the agents for each status and sum the result
|
||||
// Support for multiple status. It counts the agents for each status and sum the result.
|
||||
foreach ($agent_status as $status) {
|
||||
switch ($agent_status) {
|
||||
case AGENT_STATUS_ALL:
|
||||
@ -1666,7 +1694,7 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
break;
|
||||
|
||||
default:
|
||||
// The type doesn't exist
|
||||
// The type doesn't exist.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1711,7 +1739,7 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
*/
|
||||
function tags_get_total_agents($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[], $realtime=true)
|
||||
{
|
||||
// Always modify the agent status filter
|
||||
// Always modify the agent status filter.
|
||||
$agent_filter['status'] = AGENT_STATUS_ALL;
|
||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
||||
}
|
||||
@ -1735,7 +1763,7 @@ function tags_get_total_agents($id_tag, $groups_and_tags=[], $agent_filter=[], $
|
||||
*/
|
||||
function tags_get_normal_agents($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[], $realtime=true)
|
||||
{
|
||||
// Always modify the agent status filter
|
||||
// Always modify the agent status filter.
|
||||
$agent_filter['status'] = AGENT_STATUS_NORMAL;
|
||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
||||
}
|
||||
@ -1759,7 +1787,7 @@ function tags_get_normal_agents($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
*/
|
||||
function tags_get_warning_agents($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[], $realtime=true)
|
||||
{
|
||||
// Always modify the agent status filter
|
||||
// Always modify the agent status filter.
|
||||
$agent_filter['status'] = AGENT_STATUS_WARNING;
|
||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
||||
}
|
||||
@ -1783,7 +1811,7 @@ function tags_get_warning_agents($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
*/
|
||||
function tags_get_critical_agents($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[], $realtime=true)
|
||||
{
|
||||
// Always modify the agent status filter
|
||||
// Always modify the agent status filter.
|
||||
$agent_filter['status'] = AGENT_STATUS_CRITICAL;
|
||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
||||
}
|
||||
@ -1807,7 +1835,7 @@ function tags_get_critical_agents($id_tag, $groups_and_tags=[], $agent_filter=[]
|
||||
*/
|
||||
function tags_get_unknown_agents($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[], $realtime=true)
|
||||
{
|
||||
// Always modify the agent status filter
|
||||
// Always modify the agent status filter.
|
||||
$agent_filter['status'] = AGENT_STATUS_UNKNOWN;
|
||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
||||
}
|
||||
@ -1831,7 +1859,7 @@ function tags_get_unknown_agents($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
*/
|
||||
function tags_get_not_init_agents($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[], $realtime=true)
|
||||
{
|
||||
// Always modify the agent status filter
|
||||
// Always modify the agent status filter.
|
||||
$agent_filter['status'] = AGENT_STATUS_NOT_INIT;
|
||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
||||
}
|
||||
@ -1855,7 +1883,7 @@ function tags_get_not_init_agents($id_tag, $groups_and_tags=[], $agent_filter=[]
|
||||
*/
|
||||
function tags_get_monitors_counter($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[])
|
||||
{
|
||||
// Avoid mysql error
|
||||
// Avoid mysql error.
|
||||
if (empty($id_tag)) {
|
||||
return false;
|
||||
}
|
||||
@ -1885,12 +1913,12 @@ function tags_get_monitors_counter($id_tag, $groups_and_tags=[], $agent_filter=[
|
||||
$agent_name_filter = '';
|
||||
$agents_clause = '';
|
||||
if (!empty($agent_filter)) {
|
||||
// Name
|
||||
// Name.
|
||||
if (isset($agent_filter['name']) && !empty($agent_filter['name'])) {
|
||||
$agent_name_filter = "AND ta.nombre LIKE '%".$agent_filter['name']."%'";
|
||||
}
|
||||
|
||||
// ID
|
||||
// ID.
|
||||
if (isset($agent_filter['id'])) {
|
||||
if (is_array($agent_filter['id'])) {
|
||||
$agents = array_unique($agent_filter['id']);
|
||||
@ -1907,12 +1935,12 @@ function tags_get_monitors_counter($id_tag, $groups_and_tags=[], $agent_filter=[
|
||||
$module_status_array = '';
|
||||
$modules_clause = '';
|
||||
if (!empty($module_filter)) {
|
||||
// Name
|
||||
// Name.
|
||||
if (isset($module_filter['name']) && !empty($module_filter['name'])) {
|
||||
$module_name_filter = "AND tam.nombre LIKE '%".$module_filter['name']."%'";
|
||||
}
|
||||
|
||||
// Status
|
||||
// Status.
|
||||
if (isset($module_filter['status'])) {
|
||||
$module_status = $module_filter['status'];
|
||||
if (is_array($module_status)) {
|
||||
@ -1965,7 +1993,7 @@ function tags_get_monitors_counter($id_tag, $groups_and_tags=[], $agent_filter=[
|
||||
break;
|
||||
|
||||
default:
|
||||
// The status doesn't exist
|
||||
// The status doesn't exist.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2019,7 +2047,7 @@ function tags_get_monitors_counter($id_tag, $groups_and_tags=[], $agent_filter=[
|
||||
*/
|
||||
function tags_get_total_monitors($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[])
|
||||
{
|
||||
// Always modify the module status filter
|
||||
// Always modify the module status filter.
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_ALL;
|
||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||
}
|
||||
@ -2042,7 +2070,7 @@ function tags_get_total_monitors($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||
*/
|
||||
function tags_get_normal_monitors($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[])
|
||||
{
|
||||
// Always modify the module status filter
|
||||
// Always modify the module status filter.
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_NORMAL;
|
||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||
}
|
||||
@ -2065,7 +2093,7 @@ function tags_get_normal_monitors($id_tag, $groups_and_tags=[], $agent_filter=[]
|
||||
*/
|
||||
function tags_get_critical_monitors($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[])
|
||||
{
|
||||
// Always modify the module status filter
|
||||
// Always modify the module status filter.
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_CRITICAL_BAD;
|
||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||
}
|
||||
@ -2088,7 +2116,7 @@ function tags_get_critical_monitors($id_tag, $groups_and_tags=[], $agent_filter=
|
||||
*/
|
||||
function tags_get_warning_monitors($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[])
|
||||
{
|
||||
// Always modify the module status filter
|
||||
// Always modify the module status filter.
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_WARNING;
|
||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||
}
|
||||
@ -2111,7 +2139,7 @@ function tags_get_warning_monitors($id_tag, $groups_and_tags=[], $agent_filter=[
|
||||
*/
|
||||
function tags_get_not_init_monitors($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[])
|
||||
{
|
||||
// Always modify the module status filter
|
||||
// Always modify the module status filter.
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_NOT_INIT;
|
||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||
}
|
||||
@ -2134,7 +2162,7 @@ function tags_get_not_init_monitors($id_tag, $groups_and_tags=[], $agent_filter=
|
||||
*/
|
||||
function tags_get_unknown_monitors($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[])
|
||||
{
|
||||
// Always modify the module status filter
|
||||
// Always modify the module status filter.
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_UNKNOWN;
|
||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||
}
|
||||
@ -2151,7 +2179,7 @@ function tags_get_unknown_monitors($id_tag, $groups_and_tags=[], $agent_filter=[
|
||||
*/
|
||||
function tags_monitors_fired_alerts($id_tag, $groups_and_tags=[], $id_agente=false)
|
||||
{
|
||||
// Avoid mysql error
|
||||
// Avoid mysql error.
|
||||
if (empty($id_tag)) {
|
||||
return;
|
||||
}
|
||||
@ -2215,7 +2243,7 @@ function tags_monitors_fired_alerts($id_tag, $groups_and_tags=[], $id_agente=fal
|
||||
*/
|
||||
function tags_get_monitors_alerts($id_tag, $groups_and_tags=[], $id_agente=false)
|
||||
{
|
||||
// Avoid mysql error
|
||||
// Avoid mysql error.
|
||||
if (empty($id_tag)) {
|
||||
return;
|
||||
}
|
||||
@ -2270,20 +2298,20 @@ function tags_get_monitors_alerts($id_tag, $groups_and_tags=[], $id_agente=false
|
||||
function __add_acltags(&$acltags, $group_id, $tags_str)
|
||||
{
|
||||
if (!isset($acltags[$group_id])) {
|
||||
// Add the new element
|
||||
// Add the new element.
|
||||
$acltags[$group_id] = $tags_str;
|
||||
} else {
|
||||
// Add the tags. The empty tags have priority cause mean more permissions
|
||||
// Add the tags. The empty tags have priority cause mean more permissions.
|
||||
$existing_tags = $acltags[$group_id];
|
||||
|
||||
if (!empty($existing_tags)) {
|
||||
$existing_tags_array = explode(',', $existing_tags);
|
||||
|
||||
// Store the empty tags
|
||||
// Store the empty tags.
|
||||
if (empty($tags_str)) {
|
||||
$acltags[$group_id] = '';
|
||||
}
|
||||
// Merge the old and new tabs
|
||||
// Merge the old and new tabs.
|
||||
else {
|
||||
$new_tags_array = explode(',', $tags_str);
|
||||
|
||||
@ -2297,7 +2325,7 @@ function __add_acltags(&$acltags, $group_id, $tags_str)
|
||||
}
|
||||
}
|
||||
|
||||
// Propagation
|
||||
// Propagation.
|
||||
$propagate = (bool) db_get_value('propagate', 'tgrupo', 'id_grupo', $group_id);
|
||||
if ($propagate) {
|
||||
$sql = "SELECT id_grupo FROM tgrupo WHERE parent = $group_id";
|
||||
@ -2308,14 +2336,14 @@ function __add_acltags(&$acltags, $group_id, $tags_str)
|
||||
}
|
||||
|
||||
foreach ($children as $children_group) {
|
||||
// Add the tags to the children (recursive)
|
||||
// Add the tags to the children (recursive).
|
||||
__add_acltags($acltags, $children_group['id_grupo'], $tags_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return array with groups and their tags
|
||||
// Return array with groups and their tags.
|
||||
function tags_get_user_groups_and_tags($id_user=false, $access='AR', $strict_user=false)
|
||||
{
|
||||
global $config;
|
||||
@ -2499,7 +2527,7 @@ function tags_get_agent_modules($id_agent, $id_tag=false, $groups_and_tags=[], $
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Avoid mysql error
|
||||
// Avoid mysql error.
|
||||
if (empty($id_agent)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@
|
||||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.734';
|
||||
$build = '190429';
|
||||
$build = '190508';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
@ -285,8 +285,38 @@ if (!$meta) {
|
||||
}
|
||||
}
|
||||
|
||||
$id_filter = db_get_value(
|
||||
'id_filter',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
$config['id_user']
|
||||
);
|
||||
|
||||
// If user has event filter retrieve filter values.
|
||||
if (!empty($id_filter)) {
|
||||
$apply_filter = true;
|
||||
|
||||
$event_filter = events_get_event_filter($id_filter);
|
||||
|
||||
$event_filter['search'] = io_safe_output($event_filter['search']);
|
||||
$event_filter['id_name'] = io_safe_output($event_filter['id_name']);
|
||||
$event_filter['tag_with'] = base64_encode(
|
||||
io_safe_output($event_filter['tag_with'])
|
||||
);
|
||||
$event_filter['tag_without'] = base64_encode(
|
||||
io_safe_output($event_filter['tag_without'])
|
||||
);
|
||||
}
|
||||
|
||||
$is_filtered = get_parameter('is_filtered', false);
|
||||
$offset = (int) get_parameter('offset', 0);
|
||||
|
||||
if ($event_filter['id_group'] == '') {
|
||||
$event_filter['id_group'] = 0;
|
||||
}
|
||||
|
||||
$id_group = (int) get_parameter('id_group', 0);
|
||||
|
||||
// 0 all
|
||||
// **********************************************************************
|
||||
// TODO
|
||||
@ -297,38 +327,59 @@ $id_group = (int) get_parameter('id_group', 0);
|
||||
// **********************************************************************
|
||||
$recursion = (bool) get_parameter('recursion', true);
|
||||
// Flag show in child groups.
|
||||
$event_type = get_parameter('event_type', '');
|
||||
if (empty($event_filter['event_type'])) {
|
||||
$event_filter['event_type'] = '';
|
||||
}
|
||||
|
||||
$event_type = ($apply_filter === true && $is_filtered === false) ? $event_filter['event_type'] : get_parameter('event_type', '');
|
||||
|
||||
// 0 all.
|
||||
$severity = (int) get_parameter('severity', -1);
|
||||
$severity = ($apply_filter === true && $is_filtered === false) ? (int) $event_filter['severity'] : (int) get_parameter('severity', -1);
|
||||
// -1 all.
|
||||
$status = (int) get_parameter('status', 3);
|
||||
if ($event_filter['status'] == -1) {
|
||||
$event_filter['status'] = 3;
|
||||
}
|
||||
|
||||
$status = ($apply_filter === true && $is_filtered === false) ? (int) $event_filter['status'] : (int) get_parameter('status', 3);
|
||||
// -1 all, 0 only new, 1 only validated,
|
||||
// 2 only in process, 3 only not validated.
|
||||
$id_agent = (int) get_parameter('id_agent', 0);
|
||||
$pagination = (int) get_parameter('pagination', $config['block_size']);
|
||||
$event_view_hr = (int) get_parameter(
|
||||
$id_agent = ($apply_filter === true && $is_filtered === false) ? (int) $event_filter['id_agent'] : (int) get_parameter('id_agent', 0);
|
||||
$pagination = ($apply_filter === true && $is_filtered === false) ? (int) $event_filter['pagination'] : (int) get_parameter('pagination', $config['block_size']);
|
||||
|
||||
if (empty($event_filter['event_view_hr'])) {
|
||||
$event_filter['event_view_hr'] = ($history) ? 0 : $config['event_view_hr'];
|
||||
}
|
||||
|
||||
$event_view_hr = ($apply_filter === true && $is_filtered === false) ? (int) $event_filter['event_view_hr'] : (int) get_parameter(
|
||||
'event_view_hr',
|
||||
($history) ? 0 : $config['event_view_hr']
|
||||
);
|
||||
$id_user_ack = get_parameter('id_user_ack', 0);
|
||||
$group_rep = (int) get_parameter('group_rep', 1);
|
||||
|
||||
|
||||
$id_user_ack = ($apply_filter === true && $is_filtered === false) ? $event_filter['id_user_ack'] : get_parameter('id_user_ack', 0);
|
||||
$group_rep = ($apply_filter === true && $is_filtered === false) ? (int) $event_filter['group_rep'] : (int) get_parameter('group_rep', 1);
|
||||
$delete = (bool) get_parameter('delete');
|
||||
$validate = (bool) get_parameter('validate', 0);
|
||||
$section = (string) get_parameter('section', 'list');
|
||||
$filter_only_alert = (int) get_parameter('filter_only_alert', -1);
|
||||
$filter_only_alert = ($apply_filter === true && $is_filtered === false) ? (int) $event_filter['filter_only_alert'] : (int) get_parameter('filter_only_alert', -1);
|
||||
$filter_id = (int) get_parameter('filter_id', 0);
|
||||
$id_name = (string) get_parameter('id_name', '');
|
||||
|
||||
if (empty($event_filter['id_name'])) {
|
||||
$event_filter['id_name'] = '';
|
||||
}
|
||||
|
||||
$id_name = ($apply_filter === true && $is_filtered === false) ? (string) $event_filter['id_name'] : (string) get_parameter('id_name', '');
|
||||
$open_filter = (int) get_parameter('open_filter', 0);
|
||||
$date_from = (string) get_parameter('date_from', '');
|
||||
$date_to = (string) get_parameter('date_to', '');
|
||||
$date_from = ($apply_filter === true && $is_filtered === false) ? (string) $event_filter['date_from'] : (string) get_parameter('date_from', '');
|
||||
$date_to = ($apply_filter === true && $is_filtered === false) ? (string) $event_filter['date_to'] : (string) get_parameter('date_to', '');
|
||||
$time_from = (string) get_parameter('time_from', '');
|
||||
$time_to = (string) get_parameter('time_to', '');
|
||||
$server_id = (int) get_parameter('server_id', 0);
|
||||
$text_agent = (string) get_parameter('text_agent');
|
||||
$text_agent = ($apply_filter === true && $is_filtered === false) ? (string) $event_filter['text_agent'] : (string) get_parameter('text_agent');
|
||||
$refr = (int) get_parameter('refresh');
|
||||
$id_extra = (string) get_parameter('id_extra');
|
||||
$user_comment = (string) get_parameter('user_comment');
|
||||
$source = (string) get_parameter('source');
|
||||
$id_extra = ($apply_filter === true && $is_filtered === false) ? (string) $event_filter['id_extra'] : (string) get_parameter('id_extra');
|
||||
$user_comment = ($apply_filter === true && $is_filtered === false) ? (string) $event_filter['user_comment'] : (string) get_parameter('user_comment');
|
||||
$source = ($apply_filter === true && $is_filtered === false) ? (string) $event_filter['source'] : (string) get_parameter('source');
|
||||
|
||||
if ($id_agent != 0) {
|
||||
$text_agent = agents_get_alias($id_agent);
|
||||
@ -343,7 +394,7 @@ if ($id_agent != 0) {
|
||||
}
|
||||
|
||||
$text_module = (string) get_parameter('module_search', '');
|
||||
$id_agent_module = get_parameter(
|
||||
$id_agent_module = ($apply_filter === true && $is_filtered === false) ? $event_filter['id_agent_module'] : get_parameter(
|
||||
'module_search_hidden',
|
||||
get_parameter('id_agent_module', 0)
|
||||
);
|
||||
@ -363,7 +414,7 @@ if ($id_agent_module != 0) {
|
||||
|
||||
|
||||
|
||||
$tag_with_json = base64_decode(get_parameter('tag_with', ''));
|
||||
$tag_with_json = ($apply_filter === true && $is_filtered === false) ? base64_decode($event_filter['tag_with']) : base64_decode(get_parameter('tag_with', ''));
|
||||
$tag_with_json_clean = io_safe_output($tag_with_json);
|
||||
$tag_with_base64 = base64_encode($tag_with_json_clean);
|
||||
$tag_with = json_decode($tag_with_json_clean, true);
|
||||
@ -373,7 +424,7 @@ if (empty($tag_with)) {
|
||||
|
||||
$tag_with = array_diff($tag_with, [0 => 0]);
|
||||
|
||||
$tag_without_json = base64_decode(get_parameter('tag_without', ''));
|
||||
$tag_without_json = ($apply_filter === true && $is_filtered === false) ? base64_decode($event_filter['tag_without']) : base64_decode(get_parameter('tag_without', ''));
|
||||
$tag_without_json_clean = io_safe_output($tag_without_json);
|
||||
$tag_without_base64 = base64_encode($tag_without_json_clean);
|
||||
$tag_without = json_decode($tag_without_json_clean, true);
|
||||
|
@ -232,68 +232,70 @@ if ($user_filter != 0 && empty($id_name) && !$update_from_filter_table) {
|
||||
);
|
||||
$user_default_filter = $user_default_filter[0];
|
||||
|
||||
// FORM.
|
||||
$id_name = $user_default_filter['id_name'];
|
||||
$id_group = $user_default_filter['id_group'];
|
||||
if ($user_default_filter['event_type'] != '') {
|
||||
$event_type = $user_default_filter['event_type'];
|
||||
}
|
||||
if (!empty($user_default_filter)) {
|
||||
// FORM.
|
||||
$id_name = $user_default_filter['id_name'];
|
||||
$id_group = $user_default_filter['id_group'];
|
||||
if ($user_default_filter['event_type'] != '') {
|
||||
$event_type = $user_default_filter['event_type'];
|
||||
}
|
||||
|
||||
$severity = $user_default_filter['severity'];
|
||||
$status = $user_default_filter['status'];
|
||||
$event_view_hr = $user_default_filter['event_view_hr'];
|
||||
$group_rep = $user_default_filter['group_rep'];
|
||||
$id_extra = $user_default_filter['id_extra'];
|
||||
$user_comment = $user_default_filter['user_comment'];
|
||||
$source = $user_default_filter['source'];
|
||||
$severity = $user_default_filter['severity'];
|
||||
$status = $user_default_filter['status'];
|
||||
$event_view_hr = $user_default_filter['event_view_hr'];
|
||||
$group_rep = $user_default_filter['group_rep'];
|
||||
$id_extra = $user_default_filter['id_extra'];
|
||||
$user_comment = $user_default_filter['user_comment'];
|
||||
$source = $user_default_filter['source'];
|
||||
|
||||
if ($user_default_filter['search'] != '') {
|
||||
$search = $user_default_filter['search'];
|
||||
}
|
||||
if ($user_default_filter['search'] != '') {
|
||||
$search = $user_default_filter['search'];
|
||||
}
|
||||
|
||||
if ($user_default_filter['id_user_ack'] != 0) {
|
||||
$id_user_ack = $user_default_filter['id_user_ack'];
|
||||
}
|
||||
if ($user_default_filter['id_user_ack'] != 0) {
|
||||
$id_user_ack = $user_default_filter['id_user_ack'];
|
||||
}
|
||||
|
||||
if ($user_default_filter['id_agent_module'] != 0) {
|
||||
$id_agent_module = $user_default_filter['id_agent_module'];
|
||||
}
|
||||
if ($user_default_filter['id_agent_module'] != 0) {
|
||||
$id_agent_module = $user_default_filter['id_agent_module'];
|
||||
}
|
||||
|
||||
if ($user_default_filter['id_agent'] != 0) {
|
||||
$id_agent = $user_default_filter['id_agent'];
|
||||
$text_agent = agents_get_alias($id_agent);
|
||||
}
|
||||
if ($user_default_filter['id_agent'] != 0) {
|
||||
$id_agent = $user_default_filter['id_agent'];
|
||||
$text_agent = agents_get_alias($id_agent);
|
||||
}
|
||||
|
||||
if ($user_default_filter['filter_only_alert'] != -1) {
|
||||
$filter_only_alert = $user_default_filter['filter_only_alert'];
|
||||
}
|
||||
if ($user_default_filter['filter_only_alert'] != -1) {
|
||||
$filter_only_alert = $user_default_filter['filter_only_alert'];
|
||||
}
|
||||
|
||||
if ($user_default_filter['pagination'] != 20) {
|
||||
$pagination = $user_default_filter['pagination'];
|
||||
}
|
||||
if ($user_default_filter['pagination'] != 20) {
|
||||
$pagination = $user_default_filter['pagination'];
|
||||
}
|
||||
|
||||
if ($user_default_filter['date_from'] != '0000-00-00') {
|
||||
$date_from = $user_default_filter['date_from'];
|
||||
}
|
||||
if ($user_default_filter['date_from'] != '0000-00-00') {
|
||||
$date_from = $user_default_filter['date_from'];
|
||||
}
|
||||
|
||||
if ($user_default_filter['date_to'] != '0000-00-00') {
|
||||
$date_to = $user_default_filter['date_to'];
|
||||
}
|
||||
if ($user_default_filter['date_to'] != '0000-00-00') {
|
||||
$date_to = $user_default_filter['date_to'];
|
||||
}
|
||||
|
||||
if (io_safe_output($user_default_filter['tag_with']) != '[]'
|
||||
&& io_safe_output($user_default_filter['tag_with']) != '["0"]'
|
||||
) {
|
||||
$tag_with = $user_default_filter['tag_with'];
|
||||
$tag_with_clean = io_safe_output($tag_with);
|
||||
$tag_with = json_decode($tag_with_clean, true);
|
||||
}
|
||||
if (io_safe_output($user_default_filter['tag_with']) != '[]'
|
||||
&& io_safe_output($user_default_filter['tag_with']) != '["0"]'
|
||||
) {
|
||||
$tag_with = $user_default_filter['tag_with'];
|
||||
$tag_with_clean = io_safe_output($tag_with);
|
||||
$tag_with = json_decode($tag_with_clean, true);
|
||||
}
|
||||
|
||||
if (io_safe_output($user_default_filter['tag_without']) != '[]'
|
||||
&& io_safe_output($user_default_filter['tag_without']) != '["0"]'
|
||||
) {
|
||||
$tag_without = $user_default_filter['tag_without'];
|
||||
$tag_without_clear = io_safe_output($tag_without);
|
||||
$tag_without = json_decode($tag_without_clear, true);
|
||||
if (io_safe_output($user_default_filter['tag_without']) != '[]'
|
||||
&& io_safe_output($user_default_filter['tag_without']) != '["0"]'
|
||||
) {
|
||||
$tag_without = $user_default_filter['tag_without'];
|
||||
$tag_without_clear = io_safe_output($tag_without);
|
||||
$tag_without = json_decode($tag_without_clear, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -706,6 +708,9 @@ if (is_metaconsole()) {
|
||||
// Hidden field with the loaded filter name.
|
||||
$events_filter .= html_print_input_hidden('id_name', $id_name, true);
|
||||
|
||||
// Hidden field that signals filter has been applied.
|
||||
$events_filter .= html_print_input_hidden('is_filtered', 'true', true);
|
||||
|
||||
// Hidden open filter flag
|
||||
// If autoupdate is in use collapse filter.
|
||||
if ($open_filter) {
|
||||
@ -1039,6 +1044,20 @@ $events_filter .= $botom_update;
|
||||
|
||||
$events_filter .= '</form>';
|
||||
// This is the filter div.
|
||||
$user_filter = db_get_value(
|
||||
'default_event_filter',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
$config['id_user']
|
||||
);
|
||||
$user_default_filter = db_get_all_rows_filter(
|
||||
'tevent_filter',
|
||||
['id_filter' => $user_filter]
|
||||
);
|
||||
$user_default_filter = $user_default_filter[0];
|
||||
|
||||
$id_name = $user_default_filter['id_name'];
|
||||
|
||||
$filter_resume['title'] = empty($id_name) ? __('No filter loaded') : __('Filter loaded').': '.$id_name;
|
||||
|
||||
if (is_metaconsole()) {
|
||||
@ -1321,8 +1340,6 @@ $(document).ready( function() {
|
||||
// Update the info with the loaded filter
|
||||
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + $("#hidden-id_name").val());
|
||||
|
||||
// Update the view with the loaded filter
|
||||
$('#submit-update').trigger('click');
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
@ -182,7 +182,8 @@ if ($searchAgents) {
|
||||
}
|
||||
|
||||
$sql = "
|
||||
FROM tagente t1
|
||||
FROM tagente t1 LEFT JOIN tagent_secondary_group tasg
|
||||
ON t1.id_agente = tasg.id_agent
|
||||
INNER JOIN tgrupo t2
|
||||
ON t2.id_grupo = t1.id_grupo
|
||||
WHERE (
|
||||
@ -191,9 +192,11 @@ if ($searchAgents) {
|
||||
FROM tusuario
|
||||
WHERE id_user = '".$config['id_user']."'
|
||||
)
|
||||
OR t1.id_grupo IN (
|
||||
".implode(',', $id_userGroups)."
|
||||
) OR 0 IN (
|
||||
OR (
|
||||
t1.id_grupo IN (".implode(',', $id_userGroups).')
|
||||
OR tasg.id_group IN ('.implode(',', $id_userGroups).")
|
||||
)
|
||||
OR 0 IN (
|
||||
SELECT id_grupo
|
||||
FROM tusuario_perfil
|
||||
WHERE id_usuario = '".$config['id_user']."'
|
||||
@ -208,7 +211,7 @@ if ($searchAgents) {
|
||||
)
|
||||
';
|
||||
|
||||
$select = 'SELECT t1.id_agente, t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias, t1.quiet';
|
||||
$select = 'SELECT DISTINCT(t1.id_agente), t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias, t1.quiet';
|
||||
if ($only_count) {
|
||||
$limit = ' ORDER BY '.$order['field'].' '.$order['order'].' LIMIT '.$config['block_size'].' OFFSET 0';
|
||||
} else {
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.734
|
||||
%define release 190429
|
||||
%define release 190508
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.734
|
||||
%define release 190429
|
||||
%define release 190508
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.734
|
||||
%define release 190429
|
||||
%define release 190508
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
@ -1421,6 +1421,18 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
|
||||
`hide_no_data` tinyint(1) default 0,
|
||||
`recursion` tinyint(1) default NULL,
|
||||
`show_extended_events` tinyint(1) default '0',
|
||||
`total_time` TINYINT(1) DEFAULT '1',
|
||||
`time_failed` TINYINT(1) DEFAULT '1',
|
||||
`time_in_ok_status` TINYINT(1) DEFAULT '1',
|
||||
`time_in_unknown_status` TINYINT(1) DEFAULT '1',
|
||||
`time_of_not_initialized_module` TINYINT(1) DEFAULT '1',
|
||||
`time_of_downtime` TINYINT(1) DEFAULT '1',
|
||||
`total_checks` TINYINT(1) DEFAULT '1',
|
||||
`checks_failed` TINYINT(1) DEFAULT '1',
|
||||
`checks_in_ok_status` TINYINT(1) DEFAULT '1',
|
||||
`unknown_checks` TINYINT(1) DEFAULT '1',
|
||||
`agent_max_value` TINYINT(1) DEFAULT '1',
|
||||
`agent_min_value` TINYINT(1) DEFAULT '1',
|
||||
PRIMARY KEY(`id_rc`),
|
||||
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
@ -2948,6 +2960,18 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` (
|
||||
`lapse` int(11) UNSIGNED NOT NULL default '300',
|
||||
`visual_format` tinyint(1) UNSIGNED NOT NULL default '0',
|
||||
`hide_no_data` tinyint(1) default 0,
|
||||
`total_time` TINYINT(1) DEFAULT '1',
|
||||
`time_failed` TINYINT(1) DEFAULT '1',
|
||||
`time_in_ok_status` TINYINT(1) DEFAULT '1',
|
||||
`time_in_unknown_status` TINYINT(1) DEFAULT '1',
|
||||
`time_of_not_initialized_module` TINYINT(1) DEFAULT '1',
|
||||
`time_of_downtime` TINYINT(1) DEFAULT '1',
|
||||
`total_checks` TINYINT(1) DEFAULT '1',
|
||||
`checks_failed` TINYINT(1) DEFAULT '1',
|
||||
`checks_in_ok_status` TINYINT(1) DEFAULT '1',
|
||||
`unknown_checks` TINYINT(1) DEFAULT '1',
|
||||
`agent_max_value` TINYINT(1) DEFAULT '1',
|
||||
`agent_min_value` TINYINT(1) DEFAULT '1',
|
||||
PRIMARY KEY(`id_rc`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-server
|
||||
Version: 7.0NG.734-190429
|
||||
Version: 7.0NG.734-190508
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -14,7 +14,7 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.734-190429"
|
||||
pandora_version="7.0NG.734-190508"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
@ -45,7 +45,7 @@ our @EXPORT = qw(
|
||||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.734";
|
||||
my $pandora_build = "190429";
|
||||
my $pandora_build = "190508";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
@ -32,7 +32,7 @@ our @ISA = qw(Exporter);
|
||||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.734";
|
||||
my $pandora_build = "190429";
|
||||
my $pandora_build = "190508";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.734
|
||||
%define release 190429
|
||||
%define release 190508
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.734
|
||||
%define release 190429
|
||||
%define release 190508
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
@ -9,7 +9,7 @@
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.734"
|
||||
PI_BUILD="190429"
|
||||
PI_BUILD="190508"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
@ -34,7 +34,7 @@ use PandoraFMS::Config;
|
||||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.734 PS190429";
|
||||
my $version = "7.0NG.734 PS190508";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
||||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.734 PS190429";
|
||||
my $version = "7.0NG.734 PS190508";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
@ -155,6 +155,7 @@ sub help_screen{
|
||||
help_screen_line('--update_module', '<module_name> <agent_name> <field_to_change> <new_value>', 'Update a module field');
|
||||
help_screen_line('--get_agents_module_current_data', '<module_name>', "Get the agent and current data \n\t of all the modules with a given name");
|
||||
help_screen_line('--create_network_module_from_component', '<agent_name> <component_name>', "Create a new network \n\t module from a network component");
|
||||
help_screen_line('--create_network_component', "<network_component_name> <network_component_group> <network_component_type> \n\t [<description> <module_interval> <max_value> <min_value> \n\t <snmp_community> <id_module_group> <max_timeout> \n\t <history_data> <min_warning> <max_warning> \n\t <str_warning> <min_critical> <max_critical> \n\t <str_critical> <min_ff_event> <post_process> \n\t <disabled_types_event> <each_ff> <min_ff_event_normal> \n\t <min_ff_event_warning> <min_ff_event_critical>]", "Create a new network component");
|
||||
help_screen_line('--create_synthetic', "<module_name> <synthetic_type> <agent_name> <source_agent1>,<operation>,<source_module1>|<source_agent1>,<source_module1> \n\t [ <operation>,<fixed_value> | <source agent2>,<operation>,<source_module2> ]", "Create a new Synthetic module");
|
||||
print "\nALERTS:\n\n" unless $param ne '';
|
||||
help_screen_line('--create_template_module', '<template_name> <module_name> <agent_name>', 'Add alert template to module');
|
||||
@ -1685,6 +1686,23 @@ sub cli_create_network_module_from_component() {
|
||||
pandora_create_module_from_network_component ($conf, $component, $agent_id, $dbh);
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Create a network component.
|
||||
# Related option: --create_network_component
|
||||
##############################################################################
|
||||
sub cli_create_network_component() {
|
||||
my ($c_name, $c_group, $c_type) = @ARGV[2..4];
|
||||
my @todo = @ARGV[5..20];
|
||||
my $other = join('|', @todo);
|
||||
my @todo2 = @ARGV[22..26];
|
||||
my $other2 = join('|', @todo2);
|
||||
|
||||
# Call the API.
|
||||
my $result = api_call( $conf, 'set', 'new_network_component', $c_name, undef, "$c_type|$other|$c_group|$other2");
|
||||
|
||||
print "$result \n\n ";
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Create netflow filter
|
||||
# Related option: --create_netflow_filter
|
||||
@ -6204,6 +6222,10 @@ sub pandora_manage_main ($$$) {
|
||||
param_check($ltotal, 2);
|
||||
cli_create_network_module_from_component();
|
||||
}
|
||||
elsif ($param eq '--create_network_component') {
|
||||
param_check($ltotal, 24, 21);
|
||||
cli_create_network_component();
|
||||
}
|
||||
elsif ($param eq '--create_netflow_filter') {
|
||||
param_check($ltotal, 5);
|
||||
cli_create_netflow_filter();
|
||||
|
Loading…
x
Reference in New Issue
Block a user