Merge branch 'develop' into 'ent-3771-Nueva-tipo-de-macro-password-en-comandos-acciones-de-alerta'
# Conflicts: # pandora_console/extras/mr/28.sql Former-commit-id: f9ff15a815fa9a15f1d326174ac40acbdd4110dd
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
docker build --rm=true --build-arg BRANCH="develop" --build-arg DB_PASS="pandora" -t pandorafms/pandorafms:7 . && \
|
docker build --rm=true --pull --no-cache --build-arg BRANCH="develop" --build-arg DB_PASS="pandora" -t pandorafms/pandorafms:7 . && \
|
||||||
docker push pandorafms/pandorafms:7
|
docker push pandorafms/pandorafms:7
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package: pandorafms-agent-unix
|
package: pandorafms-agent-unix
|
||||||
Version: 7.0NG.734-190425
|
Version: 7.0NG.734-190513
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: admin
|
Section: admin
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
pandora_version="7.0NG.734-190425"
|
pandora_version="7.0NG.734-190513"
|
||||||
|
|
||||||
echo "Test if you has the tools for to make the packages."
|
echo "Test if you has the tools for to make the packages."
|
||||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||||
|
|
|
@ -42,7 +42,7 @@ my $Sem = undef;
|
||||||
my $ThreadSem = undef;
|
my $ThreadSem = undef;
|
||||||
|
|
||||||
use constant AGENT_VERSION => '7.0NG.734';
|
use constant AGENT_VERSION => '7.0NG.734';
|
||||||
use constant AGENT_BUILD => '190425';
|
use constant AGENT_BUILD => '190513';
|
||||||
|
|
||||||
# Agent log default file size maximum and instances
|
# Agent log default file size maximum and instances
|
||||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
%define name pandorafms_agent_unix
|
%define name pandorafms_agent_unix
|
||||||
%define version 7.0NG.734
|
%define version 7.0NG.734
|
||||||
%define release 190425
|
%define release 190513
|
||||||
|
|
||||||
Summary: Pandora FMS Linux agent, PERL version
|
Summary: Pandora FMS Linux agent, PERL version
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
%define name pandorafms_agent_unix
|
%define name pandorafms_agent_unix
|
||||||
%define version 7.0NG.734
|
%define version 7.0NG.734
|
||||||
%define release 190425
|
%define release 190513
|
||||||
|
|
||||||
Summary: Pandora FMS Linux agent, PERL version
|
Summary: Pandora FMS Linux agent, PERL version
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# **********************************************************************
|
# **********************************************************************
|
||||||
|
|
||||||
PI_VERSION="7.0NG.734"
|
PI_VERSION="7.0NG.734"
|
||||||
PI_BUILD="190425"
|
PI_BUILD="190513"
|
||||||
OS_NAME=`uname -s`
|
OS_NAME=`uname -s`
|
||||||
|
|
||||||
FORCE=0
|
FORCE=0
|
||||||
|
|
|
@ -4,23 +4,44 @@
|
||||||
# Copyright (c) 2009 Artica Soluciones Tecnologicas S.L.
|
# Copyright (c) 2009 Artica Soluciones Tecnologicas S.L.
|
||||||
#
|
#
|
||||||
# inventory Generate a hardware/software inventory.
|
# inventory Generate a hardware/software inventory.
|
||||||
#
|
#
|
||||||
# Sample usage: ./inventory <interval in days> [cpu] [ram] [video] [nic] [hd] [cdrom] [software] [init_services] [filesystem] [process] [users]
|
# 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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation; version 2 of the License.
|
# the Free Software Foundation; version 2 of the License.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use constant TSTAMP_FILE => '/tmp/pandora_inventory.tstamp';
|
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)
|
# Operation mode (LSHW or HWINFO)
|
||||||
my $Mode;
|
my $Mode;
|
||||||
|
|
||||||
|
@ -31,12 +52,12 @@ my $Separator;
|
||||||
sub get_module_data ($$$$) {
|
sub get_module_data ($$$$) {
|
||||||
my ($name, $hwinfo, $keys, $modules) = @_;
|
my ($name, $hwinfo, $keys, $modules) = @_;
|
||||||
my %module;
|
my %module;
|
||||||
|
$Separator='\s+\*\-';
|
||||||
# Store keys
|
# Store keys
|
||||||
foreach my $key (@{$keys}) {
|
foreach my $key (@{$keys}) {
|
||||||
push (@{$module{'_keys'}}, $key);
|
push (@{$module{'_keys'}}, $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse module data
|
# Parse module data
|
||||||
while (my $line = shift (@{$hwinfo})) {
|
while (my $line = shift (@{$hwinfo})) {
|
||||||
if ($line =~ /$Separator/) {
|
if ($line =~ /$Separator/) {
|
||||||
|
@ -46,7 +67,7 @@ sub get_module_data ($$$$) {
|
||||||
foreach my $key (@{$keys}) {
|
foreach my $key (@{$keys}) {
|
||||||
if ($line =~ /$key:\s+(.+)/) {
|
if ($line =~ /$key:\s+(.+)/) {
|
||||||
$module{$key} = $1;
|
$module{$key} = $1;
|
||||||
# Replace semicolon by comma to avoid parse errors
|
# Replace semicolon by comma to avoid parse errors
|
||||||
$module{$key} =~ s/;/,/g;
|
$module{$key} =~ s/;/,/g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,12 +79,65 @@ sub get_module_data ($$$$) {
|
||||||
|
|
||||||
push (@{$modules->{$name}}, \%module);
|
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
|
# Get a list of information file system in machine
|
||||||
sub get_file_system($$) {
|
sub get_file_system($$) {
|
||||||
my ($name, $modules) = @_;
|
my ($name, $modules) = @_;
|
||||||
|
my @fileSystems;
|
||||||
my @fileSystems = `df -hP | tail -n +2`; #remove the titles of columns
|
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) {
|
foreach my $row (@fileSystems) {
|
||||||
next unless ($row =~ /^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+\S+\s+(\S+)/);
|
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{'used'} = $2;
|
||||||
$module{'avail'} = $3;
|
$module{'avail'} = $3;
|
||||||
$module{'mount'} = $4;
|
$module{'mount'} = $4;
|
||||||
$module{'_keys'} = ['filesystem', 'used','avail', 'mount'];
|
$module{'_keys'} = ['filesystem', 'used','avail', 'mount'];
|
||||||
push (@{$modules->{$name}}, \%module);
|
push (@{$modules->{$name}}, \%module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get a list of services init in machine
|
# Get a list of services init in machine
|
||||||
sub get_servicies_init_machine($$) {
|
sub get_servicies_init_machine($$) {
|
||||||
my ($name, $modules) = @_;
|
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)
|
#ini trim($runlevel)
|
||||||
$runlevel =~ s/^\s*//; #ltrim
|
$runlevel =~ s/^\s*//; #ltrim
|
||||||
$runlevel =~ s/\s*$//; #rtrim
|
$runlevel =~ s/\s*$//; #rtrim
|
||||||
#end trim($runlevel)
|
#end trim($runlevel)
|
||||||
|
|
||||||
my $script = "";
|
my $script;
|
||||||
|
|
||||||
if (-e "/etc/rc" . $runlevel .".d/") {
|
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 {
|
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`;
|
my @services = `$script`;
|
||||||
foreach my $row (@services) {
|
foreach my $row (@services) {
|
||||||
|
|
||||||
my %module;
|
my %module;
|
||||||
$row =~ s/\n//;
|
$row =~ s/\n//;
|
||||||
$module{'service'} = $row;
|
$module{'service'} = $row;
|
||||||
$module{'_keys'} = ['service'];
|
$module{'_keys'} = ['service'];
|
||||||
push (@{$modules->{$name}}, \%module);
|
push (@{$modules->{$name}}, \%module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get a list of running processes
|
# Get a list of running processes
|
||||||
sub get_processes ($$) {
|
sub get_processes ($$) {
|
||||||
my ($name, $modules) = @_;
|
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 @services = `$script`;
|
my %module;
|
||||||
foreach my $row (@services) {
|
# Remove carriage returns
|
||||||
my %module;
|
$row =~ s/[\n\l\f]//g;
|
||||||
# Remove carriage returns
|
# Replace semicolon by comma to avoid parse errors
|
||||||
$row =~ s/[\n\l\f]//g;
|
$row =~ s/;/,/g;
|
||||||
# Replace semicolon by comma to avoid parse errors
|
$module{'service'} = $row;
|
||||||
$row =~ s/;/,/g;
|
$module{'_keys'} = ['service'];
|
||||||
$module{'service'} = $row;
|
push (@{$modules->{$name}}, \%module);
|
||||||
$module{'_keys'} = ['service'];
|
}
|
||||||
push (@{$modules->{$name}}, \%module);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get a list of valid users in the system
|
# Get a list of valid users in the system
|
||||||
sub get_users ($$) {
|
sub get_users ($$) {
|
||||||
my ($name, $modules) = @_;
|
my ($name, $modules) = @_;
|
||||||
|
my $script = "cat /etc/passwd";
|
||||||
my $script = "cat /etc/passwd";
|
|
||||||
my $user = "";
|
my $user = "";
|
||||||
my $estado = "";
|
my $estado = "";
|
||||||
|
|
||||||
my @services = `$script`;
|
my @services = `$script`;
|
||||||
foreach my $row (@services) {
|
foreach my $row (@services) {
|
||||||
my %module;
|
my %module;
|
||||||
|
|
||||||
next unless ($row =~ /^([A-Za-z0-9\-\_]*)/);
|
next unless ($row =~ /^([A-Za-z0-9\-\_]*)/);
|
||||||
|
if (is_enabled $AIX) {
|
||||||
$user = $1;
|
$user = $1;
|
||||||
$script = `passwd -S $user`;
|
$script = `lsuser $user`;
|
||||||
if ( $script =~ /^(\S+)\sP./){
|
if ( $script =~ /^(\S+)\sid./){
|
||||||
$module{'user'} = $user;
|
$module{'user'} = $user;
|
||||||
$module{'_keys'} = ['user'];
|
$module{'_keys'} = ['user'];
|
||||||
push (@{$modules->{$name}}, \%module);
|
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
|
# Show Kernel Information
|
||||||
sub get_kernel_info ($$) {
|
sub get_kernel_info ($$) {
|
||||||
my ($name, $modules) = @_;
|
my ($name, $modules) = @_;
|
||||||
my $script = `uname -a | tr -d \";\"`;
|
my $script = `uname -a | tr -d \";\"`;
|
||||||
my %module;
|
my %module;
|
||||||
|
|
||||||
$module{'Kernel'} = $script;
|
$module{'Kernel'} = $script;
|
||||||
$module{'_keys'} = ['Kernel'];
|
$module{'_keys'} = ['Kernel'];
|
||||||
push (@{$modules->{$name}}, \%module);
|
push (@{$modules->{$name}}, \%module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,11 +261,13 @@ sub get_software_module_data ($$) {
|
||||||
# Guess the current distribution
|
# Guess the current distribution
|
||||||
my $distrib_id = "";
|
my $distrib_id = "";
|
||||||
|
|
||||||
if ( -e "/etc/SuSE-release"){
|
if (is_enabled $AIX) {
|
||||||
|
$distrib_id = "AIX";
|
||||||
|
}elsif ( -e "/etc/SuSE-release"){
|
||||||
$distrib_id = "SUSE";
|
$distrib_id = "SUSE";
|
||||||
} elsif ( -e "/etc/redhat-release"){
|
}elsif ( -e "/etc/redhat-release"){
|
||||||
$distrib_id = "REDHAT";
|
$distrib_id = "REDHAT";
|
||||||
} else {
|
}else {
|
||||||
$distrib_id = "DEBIAN";
|
$distrib_id = "DEBIAN";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +275,9 @@ sub get_software_module_data ($$) {
|
||||||
my @soft;
|
my @soft;
|
||||||
if ($distrib_id eq 'DEBIAN') {
|
if ($distrib_id eq 'DEBIAN') {
|
||||||
@soft = `dpkg -l | grep ii`;
|
@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
|
# 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`;
|
@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{'program'} = $1;
|
||||||
$module{'version'} = $2;
|
$module{'version'} = $2;
|
||||||
$module{'description'} = $3;
|
$module{'description'} = $3;
|
||||||
# Replace semicolon by comma to avoid parse errors
|
# Replace semicolon by comma to avoid parse errors
|
||||||
$module{'program'} =~ s/;/,/g;
|
$module{'program'} =~ s/;/,/g;
|
||||||
$module{'version'} =~ s/;/,/g;
|
$module{'version'} =~ s/;/,/g;
|
||||||
$module{'description'} =~ s/;/,/g;
|
$module{'description'} =~ s/;/,/g;
|
||||||
|
@ -211,67 +305,95 @@ sub get_software_module_data ($$) {
|
||||||
#Get the list of interfaces with the ip assigned
|
#Get the list of interfaces with the ip assigned
|
||||||
sub get_ips ($$) {
|
sub get_ips ($$) {
|
||||||
my ($name, $modules) = @_;
|
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 @ifconfig_array = split("\n", $ifconfig);
|
||||||
my $line = $ifconfig_array[$i+1];
|
|
||||||
|
|
||||||
$line =~ s/\s+//g;
|
|
||||||
|
|
||||||
@line_split = split(":", $line);
|
foreach (@ifconfig_array){
|
||||||
|
if ($_=~/(.*)flags/){
|
||||||
if($line_split[1] =~ /(\d+\.\d+\.\d+\.\d+).+/) {
|
my $match;
|
||||||
$info{'ip'} = $1;
|
($match)=$_=~/^(.*?)\: flags/;
|
||||||
}
|
$match=~s/://;
|
||||||
|
push @interfaces,$match;
|
||||||
$info{'_keys'} = ['interface', 'ip'];
|
}
|
||||||
push (@{$modules->{$name}}, \%info);
|
}
|
||||||
|
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
|
#Get route table
|
||||||
sub get_route_table ($$) {
|
sub get_route_table ($$) {
|
||||||
my ($name, $modules) = @_;
|
my ($name, $modules) = @_;
|
||||||
|
my $route_table;
|
||||||
my $route_table = `route`;
|
my @table_split;
|
||||||
|
if (is_enabled $AIX) {
|
||||||
my @table_split = split("\n", $route_table);
|
$route_table = `netstat -rn`;
|
||||||
|
@table_split = split("\n", $route_table);
|
||||||
for (my $i=2; $i<=$#table_split; $i++) {
|
my $length=scalar @table_split;
|
||||||
|
for (my $i=4; $i<=$length-4; $i++) {
|
||||||
my @split = split(" ", $table_split[$i]);
|
|
||||||
|
my @split = split(" ", $table_split[$i]);
|
||||||
my %info;
|
|
||||||
|
my %info;
|
||||||
$info{'destination'} = $split[0];
|
|
||||||
$info{'gateway'} = $split[1];
|
$info{'destination'} = $split[0];
|
||||||
$info{'mask'} = $split[2];
|
$info{'gateway'} = $split[1];
|
||||||
$info{'flags'} = $split[3];
|
$info{'mask'} = $split[2];
|
||||||
$info{'metric'} = $split[4];
|
$info{'flags'} = $split[3];
|
||||||
$info{'ref'} = $split[5];
|
$info{'metric'} = $split[4];
|
||||||
$info{'use'} = $split[6];
|
$info{'ref'} = $split[5];
|
||||||
$info{'interface'} = $split[7];
|
$info{'use'} = $split[6];
|
||||||
|
$info{'interface'} = $split[7];
|
||||||
$info{'_keys'} = ['destination', 'gateway', 'mask', 'flags', 'metric', 'use', 'interface'];
|
|
||||||
|
$info{'_keys'} = ['destination', 'gateway', 'mask', 'flags', 'metric', 'use', 'interface'];
|
||||||
push (@{$modules->{$name}}, \%info);
|
|
||||||
}
|
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
|
# Print module data
|
||||||
sub print_module ($$) {
|
sub print_module ($$) {
|
||||||
|
@ -309,14 +431,18 @@ my $enable_all = 0;
|
||||||
|
|
||||||
$interval = $ARGV[0];
|
$interval = $ARGV[0];
|
||||||
if ($#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"){
|
if ($module eq "all"){
|
||||||
$enable_all = 1;
|
$enable_all = 1;
|
||||||
}
|
}else {
|
||||||
$enabled{$module} = 1;
|
$enabled{$module} = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check execution interval
|
# Check execution interval
|
||||||
|
@ -333,76 +459,107 @@ close (FILE);
|
||||||
# Retrieve hardware information
|
# Retrieve hardware information
|
||||||
$Mode = 'LSHW';
|
$Mode = 'LSHW';
|
||||||
$Separator = '\s+\*\-';
|
$Separator = '\s+\*\-';
|
||||||
my @hwinfo = `lshw 2>/dev/null`;
|
my @hwinfo;
|
||||||
if ($? != 0) {
|
if (is_enabled $AIX) {
|
||||||
$Mode = 'HWINFO';
|
$Separator = '^\s*$';
|
||||||
$Separator = 'Hardware Class:';
|
@hwinfo=`prtconf 2>/dev/null`;
|
||||||
@hwinfo = `hwinfo --cpu --memory --gfxcard --netcard --cdrom --disk 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;
|
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);
|
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
|
# RAM
|
||||||
if (($line =~ /\*\-cpu/ || $line =~ /Hardware Class: cpu/) && ($enable_all == 1 || $enabled{'cpu'} == 1)) {
|
if (($line =~ /\*\-bank/ || $line =~ /\*\-memory/ || $line =~ /Hardware Class: memory/) && ($enable_all == 1 || $enabled{'ram'} == 1)) {
|
||||||
if ($Mode eq 'LSHW') {
|
if ($Mode eq 'LSHW') {
|
||||||
get_module_data ('CPU', \@hwinfo, ['product', 'vendor', 'capacity'], \%modules);
|
get_module_data ('RAM', \@hwinfo, ['description', 'size'], \%modules);
|
||||||
} else {
|
} else {
|
||||||
get_module_data ('CPU', \@hwinfo, ['Model', 'Vendor', 'Clock'], \%modules);
|
get_module_data ('RAM', \@hwinfo, ['Model', 'Memory Size'], \%modules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# RAM
|
# VIDEO
|
||||||
if (($line =~ /\*\-bank/ || $line =~ /Hardware Class: memory/) && ($enable_all == 1 || $enabled{'ram'} == 1)) {
|
if (($line =~ /\*\-display/ || $line =~ /Hardware Class: graphics card/) && ($enable_all == 1 || $enabled{'video'} == 1)) {
|
||||||
if ($Mode eq 'LSHW') {
|
if ($Mode eq 'LSHW') {
|
||||||
get_module_data ('RAM', \@hwinfo, ['description', 'size'], \%modules);
|
get_module_data ('VIDEO', \@hwinfo, ['product', 'description', 'vendor'], \%modules);
|
||||||
} else {
|
} else {
|
||||||
get_module_data ('RAM', \@hwinfo, ['Model', 'Memory Size'], \%modules);
|
# Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor
|
||||||
}
|
get_module_data ('VIDEO', \@hwinfo, ['Model', ' Device', ' Vendor'], \%modules);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# VIDEO
|
# NIC
|
||||||
if (($line =~ /\*\-display/ || $line =~ /Hardware Class: graphics card/) && ($enable_all == 1 || $enabled{'video'} == 1)) {
|
if (($line =~ /\*\-network/ || $line =~ /Hardware Class: network/) && ($enable_all == 1 || $enabled{'nic'} == 1)) {
|
||||||
if ($Mode eq 'LSHW') {
|
if ($Mode eq 'LSHW') {
|
||||||
get_module_data ('VIDEO', \@hwinfo, ['product', 'description', 'vendor'], \%modules);
|
get_module_data ('NIC', \@hwinfo, ['product', 'description', 'vendor', 'serial'], \%modules);
|
||||||
} else {
|
} else {
|
||||||
# Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor
|
# Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor
|
||||||
get_module_data ('VIDEO', \@hwinfo, ['Model', ' Device', ' Vendor'], \%modules);
|
get_module_data ('NIC', \@hwinfo, ['Model', ' Device', ' Vendor', 'HW Address'], \%modules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# NIC
|
# CDROM
|
||||||
if (($line =~ /\*\-network/ || $line =~ /Hardware Class: network/) && ($enable_all == 1 || $enabled{'nic'} == 1)) {
|
if (($line =~ /\*\-cdrom/ || $line =~ /Hardware Class: cdrom/) && ($enable_all == 1 || $enabled{'cdrom'} == 1)) {
|
||||||
if ($Mode eq 'LSHW') {
|
if ($Mode eq 'LSHW') {
|
||||||
get_module_data ('NIC', \@hwinfo, ['product', 'description', 'vendor', 'serial'], \%modules);
|
get_module_data ('CDROM', \@hwinfo, ['product', 'description', 'vendor'], \%modules);
|
||||||
} else {
|
} else {
|
||||||
# Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor
|
# Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor
|
||||||
get_module_data ('NIC', \@hwinfo, ['Model', ' Device', ' Vendor', 'HW Address'], \%modules);
|
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
|
# HD
|
||||||
if (($line =~ /\*\-disk/ || $line =~ /Hardware Class: disk/) && ($enable_all == 1 || $enabled{'hd'} == 1)) {
|
if (($line =~ /\*\-disk/ || $line =~ /Hardware Class: disk/) && ($enable_all == 1 || $enabled{'hd'} == 1)) {
|
||||||
if ($Mode eq 'LSHW') {
|
if ($Mode eq 'LSHW') {
|
||||||
get_module_data ('HD', \@hwinfo, ['product', 'description', 'size'], \%modules);
|
get_module_data ('HD', \@hwinfo, ['product', 'description', 'size'], \%modules);
|
||||||
} else {
|
} else {
|
||||||
get_module_data ('HD', \@hwinfo, ['Model', 'Serial ID', 'Size'], \%modules);
|
get_module_data ('HD', \@hwinfo, ['Model', 'Serial ID', 'Size'], \%modules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Software
|
# Software
|
||||||
if ($enable_all == 1 || $enabled{'software'} == 1) {
|
if ($enable_all == 1 || $enabled{'software'} == 1) {
|
||||||
get_software_module_data ('Software', \%modules);
|
get_software_module_data ('Software', \%modules);
|
||||||
|
@ -410,12 +567,12 @@ if ($enable_all == 1 || $enabled{'software'} == 1) {
|
||||||
|
|
||||||
#init_services
|
#init_services
|
||||||
if ($enable_all == 1 || $enabled{'init_services'} == 1) {
|
if ($enable_all == 1 || $enabled{'init_services'} == 1) {
|
||||||
get_servicies_init_machine ('Init services', \%modules);
|
get_servicies_init_machine ('Init_services', \%modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
#filesystem
|
#filesystem
|
||||||
if ($enable_all == 1 || $enabled{'filesystem'} == 1) {
|
if ($enable_all == 1 || $enabled{'filesystem'} == 1) {
|
||||||
get_file_system('File system', \%modules);
|
get_file_system('Filesystem', \%modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
#processes
|
#processes
|
||||||
|
@ -442,7 +599,6 @@ if ($enable_all == 1 || $enabled{'route'} == 1) {
|
||||||
if ($enable_all == 1 || $enabled{'kernel'} == 1){
|
if ($enable_all == 1 || $enabled{'kernel'} == 1){
|
||||||
get_kernel_info ('Kernel', \%modules);
|
get_kernel_info ('Kernel', \%modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print module data
|
# Print module data
|
||||||
print "<inventory>\n";
|
print "<inventory>\n";
|
||||||
while (my ($name, $module) = each (%modules)) {
|
while (my ($name, $module) = each (%modules)) {
|
||||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Version
|
Version
|
||||||
{190425}
|
{190513}
|
||||||
|
|
||||||
ViewReadme
|
ViewReadme
|
||||||
{Yes}
|
{Yes}
|
||||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
||||||
using namespace Pandora_Strutils;
|
using namespace Pandora_Strutils;
|
||||||
|
|
||||||
#define PATH_SIZE _MAX_PATH+1
|
#define PATH_SIZE _MAX_PATH+1
|
||||||
#define PANDORA_VERSION ("7.0NG.734(Build 190425)")
|
#define PANDORA_VERSION ("7.0NG.734(Build 190513)")
|
||||||
|
|
||||||
string pandora_path;
|
string pandora_path;
|
||||||
string pandora_dir;
|
string pandora_dir;
|
||||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
||||||
VALUE "LegalCopyright", "Artica ST"
|
VALUE "LegalCopyright", "Artica ST"
|
||||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||||
VALUE "ProductVersion", "(7.0NG.734(Build 190425))"
|
VALUE "ProductVersion", "(7.0NG.734(Build 190513))"
|
||||||
VALUE "FileVersion", "1.0.0.0"
|
VALUE "FileVersion", "1.0.0.0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package: pandorafms-console
|
package: pandorafms-console
|
||||||
Version: 7.0NG.734-190425
|
Version: 7.0NG.734-190513
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: admin
|
Section: admin
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
pandora_version="7.0NG.734-190425"
|
pandora_version="7.0NG.734-190513"
|
||||||
|
|
||||||
package_pear=0
|
package_pear=0
|
||||||
package_pandora=1
|
package_pandora=1
|
||||||
|
|
|
@ -10,5 +10,16 @@
|
||||||
"require": {
|
"require": {
|
||||||
"mpdf/mpdf": "^7.1",
|
"mpdf/mpdf": "^7.1",
|
||||||
"swiftmailer/swiftmailer": "^6.0"
|
"swiftmailer/swiftmailer": "^6.0"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Models\\": "include/rest-api/models",
|
||||||
|
"Enterprise\\Models\\": "enterprise/include/rest-api/models"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Tests\\": "tests/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,8 @@ START TRANSACTION;
|
||||||
|
|
||||||
ALTER TABLE `talert_commands` ADD COLUMN `fields_hidden` text;
|
ALTER TABLE `talert_commands` ADD COLUMN `fields_hidden` text;
|
||||||
|
|
||||||
|
ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM('regex','max_min','max','min','equal','not_equal','warning','critical','onchange','unknown','always','not_normal');
|
||||||
|
|
||||||
|
DELETE FROM `tevent_response` WHERE `name` LIKE 'Create Integria IMS incident from event';
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
|
@ -122,7 +122,7 @@ function execution_time()
|
||||||
if ($times[0]['datos'] > ($times[1]['datos'] * 1.2)) {
|
if ($times[0]['datos'] > ($times[1]['datos'] * 1.2)) {
|
||||||
return "<a class= 'content' style= 'color: red;'>Warning Status</a><a>   The execution time could be degrading. For a more extensive information of this data consult the Execution Time graph</a>";
|
return "<a class= 'content' style= 'color: red;'>Warning Status</a><a>   The execution time could be degrading. For a more extensive information of this data consult the Execution Time graph</a>";
|
||||||
} else {
|
} else {
|
||||||
return "<a style ='color: green;'>Normal Status</a><a>   The execution time is correct. For a more extensive information of this data consult the Execution Time graph</a>";
|
return "<a style ='color: green;'>Normal Status</a><a>   The execution time is correct. For more information about this data, check the Execution Time graph</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,9 +173,9 @@ function license_capacity()
|
||||||
$status_license_capacity = '';
|
$status_license_capacity = '';
|
||||||
$current_count = db_get_value_sql('SELECT count(*) FROM tagente');
|
$current_count = db_get_value_sql('SELECT count(*) FROM tagente');
|
||||||
if ($current_count > ($license_limit * 90 / 100)) {
|
if ($current_count > ($license_limit * 90 / 100)) {
|
||||||
$status_license_capacity = "<a class= 'content' style= 'color: red;text-decoration: none;'>Warning Status</a><a style ='text-decoration: none;'>   The license capacity is more than 90 percent</a>";
|
$status_license_capacity = "<a class= 'content' style= 'color: red;text-decoration: none;'>Warning Status</a><a style ='text-decoration: none;'>   License capacity exceeds 90 percent</a>";
|
||||||
} else {
|
} else {
|
||||||
$status_license_capacity = "<a style= 'color: green;text-decoration: none;'>Normal Status</a><a style ='text-decoration: none;'>   The license capacity is less than 90 percent</a>";
|
$status_license_capacity = "<a style= 'color: green;text-decoration: none;'>Normal Status</a><a style ='text-decoration: none;'>   License capacity is less than 90 percent</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $status_license_capacity;
|
return $status_license_capacity;
|
||||||
|
@ -202,9 +202,9 @@ function interval_average_of_network_modules()
|
||||||
$average_time = ((int) $total_module_interval_time / $total_network_modules);
|
$average_time = ((int) $total_module_interval_time / $total_network_modules);
|
||||||
|
|
||||||
if ($average_time < 180) {
|
if ($average_time < 180) {
|
||||||
$status_average_modules = "<a class= 'content' style= 'color: red;text-decoration: none;'>Warning Status</a><a style ='text-decoration: none;'>   The system has a lot of load (average time $average_time) and a very fine configuration is required</a>";
|
$status_average_modules = "<a class= 'content' style= 'color: red;text-decoration: none;'>Warning Status</a><a style ='text-decoration: none;'>   The system is overloaded (average time $average_time) and a very fine configuration is required</a>";
|
||||||
} else {
|
} else {
|
||||||
$status_average_modules = "<a style ='color: green;text-decoration: none;'>Normal Status</a><a style ='text-decoration: none;'>   The system has an acceptable charge (average time $average_time) </a>";
|
$status_average_modules = "<a style ='color: green;text-decoration: none;'>Normal Status</a><a style ='text-decoration: none;'>   The system is not overloaded (average time $average_time) </a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($average_time == 0) {
|
if ($average_time == 0) {
|
||||||
|
@ -221,9 +221,9 @@ $attachment_total_files = count(glob($config['homedir'].'/attachment/{*.*}', GLO
|
||||||
function files_attachment_folder($total_files)
|
function files_attachment_folder($total_files)
|
||||||
{
|
{
|
||||||
if ($total_files <= 700) {
|
if ($total_files <= 700) {
|
||||||
$status_total_files = "<a style ='color: green;text-decoration: none;'>Normal Status</a><a style ='text-decoration: none;'>   The attachment folder has less than 700 files.</a>";
|
$status_total_files = "<a style ='color: green;text-decoration: none;'>Normal Status</a><a style ='text-decoration: none;'>   The attached folder contains less than 700 files.</a>";
|
||||||
} else {
|
} else {
|
||||||
$status_total_files = "<a class= 'content' style= 'color: red;text-decoration: none;'>Warning Status</a><a style ='text-decoration: none;'>   The attachment folder has more than 700 files.</a>";
|
$status_total_files = "<a class= 'content' style= 'color: red;text-decoration: none;'>Warning Status</a><a style ='text-decoration: none;'>   The attached folder contains more than 700 files.</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $status_total_files;
|
return $status_total_files;
|
||||||
|
@ -236,9 +236,9 @@ $tagente_datos_size = db_get_value_sql('SELECT COUNT(*) FROM tagente_datos');
|
||||||
function status_tagente_datos($tagente_datos_size)
|
function status_tagente_datos($tagente_datos_size)
|
||||||
{
|
{
|
||||||
if ($tagente_datos_size <= 3000000) {
|
if ($tagente_datos_size <= 3000000) {
|
||||||
$tagente_datos_size = "<a style ='color: green;text-decoration: none;'>Normal Status</a><a style ='text-decoration: none;'>   The tagente_datos table has an acceptable amount of data.</a>";
|
$tagente_datos_size = "<a style ='color: green;text-decoration: none;'>Normal Status</a><a style ='text-decoration: none;'>   The tagente_datos table contains an acceptable amount of data.</a>";
|
||||||
} else {
|
} else {
|
||||||
$tagente_datos_size = "<a class= 'content' style ='color: red;text-decoration: none;'>Warning Status</a><a>   The tagente_datos table has too much data. A historical database is recommended.</a>";
|
$tagente_datos_size = "<a class= 'content' style ='color: red;text-decoration: none;'>Warning Status</a><a>   The tagente_datos table contains too much data. A historical database is recommended.</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tagente_datos_size;
|
return $tagente_datos_size;
|
||||||
|
@ -302,9 +302,9 @@ function status_fragmentation_tables($tables_fragmentation_max_rec_value, $table
|
||||||
{
|
{
|
||||||
$status_tables_frag = '';
|
$status_tables_frag = '';
|
||||||
if ($tables_fragmentation > $tables_fragmentation_max_rec_value) {
|
if ($tables_fragmentation > $tables_fragmentation_max_rec_value) {
|
||||||
$status_tables_frag = "<a class= 'content' style ='color: red; text-decoration: none;'>Warning Status</a><a style ='text-decoration: none;'>   The fragmentation tables is higher than recommended. You should defragment them.</a>";
|
$status_tables_frag = "<a class= 'content' style ='color: red; text-decoration: none;'>Warning Status</a><a style ='text-decoration: none;'>   Table fragmentation is higher than recommended. They should be defragmented.</a>";
|
||||||
} else {
|
} else {
|
||||||
$status_tables_frag = "<a style ='color: green; text-decoration: none;'>Normal Status</a><a style ='text-decoration: none;'>   The fragmentation tables is correct.</a>";
|
$status_tables_frag = "<a style ='color: green; text-decoration: none;'>Normal Status</a><a style ='text-decoration: none;'>   Table fragmentation is correct.</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $status_tables_frag;
|
return $status_tables_frag;
|
||||||
|
@ -320,9 +320,9 @@ if ($console_mode == 1) {
|
||||||
echo "\nPandora FMS PHP diagnostic tool v3.2 (c) Artica ST 2009-2010 \n";
|
echo "\nPandora FMS PHP diagnostic tool v3.2 (c) Artica ST 2009-2010 \n";
|
||||||
|
|
||||||
if ($argc == 1 || in_array($argv[1], ['--help', '-help', '-h', '-?'])) {
|
if ($argc == 1 || in_array($argv[1], ['--help', '-help', '-h', '-?'])) {
|
||||||
echo "\nThis command line script gives information about Pandora FMS database.
|
echo "\nThis command line script contains information about Pandora FMS database.
|
||||||
This program only can be executed from console, and need a parameter, the
|
This program can only be executed from the console, and it needs a parameter, the
|
||||||
full path to Pandora FMS 'config.php' file.
|
full path to Pandora FMS 'config.php' file.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
php pandora_diag.php path_to_pandora_console
|
php pandora_diag.php path_to_pandora_console
|
||||||
|
@ -705,7 +705,7 @@ render_info_data(
|
||||||
|
|
||||||
render_row($tables_fragmentation_max_rec_value.'%', 'Tables fragmentation (maximum recommended value)');
|
render_row($tables_fragmentation_max_rec_value.'%', 'Tables fragmentation (maximum recommended value)');
|
||||||
render_row(number_format($tables_fragmentation, 2).'%', 'Tables fragmentation (current value)');
|
render_row(number_format($tables_fragmentation, 2).'%', 'Tables fragmentation (current value)');
|
||||||
render_row(status_fragmentation_tables($tables_fragmentation_max_rec_value, $tables_fragmentation), 'Status fragmentation tables');
|
render_row(status_fragmentation_tables($tables_fragmentation_max_rec_value, $tables_fragmentation), 'Table fragmentation status');
|
||||||
|
|
||||||
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' Pandora FMS logs dates').'</th></tr>';
|
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' Pandora FMS logs dates').'</th></tr>';
|
||||||
|
|
||||||
|
@ -734,14 +734,14 @@ render_info_data(
|
||||||
|
|
||||||
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' Status of the attachment folder').'</th></tr>';
|
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' Status of the attachment folder').'</th></tr>';
|
||||||
|
|
||||||
render_row($attachment_total_files, 'Total files in the attachment folder');
|
render_row($attachment_total_files, 'Total files in the attached folder');
|
||||||
render_row(files_attachment_folder($attachment_total_files), 'Status of the attachment folder');
|
render_row(files_attachment_folder($attachment_total_files), 'Status of the attachment folder');
|
||||||
|
|
||||||
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' Information from the tagente_datos table').'</th></tr>';
|
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' Information from the tagente_datos table').'</th></tr>';
|
||||||
|
|
||||||
render_row($tagente_datos_size, 'Total data in the tagente_datos table');
|
render_row($tagente_datos_size, 'Total data in tagente_datos table');
|
||||||
render_row(status_tagente_datos($tagente_datos_size), 'Status of the tagente_datos table');
|
render_row(status_tagente_datos($tagente_datos_size), 'Tangente_datos table status');
|
||||||
render_row(execution_time(), 'Degradation of the execution time when executing a count');
|
render_row(execution_time(), 'Execution time degradation when executing a count');
|
||||||
|
|
||||||
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' Pandora FMS server threads').'</th></tr>';
|
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' Pandora FMS server threads').'</th></tr>';
|
||||||
|
|
||||||
|
@ -784,6 +784,6 @@ render_info_data(
|
||||||
echo "<hr color='#b1b1b1' size=1 width=1000 align=left>";
|
echo "<hr color='#b1b1b1' size=1 width=1000 align=left>";
|
||||||
|
|
||||||
echo '<span>'.__(
|
echo '<span>'.__(
|
||||||
'(*) Please check your Pandora Server setup and be sure that database maintenance daemon is running. It\' very important to
|
'(*) Please check your Pandora Server setup and make sure that the database maintenance daemon is running. It\' is very important to
|
||||||
keep up-to-date database to get the best performance and results in Pandora'
|
keep the database up-to-date to get the best performance and results in Pandora'
|
||||||
).'</span><br><br><br>';
|
).'</span><br><br><br>';
|
||||||
|
|
|
@ -1217,13 +1217,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned;
|
||||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
|
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
|
||||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
|
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
|
||||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
|
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
|
||||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 27);
|
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 28);
|
||||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
|
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
|
||||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
|
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
|
||||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
|
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
|
||||||
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
|
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
|
||||||
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
|
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
|
||||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '734');
|
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '735');
|
||||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
|
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
|
@ -2104,3 +2104,9 @@ ALTER TABLE `tnetflow_filter` DROP COLUMN `output`;
|
||||||
-- Update table `tuser_task`
|
-- Update table `tuser_task`
|
||||||
-- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
UPDATE tuser_task set parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report";
|
UPDATE tuser_task set parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report";
|
||||||
|
|
||||||
|
-- ----------------------------------------------------------------------
|
||||||
|
-- Alter table `talert_templates`
|
||||||
|
-- ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM('regex','max_min','max','min','equal','not_equal','warning','critical','onchange','unknown','always','not_normal');
|
||||||
|
|
|
@ -167,27 +167,18 @@ if ($disk_conf_delete) {
|
||||||
|
|
||||||
echo '<form name="conf_agent" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">';
|
echo '<form name="conf_agent" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">';
|
||||||
|
|
||||||
$table = new stdClass();
|
|
||||||
$table->width = '100%';
|
|
||||||
$table->class = 'databox filters';
|
|
||||||
|
|
||||||
$table->head = [];
|
|
||||||
$table->style = [];
|
|
||||||
$table->style[0] = 'font-weight: bold; width: 150px;';
|
|
||||||
$table->data = [];
|
|
||||||
|
|
||||||
$table->align[2] = 'center';
|
|
||||||
|
|
||||||
if (!$new_agent && $alias != '') {
|
if (!$new_agent && $alias != '') {
|
||||||
$table->data[0][0] = __('Agent name').ui_print_help_tip(__("The agent's name must be the same as the one defined at the console"), true);
|
$table_agent_name = '<div class="label_select"><p class="input_label">'.__('Agent name').': '.ui_print_help_tip(__("The agent's name must be the same as the one defined at the console"), true).'</p>';
|
||||||
$table->data[0][1] = html_print_input_text('agente', $nombre_agente, '', 50, 100, true);
|
$table_agent_name .= '<div class="label_select_parent">';
|
||||||
|
$table_agent_name .= '<div class="label_select_child_left">'.html_print_input_text('agente', $nombre_agente, '', 50, 100, true).'</div>';
|
||||||
|
$table_agent_name .= '<div class="label_select_child_right agent_options_agent_name">';
|
||||||
|
|
||||||
$table->data[0][2] = __('QR Code Agent view');
|
$table_qr_code = '<div class="agent_qr white_box"><p class="input_label">'.__('QR Code Agent view').': </p>';
|
||||||
|
|
||||||
if ($id_agente) {
|
if ($id_agente) {
|
||||||
$table->data[0][1] .= ' <b>'.__('ID')."</b> $id_agente ";
|
$table_agent_name .= '<span>'.__('ID').' '.$id_agente.'</span>';
|
||||||
$table->data[0][1] .= ' <a href="index.php?sec=gagente&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'">';
|
$table_agent_name .= '<a href="index.php?sec=gagente&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'">';
|
||||||
$table->data[0][1] .= html_print_image(
|
$table_agent_name .= html_print_image(
|
||||||
'images/zoom.png',
|
'images/zoom.png',
|
||||||
true,
|
true,
|
||||||
[
|
[
|
||||||
|
@ -195,20 +186,23 @@ if (!$new_agent && $alias != '') {
|
||||||
'title' => __('Agent detail'),
|
'title' => __('Agent detail'),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$table->data[0][1] .= '</a>';
|
$table_agent_name .= '</a>';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Remote configuration available
|
$agent_options_update = 'agent_options_update';
|
||||||
if (!$new_agent) {
|
|
||||||
|
// Delete link from here.
|
||||||
|
$table_agent_name .= "<a onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=$id_agente&search=&offset=0&sort_field=&sort=none'>".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).'</a>';
|
||||||
|
|
||||||
|
// Remote configuration available.
|
||||||
if (isset($filename)) {
|
if (isset($filename)) {
|
||||||
if (file_exists($filename['md5'])) {
|
if (file_exists($filename['md5'])) {
|
||||||
$agent_name = agents_get_name($id_agente);
|
$agent_name = agents_get_name($id_agente);
|
||||||
$agent_name = io_safe_output($agent_name);
|
$agent_name = io_safe_output($agent_name);
|
||||||
$agent_md5 = md5($agent_name, false);
|
$agent_md5 = md5($agent_name, false);
|
||||||
|
|
||||||
$table->data[0][1] .= ' '.'<a href="index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'tab=remote_configuration&'.'id_agente='.$id_agente.'&'.'disk_conf='.$agent_md5.'">';
|
$table_agent_name .= '<a href="index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'tab=remote_configuration&'.'id_agente='.$id_agente.'&'.'disk_conf='.$agent_md5.'">';
|
||||||
$table->data[0][1] .= html_print_image(
|
$table_agent_name .= html_print_image(
|
||||||
'images/application_edit.png',
|
'images/application_edit.png',
|
||||||
true,
|
true,
|
||||||
[
|
[
|
||||||
|
@ -216,35 +210,44 @@ if (!$new_agent) {
|
||||||
'title' => __('This agent can be remotely configured'),
|
'title' => __('This agent can be remotely configured'),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$table->data[0][1] .= '</a>'.ui_print_help_tip(
|
$table_agent_name .= '</a>'.ui_print_help_tip(
|
||||||
__('You can remotely edit this agent configuration'),
|
__('You can remotely edit this agent configuration'),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$table_agent_name .= '</div></div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete link from here
|
|
||||||
if (!$new_agent) {
|
|
||||||
$table->data[0][1] .= " <span align='right'><a onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=$id_agente&search=&offset=0&sort_field=&sort=none'>".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$table->data[1][0] = __('Alias').ui_print_help_tip(__('Characters /,\,|,%,#,&,$ will be ignored'), true).'</span>';
|
|
||||||
$table->data[1][1] = html_print_input_text('alias', $alias, '', 50, 100, true);
|
|
||||||
if ($new_agent) {
|
if ($new_agent) {
|
||||||
$table->data[1][1] .= html_print_checkbox('alias_as_name', 1, $config['alias_as_name'], true).__('Use alias as name');
|
$label_select_child_left = 'label_select_child_left';
|
||||||
|
$label_select_parent = 'label_select_parent';
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data[2][0] = __('IP Address');
|
$table_alias = '<div class="label_select"><p class="input_label">'.__('Alias').': '.ui_print_help_tip(__('Characters /,\,|,%,#,&,$ will be ignored'), true).'</p>';
|
||||||
$table->data[2][1] = html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).html_print_checkbox('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true);
|
$table_alias .= '<div class='.$label_select_parent.'>';
|
||||||
|
$table_alias .= '<div class='.$label_select_child_left.'>'.html_print_input_text('alias', $alias, '', 50, 100, true).'</div>';
|
||||||
|
if ($new_agent) {
|
||||||
|
$table_alias .= '<div class="label_select_child_right">'.html_print_checkbox_switch('alias_as_name', 1, $config['alias_as_name'], true).__('Use alias as name').'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$table_alias .= '</div></div>';
|
||||||
|
|
||||||
|
$table_ip = '<div class="label_select"><p class="input_label">'.__('IP Address').': </p>';
|
||||||
|
$table_ip .= '<div class="label_select_parent">';
|
||||||
|
$table_ip .= '<div class="label_select_child_left">'.html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).'</div>';
|
||||||
|
$table_ip .= '<div class="label_select_child_right">'.html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true).'</div>';
|
||||||
|
$table_ip .= '</div></div>';
|
||||||
|
|
||||||
if ($id_agente) {
|
if ($id_agente) {
|
||||||
$table->data[2][1] .= ' ';
|
|
||||||
|
|
||||||
$ip_all = agents_get_addresses($id_agente);
|
$ip_all = agents_get_addresses($id_agente);
|
||||||
|
|
||||||
$table->data[2][1] .= html_print_select($ip_all, 'address_list', $direccion_agente, '', '', 0, true);
|
$table_ip .= '<div class="label_select">';
|
||||||
$table->data[2][1] .= ' '.html_print_checkbox('delete_ip', 1, false, true).__('Delete selected');
|
$table_ip .= '<div class="label_select_parent">';
|
||||||
|
$table_ip .= '<div class="label_select_child_left">'.html_print_select($ip_all, 'address_list', $direccion_agente, '', '', 0, true).'</div>';
|
||||||
|
$table_ip .= '<div class="label_select_child_right">'.html_print_checkbox_switch('delete_ip', 1, false, true).__('Delete selected').'</div>';
|
||||||
|
$table_ip .= '</div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -254,13 +257,12 @@ if ($id_agente) {
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<?php
|
<?php
|
||||||
if (!$new_agent) {
|
if (!$new_agent && $alias != '') {
|
||||||
$table->rowspan[2][2] = 3;
|
|
||||||
if ($id_agente) {
|
if ($id_agente) {
|
||||||
$table->data[2][2] = "<a id='qr_code_agent_view' href='javascript: show_dialog_qrcode(null, \"".ui_get_full_url('mobile/index.php?page=agent&id='.$id_agente)."\" );'></a>";
|
$table_qr_code .= "<a id='qr_code_agent_view' href='javascript: show_dialog_qrcode(null, \"".ui_get_full_url('mobile/index.php?page=agent&id='.$id_agente)."\" );'></a>";
|
||||||
} else {
|
|
||||||
$table->data[2][2] = __('Only it is show when<br />the agent is saved.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$table_qr_code .= '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$groups = users_get_groups($config['id_user'], 'AR', false);
|
$groups = users_get_groups($config['id_user'], 'AR', false);
|
||||||
|
@ -277,28 +279,32 @@ if (is_array($modules)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data[4][0] = __('Primary group');
|
$table_primary_group = '<div class="label_select"><p class="input_label">'.__('Primary group').': </p>';
|
||||||
// Cannot change primary group if user have not permission for that group
|
$table_primary_group .= '<div class="label_select_parent">';
|
||||||
|
// Cannot change primary group if user have not permission for that group.
|
||||||
if (isset($groups[$grupo]) || $new_agent) {
|
if (isset($groups[$grupo]) || $new_agent) {
|
||||||
$table->data[4][1] = html_print_select_groups(false, 'AR', false, 'grupo', $grupo, '', '', 0, true);
|
$table_primary_group .= html_print_select_groups(false, 'AR', false, 'grupo', $grupo, '', '', 0, true);
|
||||||
} else {
|
} else {
|
||||||
$table->data[4][1] = groups_get_name($grupo);
|
$table_primary_group .= groups_get_name($grupo);
|
||||||
$table->data[4][1] .= html_print_input_hidden('grupo', $grupo, true);
|
$table_primary_group .= html_print_input_hidden('grupo', $grupo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data[4][1] .= ' <span id="group_preview">';
|
$table_primary_group .= '<div class="label_select_child_icons"><span id="group_preview">';
|
||||||
$table->data[4][1] .= ui_print_group_icon($grupo, true);
|
$table_primary_group .= ui_print_group_icon($grupo, true);
|
||||||
$table->data[4][1] .= '</span>';
|
$table_primary_group .= '</span></div></div></div>';
|
||||||
|
|
||||||
$table->data[5][0] = __('Interval');
|
$table_interval = '<div class="label_select"><p class="input_label">'.__('Interval').': </p>';
|
||||||
|
$table_interval .= '<div class="label_select_parent">';
|
||||||
$table->data[5][1] = html_print_extended_select_for_time('intervalo', $intervalo, '', '', '0', 10, true);
|
$table_interval .= html_print_extended_select_for_time('intervalo', $intervalo, '', '', '0', 10, true);
|
||||||
if ($intervalo < SECONDS_5MINUTES) {
|
if ($intervalo < SECONDS_5MINUTES) {
|
||||||
$table->data[5][1] .= clippy_context_help('interval_agent_min');
|
$table_interval .= clippy_context_help('interval_agent_min');
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data[6][0] = __('OS');
|
$table_interval .= '</div></div>';
|
||||||
$table->data[6][1] = html_print_select_from_sql(
|
|
||||||
|
$table_os = '<div class="label_select"><p class="input_label">'.__('OS').': </p>';
|
||||||
|
$table_os .= '<div class="label_select_parent">';
|
||||||
|
$table_os .= html_print_select_from_sql(
|
||||||
'SELECT id_os, name FROM tconfig_os',
|
'SELECT id_os, name FROM tconfig_os',
|
||||||
'id_os',
|
'id_os',
|
||||||
$id_os,
|
$id_os,
|
||||||
|
@ -307,18 +313,19 @@ $table->data[6][1] = html_print_select_from_sql(
|
||||||
'0',
|
'0',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
$table->data[6][1] .= ' <span id="os_preview">';
|
$table_os .= '<div class="label_select_child_icons"> <span id="os_preview">';
|
||||||
$table->data[6][1] .= ui_print_os_icon($id_os, false, true);
|
$table_os .= ui_print_os_icon($id_os, false, true);
|
||||||
$table->data[6][1] .= '</span>';
|
$table_os .= '</span></div></div></div>';
|
||||||
|
|
||||||
// Network server
|
// Network server.
|
||||||
$servers = servers_get_names();
|
$servers = servers_get_names();
|
||||||
if (!array_key_exists($server_name, $servers)) {
|
if (!array_key_exists($server_name, $servers)) {
|
||||||
$server_Name = 0;
|
$server_Name = 0;
|
||||||
// Set the agent have not server.
|
// Set the agent have not server.
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data[7][0] = __('Server');
|
$table_server = '<div class="label_select"><p class="input_label">'.__('Server').': </p>';
|
||||||
|
$table_server .= '<div class="label_select_parent">';
|
||||||
if ($new_agent) {
|
if ($new_agent) {
|
||||||
// Set first server by default.
|
// Set first server by default.
|
||||||
$servers_get_names = servers_get_names();
|
$servers_get_names = servers_get_names();
|
||||||
|
@ -326,7 +333,7 @@ if ($new_agent) {
|
||||||
$server_name = reset($array_keys_servers_get_names);
|
$server_name = reset($array_keys_servers_get_names);
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data[7][1] = html_print_select(
|
$table_server .= html_print_select(
|
||||||
servers_get_names(),
|
servers_get_names(),
|
||||||
'server_name',
|
'server_name',
|
||||||
$server_name,
|
$server_name,
|
||||||
|
@ -334,36 +341,35 @@ $table->data[7][1] = html_print_select(
|
||||||
__('None'),
|
__('None'),
|
||||||
0,
|
0,
|
||||||
true
|
true
|
||||||
).' '.ui_print_help_icon('agent_server', true);
|
).'<div class="label_select_child_icons">'.ui_print_help_icon('agent_server', true).'</div></div></div>';
|
||||||
|
|
||||||
// Description
|
// Description.
|
||||||
$table->data[8][0] = __('Description');
|
$table_description = '<div class="label_select"><p class="input_label">'.__('Description').': </p>';
|
||||||
$table->data[8][1] = html_print_input_text(
|
$table_description .= html_print_input_text(
|
||||||
'comentarios',
|
'comentarios',
|
||||||
$comentarios,
|
$comentarios,
|
||||||
'',
|
'',
|
||||||
45,
|
45,
|
||||||
200,
|
200,
|
||||||
true
|
true
|
||||||
);
|
).'</div>';
|
||||||
|
|
||||||
html_print_table($table);
|
|
||||||
unset($table);
|
|
||||||
|
|
||||||
$table = new stdClass();
|
echo '<div class="first_row">
|
||||||
$table->width = '100%';
|
<div class="agent_options '.$agent_options_update.' white_box">
|
||||||
$table->class = 'databox filters';
|
<div class="agent_options_column_left">'.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'</div>
|
||||||
|
<div class="agent_options_column_right">'.$table_interval.$table_os.$table_server.$table_description.'</div>
|
||||||
|
</div>';
|
||||||
|
if (!$new_agent && $alias != '') {
|
||||||
|
echo $table_qr_code;
|
||||||
|
}
|
||||||
|
|
||||||
$table->head = [];
|
echo '</div>';
|
||||||
$table->style = [];
|
|
||||||
$table->style[0] = 'font-weight: bold; ';
|
|
||||||
$table->style[4] = 'font-weight: bold;';
|
|
||||||
$table->data = [];
|
|
||||||
|
|
||||||
if (enterprise_installed()) {
|
if (enterprise_installed()) {
|
||||||
$secondary_groups_selected = enterprise_hook('agents_get_secondary_groups', [$id_agente]);
|
$secondary_groups_selected = enterprise_hook('agents_get_secondary_groups', [$id_agente]);
|
||||||
$table->data['secondary_groups'][0] = __('Secondary groups').ui_print_help_icon('secondary_groups', true);
|
$table_adv_secondary_groups = '<div class="label_select"><p class="input_label">'.__('Secondary groups').': '.ui_print_help_icon('secondary_groups', true).'</p></div>';
|
||||||
$table->data['secondary_groups'][1] = html_print_select_groups(
|
$table_adv_secondary_groups_left = html_print_select_groups(
|
||||||
false,
|
false,
|
||||||
// Use the current user to select the groups
|
// Use the current user to select the groups
|
||||||
'AR',
|
'AR',
|
||||||
|
@ -390,7 +396,7 @@ if (enterprise_installed()) {
|
||||||
// CSS classnames (default)
|
// CSS classnames (default)
|
||||||
false,
|
false,
|
||||||
// Not disabled (default)
|
// Not disabled (default)
|
||||||
false,
|
'width:50%; min-width:170px; text-align:center',
|
||||||
// Inline styles (default)
|
// Inline styles (default)
|
||||||
false,
|
false,
|
||||||
// Option style select (default)
|
// Option style select (default)
|
||||||
|
@ -404,29 +410,31 @@ if (enterprise_installed()) {
|
||||||
// Do not show the primary group in this selection
|
// Do not show the primary group in this selection
|
||||||
);
|
);
|
||||||
|
|
||||||
$table->data['secondary_groups'][2] = html_print_input_image(
|
$table_adv_secondary_groups_arrows = html_print_input_image(
|
||||||
'add_secondary',
|
'add_secondary',
|
||||||
'images/darrowright.png',
|
'images/darrowright_green.png',
|
||||||
1,
|
1,
|
||||||
'',
|
'',
|
||||||
true,
|
true,
|
||||||
[
|
[
|
||||||
|
'id' => 'right_autorefreshlist',
|
||||||
'title' => __('Add secondary groups'),
|
'title' => __('Add secondary groups'),
|
||||||
'onclick' => 'agent_manager_add_secondary_groups(event, '.$id_agente.');',
|
'onclick' => 'agent_manager_add_secondary_groups(event, '.$id_agente.');',
|
||||||
]
|
]
|
||||||
).'<br /><br /><br /><br />'.html_print_input_image(
|
).html_print_input_image(
|
||||||
'remove_secondary',
|
'remove_secondary',
|
||||||
'images/darrowleft.png',
|
'images/darrowleft_green.png',
|
||||||
1,
|
1,
|
||||||
'',
|
'',
|
||||||
true,
|
true,
|
||||||
[
|
[
|
||||||
|
'id' => 'left_autorefreshlist',
|
||||||
'title' => __('Remove secondary groups'),
|
'title' => __('Remove secondary groups'),
|
||||||
'onclick' => 'agent_manager_remove_secondary_groups(event, '.$id_agente.');',
|
'onclick' => 'agent_manager_remove_secondary_groups(event, '.$id_agente.');',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$table->data['secondary_groups'][3] = html_print_select(
|
$table_adv_secondary_groups_right .= html_print_select(
|
||||||
$secondary_groups_selected['for_select'],
|
$secondary_groups_selected['for_select'],
|
||||||
// Values
|
// Values
|
||||||
'secondary_groups_selected',
|
'secondary_groups_selected',
|
||||||
|
@ -441,8 +449,16 @@ if (enterprise_installed()) {
|
||||||
// Nothing selected
|
// Nothing selected
|
||||||
true,
|
true,
|
||||||
// Return HTML (not echo)
|
// Return HTML (not echo)
|
||||||
true
|
true,
|
||||||
// Multiple selection
|
// Multiple selection
|
||||||
|
true,
|
||||||
|
// Sort
|
||||||
|
'',
|
||||||
|
// Class
|
||||||
|
false,
|
||||||
|
// Disabled
|
||||||
|
'width:50%; min-width:170px; text-align:center'
|
||||||
|
// Style
|
||||||
);
|
);
|
||||||
|
|
||||||
// safe operation mode
|
// safe operation mode
|
||||||
|
@ -457,47 +473,42 @@ if (enterprise_installed()) {
|
||||||
$safe_mode_modules[$m['id_module']] = $m['name'];
|
$safe_mode_modules[$m['id_module']] = $m['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data[2][0] = __('Safe operation mode').ui_print_help_tip(
|
$table_adv_safe = '<div class="label_select_simple label_simple_items"><p class="input_label input_label_simple">'.__('Safe operation mode').': '.ui_print_help_tip(
|
||||||
__(
|
__(
|
||||||
'This mode allow %s to disable all modules
|
'This mode allow %s to disable all modules
|
||||||
of this agent while the selected module is on CRITICAL status',
|
of this agent while the selected module is on CRITICAL status',
|
||||||
get_product_name()
|
get_product_name()
|
||||||
),
|
),
|
||||||
true
|
true
|
||||||
);
|
).'</p>';
|
||||||
$table->data[2][1] = html_print_checkbox('safe_mode', 1, $safe_mode, true);
|
$table_adv_safe .= html_print_checkbox_switch('safe_mode', 1, $safe_mode, true);
|
||||||
$table->data[2][1] .= ' '.__('Module').' '.html_print_select($safe_mode_modules, 'safe_mode_module', $safe_mode_module, '', '', 0, true);
|
$table_adv_safe .= __('Module').' '.html_print_select($safe_mode_modules, 'safe_mode_module', $safe_mode_module, '', '', 0, true).'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remote configuration
|
// Remote configuration
|
||||||
$table->data[5][0] = __('Remote configuration');
|
$table_adv_remote = '<div class="label_select"><p class="input_label">'.__('Remote configuration').': </p>';
|
||||||
|
|
||||||
if (!$new_agent) {
|
if (!$new_agent && isset($filename) && file_exists($filename['md5'])) {
|
||||||
$table->data[5][1] = '<em>'.__('Not available').'</em>';
|
$table_adv_remote .= date('F d Y H:i:s', fileatime($filename['md5']));
|
||||||
if (isset($filename)) {
|
// Delete remote configuration
|
||||||
if (file_exists($filename['md5'])) {
|
$table_adv_remote .= '<a href="index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'tab=main&'.'disk_conf_delete=1&'.'id_agente='.$id_agente.'">';
|
||||||
$table->data[5][1] = date('F d Y H:i:s', fileatime($filename['md5']));
|
$table_adv_remote .= html_print_image(
|
||||||
// Delete remote configuration
|
'images/cross.png',
|
||||||
$table->data[5][1] .= '<a href="index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'tab=main&'.'disk_conf_delete=1&'.'id_agente='.$id_agente.'">';
|
true,
|
||||||
$table->data[5][1] .= html_print_image(
|
[
|
||||||
'images/cross.png',
|
'title' => __('Delete remote configuration file'),
|
||||||
true,
|
'style' => 'vertical-align: middle;',
|
||||||
[
|
]
|
||||||
'title' => __('Delete remote configuration file'),
|
).'</a>';
|
||||||
'style' => 'vertical-align: middle;',
|
$table_adv_remote .= '</a>'.ui_print_help_tip(
|
||||||
]
|
__('Delete this conf file implies that for restore you must reactive remote config in the local agent.'),
|
||||||
).'</a>';
|
true
|
||||||
$table->data[5][1] .= '</a>'.ui_print_help_tip(
|
);
|
||||||
__('Delete this conf file implies that for restore you must reactive remote config in the local agent.'),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$table->data[5][1] = '<em>'.__('Not available').'</em>';
|
$table_adv_remote .= '<em>'.__('Not available').'</em>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$table_adv_remote .= '</div>';
|
||||||
|
|
||||||
$cps_array[-1] = __('Disabled');
|
$cps_array[-1] = __('Disabled');
|
||||||
if ($cps > 0) {
|
if ($cps > 0) {
|
||||||
|
@ -511,16 +522,16 @@ if (enterprise_installed()) {
|
||||||
$cps_array[$cps_inc] = __('Enabled');
|
$cps_array[$cps_inc] = __('Enabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data[6][0] = __('Cascade protection services');
|
$table_adv_cascade = '<div class="label_select"><p class="input_label">'.__('Cascade protection services').': ';
|
||||||
$table->data[6][0] .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true);
|
$table_adv_cascade .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true).'</p>';
|
||||||
$table->data[6][1] = html_print_select($cps_array, 'cps', $cps, '', '', 0, true);
|
$table_adv_cascade .= html_print_select($cps_array, 'cps', $cps, '', '', 0, true).'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom ID
|
// Custom ID
|
||||||
$table->data[0][0] = __('Custom ID');
|
$table_adv_custom_id = '<div class="label_select"><p class="input_label">'.__('Custom ID').': </p>';
|
||||||
$table->data[0][1] = html_print_input_text('custom_id', $custom_id, '', 16, 255, true);
|
$table_adv_custom_id .= html_print_input_text('custom_id', $custom_id, '', 16, 255, true).'</div>';
|
||||||
|
|
||||||
$table->data[1][0] = __('Parent');
|
$table_adv_parent = '<div class="label_select"><p class="input_label">'.__('Parent').': </p>';
|
||||||
$params = [];
|
$params = [];
|
||||||
$params['return'] = true;
|
$params['return'] = true;
|
||||||
$params['show_helptip'] = true;
|
$params['show_helptip'] = true;
|
||||||
|
@ -532,75 +543,79 @@ $params['value'] = db_get_value('alias', 'tagente', 'id_agente', $id_parent);
|
||||||
$params['selectbox_id'] = 'cascade_protection_module';
|
$params['selectbox_id'] = 'cascade_protection_module';
|
||||||
$params['javascript_is_function_select'] = true;
|
$params['javascript_is_function_select'] = true;
|
||||||
$params['cascade_protection'] = true;
|
$params['cascade_protection'] = true;
|
||||||
|
$table_adv_parent .= '<div class="label_simple_items">';
|
||||||
$table->data[1][1] = ui_print_agent_autocomplete_input($params);
|
$table_adv_parent .= ui_print_agent_autocomplete_input($params);
|
||||||
if (enterprise_installed()) {
|
if (enterprise_installed()) {
|
||||||
$table->data[1][1] .= html_print_checkbox('cascade_protection', 1, $cascade_protection, true).__('Cascade protection').' '.ui_print_help_icon('cascade_protection', true);
|
$table_adv_parent .= html_print_checkbox_switch('cascade_protection', 1, $cascade_protection, true).__('Cascade protection').' '.ui_print_help_icon('cascade_protection', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data[1][1] .= ' '.__('Module').' '.html_print_select($modules_values, 'cascade_protection_module', $cascade_protection_module, '', '', 0, true);
|
$table_adv_parent .= __('Module').' '.html_print_select($modules_values, 'cascade_protection_module', $cascade_protection_module, '', '', 0, true).'</div></div>';
|
||||||
|
|
||||||
// Learn mode / Normal mode
|
// Learn mode / Normal mode
|
||||||
$table->data[3][0] = __('Module definition').ui_print_help_icon('module_definition', true);
|
$table_adv_module_mode = '<div class="label_select"><p class="input_label">'.__('Module definition').': '.ui_print_help_icon('module_definition', true).'</p>';
|
||||||
$table->data[3][1] = __('Learning mode').' '.html_print_radio_button_extended(
|
$table_adv_module_mode .= '<div class="switch_radio_button">';
|
||||||
|
$table_adv_module_mode .= html_print_radio_button_extended(
|
||||||
'modo',
|
'modo',
|
||||||
1,
|
1,
|
||||||
'',
|
__('Learning mode'),
|
||||||
$modo,
|
$modo,
|
||||||
false,
|
false,
|
||||||
'show_modules_not_learning_mode_context_help();',
|
'show_modules_not_learning_mode_context_help();',
|
||||||
'style="margin-right: 40px;"',
|
'',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
$table->data[3][1] .= __('Normal mode').' '.html_print_radio_button_extended(
|
$table_adv_module_mode .= html_print_radio_button_extended(
|
||||||
'modo',
|
'modo',
|
||||||
0,
|
0,
|
||||||
'',
|
__('Normal mode'),
|
||||||
$modo,
|
$modo,
|
||||||
false,
|
false,
|
||||||
'show_modules_not_learning_mode_context_help();',
|
'show_modules_not_learning_mode_context_help();',
|
||||||
'style="margin-right: 40px;"',
|
'',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
$table->data[3][1] .= __('Autodisable mode').' '.html_print_radio_button_extended(
|
$table_adv_module_mode .= html_print_radio_button_extended(
|
||||||
'modo',
|
'modo',
|
||||||
2,
|
2,
|
||||||
'',
|
__('Autodisable mode'),
|
||||||
$modo,
|
$modo,
|
||||||
false,
|
false,
|
||||||
'show_modules_not_learning_mode_context_help();',
|
'show_modules_not_learning_mode_context_help();',
|
||||||
'style="margin-right: 40px;"',
|
'',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
$table_adv_module_mode .= '</div></div>';
|
||||||
|
|
||||||
// Status (Disabled / Enabled)
|
// Status (Disabled / Enabled)
|
||||||
$table->data[4][0] = __('Status');
|
$table_adv_status = '<div class="label_select_simple label_simple_one_item"><p class="input_label input_label_simple">'.__('Disabled').': '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).'</p>';
|
||||||
$table->data[4][1] = __('Disabled').' '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).' '.html_print_radio_button_extended('disabled', 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
|
$table_adv_status .= html_print_checkbox_switch('disabled', 1, $disabled, true).'</div>';
|
||||||
$table->data[4][1] .= __('Enabled').' '.html_print_radio_button_extended('disabled', 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
|
|
||||||
|
// Url address.
|
||||||
if (enterprise_installed()) {
|
if (enterprise_installed()) {
|
||||||
$table->data[4][2] = __('Url address').ui_print_help_tip(__('URL address must be complete, for example: https://pandorafms.com/'), true);
|
$table_adv_url = '<div class="label_select"><p class="input_label">'.__('Url address').': '.ui_print_help_tip(__('URL address must be complete, for example: https://pandorafms.com/'), true).'</p>';
|
||||||
$table->data[4][3] = html_print_input_text(
|
$table_adv_url .= html_print_input_text(
|
||||||
'url_description',
|
'url_description',
|
||||||
$url_description,
|
$url_description,
|
||||||
'',
|
'',
|
||||||
45,
|
45,
|
||||||
255,
|
255,
|
||||||
true
|
true
|
||||||
);
|
).'</div>';
|
||||||
} else {
|
} else {
|
||||||
$table->data[5][0] = __('Url address');
|
$table_adv_url = '<div class="label_select"><p class="input_label">'.__('Url address').': </p></div>';
|
||||||
$table->data[5][1] = html_print_input_text(
|
$table_adv_url .= html_print_input_text(
|
||||||
'url_description',
|
'url_description',
|
||||||
$url_description,
|
$url_description,
|
||||||
'',
|
'',
|
||||||
45,
|
45,
|
||||||
255,
|
255,
|
||||||
true
|
true
|
||||||
);
|
).'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data[5][2] = __('Quiet');
|
$table_adv_quiet = '<div class="label_select_simple label_simple_one_item"><p class="input_label input_label_simple">'.__('Quiet').': ';
|
||||||
$table->data[5][3] .= ui_print_help_tip(__('The agent still runs but the alerts and events will be stop'), true);
|
$table_adv_quiet .= ui_print_help_tip(__('The agent still runs but the alerts and events will be stop'), true).'</p>';
|
||||||
$table->data[5][3] = html_print_checkbox('quiet', 1, $quiet, true);
|
$table_adv_quiet .= html_print_checkbox_switch('quiet', 1, $quiet, true).'</div>';
|
||||||
|
|
||||||
$listIcons = gis_get_array_list_icons();
|
$listIcons = gis_get_array_list_icons();
|
||||||
|
|
||||||
|
@ -611,7 +626,7 @@ foreach ($listIcons as $index => $value) {
|
||||||
|
|
||||||
$path = 'images/gis_map/icons/';
|
$path = 'images/gis_map/icons/';
|
||||||
// TODO set better method the path
|
// TODO set better method the path
|
||||||
$table->data[0][2] = __('Agent icon').ui_print_help_tip(__('Agent icon for GIS Maps.'), true);
|
$table_adv_agent_icon = '<div class="label_select"><p class="input_label">'.__('Agent icon').': '.ui_print_help_tip(__('Agent icon for GIS Maps.'), true).'</p>';
|
||||||
if ($icon_path == '') {
|
if ($icon_path == '') {
|
||||||
$display_icons = 'none';
|
$display_icons = 'none';
|
||||||
// Hack to show no icon. Use any given image to fix not found image errors
|
// Hack to show no icon. Use any given image to fix not found image errors
|
||||||
|
@ -629,7 +644,7 @@ if ($icon_path == '') {
|
||||||
$path_warning = $path.$icon_path.'.warning.png';
|
$path_warning = $path.$icon_path.'.warning.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data[0][3] = html_print_select(
|
$table_adv_agent_icon .= html_print_select(
|
||||||
$arraySelectIcon,
|
$arraySelectIcon,
|
||||||
'icon_path',
|
'icon_path',
|
||||||
$icon_path,
|
$icon_path,
|
||||||
|
@ -637,63 +652,68 @@ $table->data[0][3] = html_print_select(
|
||||||
__('None'),
|
__('None'),
|
||||||
'',
|
'',
|
||||||
true
|
true
|
||||||
).' '.html_print_image(
|
).html_print_image(
|
||||||
$path_ok,
|
$path_ok,
|
||||||
true,
|
true,
|
||||||
[
|
[
|
||||||
'id' => 'icon_ok',
|
'id' => 'icon_ok',
|
||||||
'style' => 'display:'.$display_icons.';',
|
'style' => 'display:'.$display_icons.';',
|
||||||
]
|
]
|
||||||
).' '.html_print_image(
|
).html_print_image(
|
||||||
$path_bad,
|
$path_bad,
|
||||||
true,
|
true,
|
||||||
[
|
[
|
||||||
'id' => 'icon_bad',
|
'id' => 'icon_bad',
|
||||||
'style' => 'display:'.$display_icons.';',
|
'style' => 'display:'.$display_icons.';',
|
||||||
]
|
]
|
||||||
).' '.html_print_image(
|
).html_print_image(
|
||||||
$path_warning,
|
$path_warning,
|
||||||
true,
|
true,
|
||||||
[
|
[
|
||||||
'id' => 'icon_warning',
|
'id' => 'icon_warning',
|
||||||
'style' => 'display:'.$display_icons.';',
|
'style' => 'display:'.$display_icons.';',
|
||||||
]
|
]
|
||||||
);
|
).'</div>';
|
||||||
|
|
||||||
if ($config['activate_gis']) {
|
if ($config['activate_gis']) {
|
||||||
$table->data[3][2] = __('Ignore new GIS data:');
|
$table_adv_gis = '<div class="label_select_simple label_simple_one_item"><p class="input_label input_label_simple">'.__('Ignore new GIS data:').'</p>';
|
||||||
$table->data[3][3] = __('Yes').' '.html_print_radio_button_extended(
|
if ($new_agent) {
|
||||||
'update_gis_data',
|
$update_gis_data = true;
|
||||||
0,
|
}
|
||||||
'',
|
|
||||||
$update_gis_data,
|
$table_adv_gis .= html_print_checkbox_switch('update_gis_data', 1, $update_gis_data, true).'No / Yes</div>';
|
||||||
false,
|
|
||||||
'',
|
|
||||||
'style="margin-right: 40px;"',
|
|
||||||
true
|
|
||||||
);
|
|
||||||
$table->data[3][3] .= __('No').' '.html_print_radio_button_extended(
|
|
||||||
'update_gis_data',
|
|
||||||
1,
|
|
||||||
'',
|
|
||||||
$update_gis_data,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
'style="margin-right: 40px;"',
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_toggle(html_print_table($table, true), __('Advanced options'));
|
|
||||||
unset($table);
|
|
||||||
|
$table_adv_options = $table_adv_secondary_groups.'<div class="secondary_groups_select" style="margin-bottom:30px;">
|
||||||
|
<div class="secondary_groups_list_left">
|
||||||
|
'.$table_adv_secondary_groups_left.'
|
||||||
|
</div>
|
||||||
|
<div class="secondary_groups_select_arrows">
|
||||||
|
'.$table_adv_secondary_groups_arrows.'
|
||||||
|
</div>
|
||||||
|
<div class="secondary_groups_list_right">
|
||||||
|
'.$table_adv_secondary_groups_right.'
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="agent_options agent_options_adv">
|
||||||
|
<div class="agent_options_column_left" >'.$table_adv_parent.$table_adv_custom_id.$table_adv_module_mode.$table_adv_cascade.$table_adv_gis.'</div>
|
||||||
|
<div class="agent_options_column_right" >'.$table_adv_agent_icon.$table_adv_url.$table_adv_quiet.$table_adv_status.$table_adv_remote.$table_adv_safe.'</div>
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
echo '<div class="ui_toggle">';
|
||||||
|
ui_toggle($table_adv_options, __('Advanced options'), '', true, false, 'white_box white_box_opened');
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
|
||||||
$table = new stdClass();
|
$table = new stdClass();
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->class = 'databox filters';
|
$table->class = 'custom_fields_table';
|
||||||
|
|
||||||
$table->head = [];
|
$table->head = [];
|
||||||
$table->style = [];
|
$table->style = [];
|
||||||
$table->style[0] = 'font-weight: bold; width: 100px;';
|
$table->style[0] = 'font-weight: bold;';
|
||||||
$table->data = [];
|
$table->data = [];
|
||||||
|
|
||||||
$fields = db_get_all_fields_in_table('tagent_custom_fields');
|
$fields = db_get_all_fields_in_table('tagent_custom_fields');
|
||||||
|
@ -703,11 +723,15 @@ if ($fields === false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$data[0] = '<b>'.$field['name'].'</b>';
|
$id_custom_field = $field['id_field'];
|
||||||
|
|
||||||
|
$data[0] = '<div class="field_title" onclick="show_custom_field_row('.$id_custom_field.')">';
|
||||||
|
$data[0] .= '<b>'.$field['name'].'</b>';
|
||||||
$data[0] .= ui_print_help_tip(
|
$data[0] .= ui_print_help_tip(
|
||||||
__('This field allows url insertion using the BBCode\'s url tag').'.<br />'.__('The format is: [url=\'url to navigate\']\'text to show\'[/url]').'.<br /><br />'.__('e.g.: [url=google.com]Google web search[/url]'),
|
__('This field allows url insertion using the BBCode\'s url tag').'.<br />'.__('The format is: [url=\'url to navigate\']\'text to show\'[/url]').'.<br /><br />'.__('e.g.: [url=google.com]Google web search[/url]'),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
$data[0] .= '</div>';
|
||||||
$combo = [];
|
$combo = [];
|
||||||
$combo = $field['combo_values'];
|
$combo = $field['combo_values'];
|
||||||
$combo = explode(',', $combo);
|
$combo = explode(',', $combo);
|
||||||
|
@ -730,7 +754,7 @@ foreach ($fields as $field) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($field['is_password_type']) {
|
if ($field['is_password_type']) {
|
||||||
$data[1] = html_print_input_text_extended(
|
$data_field[1] = html_print_input_text_extended(
|
||||||
'customvalue_'.$field['id_field'],
|
'customvalue_'.$field['id_field'],
|
||||||
$custom_value,
|
$custom_value,
|
||||||
'customvalue_'.$field['id_field'],
|
'customvalue_'.$field['id_field'],
|
||||||
|
@ -744,18 +768,18 @@ foreach ($fields as $field) {
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$data[1] = html_print_textarea(
|
$data_field[1] = html_print_textarea(
|
||||||
'customvalue_'.$field['id_field'],
|
'customvalue_'.$field['id_field'],
|
||||||
2,
|
2,
|
||||||
65,
|
65,
|
||||||
$custom_value,
|
$custom_value,
|
||||||
'style="min-height: 30px; width:96%;"',
|
'style="min-height: 30px;"',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($field['combo_values'] !== '') {
|
if ($field['combo_values'] !== '') {
|
||||||
$data[1] = html_print_select(
|
$data_field[1] = html_print_select(
|
||||||
$combo_values,
|
$combo_values,
|
||||||
'customvalue_'.$field['id_field'],
|
'customvalue_'.$field['id_field'],
|
||||||
$custom_value,
|
$custom_value,
|
||||||
|
@ -776,19 +800,25 @@ foreach ($fields as $field) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$table->rowid[] = 'name_field-'.$id_custom_field;
|
||||||
array_push($table->data, $data);
|
array_push($table->data, $data);
|
||||||
|
|
||||||
|
$table->rowid[] = 'field-'.$id_custom_field;
|
||||||
|
array_push($table->data, $data_field);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($fields)) {
|
if (!empty($fields)) {
|
||||||
ui_toggle(html_print_table($table, true), __('Custom fields'));
|
echo '<div class="ui_toggle">';
|
||||||
|
ui_toggle(html_print_table($table, true), __('Custom fields'), '', true, false, 'white_box white_box_opened');
|
||||||
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
echo '<div class="action-buttons" style="display: flex; justify-content: flex-end; align-items: center; width: '.$table->width.'">';
|
||||||
|
|
||||||
|
|
||||||
// The context help about the learning mode.
|
// The context help about the learning mode.
|
||||||
if ($modo == 0) {
|
if ($modo == 0) {
|
||||||
echo "<span id='modules_not_learning_mode_context_help' style=''>";
|
echo "<span id='modules_not_learning_mode_context_help' style='padding-right:8px;'>";
|
||||||
} else {
|
} else {
|
||||||
echo "<span id='modules_not_learning_mode_context_help' style='display: none;'>";
|
echo "<span id='modules_not_learning_mode_context_help' style='display: none;'>";
|
||||||
}
|
}
|
||||||
|
@ -798,7 +828,7 @@ echo '</span>';
|
||||||
|
|
||||||
|
|
||||||
if ($id_agente) {
|
if ($id_agente) {
|
||||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
echo '<div class="action-buttons">';
|
||||||
html_print_submit_button(
|
html_print_submit_button(
|
||||||
__('Update'),
|
__('Update'),
|
||||||
'updbutton',
|
'updbutton',
|
||||||
|
@ -825,6 +855,19 @@ ui_require_jquery_file('bgiframe');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
// Show/Hide custom field row.
|
||||||
|
function show_custom_field_row(id){
|
||||||
|
if( $('#field-'+id).css('display') == 'none'){
|
||||||
|
$('#field-'+id).css('display','table-row');
|
||||||
|
$('#name_field-'+id).addClass('custom_field_row_opened');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$('#field-'+id).css('display','none');
|
||||||
|
$('#name_field-'+id).removeClass('custom_field_row_opened');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Use this function for change 3 icons when change the selectbox
|
//Use this function for change 3 icons when change the selectbox
|
||||||
function changeIcons() {
|
function changeIcons() {
|
||||||
var icon = $("#icon_path :selected").val();
|
var icon = $("#icon_path :selected").val();
|
||||||
|
@ -863,7 +906,7 @@ ui_require_jquery_file('bgiframe');
|
||||||
|
|
||||||
function show_modules_not_learning_mode_context_help() {
|
function show_modules_not_learning_mode_context_help() {
|
||||||
if ($("input[name='modo'][value=0]").is(':checked')) {
|
if ($("input[name='modo'][value=0]").is(':checked')) {
|
||||||
$("#modules_not_learning_mode_context_help").show();
|
$("#modules_not_learning_mode_context_help").show().css('padding-right','8px');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$("#modules_not_learning_mode_context_help").hide();
|
$("#modules_not_learning_mode_context_help").hide();
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
// Load global vars
|
// Load global vars.
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
enterprise_include('godmode/agentes/configurar_agente.php');
|
enterprise_include('godmode/agentes/configurar_agente.php');
|
||||||
|
@ -23,10 +23,10 @@ ui_require_javascript_file('encode_decode_base64');
|
||||||
|
|
||||||
check_login();
|
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');
|
$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');
|
$id_agente = (int) get_parameter('id_agente');
|
||||||
$group = 0;
|
$group = 0;
|
||||||
$all_groups = [$group];
|
$all_groups = [$group];
|
||||||
|
@ -46,6 +46,7 @@ if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
// Default.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,11 +64,11 @@ require_once 'include/functions_modules.php';
|
||||||
require_once 'include/functions_alerts.php';
|
require_once 'include/functions_alerts.php';
|
||||||
require_once 'include/functions_reporting.php';
|
require_once 'include/functions_reporting.php';
|
||||||
|
|
||||||
// Get passed variables
|
// Get passed variables.
|
||||||
$alerttype = get_parameter('alerttype');
|
$alerttype = get_parameter('alerttype');
|
||||||
$id_agent_module = (int) get_parameter('id_agent_module');
|
$id_agent_module = (int) get_parameter('id_agent_module');
|
||||||
|
|
||||||
// Init vars
|
// Init vars.
|
||||||
$descripcion = '';
|
$descripcion = '';
|
||||||
$comentarios = '';
|
$comentarios = '';
|
||||||
$campo_1 = '';
|
$campo_1 = '';
|
||||||
|
@ -137,7 +138,7 @@ $alert_priority = 0;
|
||||||
$server_name = '';
|
$server_name = '';
|
||||||
$grupo = 0;
|
$grupo = 0;
|
||||||
$id_os = 9;
|
$id_os = 9;
|
||||||
// Windows
|
// Windows.
|
||||||
$custom_id = '';
|
$custom_id = '';
|
||||||
$cascade_protection = 0;
|
$cascade_protection = 0;
|
||||||
$cascade_protection_modules = 0;
|
$cascade_protection_modules = 0;
|
||||||
|
@ -156,7 +157,7 @@ $cps = 0;
|
||||||
$create_agent = (bool) get_parameter('create_agent');
|
$create_agent = (bool) get_parameter('create_agent');
|
||||||
$module_macros = [];
|
$module_macros = [];
|
||||||
|
|
||||||
// Create agent
|
// Create agent.
|
||||||
if ($create_agent) {
|
if ($create_agent) {
|
||||||
$mssg_warning = 0;
|
$mssg_warning = 0;
|
||||||
$alias_safe_output = io_safe_output(get_parameter('alias', ''));
|
$alias_safe_output = io_safe_output(get_parameter('alias', ''));
|
||||||
|
@ -165,14 +166,14 @@ if ($create_agent) {
|
||||||
$direccion_agente = (string) get_parameter_post('direccion', '');
|
$direccion_agente = (string) get_parameter_post('direccion', '');
|
||||||
$unique_ip = (int) get_parameter_post('unique_ip', 0);
|
$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));
|
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||||
|
|
||||||
if (!validate_address($direccion_agente)) {
|
if (!validate_address($direccion_agente)) {
|
||||||
$mssg_warning = 1;
|
$mssg_warning = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// safe-input before validate ip
|
// Safe-input before validate ip.
|
||||||
$direccion_agente = io_safe_input($direccion_agente);
|
$direccion_agente = io_safe_input($direccion_agente);
|
||||||
|
|
||||||
$nombre_agente = hash('sha256', $alias.'|'.$direccion_agente.'|'.time().'|'.sprintf('%04d', rand(0, 10000)));
|
$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'], '');
|
$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 == '') {
|
if ($alias == '') {
|
||||||
$agent_creation_error = __('No agent alias specified');
|
$agent_creation_error = __('No agent alias specified');
|
||||||
$agent_created_ok = 0;
|
$agent_created_ok = 0;
|
||||||
|
@ -256,7 +257,7 @@ if ($create_agent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id_agente !== false) {
|
if ($id_agente !== false) {
|
||||||
// Create custom fields for this agent
|
// Create custom fields for this agent.
|
||||||
foreach ($field_values as $key => $value) {
|
foreach ($field_values as $key => $value) {
|
||||||
$update_custom = db_process_sql_insert(
|
$update_custom = db_process_sql_insert(
|
||||||
'tagent_custom_data',
|
'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 != '') {
|
if ($direccion_agente != '') {
|
||||||
agents_add_address($id_agente, $direccion_agente);
|
agents_add_address($id_agente, $direccion_agente);
|
||||||
}
|
}
|
||||||
|
@ -311,7 +312,7 @@ if ($create_agent) {
|
||||||
"Quiet":"'.(int) $quiet.'",
|
"Quiet":"'.(int) $quiet.'",
|
||||||
"Cps":"'.(int) $cps.'"}';
|
"Cps":"'.(int) $cps.'"}';
|
||||||
|
|
||||||
// Create the secondary groups
|
// Create the secondary groups.
|
||||||
enterprise_hook(
|
enterprise_hook(
|
||||||
'agents_update_secondary_groups',
|
'agents_update_secondary_groups',
|
||||||
[
|
[
|
||||||
|
@ -341,14 +342,14 @@ if ($create_agent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show tabs
|
// Show tabs.
|
||||||
$img_style = [
|
$img_style = [
|
||||||
'class' => 'top',
|
'class' => 'top',
|
||||||
'width' => 16,
|
'width' => 16,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($id_agente) {
|
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>';
|
$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') {
|
if ($tab == 'view') {
|
||||||
|
@ -359,7 +360,7 @@ if ($id_agente) {
|
||||||
|
|
||||||
$viewtab['operation'] = 1;
|
$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>';
|
$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') {
|
if ($tab == 'main') {
|
||||||
$maintab['active'] = true;
|
$maintab['active'] = true;
|
||||||
|
@ -367,7 +368,7 @@ if ($id_agente) {
|
||||||
$maintab['active'] = false;
|
$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>';
|
$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') {
|
if ($tab == 'module') {
|
||||||
|
@ -376,7 +377,7 @@ if ($id_agente) {
|
||||||
$moduletab['active'] = false;
|
$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>';
|
$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') {
|
if ($tab == 'alert') {
|
||||||
|
@ -385,7 +386,7 @@ if ($id_agente) {
|
||||||
$alerttab['active'] = false;
|
$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>';
|
$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') {
|
if ($tab == 'template') {
|
||||||
|
@ -395,7 +396,7 @@ if ($id_agente) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Inventory
|
// Inventory.
|
||||||
$inventorytab = enterprise_hook('inventory_tab');
|
$inventorytab = enterprise_hook('inventory_tab');
|
||||||
|
|
||||||
if ($inventorytab == -1) {
|
if ($inventorytab == -1) {
|
||||||
|
@ -412,7 +413,7 @@ if ($id_agente) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($has_remote_conf === true) {
|
if ($has_remote_conf === true) {
|
||||||
// Plugins
|
// Plugins.
|
||||||
$pluginstab = enterprise_hook('plugins_tab');
|
$pluginstab = enterprise_hook('plugins_tab');
|
||||||
if ($pluginstab == -1) {
|
if ($pluginstab == -1) {
|
||||||
$pluginstab = '';
|
$pluginstab = '';
|
||||||
|
@ -421,21 +422,21 @@ if ($id_agente) {
|
||||||
$pluginstab = '';
|
$pluginstab = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collection
|
// Collection.
|
||||||
$collectiontab = enterprise_hook('collection_tab');
|
$collectiontab = enterprise_hook('collection_tab');
|
||||||
|
|
||||||
if ($collectiontab == -1) {
|
if ($collectiontab == -1) {
|
||||||
$collectiontab = '';
|
$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['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;
|
$grouptab['active'] = false;
|
||||||
|
|
||||||
$gistab = [];
|
$gistab = [];
|
||||||
|
|
||||||
// GIS tab
|
// GIS tab.
|
||||||
if ($config['activate_gis']) {
|
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>';
|
$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>';
|
$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'] = '<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'] .= '<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>';
|
$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);
|
$total_incidents = agents_get_count_incidents($id_agente);
|
||||||
|
|
||||||
// Incident tab
|
// Incident tab.
|
||||||
if ($total_incidents > 0) {
|
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>';
|
$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) {
|
if ($total_incidents) {
|
||||||
$onheader['incident'] = $incidenttab;
|
$onheader['incident'] = $incidenttab;
|
||||||
}
|
}
|
||||||
|
@ -545,7 +546,7 @@ if ($id_agente) {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extensions tabs
|
// Extensions tabs.
|
||||||
foreach ($config['extensions'] as $extension) {
|
foreach ($config['extensions'] as $extension) {
|
||||||
if (isset($extension['extension_god_tab'])) {
|
if (isset($extension['extension_god_tab'])) {
|
||||||
if (check_acl($config['id_user'], $group, $extension['extension_god_tab']['acl'])) {
|
if (check_acl($config['id_user'], $group, $extension['extension_god_tab']['acl'])) {
|
||||||
|
@ -574,7 +575,7 @@ if ($id_agente) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$help_header = '';
|
$help_header = '';
|
||||||
// This add information to the header
|
// This add information to the header.
|
||||||
switch ($tab) {
|
switch ($tab) {
|
||||||
case 'main':
|
case 'main':
|
||||||
$tab_description = '- '.__('Setup');
|
$tab_description = '- '.__('Setup');
|
||||||
|
@ -639,6 +640,10 @@ if ($id_agente) {
|
||||||
case 'wmi_explorer':
|
case 'wmi_explorer':
|
||||||
$tab_description = '- '.__('WMI Wizard');
|
$tab_description = '- '.__('WMI Wizard');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -649,10 +654,15 @@ if ($id_agente) {
|
||||||
$tab_description = '- '.__('SNMP explorer');
|
$tab_description = '- '.__('SNMP explorer');
|
||||||
$help_header = 'snmp_explorer';
|
$help_header = 'snmp_explorer';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
// Default.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,7 +678,7 @@ if ($id_agente) {
|
||||||
$config['item_title_size_text']
|
$config['item_title_size_text']
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Create agent
|
// Create agent.
|
||||||
ui_print_page_header(
|
ui_print_page_header(
|
||||||
__('Agent manager'),
|
__('Agent manager'),
|
||||||
'images/bricks.png',
|
'images/bricks.png',
|
||||||
|
@ -682,12 +692,12 @@ $delete_conf_file = (bool) get_parameter('delete_conf_file');
|
||||||
|
|
||||||
if ($delete_conf_file) {
|
if ($delete_conf_file) {
|
||||||
$correct = false;
|
$correct = false;
|
||||||
// Delete remote configuration
|
// Delete remote configuration.
|
||||||
if (isset($config['remote_config'])) {
|
if (isset($config['remote_config'])) {
|
||||||
$agent_md5 = md5(io_safe_output(agents_get_name($id_agente, 'none')), false);
|
$agent_md5 = md5(io_safe_output(agents_get_name($id_agente, 'none')), false);
|
||||||
|
|
||||||
if (file_exists($config['remote_config'].'/md5/'.$agent_md5.'.md5')) {
|
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';
|
$file_name = $config['remote_config'].'/conf/'.$agent_md5.'.conf';
|
||||||
$correct = @unlink($file_name);
|
$correct = @unlink($file_name);
|
||||||
|
|
||||||
|
@ -703,7 +713,7 @@ if ($delete_conf_file) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show agent creation results
|
// Show agent creation results.
|
||||||
if ($create_agent) {
|
if ($create_agent) {
|
||||||
if (!isset($agent_creation_error)) {
|
if (!isset($agent_creation_error)) {
|
||||||
$agent_creation_error = __('Could not be created');
|
$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'])) {
|
if (isset($_GET['fix_module'])) {
|
||||||
$id_module = get_parameter_get('fix_module', 0);
|
$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);
|
$media = reporting_get_agentmodule_data_average($id_module, 30758400);
|
||||||
// Get average over the year
|
// Get average over the year.
|
||||||
$media *= 1.3;
|
$media *= 1.3;
|
||||||
$error = '';
|
$error = '';
|
||||||
$result = true;
|
$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)) {
|
if (!empty($media)) {
|
||||||
$where = [
|
$where = [
|
||||||
'datos' => '>'.$media,
|
'datos' => '>'.$media,
|
||||||
|
@ -759,9 +769,9 @@ if (isset($_GET['fix_module'])) {
|
||||||
|
|
||||||
$update_agent = (bool) get_parameter('update_agent');
|
$update_agent = (bool) get_parameter('update_agent');
|
||||||
|
|
||||||
// Update AGENT
|
// Update AGENT.
|
||||||
if ($update_agent) {
|
if ($update_agent) {
|
||||||
// if modified some agent paramenter
|
// If modified some agent paramenter.
|
||||||
$mssg_warning = 0;
|
$mssg_warning = 0;
|
||||||
$id_agente = (int) get_parameter_post('id_agente');
|
$id_agente = (int) get_parameter_post('id_agente');
|
||||||
$nombre_agente = str_replace('`', '‘', (string) get_parameter_post('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);
|
$alias_as_name = (int) get_parameter_post('alias_as_name', 0);
|
||||||
$direccion_agente = (string) get_parameter_post('direccion', '');
|
$direccion_agente = (string) get_parameter_post('direccion', '');
|
||||||
$unique_ip = (int) get_parameter_post('unique_ip', 0);
|
$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));
|
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||||
|
|
||||||
if (!validate_address($direccion_agente)) {
|
if (!validate_address($direccion_agente)) {
|
||||||
$mssg_warning = 1;
|
$mssg_warning = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// safe-input before validate ip
|
// Safe-input before validate ip.
|
||||||
$direccion_agente = io_safe_input($direccion_agente);
|
$direccion_agente = io_safe_input($direccion_agente);
|
||||||
|
|
||||||
$address_list = (string) get_parameter_post('address_list', '');
|
$address_list = (string) get_parameter_post('address_list', '');
|
||||||
|
@ -786,10 +796,13 @@ if ($update_agent) {
|
||||||
&& $direccion_agente == agents_get_address($id_agente)
|
&& $direccion_agente == agents_get_address($id_agente)
|
||||||
&& $address_list != 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
|
* If we selected another IP in the drop down list to be 'primary':
|
||||||
// b) field has not changed from current IP
|
* a) field is not the same as selectbox
|
||||||
// c) selectbox is not the current IP
|
* b) field has not changed from current IP
|
||||||
|
* c) selectbox is not the current IP.
|
||||||
|
*/
|
||||||
|
|
||||||
if (!empty($address_list)) {
|
if (!empty($address_list)) {
|
||||||
$direccion_agente = $address_list;
|
$direccion_agente = $address_list;
|
||||||
}
|
}
|
||||||
|
@ -799,7 +812,7 @@ if ($update_agent) {
|
||||||
$intervalo = (int) get_parameter_post('intervalo', SECONDS_5MINUTES);
|
$intervalo = (int) get_parameter_post('intervalo', SECONDS_5MINUTES);
|
||||||
$comentarios = str_replace('`', '‘', (string) get_parameter_post('comentarios', ''));
|
$comentarios = str_replace('`', '‘', (string) get_parameter_post('comentarios', ''));
|
||||||
$modo = (int) get_parameter_post('modo', 0);
|
$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');
|
$id_os = (int) get_parameter_post('id_os');
|
||||||
$disabled = (bool) get_parameter_post('disabled');
|
$disabled = (bool) get_parameter_post('disabled');
|
||||||
$server_name = (string) get_parameter_post('server_name', '');
|
$server_name = (string) get_parameter_post('server_name', '');
|
||||||
|
@ -837,7 +850,7 @@ if ($update_agent) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($old_value === false) {
|
if ($old_value === false) {
|
||||||
// Create custom field if not exist
|
// Create custom field if not exist.
|
||||||
$update_custom = db_process_sql_insert(
|
$update_custom = db_process_sql_insert(
|
||||||
'tagent_custom_data',
|
'tagent_custom_data',
|
||||||
[
|
[
|
||||||
|
@ -866,10 +879,10 @@ if ($update_agent) {
|
||||||
ui_print_warning_message(__('The ip or dns name entered cannot be resolved'));
|
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 == '') {
|
if ($alias == '') {
|
||||||
ui_print_error_message(__('No agent alias specified'));
|
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 != '') {
|
if ($unique_ip && $direccion_agente != '') {
|
||||||
|
@ -882,7 +895,7 @@ if ($update_agent) {
|
||||||
} else if ($exists_ip) {
|
} else if ($exists_ip) {
|
||||||
ui_print_error_message(__('Duplicate main IP address'));
|
ui_print_error_message(__('Duplicate main IP address'));
|
||||||
} else {
|
} else {
|
||||||
// If different IP is specified than previous, add the IP
|
// If different IP is specified than previous, add the IP.
|
||||||
if ($direccion_agente != ''
|
if ($direccion_agente != ''
|
||||||
&& $direccion_agente != agents_get_address($id_agente)
|
&& $direccion_agente != agents_get_address($id_agente)
|
||||||
) {
|
) {
|
||||||
|
@ -890,7 +903,7 @@ if ($update_agent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$action_delete_ip = (bool) get_parameter('delete_ip', false);
|
$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) {
|
if ($action_delete_ip) {
|
||||||
$delete_ip = get_parameter_post('address_list');
|
$delete_ip = get_parameter_post('address_list');
|
||||||
|
|
||||||
|
@ -939,11 +952,11 @@ if ($update_agent) {
|
||||||
__('There was a problem updating the agent')
|
__('There was a problem updating the agent')
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Update the agent from the metaconsole cache
|
// Update the agent from the metaconsole cache.
|
||||||
enterprise_include_once('include/functions_agents.php');
|
enterprise_include_once('include/functions_agents.php');
|
||||||
enterprise_hook('agent_update_from_cache', [$id_agente, $values, $server_name]);
|
enterprise_hook('agent_update_from_cache', [$id_agente, $values, $server_name]);
|
||||||
|
|
||||||
// Update the configuration files
|
// Update the configuration files.
|
||||||
if ($old_values['intervalo'] != $intervalo) {
|
if ($old_values['intervalo'] != $intervalo) {
|
||||||
enterprise_hook(
|
enterprise_hook(
|
||||||
'config_agents_update_config_token',
|
'config_agents_update_config_token',
|
||||||
|
@ -1057,9 +1070,9 @@ if ($update_agent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read agent data
|
// 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) {
|
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);
|
$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')) {
|
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');
|
db_pandora_audit('ACL Violation', 'Trying to admin an agent without access');
|
||||||
|
@ -1067,15 +1080,15 @@ if ($id_agente) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$agent = db_get_row('tagente', 'id_agente', $id_agente);
|
$agent = db_get_row('tagente', 'id_agente', $id_agente, false, false);
|
||||||
if (empty($agent)) {
|
if (empty($agent)) {
|
||||||
// Close out the page
|
// Close out the page.
|
||||||
ui_print_error_message(__('There was a problem loading the agent'));
|
ui_print_error_message(__('There was a problem loading the agent'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$intervalo = $agent['intervalo'];
|
$intervalo = $agent['intervalo'];
|
||||||
// Define interval in seconds
|
// Define interval in seconds.
|
||||||
$nombre_agente = $agent['nombre'];
|
$nombre_agente = $agent['nombre'];
|
||||||
if (empty($alias)) {
|
if (empty($alias)) {
|
||||||
$alias = $agent['alias'];
|
$alias = $agent['alias'];
|
||||||
|
@ -1111,11 +1124,11 @@ $create_module = (bool) get_parameter('create_module');
|
||||||
$delete_module = (bool) get_parameter('delete_module');
|
$delete_module = (bool) get_parameter('delete_module');
|
||||||
$enable_module = (int) get_parameter('enable_module');
|
$enable_module = (int) get_parameter('enable_module');
|
||||||
$disable_module = (int) get_parameter('disable_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');
|
$duplicate_module = (int) get_parameter('duplicate_module');
|
||||||
$edit_module = (bool) get_parameter('edit_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) {
|
if ($update_module || $create_module) {
|
||||||
$id_grupo = agents_get_agent_group($id_agente);
|
$id_grupo = agents_get_agent_group($id_agente);
|
||||||
$all_groups = agents_get_all_groups_agent($id_agente, $id_grupo);
|
$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');
|
$id_module_group = (int) get_parameter('id_module_group');
|
||||||
$flag = (bool) get_parameter('flag');
|
$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:
|
* Don't read as (float) because it lost it's decimals when put into MySQL
|
||||||
// 1.23E-10 is 0.000000000123
|
* 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);
|
$post_process = (string) get_parameter('post_process', 0.0);
|
||||||
if (get_parameter('prediction_module')) {
|
if (get_parameter('prediction_module')) {
|
||||||
$prediction_module = 1;
|
$prediction_module = 1;
|
||||||
|
@ -1160,7 +1176,7 @@ if ($update_module || $create_module) {
|
||||||
$tcp_send = (string) get_parameter('tcp_send');
|
$tcp_send = (string) get_parameter('tcp_send');
|
||||||
$tcp_rcv = (string) get_parameter('tcp_rcv');
|
$tcp_rcv = (string) get_parameter('tcp_rcv');
|
||||||
$tcp_port = (int) get_parameter('tcp_port');
|
$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', '');
|
$is_port_empty = get_parameter('tcp_port', '');
|
||||||
if ($is_port_empty === '') {
|
if ($is_port_empty === '') {
|
||||||
$tcp_port = null;
|
$tcp_port = null;
|
||||||
|
@ -1186,7 +1202,7 @@ if ($update_module || $create_module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id_module_type == 25) {
|
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_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);
|
$custom_integer_1 = (int) get_parameter('custom_integer_1', $custom_integer_1_default);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1198,7 +1214,7 @@ if ($update_module || $create_module) {
|
||||||
$custom_string_3 = (string) get_parameter('custom_string_3', $custom_string_3_default);
|
$custom_string_3 = (string) get_parameter('custom_string_3', $custom_string_3_default);
|
||||||
$custom_integer_2 = (int) get_parameter('custom_integer_2', 0);
|
$custom_integer_2 = (int) get_parameter('custom_integer_2', 0);
|
||||||
|
|
||||||
// Get macros
|
// Get macros.
|
||||||
$macros = (string) get_parameter('macros');
|
$macros = (string) get_parameter('macros');
|
||||||
|
|
||||||
if (!empty($macros)) {
|
if (!empty($macros)) {
|
||||||
|
@ -1225,7 +1241,8 @@ if ($update_module || $create_module) {
|
||||||
if (preg_match('/^module_name\s*(.*)/', $line, $match)) {
|
if (preg_match('/^module_name\s*(.*)/', $line, $match)) {
|
||||||
$new_configuration_data .= 'module_name '.io_safe_output($name)."\n";
|
$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)) {
|
else if (!preg_match('/^module_macro_field.*/', $line, $match)) {
|
||||||
$new_configuration_data .= "$line\n";
|
$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);
|
$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(
|
$configuration_data = str_replace(
|
||||||
'\\',
|
'\\',
|
||||||
'\',
|
'\',
|
||||||
|
@ -1269,16 +1278,16 @@ if ($update_module || $create_module) {
|
||||||
|
|
||||||
$snmp_community = (string) get_parameter('snmp_community');
|
$snmp_community = (string) get_parameter('snmp_community');
|
||||||
$snmp_oid = (string) get_parameter('snmp_oid');
|
$snmp_oid = (string) get_parameter('snmp_oid');
|
||||||
// Change double quotes by single
|
// Change double quotes by single.
|
||||||
$snmp_oid = preg_replace('/"/', ''', $snmp_oid);
|
$snmp_oid = preg_replace('/"/', ''', $snmp_oid);
|
||||||
|
|
||||||
if (empty($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');
|
$snmp_oid = (string) get_parameter('select_snmp_oid');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id_module_type >= 15 && $id_module_type <= 18) {
|
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');
|
$tcp_send = (string) get_parameter('snmp_version');
|
||||||
$plugin_user = (string) get_parameter('snmp3_auth_user');
|
$plugin_user = (string) get_parameter('snmp3_auth_user');
|
||||||
$plugin_pass = io_input_password((string) get_parameter('snmp3_auth_pass'));
|
$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_macro_values = (array) get_parameter('module_macro_values', []);
|
||||||
$module_macros = modules_get_module_macros_json($module_macro_names, $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');
|
enterprise_include_once('include/functions_config_agents.php');
|
||||||
|
|
||||||
$module_in_policy = enterprise_hook('policies_is_module_in_policy', [$id_agent_module]);
|
$module_in_policy = enterprise_hook('policies_is_module_in_policy', [$id_agent_module]);
|
||||||
$module_linked = enterprise_hook('policies_is_module_linked', [$id_agent_module]);
|
$module_linked = enterprise_hook('policies_is_module_linked', [$id_agent_module]);
|
||||||
|
|
||||||
if ((!$module_in_policy && !$module_linked )
|
if ((!$module_in_policy && !$module_linked && $update_module)
|
||||||
|| ( $module_in_policy && !$module_linked )
|
|| ( $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(
|
enterprise_hook(
|
||||||
'config_agents_write_module_in_conf',
|
'config_agents_write_module_in_conf',
|
||||||
[
|
[
|
||||||
|
@ -1431,7 +1450,7 @@ if ($update_module || $create_module) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE UPDATE
|
// MODULE UPDATE.
|
||||||
if ($update_module) {
|
if ($update_module) {
|
||||||
$id_agent_module = (int) get_parameter('id_agent_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');
|
$module_kind = (int) get_parameter('moduletype');
|
||||||
if ($module_kind == MODULE_DATA) {
|
if ($module_kind == MODULE_DATA) {
|
||||||
unset($values['module_interval']);
|
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);
|
cron_update_module_interval($id_agent_module, $cron_interval);
|
||||||
|
|
||||||
ui_print_success_message(__('Module successfully updated'));
|
ui_print_success_message(__('Module successfully updated'));
|
||||||
|
@ -1605,8 +1624,7 @@ if ($update_module) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE INSERT
|
// MODULE INSERT.
|
||||||
// =================
|
|
||||||
if ($create_module) {
|
if ($create_module) {
|
||||||
if (isset($_POST['combo_snmp_oid'])) {
|
if (isset($_POST['combo_snmp_oid'])) {
|
||||||
$combo_snmp_oid = get_parameter_post('combo_snmp_oid');
|
$combo_snmp_oid = get_parameter_post('combo_snmp_oid');
|
||||||
|
@ -1630,6 +1648,10 @@ if ($create_module) {
|
||||||
$description = ' ';
|
$description = ' ';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = [
|
$values = [
|
||||||
|
@ -1755,7 +1777,7 @@ if ($create_module) {
|
||||||
enterprise_hook('modules_create_synthetic_operations', [$id_agent_module, $serialize_ops]);
|
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);
|
cron_update_module_interval($id_agent_module, $cron_interval);
|
||||||
|
|
||||||
ui_print_success_message(__('Module added successfully'));
|
ui_print_success_message(__('Module added successfully'));
|
||||||
|
@ -1776,7 +1798,7 @@ if ($create_module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE DELETION
|
// MODULE DELETION
|
||||||
// =================
|
// =================.
|
||||||
if ($delete_module) {
|
if ($delete_module) {
|
||||||
// DELETE agent module !
|
// DELETE agent module !
|
||||||
$id_borrar_modulo = (int) get_parameter_get('delete_module', 0);
|
$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_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)]);
|
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;
|
$error = 0;
|
||||||
|
|
||||||
// First delete from tagente_modulo -> if not successful, increment
|
// First delete from tagente_modulo -> if not successful, increment
|
||||||
|
@ -1831,7 +1853,7 @@ if ($delete_module) {
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
$error++;
|
$error++;
|
||||||
} else {
|
} else {
|
||||||
// Set flag to update module status count
|
// Set flag to update module status count.
|
||||||
db_process_sql(
|
db_process_sql(
|
||||||
'UPDATE tagente
|
'UPDATE tagente
|
||||||
SET update_module_count = 1, update_alert_count = 1
|
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)
|
// 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]);
|
$ops_json = enterprise_hook('modules_get_synthetic_operations', [$id_borrar_modulo]);
|
||||||
$result_ops_synthetic = json_decode($ops_json);
|
$result_ops_synthetic = json_decode($ops_json);
|
||||||
if (!empty($result_ops_synthetic)) {
|
if (!empty($result_ops_synthetic)) {
|
||||||
|
@ -1881,18 +1903,17 @@ if ($delete_module) {
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
} //end if
|
} else {
|
||||||
else {
|
|
||||||
$result_components = enterprise_hook('modules_get_synthetic_components', [$id_borrar_modulo]);
|
$result_components = enterprise_hook('modules_get_synthetic_components', [$id_borrar_modulo]);
|
||||||
$count_components = 1;
|
$count_components = 1;
|
||||||
if (!empty($result_components)) {
|
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);
|
$num_components = count($result_components);
|
||||||
$last_target_module = 0;
|
$last_target_module = 0;
|
||||||
foreach ($result_components as $id_target_module) {
|
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)
|
if (($count_components == $num_components)
|
||||||
or ($last_target_module != $id_target_module)
|
|| ($last_target_module != $id_target_module)
|
||||||
) {
|
) {
|
||||||
$update_orders = true;
|
$update_orders = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1911,7 +1932,7 @@ if ($delete_module) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors.
|
||||||
if ($error != 0) {
|
if ($error != 0) {
|
||||||
ui_print_error_message(__('There was a problem deleting the module'));
|
ui_print_error_message(__('There was a problem deleting the module'));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1929,7 +1950,7 @@ if ($delete_module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE DUPLICATION
|
// MODULE DUPLICATION
|
||||||
// ==================
|
// ==================.
|
||||||
if (!empty($duplicate_module)) {
|
if (!empty($duplicate_module)) {
|
||||||
// DUPLICATE agent module !
|
// DUPLICATE agent module !
|
||||||
$id_duplicate_module = $duplicate_module;
|
$id_duplicate_module = $duplicate_module;
|
||||||
|
@ -1976,7 +1997,7 @@ if (!empty($duplicate_module)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE ENABLE/DISABLE
|
// MODULE ENABLE/DISABLE
|
||||||
// =====================
|
// =====================.
|
||||||
if ($enable_module) {
|
if ($enable_module) {
|
||||||
$result = modules_change_disabled($enable_module, 0);
|
$result = modules_change_disabled($enable_module, 0);
|
||||||
$modulo_nombre = db_get_row_sql('SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = '.$enable_module.'');
|
$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
|
// UPDATE GIS
|
||||||
// ==========
|
// ==========.
|
||||||
$updateGIS = get_parameter('update_gis', 0);
|
$updateGIS = get_parameter('update_gis', 0);
|
||||||
if ($updateGIS) {
|
if ($updateGIS) {
|
||||||
$updateGisData = get_parameter('update_gis_data');
|
$updateGisData = get_parameter('update_gis_data');
|
||||||
|
@ -2104,9 +2125,8 @@ switch ($tab) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'alert':
|
case 'alert':
|
||||||
/*
|
// Because $id_agente is set, it will show only agent alerts.
|
||||||
Because $id_agente is set, it will show only agent alerts */
|
// This var is for not display create button on alert list.
|
||||||
// This var is for not display create button on alert list
|
|
||||||
$dont_display_alert_create_bttn = true;
|
$dont_display_alert_create_bttn = true;
|
||||||
include 'godmode/alerts/alert_list.php';
|
include 'godmode/alerts/alert_list.php';
|
||||||
break;
|
break;
|
||||||
|
@ -2155,7 +2175,7 @@ switch ($tab) {
|
||||||
default:
|
default:
|
||||||
if (enterprise_hook('switch_agent_tab', [$tab])) {
|
if (enterprise_hook('switch_agent_tab', [$tab])) {
|
||||||
// This will make sure that blank pages will have at least some
|
// 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'));
|
ui_print_error_message(__('Invalid tab specified'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1170,6 +1170,7 @@ html_print_input_hidden('module_relations_count', $relations_count);
|
||||||
|
|
||||||
ui_require_jquery_file('json');
|
ui_require_jquery_file('json');
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -1363,7 +1364,7 @@ function disabled_two_tailed (disabledBecauseInPolicy) {
|
||||||
function advanced_option_dynamic() {
|
function advanced_option_dynamic() {
|
||||||
if($('.hide_dinamic').is(":visible")){
|
if($('.hide_dinamic').is(":visible")){
|
||||||
$('.hide_dinamic').hide();
|
$('.hide_dinamic').hide();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$('.hide_dinamic').show();
|
$('.hide_dinamic').show();
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,9 @@ $url = ui_get_url_refresh(
|
||||||
'offset' => false,
|
'offset' => false,
|
||||||
'search_string' => $search_string,
|
'search_string' => $search_string,
|
||||||
'search_type' => $search_type,
|
'search_type' => $search_type,
|
||||||
]
|
],
|
||||||
|
true,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
$table = new stdClass();
|
$table = new stdClass();
|
||||||
|
|
|
@ -186,6 +186,10 @@ switch ($template['type']) {
|
||||||
$condition = __('The alert would fire when the module is in critical status');
|
$condition = __('The alert would fire when the module is in critical status');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'not_normal':
|
||||||
|
$condition = __('The alert would fire when the module is in not normal status');
|
||||||
|
break;
|
||||||
|
|
||||||
case 'unknown':
|
case 'unknown':
|
||||||
$condition = __('The alert would fire when the module is in unknown status');
|
$condition = __('The alert would fire when the module is in unknown status');
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -33,6 +33,7 @@ if (! check_acl($config['id_user'], 0, 'LM')) {
|
||||||
$update_command = (bool) get_parameter('update_command');
|
$update_command = (bool) get_parameter('update_command');
|
||||||
$id = (int) get_parameter('id');
|
$id = (int) get_parameter('id');
|
||||||
$pure = get_parameter('pure', 0);
|
$pure = get_parameter('pure', 0);
|
||||||
|
$alert = [];
|
||||||
|
|
||||||
// Header.
|
// Header.
|
||||||
if (defined('METACONSOLE')) {
|
if (defined('METACONSOLE')) {
|
||||||
|
@ -89,7 +90,15 @@ if ($update_command) {
|
||||||
$result = '';
|
$result = '';
|
||||||
} else {
|
} else {
|
||||||
$result = alerts_update_alert_command($id, $values);
|
$result = alerts_update_alert_command($id, $values);
|
||||||
$info = '{"Name":"'.$name.'","Command":"'.$command.'","Description":"'.$description.' '.$info_fields.'"}';
|
if ($result) {
|
||||||
|
$info = '{"Name":"'.$name.'","Command":"'.$command.'","Description":"'.$description.' '.$info_fields.'"}';
|
||||||
|
$alert['fields_values'] = io_json_mb_encode($fields_values);
|
||||||
|
$alert['fields_descriptions'] = io_json_mb_encode($fields_descriptions);
|
||||||
|
$alert['name'] = $name;
|
||||||
|
$alert['command'] = $command;
|
||||||
|
$alert['description'] = $description;
|
||||||
|
$alert['id_group'] = $id_group;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
|
@ -113,7 +122,10 @@ $fields_descriptions = '';
|
||||||
$fields_values = '';
|
$fields_values = '';
|
||||||
$id_group = 0;
|
$id_group = 0;
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$alert = alerts_get_alert_command($id);
|
if (!$result) {
|
||||||
|
$alert = alerts_get_alert_command($id);
|
||||||
|
}
|
||||||
|
|
||||||
$name = $alert['name'];
|
$name = $alert['name'];
|
||||||
$command = $alert['command'];
|
$command = $alert['command'];
|
||||||
$description = $alert['description'];
|
$description = $alert['description'];
|
||||||
|
|
|
@ -679,7 +679,7 @@ if ($step == 2) {
|
||||||
'type',
|
'type',
|
||||||
$type,
|
$type,
|
||||||
'',
|
'',
|
||||||
__('Select'),
|
__('None'),
|
||||||
0,
|
0,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
@ -1018,6 +1018,7 @@ var onchange_msg = <?php echo '"'.__('The alert would fire when the module value
|
||||||
var onchange_not = <?php echo '"'.__('The alert would fire when the module value does not change').'"'; ?>;
|
var onchange_not = <?php echo '"'.__('The alert would fire when the module value does not change').'"'; ?>;
|
||||||
var unknown = <?php echo "'".__('The alert would fire when the module is in unknown status')."'"; ?>;
|
var unknown = <?php echo "'".__('The alert would fire when the module is in unknown status')."'"; ?>;
|
||||||
var error_message_min_max_zero = <?php echo "'".__('The alert template cannot have the same value for min and max thresholds.')."'"; ?>;
|
var error_message_min_max_zero = <?php echo "'".__('The alert template cannot have the same value for min and max thresholds.')."'"; ?>;
|
||||||
|
var not_normal = <?php echo "'".__('The alert would fire when the module is in not normal status')."'"; ?>;
|
||||||
|
|
||||||
function check_fields_step2() {
|
function check_fields_step2() {
|
||||||
var correct = true;
|
var correct = true;
|
||||||
|
@ -1174,6 +1175,13 @@ if ($step == 2) {
|
||||||
/* Show example */
|
/* Show example */
|
||||||
$("span#example").empty ().append (critical);
|
$("span#example").empty ().append (critical);
|
||||||
break;
|
break;
|
||||||
|
case "not_normal":
|
||||||
|
$("#template-value, #template-max, span#matches_value, #template-min").hide ();
|
||||||
|
$("#template-example").show ();
|
||||||
|
|
||||||
|
/* Show example */
|
||||||
|
$("span#example").empty ().append (not_normal);
|
||||||
|
break;
|
||||||
case "onchange":
|
case "onchange":
|
||||||
$("#template-value, #template-max, #template-min").hide ();
|
$("#template-value, #template-max, #template-min").hide ();
|
||||||
$("#template-example, span#matches_value").show ();
|
$("#template-example, span#matches_value").show ();
|
||||||
|
|
|
@ -1090,10 +1090,11 @@ function readFields() {
|
||||||
var text = tinymce.get("text-label").getContent();
|
var text = tinymce.get("text-label").getContent();
|
||||||
values["label"] = text;
|
values["label"] = text;
|
||||||
|
|
||||||
|
values["percentile_label_color"] = $(
|
||||||
|
"input[name=percentile_label_color]"
|
||||||
|
).val();
|
||||||
|
|
||||||
if ($("input[name=percentile_label]").val().length > 0) {
|
if ($("input[name=percentile_label]").val().length > 0) {
|
||||||
values["percentile_label_color"] = $(
|
|
||||||
"input[name=percentile_label_color]"
|
|
||||||
).val();
|
|
||||||
values["label"] =
|
values["label"] =
|
||||||
"<span style='color:" +
|
"<span style='color:" +
|
||||||
values["percentile_label_color"] +
|
values["percentile_label_color"] +
|
||||||
|
|
|
@ -242,7 +242,6 @@ if ($filemanager) {
|
||||||
$chunck_url = '&create=1';
|
$chunck_url = '&create=1';
|
||||||
}
|
}
|
||||||
|
|
||||||
$homedir_filemanager = isset($config['homedir_filemanager']) ? $config['homedir_filemanager'] : false;
|
|
||||||
filemanager_file_explorer(
|
filemanager_file_explorer(
|
||||||
$real_directory,
|
$real_directory,
|
||||||
$directory,
|
$directory,
|
||||||
|
@ -253,7 +252,7 @@ if ($filemanager) {
|
||||||
'index.php?sec=gservers&sec2=godmode/servers/plugin'.$chunck_url.'&plugin_command=[FILE_FULLPATH]&id_plugin='.$id_plugin,
|
'index.php?sec=gservers&sec2=godmode/servers/plugin'.$chunck_url.'&plugin_command=[FILE_FULLPATH]&id_plugin='.$id_plugin,
|
||||||
true,
|
true,
|
||||||
0775,
|
0775,
|
||||||
$homedir_filemanager
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,6 @@ $real_directory = realpath($config['homedir'].'/'.$directory);
|
||||||
|
|
||||||
echo '<h4>'.__('Index of %s', $directory).'</h4>';
|
echo '<h4>'.__('Index of %s', $directory).'</h4>';
|
||||||
|
|
||||||
$homedir_filemanager = isset($config['homedir_filemanager']) ? $config['homedir_filemanager'] : false;
|
|
||||||
|
|
||||||
filemanager_file_explorer(
|
filemanager_file_explorer(
|
||||||
$real_directory,
|
$real_directory,
|
||||||
$directory,
|
$directory,
|
||||||
|
@ -78,5 +76,5 @@ filemanager_file_explorer(
|
||||||
'',
|
'',
|
||||||
false,
|
false,
|
||||||
'',
|
'',
|
||||||
$homedir_filemanager
|
false
|
||||||
);
|
);
|
||||||
|
|
|
@ -331,7 +331,7 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
|
||||||
theme : "advanced",
|
theme : "advanced",
|
||||||
theme_advanced_toolbar_location : "top",
|
theme_advanced_toolbar_location : "top",
|
||||||
theme_advanced_toolbar_align : "left",
|
theme_advanced_toolbar_align : "left",
|
||||||
theme_advanced_buttons1 : "bold,italic, |, image, link, |, cut, copy, paste, |, undo, redo, |, forecolor, |, fontsizeselect, |, justifyleft, justifycenter, justifyright",
|
theme_advanced_buttons1 : "bold,italic, |, image, link, |, cut, copy, paste, |, undo, redo, |, forecolor, |, fontsizeselect, |, justifyleft, justifycenter, justifyright, | ,code",
|
||||||
theme_advanced_buttons2 : "",
|
theme_advanced_buttons2 : "",
|
||||||
theme_advanced_buttons3 : "",
|
theme_advanced_buttons3 : "",
|
||||||
convert_urls : false,
|
convert_urls : false,
|
||||||
|
|
|
@ -200,8 +200,8 @@ if ($config['history_db_enabled'] == 1) {
|
||||||
);
|
);
|
||||||
|
|
||||||
$time_pandora_db_history = false;
|
$time_pandora_db_history = false;
|
||||||
if ($history_connect !== false) {
|
if ($history_connect) {
|
||||||
if ($config['history_db_connection'] !== false) {
|
if ($config['history_db_connection']) {
|
||||||
$time_pandora_db_history = mysql_db_process_sql(
|
$time_pandora_db_history = mysql_db_process_sql(
|
||||||
$sql,
|
$sql,
|
||||||
'insert_id',
|
'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;
|
$config_history = false;
|
||||||
if ($history_connect !== false) {
|
if ($config['history_db_connection']) {
|
||||||
if ($config['history_db_connection'] != false) {
|
$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(
|
$config_history_array = mysql_db_process_sql(
|
||||||
'SELECT * FROM tconfig',
|
'SELECT * FROM tconfig',
|
||||||
'affected_rows',
|
'affected_rows',
|
||||||
|
@ -427,11 +427,11 @@ if ($config['history_db_enabled'] == 1) {
|
||||||
$config_history[$value['token']] = $value['value'];
|
$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) {
|
if ($config_history === false) {
|
||||||
|
|
|
@ -70,10 +70,6 @@ $values[SECONDS_5MINUTES] = human_time_description_raw(SECONDS_5MINUTES);
|
||||||
$values[SECONDS_10MINUTES] = human_time_description_raw(SECONDS_10MINUTES);
|
$values[SECONDS_10MINUTES] = human_time_description_raw(SECONDS_10MINUTES);
|
||||||
$values[SECONDS_30MINUTES] = human_time_description_raw(SECONDS_30MINUTES);
|
$values[SECONDS_30MINUTES] = human_time_description_raw(SECONDS_30MINUTES);
|
||||||
|
|
||||||
$table_behaviour->data[$row][0] = __('Default interval for refresh on Visual Console').ui_print_help_tip(__('This interval will affect to Visual Console pages'), true);
|
|
||||||
$table_behaviour->data[$row][1] = html_print_select($values, 'vc_refr', $config['vc_refr'], '', 'N/A', 0, true, false, false);
|
|
||||||
$row++;
|
|
||||||
|
|
||||||
$table_behaviour->data[$row][0] = __('Paginated module view');
|
$table_behaviour->data[$row][0] = __('Paginated module view');
|
||||||
$table_behaviour->data[$row][1] = html_print_checkbox_switch(
|
$table_behaviour->data[$row][1] = html_print_checkbox_switch(
|
||||||
'paginate_module',
|
'paginate_module',
|
||||||
|
@ -908,6 +904,24 @@ $row++;
|
||||||
$table_vc->size[0] = '50%';
|
$table_vc->size[0] = '50%';
|
||||||
$table_vc->data = [];
|
$table_vc->data = [];
|
||||||
|
|
||||||
|
// Remove when the new view reaches rock solid stability.
|
||||||
|
$table_vc->data[$row][0] = __('Legacy Visual Console View');
|
||||||
|
$table_vc->data[$row][0] .= ui_print_help_tip(
|
||||||
|
__('To use the old view when using the Visual Console visor'),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$table_vc->data[$row][1] = html_print_checkbox_switch(
|
||||||
|
'legacy_vc',
|
||||||
|
1,
|
||||||
|
(bool) $config['legacy_vc'],
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$row++;
|
||||||
|
|
||||||
|
$table_vc->data[$row][0] = __('Default interval for refresh on Visual Console').ui_print_help_tip(__('This interval will affect to Visual Console pages'), true);
|
||||||
|
$table_vc->data[$row][1] = html_print_select($values, 'vc_refr', (int) $config['vc_refr'], '', 'N/A', 0, true, false, false);
|
||||||
|
$row++;
|
||||||
|
|
||||||
$vc_favourite_view_array[0] = __('Classic view');
|
$vc_favourite_view_array[0] = __('Classic view');
|
||||||
$vc_favourite_view_array[1] = __('View of favorites');
|
$vc_favourite_view_array[1] = __('View of favorites');
|
||||||
$table_vc->data[$row][0] = __('Type of view of visual consoles').ui_print_help_tip(__('Allows you to directly display the list of favorite visual consoles'), true);
|
$table_vc->data[$row][0] = __('Type of view of visual consoles').ui_print_help_tip(__('Allows you to directly display the list of favorite visual consoles'), true);
|
||||||
|
@ -918,12 +932,8 @@ $row++;
|
||||||
$table_vc->data[$row][1] = "<input type ='number' value=".$config['vc_menu_items']." size='5' name='vc_menu_items' min='0' max='25'>";
|
$table_vc->data[$row][1] = "<input type ='number' value=".$config['vc_menu_items']." size='5' name='vc_menu_items' min='0' max='25'>";
|
||||||
$row++;
|
$row++;
|
||||||
|
|
||||||
if (empty($config['vc_line_thickness'])) {
|
|
||||||
$config['vc_line_thickness'] = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table_vc->data[$row][0] = __('Default line thickness for the Visual Console').ui_print_help_tip(__('This interval will affect to the lines between elements on the Visual Console'), true);
|
$table_vc->data[$row][0] = __('Default line thickness for the Visual Console').ui_print_help_tip(__('This interval will affect to the lines between elements on the Visual Console'), true);
|
||||||
$table_vc->data[$row][1] = html_print_input_text('vc_line_thickness', $config['vc_line_thickness'], '', 5, 5, true);
|
$table_vc->data[$row][1] = html_print_input_text('vc_line_thickness', (int) $config['vc_line_thickness'], '', 5, 5, true);
|
||||||
|
|
||||||
|
|
||||||
echo '<fieldset>';
|
echo '<fieldset>';
|
||||||
|
|
|
@ -140,6 +140,162 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#box_online {
|
#box_online {
|
||||||
background-color: #e6e6e6;
|
background-image: url("../../images/update_manager_background.jpg");
|
||||||
padding: 10px;
|
background-size: cover;
|
||||||
|
background-position: center center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 40px 50px;
|
||||||
|
border: 1px solid #f3f3f3;
|
||||||
|
border-radius: 5px;
|
||||||
|
min-height: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#box_online * {
|
||||||
|
font-size: 16pt;
|
||||||
|
font-family: "Open Sans", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
#box_online .content {
|
||||||
|
max-width: 60%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update_popup {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update_icon {
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update_text h3 {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 12pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update_text p {
|
||||||
|
font-size: 11pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update_text a {
|
||||||
|
font-size: 11pt;
|
||||||
|
color: #82b92e !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
|
||||||
|
float: left !important;
|
||||||
|
padding-left: 19px;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-dialog-buttonset > button.ui-button.ui-corner-all.ui-widget {
|
||||||
|
background-color: #cecece !important;
|
||||||
|
border: none !important;
|
||||||
|
border-radius: 2px !important;
|
||||||
|
text-transform: uppercase !important;
|
||||||
|
font-weight: bold !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-dialog-buttonset > button.success_button.ui-button.ui-corner-all.ui-widget,
|
||||||
|
.update_manager_button {
|
||||||
|
background-color: #82b92e !important;
|
||||||
|
color: #fff !important;
|
||||||
|
border-radius: 2px !important;
|
||||||
|
text-transform: uppercase !important;
|
||||||
|
font-weight: bold !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.update_manager_button {
|
||||||
|
padding: 10px 12px;
|
||||||
|
margin-top: 10px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 16px !important;
|
||||||
|
border-radius: 4px !important;
|
||||||
|
text-decoration: none;
|
||||||
|
font-family: "Open Sans", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.update_manager_button:after {
|
||||||
|
content: url(../../images/update_manager_button.png);
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressbar {
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-draggable,
|
||||||
|
.ui-draggable .ui-dialog-titlebar {
|
||||||
|
cursor: default !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#box_online #pkg_version {
|
||||||
|
color: #82b92e;
|
||||||
|
font-size: 75pt;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* METACONSOLE */
|
||||||
|
.box_online_meta {
|
||||||
|
background: none !important;
|
||||||
|
min-height: 400px !important;
|
||||||
|
text-align: center;
|
||||||
|
border: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#box_online.box_online_meta * {
|
||||||
|
font-size: 14pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
#box_online.box_online_meta .content {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#box_online.box_online_meta #pkg_version {
|
||||||
|
font-size: 60pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* COMMUNITY */
|
||||||
|
.update_manager_open {
|
||||||
|
max-width: 50%;
|
||||||
|
font-size: 10pt;
|
||||||
|
margin-top: 40px;
|
||||||
|
padding: 20px;
|
||||||
|
border: 1px solid #eaeaea;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update_manager_warning {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update_manager_warning p {
|
||||||
|
font-size: 10pt !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update_manager_warning img {
|
||||||
|
padding-right: 20px;
|
||||||
|
width: 90px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.update_manager_button_open {
|
||||||
|
padding: 5px 10px;
|
||||||
|
font-size: 16px !important;
|
||||||
|
border-radius: 4px !important;
|
||||||
|
text-decoration: none;
|
||||||
|
border: 1px solid #82b92e;
|
||||||
|
color: #82b92e;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.update_manager_button_open:hover {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #82b92e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Pandora FMS - http://pandorafms.com
|
/**
|
||||||
// ==================================================
|
Pandora FMS - http://pandorafms.com
|
||||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
* ==================================================
|
||||||
// Please see http://pandorafms.org for full contribution list
|
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||||
// This program is free software; you can redistribute it and/or
|
* Please see http://pandorafms.org for full contribution list
|
||||||
// modify it under the terms of the GNU General Public License
|
* This program is free software; you can redistribute it and/or
|
||||||
// as published by the Free Software Foundation; version 2
|
* modify it under the terms of the GNU General Public License
|
||||||
// This program is distributed in the hope that it will be useful,
|
* as published by the Free Software Foundation; version 2
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* This program is distributed in the hope that it will be useful,
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// GNU General Public License for more details.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* @package category
|
||||||
|
* @subpackage category
|
||||||
|
*/
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
check_login();
|
check_login();
|
||||||
|
@ -61,7 +67,7 @@ if ($memory_limit < 100) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translators: Do not translade Update Manager, it's the name of the program
|
// Translators: Do not translade Update Manager, it's the name of the program.
|
||||||
if (is_metaconsole()) {
|
if (is_metaconsole()) {
|
||||||
echo "<style type='text/css' media='screen'>
|
echo "<style type='text/css' media='screen'>
|
||||||
@import 'styles/meta_pandora.css';
|
@import 'styles/meta_pandora.css';
|
||||||
|
@ -69,23 +75,29 @@ if (is_metaconsole()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_metaconsole()) {
|
if (is_metaconsole()) {
|
||||||
echo "<div id='box_online' style='float:right;padding-right:400px;padding-top:40px;padding-bottom:40px;' class='cargatextodialogo'>";
|
$baseurl = ui_get_full_url(false, false, false, false);
|
||||||
|
echo ' <link rel="stylesheet" type="text/css" href="'.$baseurl.'/godmode/update_manager/update_manager.css">';
|
||||||
|
echo "<div id='box_online' class='box_online_meta'>";
|
||||||
} else {
|
} else {
|
||||||
echo "<div id='box_online' style='padding-top:40px;padding-bottom:40px;' class='cargatextodialogo'>";
|
echo "<div id='box_online'>";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<span class='loading' style='font-size:18pt;'>";
|
echo "<span class='loading' style='font-size:18pt;'>";
|
||||||
echo "<img src='images/wait.gif' />";
|
echo "<img src='images/wait.gif' />";
|
||||||
echo '</span><br><br>';
|
echo '</span>';
|
||||||
|
|
||||||
echo '<div><b>'.__('The latest version of package installed is:').'</b></div><br>';
|
echo '<p style="font-weight: 600;">'.__('The latest version of package installed is:').'</p>';
|
||||||
echo "<div id='pkg_version' style='color:#82b92e;font-size:40pt;font-weight:bold;'>".$current_package.'</div>';
|
if ($open) {
|
||||||
|
echo '<div id="pkg_version" style="font-size:40pt;">'.$build_version.'</div>';
|
||||||
|
} else {
|
||||||
|
echo '<div id="pkg_version">'.$current_package.'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
echo "<div class='checking_package' style='font-size:18pt;width:100%; text-align: center; display: none;'>";
|
echo "<div class='checking_package' style='font-size:18pt;width:100%; display: none;'>";
|
||||||
echo __('Checking for the newest package.');
|
echo __('Checking for the newest package.');
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
echo "<div class='downloading_package' style='font-size:18pt;width:100%; text-align: center; display: none;'>";
|
echo "<div class='downloading_package' style='font-size:18pt;width:100%; display: none;'>";
|
||||||
echo __('Downloading for the newest package.');
|
echo __('Downloading for the newest package.');
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
|
@ -119,22 +131,26 @@ echo "<div id='pkg_version' style='color:#82b92e;font-size:40pt;font-weight:bold
|
||||||
let you know this does not reflect any change in our opensource mentality of
|
let you know this does not reflect any change in our opensource mentality of
|
||||||
does the last 14 years.
|
does the last 14 years.
|
||||||
|
|
||||||
------------------------------------------------------------------------- */
|
-------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
if ($open) {
|
if ($open) {
|
||||||
echo "
|
echo "<div class='update_manager_open'>
|
||||||
<br><br>
|
<div class='update_manager_warning'>
|
||||||
<div id='updatemodal' class='publienterprisehide' title='Community version' style=''>
|
<div><img src='images/icono_info.png'></div>
|
||||||
<img data-title='Enterprise version' class='img_help forced_title' data-use_title_for_force_title='1' src='images/icono_exclamacion_2.png'>
|
<div><p>".__('WARNING: You are just one click away from an automated update. This may result in a damaged system, including loss of data and operativity. Check you have a recent backup. OpenSource updates are automatically created packages, and there is no WARRANTY or SUPPORT. If you need professional support and warranty, please upgrade to Enterprise Version.')."</p></div>
|
||||||
</div>
|
</div>
|
||||||
<br>";
|
<div style='text-align:center; margin-top:10px;'>
|
||||||
|
<a class='update_manager_button_open' href='https://pandorafms.com/pandora-fms-enterprise/' target='_blank'>About Enterprise</a>
|
||||||
|
</div>
|
||||||
|
</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$enterprise = enterprise_hook('update_manager_enterprise_main');
|
$enterprise = enterprise_hook('update_manager_enterprise_main');
|
||||||
|
|
||||||
if ($enterprise == ENTERPRISE_NOT_HOOK) {
|
if ($enterprise == ENTERPRISE_NOT_HOOK) {
|
||||||
// Open view
|
// Open view.
|
||||||
update_manager_main();
|
update_manager_main();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -594,11 +594,11 @@ class HostDevices extends Wizard
|
||||||
if (isset($this->page) === false
|
if (isset($this->page) === false
|
||||||
|| $this->page == 0
|
|| $this->page == 0
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// Comment input
|
// Comment input
|
||||||
$comment_input ='<div class="label_select"><label>'.__('Comment').':</label></div>';
|
$comment_input = '<div class="label_select"><label>'.__('Comment').':</label></div>';
|
||||||
|
|
||||||
$comment_input .= $this->printInput([
|
$comment_input .= $this->printInput(
|
||||||
|
[
|
||||||
'name' => 'comment',
|
'name' => 'comment',
|
||||||
'rows' => 1,
|
'rows' => 1,
|
||||||
'columns' => 1,
|
'columns' => 1,
|
||||||
|
@ -606,49 +606,55 @@ class HostDevices extends Wizard
|
||||||
'type' => 'textarea',
|
'type' => 'textarea',
|
||||||
'size' => 25,
|
'size' => 25,
|
||||||
'class' => 'discovery_textarea_input',
|
'class' => 'discovery_textarea_input',
|
||||||
'return' => true
|
'return' => true,
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
|
|
||||||
// Task input
|
// Task input
|
||||||
$taskname_input_label = '<div class="label_select"><label>'.__('Task name').':</label></div>';
|
$taskname_input_label = '<div class="label_select"><label>'.__('Task name').':</label></div>';
|
||||||
|
|
||||||
$taskname_input = $this->printInput([
|
$taskname_input = $this->printInput(
|
||||||
|
[
|
||||||
'name' => 'taskname',
|
'name' => 'taskname',
|
||||||
'value' => $this->task['name'],
|
'value' => $this->task['name'],
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'size' => 25,
|
'size' => 25,
|
||||||
'class' => 'discovery_full_width_input'
|
'class' => 'discovery_full_width_input',
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
|
|
||||||
// Network input
|
// Network input
|
||||||
$network_input_label .= '<div class="label_select discovery_label_hint"><label>'.__('Network').':</label>'.ui_print_help_tip(__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), true).'</div>';
|
$network_input_label .= '<div class="label_select discovery_label_hint"><label>'.__('Network').':</label>'.ui_print_help_tip(__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), true).'</div>';
|
||||||
|
|
||||||
$network_input = $this->printInput([
|
$network_input = $this->printInput(
|
||||||
|
[
|
||||||
'name' => 'network',
|
'name' => 'network',
|
||||||
'value' => $this->task['subnet'],
|
'value' => $this->task['subnet'],
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'size' => 25,
|
'size' => 25,
|
||||||
'class' => 'discovery_full_width_input',
|
'class' => 'discovery_full_width_input',
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
|
|
||||||
// Discovery server input
|
// Discovery server input
|
||||||
$discovery_server_select_label = '<div class="label_select discovery_label_hint"><label>'.__('Discovery server').':</label>'.ui_print_help_tip(__('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'), true).'</div>';
|
$discovery_server_select_label = '<div class="label_select discovery_label_hint"><label>'.__('Discovery server').':</label>'.ui_print_help_tip(__('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'), true).'</div>';
|
||||||
|
|
||||||
$discovery_server_select = $this->printInput([
|
$discovery_server_select = $this->printInput(
|
||||||
'type' => 'select_from_sql',
|
[
|
||||||
'sql' => sprintf(
|
'type' => 'select_from_sql',
|
||||||
'SELECT id_server, name
|
'sql' => sprintf(
|
||||||
|
'SELECT id_server, name
|
||||||
FROM tserver
|
FROM tserver
|
||||||
WHERE server_type = %d
|
WHERE server_type = %d
|
||||||
ORDER BY name',
|
ORDER BY name',
|
||||||
SERVER_TYPE_DISCOVERY
|
SERVER_TYPE_DISCOVERY
|
||||||
),
|
),
|
||||||
'name' => 'id_recon_server',
|
'name' => 'id_recon_server',
|
||||||
'selected' => $this->task['id_recon_server'],
|
'selected' => $this->task['id_recon_server'],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
'style' => 'width: 100%',
|
'style' => 'width: 100%',
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
|
|
||||||
// Interval input
|
// Interval input
|
||||||
$interv_manual = 0;
|
$interv_manual = 0;
|
||||||
|
@ -658,38 +664,40 @@ class HostDevices extends Wizard
|
||||||
|
|
||||||
$interval_input_label = '<div class="label_select discovery_label_hint" style="padding-top: 6px;"><label>'.__('Interval').':</label>'.ui_print_help_tip(__('Manual interval means that it will run only on demand.'), true).'</div>';
|
$interval_input_label = '<div class="label_select discovery_label_hint" style="padding-top: 6px;"><label>'.__('Interval').':</label>'.ui_print_help_tip(__('Manual interval means that it will run only on demand.'), true).'</div>';
|
||||||
|
|
||||||
$interval_input = $this->printInput([
|
$interval_input = $this->printInput(
|
||||||
'type' => 'select',
|
[
|
||||||
'selected' => $interv_manual,
|
'type' => 'select',
|
||||||
'fields' => [
|
'selected' => $interv_manual,
|
||||||
0 => __('Defined'),
|
'fields' => [
|
||||||
1 => __('Manual'),
|
0 => __('Defined'),
|
||||||
],
|
1 => __('Manual'),
|
||||||
'name' => 'interval_manual_defined',
|
],
|
||||||
'return' => true,
|
'name' => 'interval_manual_defined',
|
||||||
'style' => 'float: right;'
|
'return' => true,
|
||||||
]);
|
'style' => 'float: right;',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$interval_input_extra = '<span id="interval_manual_container">'.html_print_extended_select_for_time(
|
$interval_input_extra = '<span id="interval_manual_container">'.html_print_extended_select_for_time(
|
||||||
'interval',
|
'interval',
|
||||||
$this->task['interval_sweep'],
|
$this->task['interval_sweep'],
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'0',
|
'0',
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
).ui_print_help_tip(
|
).ui_print_help_tip(
|
||||||
__('The minimum recomended interval for Recon Task is 5 minutes'),
|
__('The minimum recomended interval for Recon Task is 5 minutes'),
|
||||||
true
|
true
|
||||||
).'</span>';
|
).'</span>';
|
||||||
|
|
||||||
|
|
||||||
// Group select
|
// Group select
|
||||||
$group_select = '<div class="label_select"><label>'.__('Group').':</label></div>';
|
$group_select = '<div class="label_select"><label>'.__('Group').':</label></div>';
|
||||||
|
|
||||||
$group_select .= $this->printInput([
|
$group_select .= $this->printInput(
|
||||||
|
[
|
||||||
'name' => 'id_group',
|
'name' => 'id_group',
|
||||||
'returnAllGroup' => false,
|
'returnAllGroup' => false,
|
||||||
'privilege' => 'PM',
|
'privilege' => 'PM',
|
||||||
|
@ -699,15 +707,18 @@ class HostDevices extends Wizard
|
||||||
'class' => 'discovery_list_input',
|
'class' => 'discovery_list_input',
|
||||||
'size' => 9,
|
'size' => 9,
|
||||||
'simple_multiple_options' => true,
|
'simple_multiple_options' => true,
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
|
|
||||||
if (isset($this->task['id_rt']) === true) {
|
if (isset($this->task['id_rt']) === true) {
|
||||||
//Propagate ID
|
// Propagate ID
|
||||||
$task_hidden = $this->printInput([
|
$task_hidden = $this->printInput(
|
||||||
'name' => 'task',
|
[
|
||||||
'value' => $this->task['id_rt'],
|
'name' => 'task',
|
||||||
'type' => 'hidden'
|
'value' => $this->task['id_rt'],
|
||||||
]);
|
'type' => 'hidden',
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$task_url = '';
|
$task_url = '';
|
||||||
|
@ -725,32 +736,20 @@ class HostDevices extends Wizard
|
||||||
|
|
||||||
// XXX: Could be improved validating inputs before continue (JS)
|
// XXX: Could be improved validating inputs before continue (JS)
|
||||||
// Print NetScan page 0.
|
// Print NetScan page 0.
|
||||||
//$this->printForm($form);
|
// $this->printForm($form);
|
||||||
|
|
||||||
echo '<form action="'.$this->url.'&mode=netscan&page='.($this->page + 1).$task_url.'" method="POST">';
|
echo '<form action="'.$this->url.'&mode=netscan&page='.($this->page + 1).$task_url.'" method="POST">';
|
||||||
echo $task_hidden;
|
echo $task_hidden;
|
||||||
|
|
||||||
echo '<div class="white_box">
|
echo '<div class="white_box">
|
||||||
<div class="edit_discovery_info" style="margin-bottom: 15px;">
|
<div class="edit_discovery_info" style="margin-bottom: 15px;">
|
||||||
<div style="width: 25%; padding: 9px;">'
|
<div style="width: 25%; padding: 9px;">'.'<div style="height: 50%; margin-bottom: 35px;">'.html_print_image('images/wizard/netscan_green.png', true, ['title' => __('Close')], false).'</div>'.'<div class="edit_discovery_input"><div style="display: flex;">'.$interval_input_label.'<div style="margin-left: 15 px; width: 50%;">'.$interval_input.'</div></div>'.$interval_input_extra.'</div>'.'</div>
|
||||||
.'<div style="height: 50%; margin-bottom: 35px;">'.html_print_image ("images/wizard/netscan_green.png", true, array ("title" => __('Close'), "style" => 'width: 60%;'), false).'</div>'
|
|
||||||
.'<div class="edit_discovery_input"><div style="display: flex;">'.$interval_input_label.'<div style="margin-left: 15 px; width: 50%;">'.$interval_input.'</div></div>'.$interval_input_extra.'</div>'
|
|
||||||
.'</div>
|
|
||||||
|
|
||||||
<div style="width: 40%; padding-left: 5%; padding-right: 12%;">
|
<div style="width: 40%; padding-left: 5%; padding-right: 12%;">
|
||||||
<div class="edit_discovery_input">'.$taskname_input_label.'<div class="discovery_text_input">'.$taskname_input.'</div></div>'
|
<div class="edit_discovery_input">'.$taskname_input_label.'<div class="discovery_text_input">'.$taskname_input.'</div></div>'.'<div class="edit_discovery_input discovery_select_input">'.$discovery_server_select_label.$discovery_server_select.'<div class="discovery_hint"></div></div>'.'<div class="edit_discovery_input">'.$network_input_label.'<div class="discovery_text_input">'.$network_input.'</div></div>'.'</div>'.'<div style="width: 35%;">'.$group_select.'</div>'.'</div>'.'<div class="edit_discovery_info">
|
||||||
.'<div class="edit_discovery_input discovery_select_input">'.$discovery_server_select_label.$discovery_server_select.'<div class="discovery_hint"></div></div>'
|
|
||||||
.'<div class="edit_discovery_input">'.$network_input_label.'<div class="discovery_text_input">'.$network_input.'</div></div>'
|
|
||||||
.'</div>'
|
|
||||||
.'<div style="width: 35%;">'.$group_select.'</div>'
|
|
||||||
.'</div>'
|
|
||||||
|
|
||||||
.'<div class="edit_discovery_info">
|
|
||||||
<div style="width: 100%;">
|
<div style="width: 100%;">
|
||||||
'.$comment_input.'
|
'.$comment_input.'
|
||||||
</div>
|
</div>
|
||||||
</div>'
|
</div>'.'</div>';
|
||||||
.'</div>';
|
|
||||||
|
|
||||||
$str = __('Next');
|
$str = __('Next');
|
||||||
|
|
||||||
|
@ -778,7 +777,6 @@ class HostDevices extends Wizard
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
</script>';
|
</script>';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -661,22 +661,25 @@ class Wizard
|
||||||
$output_submit = '';
|
$output_submit = '';
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
if ($print_white_box === true)
|
if ($print_white_box === true) {
|
||||||
$output .= '<div class="white_box">';
|
$output .= '<div class="white_box">';
|
||||||
|
}
|
||||||
|
|
||||||
$output .= '<ul class="wizard">';
|
$output .= '<ul class="wizard">';
|
||||||
|
|
||||||
foreach ($inputs as $input) {
|
foreach ($inputs as $input) {
|
||||||
if ($input['arguments']['type']!='submit')
|
if ($input['arguments']['type'] != 'submit') {
|
||||||
$output .= $this->printBlock($input, true);
|
$output .= $this->printBlock($input, true);
|
||||||
else
|
} else {
|
||||||
$output_submit .= $this->printBlock($input, true);
|
$output_submit .= $this->printBlock($input, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= '</ul>';
|
$output .= '</ul>';
|
||||||
|
|
||||||
if ($print_white_box === true)
|
if ($print_white_box === true) {
|
||||||
$output .= '</div>';
|
$output .= '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
$output .= '<ul class="wizard">'.$output_submit.'</ul>';
|
$output .= '<ul class="wizard">'.$output_submit.'</ul>';
|
||||||
$output .= '</form>';
|
$output .= '</form>';
|
||||||
|
|
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 266 KiB |
After Width: | Height: | Size: 291 B |
|
@ -1,17 +1,33 @@
|
||||||
<?php
|
<?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()) {
|
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;
|
global $config;
|
||||||
|
|
||||||
include_once $config['homedir'].'/include/functions_agents.php';
|
include_once $config['homedir'].'/include/functions_agents.php';
|
||||||
|
@ -21,9 +37,18 @@ if (check_login()) {
|
||||||
enterprise_include_once('include/functions_metaconsole.php');
|
enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
|
||||||
$get_custom_fields_data = (bool) get_parameter('get_custom_fields_data', 0);
|
$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_custom_fields = (bool) get_parameter(
|
||||||
$build_table_child_custom_fields = (bool) get_parameter('build_table_child_custom_fields', 0);
|
'build_table_custom_fields',
|
||||||
$build_table_save_filter = (bool) get_parameter('build_table_save_filter', 0);
|
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);
|
$append_tab_filter = (bool) get_parameter('append_tab_filter', 0);
|
||||||
$create_filter_cf = (bool) get_parameter('create_filter_cf', 0);
|
$create_filter_cf = (bool) get_parameter('create_filter_cf', 0);
|
||||||
$update_filter_cf = (bool) get_parameter('update_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);
|
$start = get_parameter('start', 0);
|
||||||
$draw = get_parameter('draw', 0);
|
$draw = get_parameter('draw', 0);
|
||||||
$search = get_parameter('search', '');
|
$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'];
|
$order_column = $order[0]['column'];
|
||||||
$type_order = $order[0]['dir'];
|
$type_order = $order[0]['dir'];
|
||||||
switch ($order_column) {
|
switch ($order_column) {
|
||||||
|
@ -66,27 +98,34 @@ if (check_login()) {
|
||||||
break;
|
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 (
|
$table_temporary = 'CREATE TEMPORARY TABLE temp_custom_fields (
|
||||||
id_server int(10),
|
id_server int(10),
|
||||||
id_agent int(10),
|
id_agent int(10),
|
||||||
name_custom_fields varchar(2048),
|
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),
|
`status` int(2),
|
||||||
KEY `data_index_temp_1` (`id_server`, `id_agent`)
|
KEY `data_index_temp_1` (`id_server`, `id_agent`)
|
||||||
)';
|
)';
|
||||||
db_process_sql($table_temporary);
|
db_process_sql($table_temporary);
|
||||||
|
|
||||||
// insert values array in table temporary
|
// Insert values array in table temporary.
|
||||||
$values_insert = [];
|
$values_insert = [];
|
||||||
foreach ($indexed_descriptions as $key => $value) {
|
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);
|
$values_insert_implode = implode(',', $values_insert);
|
||||||
$query_insert = 'INSERT INTO temp_custom_fields VALUES '.$values_insert_implode;
|
$query_insert = 'INSERT INTO temp_custom_fields VALUES '.$values_insert_implode;
|
||||||
db_process_sql($query_insert);
|
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 = '';
|
$search_query = '';
|
||||||
if ($search['value'] != '') {
|
if ($search['value'] != '') {
|
||||||
$search_query = ' AND (tma.alias LIKE "%'.$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'].'%" ) ';
|
$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(
|
$query = sprintf(
|
||||||
'SELECT
|
'SELECT
|
||||||
tma.id_agente,
|
tma.id_agente,
|
||||||
|
@ -112,10 +205,14 @@ if (check_login()) {
|
||||||
AND temp.id_server = tma.id_tmetaconsole_setup
|
AND temp.id_server = tma.id_tmetaconsole_setup
|
||||||
WHERE tma.disabled = 0
|
WHERE tma.disabled = 0
|
||||||
%s
|
%s
|
||||||
|
%s
|
||||||
|
%s
|
||||||
%s
|
%s
|
||||||
LIMIT %d OFFSET %d
|
LIMIT %d OFFSET %d
|
||||||
',
|
',
|
||||||
$search_query,
|
$search_query,
|
||||||
|
$status_agent_search,
|
||||||
|
$status_module_search,
|
||||||
$order_by,
|
$order_by,
|
||||||
$length,
|
$length,
|
||||||
$start
|
$start
|
||||||
|
@ -123,23 +220,27 @@ if (check_login()) {
|
||||||
|
|
||||||
$result = db_get_all_rows_sql($query);
|
$result = db_get_all_rows_sql($query);
|
||||||
|
|
||||||
// query count
|
// Query count.
|
||||||
$query_count = sprintf(
|
$query_count = sprintf(
|
||||||
'SELECT
|
'SELECT
|
||||||
COUNT(tma.id_agente) AS `count`
|
COUNT(tma.id_agente) AS `count`
|
||||||
FROM tmetaconsole_agent tma
|
FROM tmetaconsole_agent tma
|
||||||
INNER JOIN temp_custom_fields temp
|
INNER JOIN temp_custom_fields temp
|
||||||
ON temp.id_agent = tma.id_tagente
|
ON temp.id_agent = tma.id_tagente
|
||||||
AND temp.id_server = tma.id_tmetaconsole_setup
|
AND temp.id_server = tma.id_tmetaconsole_setup
|
||||||
WHERE tma.disabled = 0
|
WHERE tma.disabled = 0
|
||||||
%s
|
%s
|
||||||
',
|
%s
|
||||||
$search_query
|
%s
|
||||||
|
',
|
||||||
|
$search_query,
|
||||||
|
$status_agent_search,
|
||||||
|
$status_module_search
|
||||||
);
|
);
|
||||||
|
|
||||||
$count = db_get_sql($query_count);
|
$count = db_get_sql($query_count);
|
||||||
|
|
||||||
// for link nodes.
|
// For link nodes.
|
||||||
$array_nodes = metaconsole_get_connections();
|
$array_nodes = metaconsole_get_connections();
|
||||||
if (isset($array_nodes) && is_array($array_nodes)) {
|
if (isset($array_nodes) && is_array($array_nodes)) {
|
||||||
$hash_array_nodes = [];
|
$hash_array_nodes = [];
|
||||||
|
@ -158,20 +259,20 @@ if (check_login()) {
|
||||||
$user_rot13 = str_rot13($config['id_user']);
|
$user_rot13 = str_rot13($config['id_user']);
|
||||||
$hashdata = $user.$pwd;
|
$hashdata = $user.$pwd;
|
||||||
$hashdata = md5($hashdata);
|
$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']]['hashurl'] = $url_hash;
|
||||||
$hash_array_nodes[$server['id']]['server_url'] = $server['server_url'];
|
$hash_array_nodes[$server['id']]['server_url'] = $server['server_url'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare rows for table dinamic
|
// Prepare rows for table dinamic.
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach ($result as $values) {
|
foreach ($result as $values) {
|
||||||
$image_status = agents_get_image_status($values['status']);
|
$image_status = agents_get_image_status($values['status']);
|
||||||
|
|
||||||
// link nodes
|
// 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_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(
|
$agent_alias = ui_print_truncate_text(
|
||||||
$values['alias'],
|
$values['alias'],
|
||||||
|
@ -225,7 +326,7 @@ if (check_login()) {
|
||||||
$name_where = " AND tam.nombre LIKE '%".$module_search."%'";
|
$name_where = " AND tam.nombre LIKE '%".$module_search."%'";
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter by status module
|
// Filter by status module.
|
||||||
$and_module_status = '';
|
$and_module_status = '';
|
||||||
if (is_array($module_status)) {
|
if (is_array($module_status)) {
|
||||||
if (!in_array(-1, $module_status)) {
|
if (!in_array(-1, $module_status)) {
|
||||||
|
@ -260,7 +361,7 @@ if (check_login()) {
|
||||||
$and_module_status .= ' ) ';
|
$and_module_status .= ' ) ';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not normal
|
// Not normal.
|
||||||
$and_module_status = 'AND tae.estado <> 0 AND tae.estado <> 300 ';
|
$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'] != 23
|
||||||
&& $value['id_tipo_modulo'] != 33
|
&& $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 {
|
} else {
|
||||||
$table_modules->data[$key][1] = $value['datos'];
|
$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][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']) {
|
switch ($value['estado']) {
|
||||||
case 0:
|
case 0:
|
||||||
case 300:
|
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;
|
$sql_info_agents = 'SELECT * fROM tagente WHERE id_agente ='.$id_agent;
|
||||||
$info_agents = db_get_row_sql($sql_info_agents);
|
$info_agents = db_get_row_sql($sql_info_agents);
|
||||||
$status_agent = agents_get_status_from_counts($info_agents);
|
$status_agent = agents_get_status_from_counts($info_agents);
|
||||||
|
@ -463,7 +572,13 @@ if (check_login()) {
|
||||||
false
|
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'>";
|
echo "<form action='' method='post'>";
|
||||||
html_print_table($table);
|
html_print_table($table);
|
||||||
|
@ -474,7 +589,12 @@ if (check_login()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($append_tab_filter) {
|
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 = new StdClass;
|
||||||
$table->id = 'save_filter_form';
|
$table->id = 'save_filter_form';
|
||||||
|
@ -485,7 +605,14 @@ if (check_login()) {
|
||||||
if ($filters['id'] == 'extended_create_filter') {
|
if ($filters['id'] == 'extended_create_filter') {
|
||||||
echo "<div id='msg_error_create'></div>";
|
echo "<div id='msg_error_create'></div>";
|
||||||
$table->data[0][0] = __('Filter name');
|
$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][0] = __('Group');
|
||||||
$table->data[1][1] = html_print_select_groups(
|
$table->data[1][1] = html_print_select_groups(
|
||||||
|
@ -510,7 +637,13 @@ if (check_login()) {
|
||||||
);
|
);
|
||||||
|
|
||||||
$table->rowspan[0][2] = 2;
|
$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 {
|
} else {
|
||||||
echo "<div id='msg_error_update'></div>";
|
echo "<div id='msg_error_update'></div>";
|
||||||
echo "<div id='msg_error_delete'></div>";
|
echo "<div id='msg_error_delete'></div>";
|
||||||
|
@ -552,8 +685,20 @@ if (check_login()) {
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
$table->data[0][2] = html_print_submit_button(__('Delete filter'), 'delete_filter', false, 'class="sub upd"', true);
|
$table->data[0][2] = html_print_submit_button(
|
||||||
$table->data[1][2] = html_print_submit_button(__('Update filter'), 'update_filter', false, 'class="sub upd"', true);
|
__('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);
|
html_print_table($table);
|
||||||
|
@ -561,17 +706,20 @@ if (check_login()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($create_filter_cf) {
|
if ($create_filter_cf) {
|
||||||
// initialize result
|
// Initialize result.
|
||||||
$result_array = [];
|
$result_array = [];
|
||||||
$result_array['error'] = 0;
|
$result_array['error'] = 0;
|
||||||
$result_array['msg'] = '';
|
$result_array['msg'] = '';
|
||||||
|
|
||||||
// initialize vars
|
// Initialize vars.
|
||||||
$filters = json_decode(io_safe_output(get_parameter('filters', '')), true);
|
$filters = json_decode(
|
||||||
|
io_safe_output(get_parameter('filters', '')),
|
||||||
|
true
|
||||||
|
);
|
||||||
$name_filter = get_parameter('name_filter', '');
|
$name_filter = get_parameter('name_filter', '');
|
||||||
$group_search = get_parameter('group_search', 0);
|
$group_search = get_parameter('group_search', 0);
|
||||||
|
|
||||||
// check that the name is not empty
|
// Check that the name is not empty.
|
||||||
if ($name_filter == '') {
|
if ($name_filter == '') {
|
||||||
$result_array['error'] = 1;
|
$result_array['error'] = 1;
|
||||||
$result_array['msg'] = ui_print_error_message(
|
$result_array['msg'] = ui_print_error_message(
|
||||||
|
@ -596,7 +744,7 @@ if (check_login()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check custom field is not empty
|
// Check custom field is not empty.
|
||||||
if ($filters['id_custom_fields'] == '') {
|
if ($filters['id_custom_fields'] == '') {
|
||||||
$result_array['error'] = 1;
|
$result_array['error'] = 1;
|
||||||
$result_array['msg'] = ui_print_error_message(
|
$result_array['msg'] = ui_print_error_message(
|
||||||
|
@ -608,13 +756,15 @@ if (check_login()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert
|
// Insert.
|
||||||
$values = [];
|
$values = [];
|
||||||
$values['name'] = $name_filter;
|
$values['name'] = $name_filter;
|
||||||
$values['group_search'] = $group_search;
|
$values['group_search'] = $group_search;
|
||||||
$values['id_group'] = $filters['group'];
|
$values['id_group'] = $filters['group'];
|
||||||
$values['id_custom_field'] = $filters['id_custom_fields'];
|
$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['id_status'] = json_encode($filters['id_status']);
|
||||||
$values['module_search'] = $filters['module_search'];
|
$values['module_search'] = $filters['module_search'];
|
||||||
$values['module_status'] = json_encode($filters['module_status']);
|
$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);
|
$insert = db_process_sql_insert('tagent_custom_fields_filter', $values);
|
||||||
|
|
||||||
// check error insert
|
// Check error insert.
|
||||||
if ($insert) {
|
if ($insert) {
|
||||||
$result_array['error'] = 0;
|
$result_array['error'] = 0;
|
||||||
$result_array['msg'] = ui_print_success_message(
|
$result_array['msg'] = ui_print_success_message(
|
||||||
|
@ -644,17 +794,17 @@ if (check_login()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($update_filter_cf) {
|
if ($update_filter_cf) {
|
||||||
// initialize result
|
// Initialize result.
|
||||||
$result_array = [];
|
$result_array = [];
|
||||||
$result_array['error'] = 0;
|
$result_array['error'] = 0;
|
||||||
$result_array['msg'] = '';
|
$result_array['msg'] = '';
|
||||||
|
|
||||||
// initialize vars
|
// Initialize vars.
|
||||||
$filters = json_decode(io_safe_output(get_parameter('filters', '')), true);
|
$filters = json_decode(io_safe_output(get_parameter('filters', '')), true);
|
||||||
$id_filter = get_parameter('id_filter', '');
|
$id_filter = get_parameter('id_filter', '');
|
||||||
$group_search = get_parameter('group_search', 0);
|
$group_search = get_parameter('group_search', 0);
|
||||||
|
|
||||||
// check selected filter
|
// Check selected filter.
|
||||||
if ($id_filter == -1) {
|
if ($id_filter == -1) {
|
||||||
$result_array['error'] = 1;
|
$result_array['error'] = 1;
|
||||||
$result_array['msg'] = ui_print_error_message(
|
$result_array['msg'] = ui_print_error_message(
|
||||||
|
@ -666,11 +816,11 @@ if (check_login()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// array condition update
|
// Array condition update.
|
||||||
$condition = [];
|
$condition = [];
|
||||||
$condition['id'] = $id_filter;
|
$condition['id'] = $id_filter;
|
||||||
|
|
||||||
// check selected custom fields
|
// Check selected custom fields.
|
||||||
if ($filters['id_custom_fields'] == '') {
|
if ($filters['id_custom_fields'] == '') {
|
||||||
$result_array['error'] = 1;
|
$result_array['error'] = 1;
|
||||||
$result_array['msg'] = ui_print_error_message(
|
$result_array['msg'] = ui_print_error_message(
|
||||||
|
@ -682,7 +832,7 @@ if (check_login()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// array values update
|
// Array values update.
|
||||||
$values = [];
|
$values = [];
|
||||||
$values['id_group'] = $filters['group'];
|
$values['id_group'] = $filters['group'];
|
||||||
$values['group_search'] = $group_search;
|
$values['group_search'] = $group_search;
|
||||||
|
@ -693,10 +843,10 @@ if (check_login()) {
|
||||||
$values['module_status'] = json_encode($filters['module_status']);
|
$values['module_status'] = json_encode($filters['module_status']);
|
||||||
$values['recursion'] = $filters['recursion'];
|
$values['recursion'] = $filters['recursion'];
|
||||||
|
|
||||||
// update
|
// Update.
|
||||||
$update = db_process_sql_update('tagent_custom_fields_filter', $values, $condition);
|
$update = db_process_sql_update('tagent_custom_fields_filter', $values, $condition);
|
||||||
|
|
||||||
// check error insert
|
// Check error insert.
|
||||||
if ($update) {
|
if ($update) {
|
||||||
$result_array['error'] = 0;
|
$result_array['error'] = 0;
|
||||||
$result_array['msg'] = ui_print_success_message(
|
$result_array['msg'] = ui_print_success_message(
|
||||||
|
@ -718,16 +868,16 @@ if (check_login()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($delete_filter_cf) {
|
if ($delete_filter_cf) {
|
||||||
// Initialize result
|
// Initialize result.
|
||||||
$result_array = [];
|
$result_array = [];
|
||||||
$result_array['error'] = 0;
|
$result_array['error'] = 0;
|
||||||
$result_array['msg'] = '';
|
$result_array['msg'] = '';
|
||||||
|
|
||||||
// Initialize vars
|
// Initialize vars.
|
||||||
$filters = json_decode(io_safe_output(get_parameter('filters', '')), true);
|
$filters = json_decode(io_safe_output(get_parameter('filters', '')), true);
|
||||||
$id_filter = get_parameter('id_filter', '');
|
$id_filter = get_parameter('id_filter', '');
|
||||||
|
|
||||||
// Check selected filter
|
// Check selected filter.
|
||||||
if ($id_filter == -1) {
|
if ($id_filter == -1) {
|
||||||
$result_array['error'] = 1;
|
$result_array['error'] = 1;
|
||||||
$result_array['msg'] = ui_print_error_message(
|
$result_array['msg'] = ui_print_error_message(
|
||||||
|
@ -739,14 +889,14 @@ if (check_login()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Array condition update
|
// Array condition update.
|
||||||
$condition = [];
|
$condition = [];
|
||||||
$condition['id'] = $id_filter;
|
$condition['id'] = $id_filter;
|
||||||
|
|
||||||
// Delete
|
// Delete.
|
||||||
$delete = db_process_sql_delete('tagent_custom_fields_filter', $condition);
|
$delete = db_process_sql_delete('tagent_custom_fields_filter', $condition);
|
||||||
|
|
||||||
// Check error insert
|
// Check error insert.
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
$result_array['error'] = 0;
|
$result_array['error'] = 0;
|
||||||
$result_array['msg'] = ui_print_success_message(
|
$result_array['msg'] = ui_print_success_message(
|
||||||
|
|
|
@ -418,15 +418,15 @@ if ($get_extended_event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tabs.
|
// Tabs.
|
||||||
$tabs = "<ul style='background:#ffffff !important; border-top: 0px; border-left: 0px; border-right: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color: #D3D3D3;'>";
|
$tabs = "<ul class='events_tabs'>";
|
||||||
$tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('General').'</span></a></li>';
|
$tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png', true).'<span>'.__('General').'</span></a></li>';
|
||||||
if (events_has_extended_info($event['id_evento']) === true) {
|
if (events_has_extended_info($event['id_evento']) === true) {
|
||||||
$tabs .= "<li><a href='#extended_event_related_page' id='link_related'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Related').'</span></a></li>';
|
$tabs .= "<li><a href='#extended_event_related_page' id='link_related'>".html_print_image('images/zoom.png', true).'<span>'.__('Related').'</span></a></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$tabs .= "<li><a href='#extended_event_details_page' id='link_details'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Details').'</span></a></li>';
|
$tabs .= "<li><a href='#extended_event_details_page' id='link_details'>".html_print_image('images/zoom.png', true).'<span>'.__('Details').'</span></a></li>';
|
||||||
$tabs .= "<li><a href='#extended_event_custom_fields_page' id='link_custom_fields'>".html_print_image('images/custom_field_col.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Agent fields').'</span></a></li>';
|
$tabs .= "<li><a href='#extended_event_custom_fields_page' id='link_custom_fields'>".html_print_image('images/custom_field_col.png', true).'<span>'.__('Agent fields').'</span></a></li>';
|
||||||
$tabs .= "<li><a href='#extended_event_comments_page' id='link_comments'>".html_print_image('images/pencil.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Comments').'</span></a></li>';
|
$tabs .= "<li><a href='#extended_event_comments_page' id='link_comments'>".html_print_image('images/pencil.png', true).'<span>'.__('Comments').'</span></a></li>';
|
||||||
|
|
||||||
if (!$readonly
|
if (!$readonly
|
||||||
&& ((tags_checks_event_acl(
|
&& ((tags_checks_event_acl(
|
||||||
|
@ -546,7 +546,7 @@ if ($get_extended_event) {
|
||||||
|
|
||||||
$loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif', true).'</div>';
|
$loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif', true).'</div>';
|
||||||
|
|
||||||
$out = '<div id="tabs" style="height:95%; overflow: auto">'.$tabs.$notifications.$loading.$general.$details.$related.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>';
|
$out = '<div id="tabs">'.$tabs.$notifications.$loading.$general.$details.$related.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>';
|
||||||
|
|
||||||
$js = '<script>
|
$js = '<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
|
@ -82,11 +82,9 @@ if ($get_extended_info == 1) {
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->data = [];
|
$table->data = [];
|
||||||
$table->head = [];
|
$table->head = [];
|
||||||
$table->style[0] = 'min-width:120px; text-align: left;';
|
|
||||||
$table->style[1] = 'text-align: left;';
|
|
||||||
$table->cellspacing = 2;
|
$table->cellspacing = 2;
|
||||||
$table->cellpadding = 2;
|
$table->cellpadding = 2;
|
||||||
$table->class = 'alternate rounded_cells';
|
$table->class = 'events_show_more_table';
|
||||||
|
|
||||||
$output = [];
|
$output = [];
|
||||||
$output[] = '<b>'.__('Timestamp').'</b>';
|
$output[] = '<b>'.__('Timestamp').'</b>';
|
||||||
|
|
|
@ -1120,11 +1120,11 @@ if (check_login()) {
|
||||||
$draw_events = 0;
|
$draw_events = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$link = "winopeng('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&'.'id='.$module['id_agente_modulo'].'&'.'label='.rawurlencode(
|
$link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&'.'id='.$module['id_agente_modulo'].'&'.'label='.rawurlencode(
|
||||||
urlencode(
|
urlencode(
|
||||||
base64_encode($module['nombre'])
|
base64_encode($module['nombre'])
|
||||||
)
|
)
|
||||||
).'&'.'refresh='.SECONDS_10MINUTES.'&'."draw_events=$draw_events', 'day_".$win_handle."')";
|
).'&'.'refresh='.SECONDS_10MINUTES.'&'."draw_events=$draw_events', 'day_".$win_handle."', 1000, 650)";
|
||||||
if (!is_snapshot_data($module['datos'])) {
|
if (!is_snapshot_data($module['datos'])) {
|
||||||
$data[8] .= '<a href="javascript:'.$link.'">'.html_print_image('images/chart_curve.png', true, ['border' => '0', 'alt' => '']).'</a> ';
|
$data[8] .= '<a href="javascript:'.$link.'">'.html_print_image('images/chart_curve.png', true, ['border' => '0', 'alt' => '']).'</a> ';
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,9 @@ $api_password = get_parameter('apipass', '');
|
||||||
$password = get_parameter('pass', '');
|
$password = get_parameter('pass', '');
|
||||||
$user = get_parameter('user', '');
|
$user = get_parameter('user', '');
|
||||||
$info = get_parameter('info', '');
|
$info = get_parameter('info', '');
|
||||||
|
|
||||||
|
$other = parseOtherParameter($otherSerialize, $otherMode);
|
||||||
|
|
||||||
$other = parseOtherParameter($otherSerialize, $otherMode);
|
$other = parseOtherParameter($otherSerialize, $otherMode);
|
||||||
$apiPassword = io_output_password(db_get_value_filter('value', 'tconfig', ['token' => 'api_password']));
|
$apiPassword = io_output_password(db_get_value_filter('value', 'tconfig', ['token' => 'api_password']));
|
||||||
|
|
||||||
|
@ -104,6 +107,7 @@ if ($correctLogin) {
|
||||||
if ($op == 'set' && $id) {
|
if ($op == 'set' && $id) {
|
||||||
switch ($op2) {
|
switch ($op2) {
|
||||||
case 'update_agent':
|
case 'update_agent':
|
||||||
|
|
||||||
case 'add_module_in_conf':
|
case 'add_module_in_conf':
|
||||||
case 'update_module_in_conf':
|
case 'update_module_in_conf':
|
||||||
case 'delete_module_in_conf':
|
case 'delete_module_in_conf':
|
||||||
|
@ -184,6 +188,7 @@ if ($correctLogin) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
// break;
|
// break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -443,7 +443,7 @@ class CustomNetScan extends Wizard
|
||||||
'name' => 'taskname',
|
'name' => 'taskname',
|
||||||
'value' => $this->task['name'],
|
'value' => $this->task['name'],
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'size' => 25,
|
'size' => 50,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ class CustomNetScan extends Wizard
|
||||||
'name' => 'comment',
|
'name' => 'comment',
|
||||||
'value' => $this->task['description'],
|
'value' => $this->task['description'],
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'size' => 25,
|
'size' => 50,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -652,7 +652,7 @@ class CustomNetScan extends Wizard
|
||||||
'value' => $explanation,
|
'value' => $explanation,
|
||||||
'return' => true,
|
'return' => true,
|
||||||
'attributes' => 'style="width: 388px;"',
|
'attributes' => 'style="width: 388px;"',
|
||||||
'class' => 'discovery_textarea_input'
|
'class' => 'discovery_textarea_input',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -1684,7 +1684,12 @@ class NetworkMap
|
||||||
$node[$k] = $v;
|
$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';
|
$node['style']['shape'] = 'circle';
|
||||||
if (isset($source_data['color'])) {
|
if (isset($source_data['color'])) {
|
||||||
$item['color'] = $source_data['color'];
|
$item['color'] = $source_data['color'];
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
/**
|
/**
|
||||||
* Pandora build version and version
|
* Pandora build version and version
|
||||||
*/
|
*/
|
||||||
$build_version = 'PC190425';
|
$build_version = 'PC190513';
|
||||||
$pandora_version = 'v7.0NG.734';
|
$pandora_version = 'v7.0NG.734';
|
||||||
|
|
||||||
// Do not overwrite default timezone set if defined.
|
// Do not overwrite default timezone set if defined.
|
||||||
|
|
|
@ -205,7 +205,7 @@ function mysql_db_get_value($field, $table, $field_search=1, $condition=1, $sear
|
||||||
*
|
*
|
||||||
* @return mixed The first row of a database query or false.
|
* @return mixed The first row of a database query or false.
|
||||||
*/
|
*/
|
||||||
function mysql_db_get_row($table, $field_search, $condition, $fields=false)
|
function mysql_db_get_row($table, $field_search, $condition, $fields=false, $cache=true)
|
||||||
{
|
{
|
||||||
if (empty($fields)) {
|
if (empty($fields)) {
|
||||||
$fields = '*';
|
$fields = '*';
|
||||||
|
@ -243,7 +243,7 @@ function mysql_db_get_row($table, $field_search, $condition, $fields=false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = db_get_all_rows_sql($sql);
|
$result = db_get_all_rows_sql($sql, false, $cache);
|
||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -3541,25 +3541,27 @@ function series_type_graph_array($data, $show_elements_graph)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($show_elements_graph['labels'])
|
if (isset($show_elements_graph['labels'][$value['agent_module_id']])
|
||||||
&& is_array($show_elements_graph['labels'])
|
&& is_array($show_elements_graph['labels'])
|
||||||
&& (count($show_elements_graph['labels']) > 0)
|
&& (count($show_elements_graph['labels']) > 0)
|
||||||
) {
|
) {
|
||||||
if ($show_elements_graph['unit']) {
|
if ($show_elements_graph['unit']) {
|
||||||
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$show_elements_graph['unit'].': ';
|
$name_legend = $show_elements_graph['labels'][$value['agent_module_id']].' / '.__('Unit ').' '.$show_elements_graph['unit'].': ';
|
||||||
|
$data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']].' / '.__('Unit ').' '.$show_elements_graph['unit'].': ';
|
||||||
} else {
|
} else {
|
||||||
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].': ';
|
$name_legend = $show_elements_graph['labels'][$value['agent_module_id']].': ';
|
||||||
|
$data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']].': ';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (strpos($key, 'baseline') !== false) {
|
if (strpos($key, 'baseline') !== false) {
|
||||||
if ($show_elements_graph['unit']) {
|
if ($value['unit']) {
|
||||||
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$show_elements_graph['unit'].'Baseline ';
|
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$value['unit'].'Baseline ';
|
||||||
} else {
|
} else {
|
||||||
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].'Baseline ';
|
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].'Baseline ';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($show_elements_graph['unit']) {
|
if ($value['unit']) {
|
||||||
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$show_elements_graph['unit'].': ';
|
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$value['unit'].': ';
|
||||||
} else {
|
} else {
|
||||||
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].': ';
|
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].': ';
|
||||||
}
|
}
|
||||||
|
@ -3853,9 +3855,10 @@ function pandora_xhprof_display_result($key='', $method='link')
|
||||||
/**
|
/**
|
||||||
* From a network with a mask remove the smallest ip and the highest
|
* From a network with a mask remove the smallest ip and the highest
|
||||||
*
|
*
|
||||||
* @param string address to identify the network.
|
* @param string $address Identify the network.
|
||||||
* @param string mask to identify the mask network
|
* @param string $mask Identify the mask network.
|
||||||
* @return array or false with smallest ip and highest ip
|
*
|
||||||
|
* @return array or false with smallest ip and highest ip.
|
||||||
*/
|
*/
|
||||||
function range_ips_for_network($address, $mask)
|
function range_ips_for_network($address, $mask)
|
||||||
{
|
{
|
||||||
|
@ -3863,15 +3866,15 @@ function range_ips_for_network($address, $mask)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert ip addresses to long form
|
// Convert ip addresses to long form.
|
||||||
$address_long = ip2long($address);
|
$address_long = ip2long($address);
|
||||||
$mask_long = ip2long($mask);
|
$mask_long = ip2long($mask);
|
||||||
|
|
||||||
// caculate first usable address
|
// Calculate first usable address.
|
||||||
$ip_host_first = ((~$mask_long) & $address_long);
|
$ip_host_first = ((~$mask_long) & $address_long);
|
||||||
$ip_first = (($address_long ^ $ip_host_first) + 1);
|
$ip_first = (($address_long ^ $ip_host_first));
|
||||||
|
|
||||||
// caculate last usable address
|
// Calculate last usable address.
|
||||||
$ip_broadcast_invert = ~$mask_long;
|
$ip_broadcast_invert = ~$mask_long;
|
||||||
$ip_last = (($address_long | $ip_broadcast_invert) - 1);
|
$ip_last = (($address_long | $ip_broadcast_invert) - 1);
|
||||||
|
|
||||||
|
@ -3887,9 +3890,10 @@ function range_ips_for_network($address, $mask)
|
||||||
/**
|
/**
|
||||||
* from two ips find out if there is such an ip
|
* from two ips find out if there is such an ip
|
||||||
*
|
*
|
||||||
* @param string ip ip wont validate
|
* @param string ip ip wont validate
|
||||||
* @param string ip_lower
|
* @param string ip_lower
|
||||||
* @param string ip_upper
|
* @param string ip_upper
|
||||||
|
*
|
||||||
* @return boolean true or false if the ip is between the two ips
|
* @return boolean true or false if the ip is between the two ips
|
||||||
*/
|
*/
|
||||||
function is_in_network($ip, $ip_lower, $ip_upper)
|
function is_in_network($ip, $ip_lower, $ip_upper)
|
||||||
|
|
|
@ -328,14 +328,21 @@ function agents_get_alerts_simple($id_agent=false, $filter='', $options=false, $
|
||||||
*
|
*
|
||||||
* By default, it will return all the agents where the user has reading access.
|
* By default, it will return all the agents where the user has reading access.
|
||||||
*
|
*
|
||||||
* @param array filter options in an indexed array. See
|
* @param array $filter Filter options in an indexed array.
|
||||||
* db_format_array_where_clause_sql()
|
* See db_format_array_where_clause_sql().
|
||||||
* @param array Fields to get.
|
* @param array $fields DB fields to get.
|
||||||
* @param string Access needed in the agents groups.
|
* @param string $access ACL level needed in the agents groups.
|
||||||
* @param array $order The order of agents, by default is upward for field nombre.
|
* @param array $order The order of agents, by default is upward
|
||||||
* @param boolean $return Whether to return array with agents or false, or sql string statement
|
* for field nombre.
|
||||||
|
* @param boolean $return Whether to return array with agents or
|
||||||
|
* the sql string statement.
|
||||||
|
* @param boolean $disabled_agent Whether to return only the enabled agents
|
||||||
|
* or not.
|
||||||
|
* @param boolean $use_meta_table Whether to use the regular or the meta table
|
||||||
|
* to retrieve the agents.
|
||||||
*
|
*
|
||||||
* @return mixed An array with all alerts defined for an agent or false in case no allowed groups are specified.
|
* @return mixed An array with all alerts defined for an agent
|
||||||
|
* or false in case no allowed groups are specified.
|
||||||
*/
|
*/
|
||||||
function agents_get_agents(
|
function agents_get_agents(
|
||||||
$filter=false,
|
$filter=false,
|
||||||
|
@ -346,7 +353,8 @@ function agents_get_agents(
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
],
|
],
|
||||||
$return=false,
|
$return=false,
|
||||||
$disabled_agent=0
|
$disabled_agent=0,
|
||||||
|
$use_meta_table=false
|
||||||
) {
|
) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -563,11 +571,15 @@ function agents_get_agents(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$table_name = ($use_meta_table === true) ? 'tmetaconsole_agent' : 'tagente';
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
'SELECT DISTINCT %s
|
'SELECT DISTINCT %s
|
||||||
FROM tagente LEFT JOIN tagent_secondary_group ON tagent_secondary_group.id_agent=tagente.id_agente
|
FROM `%s` tagente
|
||||||
|
LEFT JOIN tagent_secondary_group
|
||||||
|
ON tagent_secondary_group.id_agent=tagente.id_agente
|
||||||
WHERE %s %s',
|
WHERE %s %s',
|
||||||
implode(',', $fields),
|
implode(',', $fields),
|
||||||
|
$table_name,
|
||||||
$where,
|
$where,
|
||||||
$order
|
$order
|
||||||
);
|
);
|
||||||
|
|
|
@ -664,6 +664,7 @@ function alerts_get_alert_templates_types()
|
||||||
$types['unknown'] = __('Unknown status');
|
$types['unknown'] = __('Unknown status');
|
||||||
$types['onchange'] = __('On Change');
|
$types['onchange'] = __('On Change');
|
||||||
$types['always'] = __('Always');
|
$types['always'] = __('Always');
|
||||||
|
$types['not_normal'] = __('Not normal status');
|
||||||
|
|
||||||
return $types;
|
return $types;
|
||||||
}
|
}
|
||||||
|
@ -680,7 +681,7 @@ function alerts_get_alert_templates_type_name($type)
|
||||||
{
|
{
|
||||||
$types = alerts_get_alert_templates_types();
|
$types = alerts_get_alert_templates_types();
|
||||||
|
|
||||||
if (! isset($type[$type])) {
|
if (!isset($types[$type])) {
|
||||||
return __('Unknown');
|
return __('Unknown');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Extension to manage a list of gateways and the node address where they should
|
|
||||||
* point to.
|
|
||||||
*
|
|
||||||
* @category API
|
|
||||||
* @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.
|
|
||||||
* ============================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
// Pandora FMS- http://pandorafms.com
|
||||||
|
// ==================================================
|
||||||
|
// Copyright (c) 2005-2009 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;
|
global $config;
|
||||||
|
|
||||||
// Set character encoding to UTF-8
|
// Set character encoding to UTF-8 - fixes a lot of multibyte character headaches
|
||||||
// fixes a lot of multibyte character headaches.
|
|
||||||
require_once 'functions_agents.php';
|
require_once 'functions_agents.php';
|
||||||
require_once 'functions_modules.php';
|
require_once 'functions_modules.php';
|
||||||
require_once $config['homedir'].'/include/functions_profile.php';
|
require_once $config['homedir'].'/include/functions_profile.php';
|
||||||
|
@ -254,7 +237,7 @@ function returnData($returnType, $data, $separator=';')
|
||||||
case 'json':
|
case 'json':
|
||||||
$data = array_apply_io_safe_output($data);
|
$data = array_apply_io_safe_output($data);
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
// Allows extra parameters to json_encode, like JSON_FORCE_OBJECT.
|
// Allows extra parameters to json_encode, like JSON_FORCE_OBJECT
|
||||||
if ($separator == ';') {
|
if ($separator == ';') {
|
||||||
$separator = null;
|
$separator = null;
|
||||||
}
|
}
|
||||||
|
@ -559,6 +542,7 @@ $module_field_column_mampping = [
|
||||||
'module_critical_inverse' => 'critical_inverse as module_critical_inverse',
|
'module_critical_inverse' => 'critical_inverse as module_critical_inverse',
|
||||||
'module_warning_inverse' => 'warning_inverse as module_warning_inverse',
|
'module_warning_inverse' => 'warning_inverse as module_warning_inverse',
|
||||||
];
|
];
|
||||||
|
|
||||||
// module related field mappings 2/2 (output field => column for 'tagente_estado')
|
// module related field mappings 2/2 (output field => column for 'tagente_estado')
|
||||||
// module_id_agent_modulo is not in this list
|
// module_id_agent_modulo is not in this list
|
||||||
$estado_fields_to_columns_mapping = [
|
$estado_fields_to_columns_mapping = [
|
||||||
|
@ -3030,20 +3014,21 @@ function api_get_policy_modules($thrash1, $thrash2, $other, $thrash3)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a network module in agent.
|
* Create a network module in agent. And return the id_agent_module of new module.
|
||||||
* And return the id_agent_module of new module.
|
|
||||||
*
|
*
|
||||||
* @param string $id Name of agent to add the module.
|
* @param string $id Name of agent to add the module.
|
||||||
* @param string $thrash1 Don't use.
|
* @param $thrash1 Don't use.
|
||||||
* @param array $other It's array, $other as param is <name_module>;<disabled>;<id_module_type>;
|
* @param array $other it's array, $other as param is <name_module>;<disabled>;<id_module_type>;
|
||||||
* <id_module_group>;<min_warning>;<max_warning>;<str_warning>;<min_critical>;<max_critical>;<str_critical>;<ff_threshold>;
|
* <id_module_group>;<min_warning>;<max_warning>;<str_warning>;<min_critical>;<max_critical>;<str_critical>;<ff_threshold>;
|
||||||
* <history_data>;<ip_target>;<module_port>;<snmp_community>;<snmp_oid>;<module_interval>;<post_process>;
|
* <history_data>;<ip_target>;<module_port>;<snmp_community>;<snmp_oid>;<module_interval>;<post_process>;
|
||||||
* <min>;<max>;<custom_id>;<description>;<disabled_types_event>;<module_macros>;
|
* <min>;<max>;<custom_id>;<description>;<disabled_types_event>;<module_macros>;
|
||||||
* <each_ff>;<ff_threshold_normal>;<ff_threshold_warning>;<ff_threshold_critical>; in this order
|
* <each_ff>;<ff_threshold_normal>;<ff_threshold_warning>;<ff_threshold_critical>; in this order
|
||||||
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>).
|
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>)
|
||||||
* @param string $thrash3 Don't use.
|
* example:
|
||||||
* @example: api.php?op=set&op2=create_network_module&id=pepito&other=prueba|0|7|1|10|15|0|16|18|0|15|0|www.google.es|0||0|180|0|0|0|0|latency%20ping&other_mode=url_encode_separator_|*
|
*
|
||||||
* @return mixed Return.
|
* api.php?op=set&op2=create_network_module&id=pepito&other=prueba|0|7|1|10|15|0|16|18|0|15|0|www.google.es|0||0|180|0|0|0|0|latency%20ping&other_mode=url_encode_separator_|
|
||||||
|
*
|
||||||
|
* @param $thrash3 Don't use
|
||||||
*/
|
*/
|
||||||
function api_set_create_network_module($id, $thrash1, $other, $thrash3)
|
function api_set_create_network_module($id, $thrash1, $other, $thrash3)
|
||||||
{
|
{
|
||||||
|
@ -3105,23 +3090,22 @@ function api_set_create_network_module($id, $thrash1, $other, $thrash3)
|
||||||
'min_ff_event_critical' => $other['data'][27],
|
'min_ff_event_critical' => $other['data'][27],
|
||||||
'critical_inverse' => $other['data'][28],
|
'critical_inverse' => $other['data'][28],
|
||||||
'warning_inverse' => $other['data'][29],
|
'warning_inverse' => $other['data'][29],
|
||||||
'ff_type' => $other['data'][30],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if (! $values['descripcion']) {
|
if (! $values['descripcion']) {
|
||||||
$values['descripcion'] = '';
|
$values['descripcion'] = '';
|
||||||
// Column 'descripcion' cannot be null.
|
// Column 'descripcion' cannot be null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $values['module_macros']) {
|
if (! $values['module_macros']) {
|
||||||
$values['module_macros'] = '';
|
$values['module_macros'] = '';
|
||||||
// Column 'module_macros' cannot be null.
|
// Column 'module_macros' cannot be null
|
||||||
}
|
}
|
||||||
|
|
||||||
$idModule = modules_create_agent_module($idAgent, $name, $values, true);
|
$idModule = modules_create_agent_module($idAgent, $name, $values, true);
|
||||||
|
|
||||||
if (is_error($idModule)) {
|
if (is_error($idModule)) {
|
||||||
// TODO: Improve the error returning more info.
|
// TODO: Improve the error returning more info
|
||||||
returnError('error_create_network_module', __('Error in creation network module.'));
|
returnError('error_create_network_module', __('Error in creation network module.'));
|
||||||
} else {
|
} else {
|
||||||
returnData('string', ['type' => 'string', 'data' => $idModule]);
|
returnData('string', ['type' => 'string', 'data' => $idModule]);
|
||||||
|
@ -3238,7 +3222,6 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3)
|
||||||
'critical_inverse',
|
'critical_inverse',
|
||||||
'warning_inverse',
|
'warning_inverse',
|
||||||
'policy_linked',
|
'policy_linked',
|
||||||
'ff_type',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
@ -3343,23 +3326,22 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3)
|
||||||
'min_ff_event_critical' => $other['data'][32],
|
'min_ff_event_critical' => $other['data'][32],
|
||||||
'critical_inverse' => $other['data'][33],
|
'critical_inverse' => $other['data'][33],
|
||||||
'warning_inverse' => $other['data'][34],
|
'warning_inverse' => $other['data'][34],
|
||||||
'ff_type' => $other['data'][35],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if (! $values['descripcion']) {
|
if (! $values['descripcion']) {
|
||||||
$values['descripcion'] = '';
|
$values['descripcion'] = '';
|
||||||
// Column 'descripcion' cannot be null.
|
// Column 'descripcion' cannot be null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $values['module_macros']) {
|
if (! $values['module_macros']) {
|
||||||
$values['module_macros'] = '';
|
$values['module_macros'] = '';
|
||||||
// Column 'module_macros' cannot be null.
|
// Column 'module_macros' cannot be null
|
||||||
}
|
}
|
||||||
|
|
||||||
$idModule = modules_create_agent_module($idAgent, $name, $values, true);
|
$idModule = modules_create_agent_module($idAgent, $name, $values, true);
|
||||||
|
|
||||||
if (is_error($idModule)) {
|
if (is_error($idModule)) {
|
||||||
// TODO: Improve the error returning more info.
|
// TODO: Improve the error returning more info
|
||||||
returnError('error_create_plugin_module', __('Error in creation plugin module.'));
|
returnError('error_create_plugin_module', __('Error in creation plugin module.'));
|
||||||
} else {
|
} else {
|
||||||
returnData('string', ['type' => 'string', 'data' => $idModule]);
|
returnData('string', ['type' => 'string', 'data' => $idModule]);
|
||||||
|
@ -3405,7 +3387,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we want to change the module to a new agent.
|
// If we want to change the module to a new agent
|
||||||
if ($other['data'][0] != '') {
|
if ($other['data'][0] != '') {
|
||||||
if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) {
|
if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) {
|
||||||
return;
|
return;
|
||||||
|
@ -3422,7 +3404,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if agent exists.
|
// Check if agent exists
|
||||||
$check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]);
|
$check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]);
|
||||||
if (!$check_id_agent) {
|
if (!$check_id_agent) {
|
||||||
returnError('error_update_data_module', __('Error updating plugin module. Id_agent doesn\'t exist.'));
|
returnError('error_update_data_module', __('Error updating plugin module. Id_agent doesn\'t exist.'));
|
||||||
|
@ -3466,7 +3448,6 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3)
|
||||||
'critical_inverse',
|
'critical_inverse',
|
||||||
'warning_inverse',
|
'warning_inverse',
|
||||||
'policy_linked',
|
'policy_linked',
|
||||||
'ff_type',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
@ -3565,23 +3546,22 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3)
|
||||||
'ff_timeout' => $other['data'][23],
|
'ff_timeout' => $other['data'][23],
|
||||||
'critical_inverse' => $other['data'][24],
|
'critical_inverse' => $other['data'][24],
|
||||||
'warning_inverse' => $other['data'][25],
|
'warning_inverse' => $other['data'][25],
|
||||||
'ff_type' => $other['data'][26],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if (! $values['descripcion']) {
|
if (! $values['descripcion']) {
|
||||||
$values['descripcion'] = '';
|
$values['descripcion'] = '';
|
||||||
// Column 'descripcion' cannot be null.
|
// Column 'descripcion' cannot be null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $values['module_macros']) {
|
if (! $values['module_macros']) {
|
||||||
$values['module_macros'] = '';
|
$values['module_macros'] = '';
|
||||||
// Column 'module_macros' cannot be null.
|
// Column 'module_macros' cannot be null
|
||||||
}
|
}
|
||||||
|
|
||||||
$idModule = modules_create_agent_module($idAgent, $name, $values, true);
|
$idModule = modules_create_agent_module($idAgent, $name, $values, true);
|
||||||
|
|
||||||
if (is_error($idModule)) {
|
if (is_error($idModule)) {
|
||||||
// TODO: Improve the error returning more info.
|
// TODO: Improve the error returning more info
|
||||||
returnError('error_create_data_module', __('Error in creation data module.'));
|
returnError('error_create_data_module', __('Error in creation data module.'));
|
||||||
} else {
|
} else {
|
||||||
returnData('string', ['type' => 'string', 'data' => $idModule]);
|
returnData('string', ['type' => 'string', 'data' => $idModule]);
|
||||||
|
@ -3838,7 +3818,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we want to change the module to a new agent.
|
// If we want to change the module to a new agent
|
||||||
if ($other['data'][0] != '') {
|
if ($other['data'][0] != '') {
|
||||||
if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) {
|
if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) {
|
||||||
return;
|
return;
|
||||||
|
@ -3855,7 +3835,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if agent exists.
|
// Check if agent exists
|
||||||
$check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]);
|
$check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]);
|
||||||
if (!$check_id_agent) {
|
if (!$check_id_agent) {
|
||||||
returnError('error_update_data_module', __('Error updating data module. Id_agent doesn\'t exist.'));
|
returnError('error_update_data_module', __('Error updating data module. Id_agent doesn\'t exist.'));
|
||||||
|
@ -3890,7 +3870,6 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3)
|
||||||
'critical_inverse',
|
'critical_inverse',
|
||||||
'warning_inverse',
|
'warning_inverse',
|
||||||
'policy_linked',
|
'policy_linked',
|
||||||
'ff_type',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
|
@ -3968,7 +3947,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3)
|
||||||
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int) !$other['data'][27];
|
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int) !$other['data'][27];
|
||||||
$disabled_types_event = json_encode($disabled_types_event);
|
$disabled_types_event = json_encode($disabled_types_event);
|
||||||
|
|
||||||
// SNMP version 3.
|
// SNMP version 3
|
||||||
if ($other['data'][14] == '3') {
|
if ($other['data'][14] == '3') {
|
||||||
if ($other['data'][23] != 'AES' and $other['data'][23] != 'DES') {
|
if ($other['data'][23] != 'AES' and $other['data'][23] != 'DES') {
|
||||||
returnError('error_create_snmp_module', __('Error in creation SNMP module. snmp3_priv_method doesn\'t exist. Set it to \'AES\' or \'DES\'. '));
|
returnError('error_create_snmp_module', __('Error in creation SNMP module. snmp3_priv_method doesn\'t exist. Set it to \'AES\' or \'DES\'. '));
|
||||||
|
@ -4021,7 +4000,6 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3)
|
||||||
'min_ff_event_normal' => $other['data'][31],
|
'min_ff_event_normal' => $other['data'][31],
|
||||||
'min_ff_event_warning' => $other['data'][32],
|
'min_ff_event_warning' => $other['data'][32],
|
||||||
'min_ff_event_critical' => $other['data'][33],
|
'min_ff_event_critical' => $other['data'][33],
|
||||||
'ff_type' => $other['data'][34],
|
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$values = [
|
$values = [
|
||||||
|
@ -4054,19 +4032,18 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3)
|
||||||
'min_ff_event_normal' => $other['data'][25],
|
'min_ff_event_normal' => $other['data'][25],
|
||||||
'min_ff_event_warning' => $other['data'][26],
|
'min_ff_event_warning' => $other['data'][26],
|
||||||
'min_ff_event_critical' => $other['data'][27],
|
'min_ff_event_critical' => $other['data'][27],
|
||||||
'ff_type' => $other['data'][28],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $values['descripcion']) {
|
if (! $values['descripcion']) {
|
||||||
$values['descripcion'] = '';
|
$values['descripcion'] = '';
|
||||||
// Column 'descripcion' cannot be null.
|
// Column 'descripcion' cannot be null
|
||||||
}
|
}
|
||||||
|
|
||||||
$idModule = modules_create_agent_module($idAgent, $name, $values, true);
|
$idModule = modules_create_agent_module($idAgent, $name, $values, true);
|
||||||
|
|
||||||
if (is_error($idModule)) {
|
if (is_error($idModule)) {
|
||||||
// TODO: Improve the error returning more info.
|
// TODO: Improve the error returning more info
|
||||||
returnError('error_create_snmp_module', __('Error in creation SNMP module.'));
|
returnError('error_create_snmp_module', __('Error in creation SNMP module.'));
|
||||||
} else {
|
} else {
|
||||||
returnData('string', ['type' => 'string', 'data' => $idModule]);
|
returnData('string', ['type' => 'string', 'data' => $idModule]);
|
||||||
|
@ -4114,7 +4091,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we want to change the module to a new agent.
|
// If we want to change the module to a new agent
|
||||||
if ($other['data'][0] != '') {
|
if ($other['data'][0] != '') {
|
||||||
if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) {
|
if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) {
|
||||||
return;
|
return;
|
||||||
|
@ -4131,7 +4108,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if agent exists.
|
// Check if agent exists
|
||||||
$check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]);
|
$check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]);
|
||||||
if (!$check_id_agent) {
|
if (!$check_id_agent) {
|
||||||
returnError('error_update_data_module', __('Error updating snmp module. Id_agent doesn\'t exist.'));
|
returnError('error_update_data_module', __('Error updating snmp module. Id_agent doesn\'t exist.'));
|
||||||
|
@ -4139,7 +4116,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SNMP version 3.
|
// SNMP version 3
|
||||||
if ($other['data'][13] == '3') {
|
if ($other['data'][13] == '3') {
|
||||||
if ($other['data'][22] != 'AES' and $other['data'][22] != 'DES') {
|
if ($other['data'][22] != 'AES' and $other['data'][22] != 'DES') {
|
||||||
returnError(
|
returnError(
|
||||||
|
@ -4203,7 +4180,6 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
|
||||||
'min_ff_event_warning',
|
'min_ff_event_warning',
|
||||||
'min_ff_event_critical',
|
'min_ff_event_critical',
|
||||||
'policy_linked',
|
'policy_linked',
|
||||||
'ff_type',
|
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$snmp_module_fields = [
|
$snmp_module_fields = [
|
||||||
|
@ -4235,7 +4211,6 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
|
||||||
'min_ff_event_warning',
|
'min_ff_event_warning',
|
||||||
'min_ff_event_critical',
|
'min_ff_event_critical',
|
||||||
'policy_linked',
|
'policy_linked',
|
||||||
'ff_type',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4333,7 +4308,6 @@ function api_set_new_network_component($id, $thrash1, $other, $thrash2)
|
||||||
'min_ff_event_normal' => $other['data'][20],
|
'min_ff_event_normal' => $other['data'][20],
|
||||||
'min_ff_event_warning' => $other['data'][21],
|
'min_ff_event_warning' => $other['data'][21],
|
||||||
'min_ff_event_critical' => $other['data'][22],
|
'min_ff_event_critical' => $other['data'][22],
|
||||||
'ff_type' => $other['data'][23],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$name_check = db_get_value('name', 'tnetwork_component', 'name', $id);
|
$name_check = db_get_value('name', 'tnetwork_component', 'name', $id);
|
||||||
|
@ -4434,7 +4408,6 @@ function api_set_new_plugin_component($id, $thrash1, $other, $thrash2)
|
||||||
'min_ff_event_normal' => $other['data'][24],
|
'min_ff_event_normal' => $other['data'][24],
|
||||||
'min_ff_event_warning' => $other['data'][25],
|
'min_ff_event_warning' => $other['data'][25],
|
||||||
'min_ff_event_critical' => $other['data'][26],
|
'min_ff_event_critical' => $other['data'][26],
|
||||||
'ff_type' => $other['data'][27],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$name_check = db_get_value('name', 'tnetwork_component', 'name', $id);
|
$name_check = db_get_value('name', 'tnetwork_component', 'name', $id);
|
||||||
|
@ -4570,7 +4543,6 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2)
|
||||||
'min_ff_event_normal' => $other['data'][29],
|
'min_ff_event_normal' => $other['data'][29],
|
||||||
'min_ff_event_warning' => $other['data'][30],
|
'min_ff_event_warning' => $other['data'][30],
|
||||||
'min_ff_event_critical' => $other['data'][31],
|
'min_ff_event_critical' => $other['data'][31],
|
||||||
'ff_type' => $other['data'][32],
|
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$values = [
|
$values = [
|
||||||
|
@ -4602,7 +4574,6 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2)
|
||||||
'min_ff_event_normal' => $other['data'][25],
|
'min_ff_event_normal' => $other['data'][25],
|
||||||
'min_ff_event_warning' => $other['data'][26],
|
'min_ff_event_warning' => $other['data'][26],
|
||||||
'min_ff_event_critical' => $other['data'][27],
|
'min_ff_event_critical' => $other['data'][27],
|
||||||
'ff_type' => $other['data'][28],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4613,7 +4584,7 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2)
|
||||||
return;
|
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) {
|
if (!$id) {
|
||||||
returnError('error_set_new_snmp_component', 'Error creating SNMP component.');
|
returnError('error_set_new_snmp_component', 'Error creating SNMP component.');
|
||||||
|
@ -4683,7 +4654,6 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2)
|
||||||
'min_ff_event_warning' => $other['data'][8],
|
'min_ff_event_warning' => $other['data'][8],
|
||||||
'min_ff_event_critical' => $other['data'][9],
|
'min_ff_event_critical' => $other['data'][9],
|
||||||
'ff_timeout' => $other['data'][10],
|
'ff_timeout' => $other['data'][10],
|
||||||
'ff_type' => $other['data'][11],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$name_check = enterprise_hook(
|
$name_check = enterprise_hook(
|
||||||
|
@ -6439,7 +6409,6 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3)
|
||||||
$values['min_ff_event_warning'] = $other['data'][21];
|
$values['min_ff_event_warning'] = $other['data'][21];
|
||||||
$values['min_ff_event_critical'] = $other['data'][22];
|
$values['min_ff_event_critical'] = $other['data'][22];
|
||||||
$values['ff_timeout'] = $other['data'][23];
|
$values['ff_timeout'] = $other['data'][23];
|
||||||
$values['ff_type'] = $other['data'][24];
|
|
||||||
|
|
||||||
if ($name_module_policy !== false) {
|
if ($name_module_policy !== false) {
|
||||||
if ($name_module_policy[0]['name'] == $other['data'][0]) {
|
if ($name_module_policy[0]['name'] == $other['data'][0]) {
|
||||||
|
@ -6681,7 +6650,6 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3)
|
||||||
$values['min_ff_event_normal'] = $other['data'][24];
|
$values['min_ff_event_normal'] = $other['data'][24];
|
||||||
$values['min_ff_event_warning'] = $other['data'][25];
|
$values['min_ff_event_warning'] = $other['data'][25];
|
||||||
$values['min_ff_event_critical'] = $other['data'][26];
|
$values['min_ff_event_critical'] = $other['data'][26];
|
||||||
$values['ff_type'] = $other['data'][27];
|
|
||||||
|
|
||||||
if ($name_module_policy !== false) {
|
if ($name_module_policy !== false) {
|
||||||
if ($name_module_policy[0]['name'] == $other['data'][0]) {
|
if ($name_module_policy[0]['name'] == $other['data'][0]) {
|
||||||
|
@ -6891,7 +6859,6 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3)
|
||||||
$values['min_ff_event_normal'] = $other['data'][29];
|
$values['min_ff_event_normal'] = $other['data'][29];
|
||||||
$values['min_ff_event_warning'] = $other['data'][30];
|
$values['min_ff_event_warning'] = $other['data'][30];
|
||||||
$values['min_ff_event_critical'] = $other['data'][31];
|
$values['min_ff_event_critical'] = $other['data'][31];
|
||||||
$values['ff_type'] = $other['data'][32];
|
|
||||||
|
|
||||||
if ($name_module_policy !== false) {
|
if ($name_module_policy !== false) {
|
||||||
if ($name_module_policy[0]['name'] == $other['data'][0]) {
|
if ($name_module_policy[0]['name'] == $other['data'][0]) {
|
||||||
|
@ -7309,7 +7276,6 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3)
|
||||||
'min_ff_event_normal' => $other['data'][30],
|
'min_ff_event_normal' => $other['data'][30],
|
||||||
'min_ff_event_warning' => $other['data'][31],
|
'min_ff_event_warning' => $other['data'][31],
|
||||||
'min_ff_event_critical' => $other['data'][32],
|
'min_ff_event_critical' => $other['data'][32],
|
||||||
'ff_type' => $other['data'][33],
|
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$values = [
|
$values = [
|
||||||
|
@ -7339,7 +7305,6 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3)
|
||||||
'min_ff_event_normal' => $other['data'][24],
|
'min_ff_event_normal' => $other['data'][24],
|
||||||
'min_ff_event_warning' => $other['data'][25],
|
'min_ff_event_warning' => $other['data'][25],
|
||||||
'min_ff_event_critical' => $other['data'][26],
|
'min_ff_event_critical' => $other['data'][26],
|
||||||
'ff_type' => $other['data'][27],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8829,14 +8794,7 @@ function api_set_alert_actions($id, $id2, $other, $trash1)
|
||||||
}
|
}
|
||||||
|
|
||||||
$firesMin = $other['data'][2];
|
$firesMin = $other['data'][2];
|
||||||
if (!$firesMin) {
|
|
||||||
$firesMin = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$firesMax = $other['data'][3];
|
$firesMax = $other['data'][3];
|
||||||
if (!$firesMax) {
|
|
||||||
$firesMax = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$values = [
|
$values = [
|
||||||
'id_alert_template_module' => $idAlertTemplateModule,
|
'id_alert_template_module' => $idAlertTemplateModule,
|
||||||
|
@ -13311,7 +13269,6 @@ function api_set_apply_module_template($id_template, $id_agent, $thrash3, $thras
|
||||||
'min_ff_event_normal' => $row2['min_ff_event_normal'],
|
'min_ff_event_normal' => $row2['min_ff_event_normal'],
|
||||||
'min_ff_event_warning' => $row2['min_ff_event_warning'],
|
'min_ff_event_warning' => $row2['min_ff_event_warning'],
|
||||||
'min_ff_event_critical' => $row2['min_ff_event_critical'],
|
'min_ff_event_critical' => $row2['min_ff_event_critical'],
|
||||||
'ff_type' => $row2['ff_type'],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$name = $row2['name'];
|
$name = $row2['name'];
|
||||||
|
|
|
@ -980,7 +980,11 @@ function config_update_config()
|
||||||
$error_update[] = __('Custom support url');
|
$error_update[] = __('Custom support url');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config_update_value('vc_refr', get_parameter('vc_refr'))) {
|
if (!config_update_value('legacy_vc', (int) get_parameter('legacy_vc'))) {
|
||||||
|
$error_update[] = __('Use the legacy Visual Console');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config_update_value('vc_refr', (int) get_parameter('vc_refr'))) {
|
||||||
$error_update[] = __('Default interval for refresh on Visual Console');
|
$error_update[] = __('Default interval for refresh on Visual Console');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2415,10 +2419,18 @@ function config_process_config()
|
||||||
config_update_value('dbtype', 'mysql');
|
config_update_value('dbtype', 'mysql');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($config['legacy_vc'])) {
|
||||||
|
config_update_value('legacy_vc', 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($config['vc_refr'])) {
|
if (!isset($config['vc_refr'])) {
|
||||||
config_update_value('vc_refr', 300);
|
config_update_value('vc_refr', 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($config['vc_line_thickness'])) {
|
||||||
|
config_update_value('vc_line_thickness', 2);
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($config['agent_size_text_small'])) {
|
if (!isset($config['agent_size_text_small'])) {
|
||||||
config_update_value('agent_size_text_small', 18);
|
config_update_value('agent_size_text_small', 18);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
// Pandora FMS - http://pandorafms.com
|
* Extension to manage a list of gateways and the node address where they should
|
||||||
// ==================================================
|
* point to.
|
||||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
*
|
||||||
// Please see http://pandorafms.org for full contribution list
|
* @category Custom fields View
|
||||||
// This program is free software; you can redistribute it and/or
|
* @package Pandora FMS
|
||||||
// modify it under the terms of the GNU Lesser General Public License
|
* @subpackage Community
|
||||||
// as published by the Free Software Foundation; version 2
|
* @version 1.0.0
|
||||||
// This program is distributed in the hope that it will be useful,
|
* @license See below
|
||||||
// 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.
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* 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 {
|
} else {
|
||||||
$metaconsole_connections = metaconsole_get_connection_names();
|
$metaconsole_connections = metaconsole_get_connection_names();
|
||||||
// For all nodes
|
// For all nodes.
|
||||||
if (isset($metaconsole_connections) && is_array($metaconsole_connections)) {
|
if (isset($metaconsole_connections) && is_array($metaconsole_connections)) {
|
||||||
$result_meta = [];
|
$result_meta = [];
|
||||||
foreach ($metaconsole_connections as $metaconsole) {
|
foreach ($metaconsole_connections as $metaconsole) {
|
||||||
// Get server connection data
|
// Get server connection data.
|
||||||
$server_data = metaconsole_get_connection($metaconsole);
|
$server_data = metaconsole_get_connection($metaconsole);
|
||||||
|
|
||||||
// Establishes connection
|
// Establishes connection.
|
||||||
if (metaconsole_load_external_db($server_data) !== NOERR) {
|
if (metaconsole_load_external_db($server_data) !== NOERR) {
|
||||||
continue;
|
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);
|
$result[] = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
// Restore connection to root node
|
// Restore connection to root node.
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
|
|
||||||
if (isset($result) && is_array($result)) {
|
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.
|
* Returns custom field data.
|
||||||
*
|
*
|
||||||
* @param integer custom_field_id id.
|
* @param integer $custom_field_name Custom_field_id id.
|
||||||
*
|
*
|
||||||
* @return array custom fields data.
|
* @return array custom fields data.
|
||||||
*/
|
*/
|
||||||
|
@ -141,14 +156,14 @@ function get_custom_fields_data($custom_field_name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$metaconsole_connections = metaconsole_get_connection_names();
|
$metaconsole_connections = metaconsole_get_connection_names();
|
||||||
// For all nodes
|
// For all nodes.
|
||||||
if (isset($metaconsole_connections) && is_array($metaconsole_connections)) {
|
if (isset($metaconsole_connections) && is_array($metaconsole_connections)) {
|
||||||
$result_meta = [];
|
$result_meta = [];
|
||||||
foreach ($metaconsole_connections as $metaconsole) {
|
foreach ($metaconsole_connections as $metaconsole) {
|
||||||
// Get server connection data
|
// Get server connection data.
|
||||||
$server_data = metaconsole_get_connection($metaconsole);
|
$server_data = metaconsole_get_connection($metaconsole);
|
||||||
|
|
||||||
// Establishes connection
|
// Establishes connection.
|
||||||
if (metaconsole_load_external_db($server_data) !== NOERR) {
|
if (metaconsole_load_external_db($server_data) !== NOERR) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +183,7 @@ function get_custom_fields_data($custom_field_name)
|
||||||
|
|
||||||
$result_meta[] = db_get_all_rows_sql($sql);
|
$result_meta[] = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
// Restore connection to root node
|
// Restore connection to root node.
|
||||||
metaconsole_restore_db();
|
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)
|
function agent_counters_custom_fields($filters)
|
||||||
{
|
{
|
||||||
// filter by status agent
|
// Filter by status agent.
|
||||||
$and_status = '';
|
$and_status = '';
|
||||||
|
|
||||||
$agent_state_normal = 0;
|
$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
|
$empty_agents_count = "UNION ALL
|
||||||
SELECT ta.id_agente,
|
SELECT ta.id_agente,
|
||||||
0 AS c_m_total,
|
0 AS c_m_total,
|
||||||
|
@ -314,20 +335,20 @@ function agent_counters_custom_fields($filters)
|
||||||
$and_module_status .= ' ) ';
|
$and_module_status .= ' ) ';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not normal
|
// Not normal.
|
||||||
$and_module_status = 'AND tae.estado <> 0 AND tae.estado <> 300 ';
|
$and_module_status = 'AND tae.estado <> 0 AND tae.estado <> 300 ';
|
||||||
$empty_agents_count = '';
|
$empty_agents_count = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// filters module
|
// Filters module.
|
||||||
if ($filters['module_search']) {
|
if ($filters['module_search']) {
|
||||||
$and_module_search = 'AND tam.nombre LIKE "%'.$filters['module_search'].'%"';
|
$and_module_search = 'AND tam.nombre LIKE "%'.$filters['module_search'].'%"';
|
||||||
$empty_agents_count = '';
|
$empty_agents_count = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter group and check ACL groups
|
// Filter group and check ACL groups.
|
||||||
$groups_and = '';
|
$groups_and = '';
|
||||||
if (!users_can_manage_group_all('AR')) {
|
if (!users_can_manage_group_all('AR')) {
|
||||||
if ($filters['group']) {
|
if ($filters['group']) {
|
||||||
|
@ -338,7 +359,7 @@ function agent_counters_custom_fields($filters)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filters['group']) {
|
if ($filters['group']) {
|
||||||
// recursion check acl
|
// Recursion check acl.
|
||||||
if ($filters['recursion']) {
|
if ($filters['recursion']) {
|
||||||
$recursion_groups = groups_get_id_recursive($filters['group'], true);
|
$recursion_groups = groups_get_id_recursive($filters['group'], true);
|
||||||
if (!users_can_manage_group_all('AR')) {
|
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 = '';
|
$custom_data_and = '';
|
||||||
if (!in_array(-1, $filters['id_custom_fields_data'])) {
|
if (!in_array(-1, $filters['id_custom_fields_data'])) {
|
||||||
$custom_data_array = implode("', '", $filters['id_custom_fields_data']);
|
$custom_data_array = implode("', '", $filters['id_custom_fields_data']);
|
||||||
$custom_data_and = "AND tcd.description IN ('".$custom_data_array."')";
|
$custom_data_and = "AND tcd.description IN ('".$custom_data_array."')";
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter custom name
|
// Filter custom name.
|
||||||
$custom_field_name = $filters['id_custom_fields'];
|
$custom_field_name = $filters['id_custom_fields'];
|
||||||
|
|
||||||
if (is_metaconsole()) {
|
if (is_metaconsole()) {
|
||||||
$metaconsole_connections = metaconsole_get_connection_names();
|
$metaconsole_connections = metaconsole_get_connection_names();
|
||||||
// For all nodes
|
// For all nodes.
|
||||||
if (isset($metaconsole_connections) && is_array($metaconsole_connections)) {
|
if (isset($metaconsole_connections) && is_array($metaconsole_connections)) {
|
||||||
$result_meta = [];
|
$result_meta = [];
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach ($metaconsole_connections as $metaconsole) {
|
foreach ($metaconsole_connections as $metaconsole) {
|
||||||
// Get server connection data
|
// Get server connection data.
|
||||||
$server_data = metaconsole_get_connection($metaconsole);
|
$server_data = metaconsole_get_connection($metaconsole);
|
||||||
// Establishes connection
|
// Establishes connection.
|
||||||
if (metaconsole_load_external_db($server_data) !== NOERR) {
|
if (metaconsole_load_external_db($server_data) !== NOERR) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -470,7 +491,13 @@ function agent_counters_custom_fields($filters)
|
||||||
WHEN ta.total_count = ta.notinit_count
|
WHEN ta.total_count = ta.notinit_count
|
||||||
THEN 5
|
THEN 5
|
||||||
ELSE 0
|
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
|
FROM tagente ta
|
||||||
LEFT JOIN tagent_secondary_group tasg
|
LEFT JOIN tagent_secondary_group tasg
|
||||||
ON ta.id_agente = tasg.id_agent
|
ON ta.id_agente = tasg.id_agent
|
||||||
|
@ -510,7 +537,7 @@ function agent_counters_custom_fields($filters)
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array_merge($data, $node_result);
|
$data = array_merge($data, $node_result);
|
||||||
// Restore connection to root node
|
// Restore connection to root node.
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -519,7 +546,7 @@ function agent_counters_custom_fields($filters)
|
||||||
$array_data = [];
|
$array_data = [];
|
||||||
|
|
||||||
if (isset($result_meta) && is_array($result_meta)) {
|
if (isset($result_meta) && is_array($result_meta)) {
|
||||||
// initialize counters
|
// Initialize counters.
|
||||||
$final_result['counters_total'] = [
|
$final_result['counters_total'] = [
|
||||||
't_m_normal' => 0,
|
't_m_normal' => 0,
|
||||||
't_m_critical' => 0,
|
't_m_critical' => 0,
|
||||||
|
@ -538,7 +565,7 @@ function agent_counters_custom_fields($filters)
|
||||||
foreach ($result_meta as $k => $nodo) {
|
foreach ($result_meta as $k => $nodo) {
|
||||||
if (isset($nodo) && is_array($nodo)) {
|
if (isset($nodo) && is_array($nodo)) {
|
||||||
foreach ($nodo as $key => $value) {
|
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_normal'] += $value['m_normal'];
|
||||||
$final_result['counters_total']['t_m_critical'] += $value['m_critical'];
|
$final_result['counters_total']['t_m_critical'] += $value['m_critical'];
|
||||||
$final_result['counters_total']['t_m_warning'] += $value['m_warning'];
|
$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_not_init'] += $value['a_not_init'];
|
||||||
$final_result['counters_total']['t_a_agents'] += $value['a_agents'];
|
$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_normal'] += $value['m_normal'];
|
||||||
$array_data[$value['name_data']]['m_critical'] += $value['m_critical'];
|
$array_data[$value['name_data']]['m_critical'] += $value['m_critical'];
|
||||||
$array_data[$value['name_data']]['m_warning'] += $value['m_warning'];
|
$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;
|
$final_result['indexed_descriptions'] = $data;
|
||||||
} else {
|
} else {
|
||||||
// TODO
|
// TODO.
|
||||||
$final_result = false;
|
$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='')
|
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 = '';
|
$groups_and = '';
|
||||||
if (!users_can_manage_group_all()) {
|
if (!users_can_manage_group_all()) {
|
||||||
$user_groups = array_keys(users_get_groups(false, 'AR', false));
|
$user_groups = array_keys(users_get_groups(false, 'AR', false));
|
||||||
|
@ -631,3 +658,38 @@ function get_group_filter_custom_field_view($id)
|
||||||
|
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -421,13 +421,13 @@ function db_get_row_sql($sql, $search_history_db=false)
|
||||||
*
|
*
|
||||||
* @return mixed The first row of a database query or false.
|
* @return mixed The first row of a database query or false.
|
||||||
*/
|
*/
|
||||||
function db_get_row($table, $field_search, $condition, $fields=false)
|
function db_get_row($table, $field_search, $condition, $fields=false, $cache=true)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
switch ($config['dbtype']) {
|
switch ($config['dbtype']) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
return mysql_db_get_row($table, $field_search, $condition, $fields);
|
return mysql_db_get_row($table, $field_search, $condition, $fields, $cache);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'postgresql':
|
case 'postgresql':
|
||||||
|
|
|
@ -1987,9 +1987,9 @@ function events_page_responses($event, $childrens_ids=[])
|
||||||
$table_responses->width = '100%';
|
$table_responses->width = '100%';
|
||||||
$table_responses->data = [];
|
$table_responses->data = [];
|
||||||
$table_responses->head = [];
|
$table_responses->head = [];
|
||||||
$table_responses->style[0] = 'width:35%; font-weight: bold; text-align: left; height: 23px;';
|
$table_responses->style[0] = 'height:30px';
|
||||||
$table_responses->style[1] = 'text-align: left; height: 23px; text-align: right;';
|
$table_responses->style[2] = 'text-align:right;';
|
||||||
$table_responses->class = 'alternate rounded_cells';
|
$table_responses->class = 'events_show_more_table';
|
||||||
|
|
||||||
if (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) {
|
if (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) {
|
||||||
// Owner.
|
// Owner.
|
||||||
|
@ -2056,7 +2056,7 @@ function events_page_responses($event, $childrens_ids=[])
|
||||||
-1,
|
-1,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
$data[1] .= html_print_button(
|
$data[2] .= html_print_button(
|
||||||
__('Update'),
|
__('Update'),
|
||||||
'owner_button',
|
'owner_button',
|
||||||
false,
|
false,
|
||||||
|
@ -2136,7 +2136,7 @@ function events_page_responses($event, $childrens_ids=[])
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$status_blocked) {
|
if (!$status_blocked) {
|
||||||
$data[1] .= html_print_button(
|
$data[2] .= html_print_button(
|
||||||
__('Update'),
|
__('Update'),
|
||||||
'status_button',
|
'status_button',
|
||||||
false,
|
false,
|
||||||
|
@ -2151,7 +2151,8 @@ function events_page_responses($event, $childrens_ids=[])
|
||||||
// Comments.
|
// Comments.
|
||||||
$data = [];
|
$data = [];
|
||||||
$data[0] = __('Comment');
|
$data[0] = __('Comment');
|
||||||
$data[1] = html_print_button(
|
$data[1] = '';
|
||||||
|
$data[2] = html_print_button(
|
||||||
__('Add comment'),
|
__('Add comment'),
|
||||||
'comment_button',
|
'comment_button',
|
||||||
false,
|
false,
|
||||||
|
@ -2173,8 +2174,9 @@ function events_page_responses($event, $childrens_ids=[])
|
||||||
// Delete.
|
// Delete.
|
||||||
$data = [];
|
$data = [];
|
||||||
$data[0] = __('Delete event');
|
$data[0] = __('Delete event');
|
||||||
$data[1] = '<form method="post">';
|
$data[1] = '';
|
||||||
$data[1] .= html_print_button(
|
$data[2] = '<form method="post">';
|
||||||
|
$data[2] .= html_print_button(
|
||||||
__('Delete event'),
|
__('Delete event'),
|
||||||
'delete_button',
|
'delete_button',
|
||||||
false,
|
false,
|
||||||
|
@ -2182,13 +2184,13 @@ function events_page_responses($event, $childrens_ids=[])
|
||||||
'class="sub cancel"',
|
'class="sub cancel"',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
$data[1] .= html_print_input_hidden('delete', 1, true);
|
$data[2] .= html_print_input_hidden('delete', 1, true);
|
||||||
$data[1] .= html_print_input_hidden(
|
$data[2] .= html_print_input_hidden(
|
||||||
'validate_ids',
|
'validate_ids',
|
||||||
$event['id_evento'],
|
$event['id_evento'],
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
$data[1] .= '</form>';
|
$data[2] .= '</form>';
|
||||||
|
|
||||||
$table_responses->data[] = $data;
|
$table_responses->data[] = $data;
|
||||||
}
|
}
|
||||||
|
@ -2229,7 +2231,7 @@ function events_page_responses($event, $childrens_ids=[])
|
||||||
$server_id = 0;
|
$server_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[1] .= html_print_button(
|
$data[2] .= html_print_button(
|
||||||
__('Execute'),
|
__('Execute'),
|
||||||
'custom_response_button',
|
'custom_response_button',
|
||||||
false,
|
false,
|
||||||
|
@ -2249,14 +2251,14 @@ function events_page_responses($event, $childrens_ids=[])
|
||||||
$('.params_rows').remove();
|
$('.params_rows').remove();
|
||||||
|
|
||||||
$('#responses_table')
|
$('#responses_table')
|
||||||
.append('<tr class=\"params_rows\"><td style=\"text-align:left; font-weight: bolder;\">".__('Description')."</td><td style=\"text-align:left;\">'+description+'</td></tr>');
|
.append('<tr class=\"params_rows\"><td>".__('Description')."</td><td style=\"text-align:left; height:30px;\" colspan=\"2\">'+description+'</td></tr>');
|
||||||
|
|
||||||
if (params.length == 1 && params[0] == '') {
|
if (params.length == 1 && params[0] == '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#responses_table')
|
$('#responses_table')
|
||||||
.append('<tr class=\"params_rows\"><td style=\"text-align:left; padding-left:20px;\" colspan=\"2\">".__('Parameters')."</td></tr>');
|
.append('<tr class=\"params_rows\"><td style=\"text-align:left; padding-left:20px; height:30px;\" colspan=\"3\">".__('Parameters')."</td></tr>');
|
||||||
|
|
||||||
for (i = 0; i < params.length; i++) {
|
for (i = 0; i < params.length; i++) {
|
||||||
add_row_param('responses_table',params[i]);
|
add_row_param('responses_table',params[i]);
|
||||||
|
@ -2521,9 +2523,7 @@ function events_page_custom_fields($event)
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->data = [];
|
$table->data = [];
|
||||||
$table->head = [];
|
$table->head = [];
|
||||||
$table->style[0] = 'width:35%; font-weight: bold; text-align: left; height: 23px;';
|
$table->class = 'events_show_more_table';
|
||||||
$table->style[1] = 'text-align: left; height: 23px;';
|
|
||||||
$table->class = 'alternate rounded_cells';
|
|
||||||
|
|
||||||
$all_customs_fields = (bool) check_acl(
|
$all_customs_fields = (bool) check_acl(
|
||||||
$config['id_user'],
|
$config['id_user'],
|
||||||
|
@ -2671,11 +2671,9 @@ function events_page_details($event, $server='')
|
||||||
$table_details->width = '100%';
|
$table_details->width = '100%';
|
||||||
$table_details->data = [];
|
$table_details->data = [];
|
||||||
$table_details->head = [];
|
$table_details->head = [];
|
||||||
$table_details->cellspacing = 2;
|
$table_details->cellspacing = 0;
|
||||||
$table_details->cellpadding = 2;
|
$table_details->cellpadding = 0;
|
||||||
$table_details->style[0] = 'width:35%; font-weight: bold; text-align: left; height: 23px;';
|
$table_details->class = 'events_show_more_table';
|
||||||
$table_details->style[1] = 'text-align: left; height: 23px;';
|
|
||||||
$table_details->class = 'alternate rounded_cells';
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Useless switch.
|
* Useless switch.
|
||||||
|
@ -2985,9 +2983,7 @@ function events_page_custom_data($event)
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->data = [];
|
$table->data = [];
|
||||||
$table->head = [];
|
$table->head = [];
|
||||||
$table->style[0] = 'width:35%; font-weight: bold; text-align: left;';
|
$table->class = 'events_show_more_table';
|
||||||
$table->style[1] = 'text-align: left;';
|
|
||||||
$table->class = 'alternate rounded_cells';
|
|
||||||
|
|
||||||
$json_custom_data = base64_decode($event['custom_data']);
|
$json_custom_data = base64_decode($event['custom_data']);
|
||||||
$custom_data = json_decode($json_custom_data);
|
$custom_data = json_decode($json_custom_data);
|
||||||
|
@ -3137,14 +3133,12 @@ function events_page_general($event)
|
||||||
|
|
||||||
// General.
|
// General.
|
||||||
$table_general = new stdClass;
|
$table_general = new stdClass;
|
||||||
$table_general->cellspacing = 2;
|
$table_general->cellspacing = 0;
|
||||||
$table_general->cellpadding = 2;
|
$table_general->cellpadding = 0;
|
||||||
$table_general->width = '100%';
|
$table_general->width = '100%';
|
||||||
$table_general->data = [];
|
$table_general->data = [];
|
||||||
$table_general->head = [];
|
$table_general->head = [];
|
||||||
$table_general->style[0] = 'width:35%; font-weight: bold; text-align: left; height: 23px;';
|
$table_general->class = 'events_show_more_table';
|
||||||
$table_general->style[1] = 'text-align: left; height: 23px;';
|
|
||||||
$table_general->class = 'alternate rounded_cells';
|
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
$data[0] = __('Event ID');
|
$data[0] = __('Event ID');
|
||||||
|
@ -3185,10 +3179,12 @@ function events_page_general($event)
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
$data[0] = __('Type');
|
$data[0] = __('Type');
|
||||||
$data[1] = events_print_type_img(
|
$data[1] = events_print_type_description($event['event_type'], true);
|
||||||
|
$data[2] = events_print_type_img(
|
||||||
$event['event_type'],
|
$event['event_type'],
|
||||||
true
|
true
|
||||||
).' '.events_print_type_description($event['event_type'], true);
|
);
|
||||||
|
|
||||||
$table_general->data[] = $data;
|
$table_general->data[] = $data;
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
@ -3208,8 +3204,8 @@ function events_page_general($event)
|
||||||
$data = [];
|
$data = [];
|
||||||
$data[0] = __('Severity');
|
$data[0] = __('Severity');
|
||||||
$event_criticity = get_priority_name($event['criticity']);
|
$event_criticity = get_priority_name($event['criticity']);
|
||||||
|
$data[1] = $event_criticity;
|
||||||
$data[1] = html_print_image(
|
$data[2] = html_print_image(
|
||||||
$img_sev,
|
$img_sev,
|
||||||
true,
|
true,
|
||||||
[
|
[
|
||||||
|
@ -3219,7 +3215,6 @@ function events_page_general($event)
|
||||||
'title' => $event_criticity,
|
'title' => $event_criticity,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$data[1] .= ' '.$event_criticity;
|
|
||||||
$table_general->data[] = $data;
|
$table_general->data[] = $data;
|
||||||
|
|
||||||
// Get Status.
|
// Get Status.
|
||||||
|
@ -3227,7 +3222,8 @@ function events_page_general($event)
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
$data[0] = __('Status');
|
$data[0] = __('Status');
|
||||||
$data[1] = html_print_image($event_st['img'], true).' '.$event_st['title'];
|
$data[1] = $event_st['title'];
|
||||||
|
$data[2] = html_print_image($event_st['img'], true);
|
||||||
$table_general->data[] = $data;
|
$table_general->data[] = $data;
|
||||||
|
|
||||||
// If event is validated, show who and when acknowleded it.
|
// If event is validated, show who and when acknowleded it.
|
||||||
|
@ -3250,12 +3246,23 @@ function events_page_general($event)
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
$data[0] = __('Group');
|
$data[0] = __('Group');
|
||||||
$data[1] = '';
|
$data[1] = groups_get_name($event['id_grupo']);
|
||||||
if (!$config['show_group_name']) {
|
if (!$config['show_group_name']) {
|
||||||
$data[1] = ui_print_group_icon($event['id_grupo'], true);
|
$data[2] = ui_print_group_icon($event['id_grupo'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$table_general->data[] = $data;
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
$data[0] = __('Contact');
|
||||||
|
$data[1] = '';
|
||||||
|
$contact = db_get_value('contact', 'tgrupo', 'id_grupo', $event['id_grupo']);
|
||||||
|
if (empty($contact)) {
|
||||||
|
$data[1] = '<i>'.__('N/A').'</i>';
|
||||||
|
} else {
|
||||||
|
$data[1] = $contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[1] .= groups_get_name($event['id_grupo']);
|
|
||||||
$table_general->data[] = $data;
|
$table_general->data[] = $data;
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
@ -3281,6 +3288,16 @@ function events_page_general($event)
|
||||||
|
|
||||||
$table_general->data[] = $data;
|
$table_general->data[] = $data;
|
||||||
|
|
||||||
|
$table_data = $table_general->data;
|
||||||
|
$table_data_total = count($table_data);
|
||||||
|
|
||||||
|
for ($i = 0; $i <= $table_data_total; $i++) {
|
||||||
|
if (count($table_data[$i]) == 2) {
|
||||||
|
$table_general->colspan[$i][1] = 2;
|
||||||
|
$table_general->style[2] = 'text-align:center; width:10%;';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$general = '<div id="extended_event_general_page" class="extended_event_pages">'.html_print_table($table_general, true).'</div>';
|
$general = '<div id="extended_event_general_page" class="extended_event_pages">'.html_print_table($table_general, true).'</div>';
|
||||||
|
|
||||||
return $general;
|
return $general;
|
||||||
|
@ -3304,9 +3321,7 @@ function events_page_comments($event, $childrens_ids=[])
|
||||||
$table_comments->width = '100%';
|
$table_comments->width = '100%';
|
||||||
$table_comments->data = [];
|
$table_comments->data = [];
|
||||||
$table_comments->head = [];
|
$table_comments->head = [];
|
||||||
$table_comments->style[0] = 'width:35%; vertical-align: top; text-align: left;';
|
$table_comments->class = 'events_show_more_table';
|
||||||
$table_comments->style[1] = 'text-align: left;';
|
|
||||||
$table_comments->class = 'alternate rounded_cells';
|
|
||||||
|
|
||||||
$event_comments = $event['user_comment'];
|
$event_comments = $event['user_comment'];
|
||||||
$event_comments = str_replace(["\n", '
'], '<br>', $event_comments);
|
$event_comments = str_replace(["\n", '
'], '<br>', $event_comments);
|
||||||
|
@ -3411,9 +3426,9 @@ function events_page_comments($event, $childrens_ids=[])
|
||||||
$childrens_ids
|
$childrens_ids
|
||||||
))) && $config['show_events_in_local'] == false || $config['event_replication'] == false
|
))) && $config['show_events_in_local'] == false || $config['event_replication'] == false
|
||||||
) {
|
) {
|
||||||
$comments_form = '<br><div id="comments_form" style="width:98%;">'.html_print_textarea('comment', 3, 10, '', 'style="min-height: 15px; width: 100%; disabled"', true);
|
$comments_form = '<br><div id="comments_form" style="width:98%;">'.html_print_textarea('comment', 3, 10, '', 'style="min-height: 15px; padding:0; width: 100%; disabled"', true);
|
||||||
|
|
||||||
$comments_form .= '<br><div style="text-align:right;">'.html_print_button(__('Add comment'), 'comment_button', false, 'event_comment();', 'class="sub next"', true).'</div><br></div>';
|
$comments_form .= '<br><div style="text-align:right; margin-top:10px;">'.html_print_button(__('Add comment'), 'comment_button', false, 'event_comment();', 'class="sub next"', true).'</div><br></div>';
|
||||||
} else {
|
} else {
|
||||||
$comments_form = ui_print_message(
|
$comments_form = ui_print_message(
|
||||||
__('If event replication is ongoing, it won\'t be possible to enter comments here. This option is only to allow local pandora users to see comments, but not to operate with them. The operation, when event replication is enabled, must be done only in the Metaconsole.')
|
__('If event replication is ongoing, it won\'t be possible to enter comments here. This option is only to allow local pandora users to see comments, but not to operate with them. The operation, when event replication is enabled, must be done only in the Metaconsole.')
|
||||||
|
|
|
@ -120,18 +120,13 @@ if (!function_exists('mime_content_type')) {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (isset($config['homedir_filemanager'])) {
|
|
||||||
$homedir_filemanager = trim(io_safe_output($config['homedir_filemanager']));
|
|
||||||
} else {
|
|
||||||
$homedir_filemanager = trim($config['homedir']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$homedir_filemanager = trim($config['homedir']);
|
||||||
$sec2 = get_parameter('sec2');
|
$sec2 = get_parameter('sec2');
|
||||||
if ($sec2 == 'enterprise/godmode/agentes/collections' || $sec2 == 'advanced/collections') {
|
if ($sec2 == 'enterprise/godmode/agentes/collections' || $sec2 == 'advanced/collections') {
|
||||||
$homedir_filemanager .= '/attachment/collection/';
|
$homedir_filemanager .= '/attachment/collection/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$upload_file_or_zip = (bool) get_parameter('upload_file_or_zip');
|
$upload_file_or_zip = (bool) get_parameter('upload_file_or_zip');
|
||||||
|
|
||||||
if ($upload_file_or_zip) {
|
if ($upload_file_or_zip) {
|
||||||
|
@ -738,6 +733,7 @@ function filemanager_file_explorer(
|
||||||
$data[4] .= html_print_input_hidden('delete_file', 1, true);
|
$data[4] .= html_print_input_hidden('delete_file', 1, true);
|
||||||
|
|
||||||
$relative_dir = str_replace($homedir_filemanager, '', str_replace('\\', '/', dirname($fileinfo['realpath'])));
|
$relative_dir = str_replace($homedir_filemanager, '', str_replace('\\', '/', dirname($fileinfo['realpath'])));
|
||||||
|
|
||||||
if ($relative_dir[0] == '/') {
|
if ($relative_dir[0] == '/') {
|
||||||
$relative_dir = substr($relative_dir, 1);
|
$relative_dir = substr($relative_dir, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,6 +256,7 @@ function grafico_modulo_sparse_data(
|
||||||
$array_data['sum'.$series_suffix]['agent_name'] = $data_module_graph['agent_name'];
|
$array_data['sum'.$series_suffix]['agent_name'] = $data_module_graph['agent_name'];
|
||||||
$array_data['sum'.$series_suffix]['module_name'] = $data_module_graph['module_name'];
|
$array_data['sum'.$series_suffix]['module_name'] = $data_module_graph['module_name'];
|
||||||
$array_data['sum'.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
|
$array_data['sum'.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
|
||||||
|
$array_data['sum'.$series_suffix]['unit'] = $data_module_graph['unit'];
|
||||||
|
|
||||||
// This is for a specific type of report that consists in passing an interval and doing the average sum and avg.
|
// This is for a specific type of report that consists in passing an interval and doing the average sum and avg.
|
||||||
if ($params['force_interval'] != '') {
|
if ($params['force_interval'] != '') {
|
||||||
|
@ -759,6 +760,7 @@ function grafico_modulo_sparse($params)
|
||||||
$data_module_graph['c_min'] = $module_data['min_critical'];
|
$data_module_graph['c_min'] = $module_data['min_critical'];
|
||||||
$data_module_graph['c_max'] = $module_data['max_critical'];
|
$data_module_graph['c_max'] = $module_data['max_critical'];
|
||||||
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
|
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
|
||||||
|
$data_module_graph['unit'] = $module_data['unit'];
|
||||||
} else {
|
} else {
|
||||||
$data_module_graph = false;
|
$data_module_graph = false;
|
||||||
}
|
}
|
||||||
|
@ -1225,11 +1227,11 @@ function graphic_combined_module(
|
||||||
foreach ($sources as $source) {
|
foreach ($sources as $source) {
|
||||||
array_push($modules, $source['id_agent_module']);
|
array_push($modules, $source['id_agent_module']);
|
||||||
array_push($weights, $source['weight']);
|
array_push($weights, $source['weight']);
|
||||||
if ($source['label'] != '') {
|
if ($source['label'] != '' || $params_combined['labels']) {
|
||||||
$item['type'] = 'custom_graph';
|
$item['type'] = 'custom_graph';
|
||||||
$item['id_agent'] = agents_get_module_id($source['id_agent_module']);
|
$item['id_agent'] = agents_get_module_id($source['id_agent_module']);
|
||||||
$item['id_agent_module'] = $source['id_agent_module'];
|
$item['id_agent_module'] = $source['id_agent_module'];
|
||||||
$labels[$source['id_agent_module']] = reporting_label_macro($item, $source['label']);
|
$labels[$source['id_agent_module']] = ($source['label'] != '') ? reporting_label_macro($item, $source['label']) : reporting_label_macro($item, $params_combined['labels']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1357,8 +1359,9 @@ function graphic_combined_module(
|
||||||
$data_module_graph['c_max'] = $module_data['max_critical'];
|
$data_module_graph['c_max'] = $module_data['max_critical'];
|
||||||
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
|
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
|
||||||
$data_module_graph['module_id'] = $agent_module_id;
|
$data_module_graph['module_id'] = $agent_module_id;
|
||||||
|
$data_module_graph['unit'] = $module_data['unit'];
|
||||||
|
|
||||||
// stract data
|
// Stract data.
|
||||||
$array_data_module = grafico_modulo_sparse_data(
|
$array_data_module = grafico_modulo_sparse_data(
|
||||||
$agent_module_id,
|
$agent_module_id,
|
||||||
$date_array,
|
$date_array,
|
||||||
|
@ -1369,12 +1372,14 @@ function graphic_combined_module(
|
||||||
|
|
||||||
$series_suffix = $i;
|
$series_suffix = $i;
|
||||||
|
|
||||||
// convert to array graph and weight
|
// Convert to array graph and weight.
|
||||||
foreach ($array_data_module as $key => $value) {
|
foreach ($array_data_module as $key => $value) {
|
||||||
$array_data[$key] = $value;
|
$array_data[$key] = $value;
|
||||||
if ($params_combined['weight_list'][$i] > 1) {
|
if ($params_combined['weight_list'][$i] != 1) {
|
||||||
foreach ($value['data'] as $k => $v) {
|
foreach ($value['data'] as $k => $v) {
|
||||||
$array_data[$key]['data'][$k][1] = ($v[1] * $params_combined['weight_list'][$i]);
|
if ($v[1] != false) {
|
||||||
|
$array_data[$key]['data'][$k][1] = ($v[1] * $params_combined['weight_list'][$i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1790,7 +1790,6 @@ function html_print_button($label='OK', $name='', $disabled=false, $script='', $
|
||||||
*/
|
*/
|
||||||
function html_print_textarea($name, $rows, $columns, $value='', $attributes='', $return=false, $class='')
|
function html_print_textarea($name, $rows, $columns, $value='', $attributes='', $return=false, $class='')
|
||||||
{
|
{
|
||||||
|
|
||||||
$output = '<textarea id="textarea_'.$name.'" name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" '.$attributes.'" class="'.$class.'">';
|
$output = '<textarea id="textarea_'.$name.'" name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" '.$attributes.'" class="'.$class.'">';
|
||||||
// $output .= io_safe_input ($value);
|
// $output .= io_safe_input ($value);
|
||||||
$output .= ($value);
|
$output .= ($value);
|
||||||
|
|
|
@ -4439,6 +4439,9 @@ function reporting_value($report, $content, $type, $pdf=false)
|
||||||
$return['description'] = $content['description'];
|
$return['description'] = $content['description'];
|
||||||
$return['date'] = reporting_get_date_text($report, $content);
|
$return['date'] = reporting_get_date_text($report, $content);
|
||||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||||
|
$return['agents'] = [$content['id_agent']];
|
||||||
|
$return['id_agent'] = $content['id_agent'];
|
||||||
|
$return['id_agent_module'] = $content['id_agent_module'];
|
||||||
|
|
||||||
$return['agent_name'] = $agent_name;
|
$return['agent_name'] = $agent_name;
|
||||||
$return['module_name'] = $module_name;
|
$return['module_name'] = $module_name;
|
||||||
|
@ -7267,6 +7270,7 @@ function reporting_custom_graph(
|
||||||
'modules_series' => $graphs[0]['modules_series'],
|
'modules_series' => $graphs[0]['modules_series'],
|
||||||
'id_graph' => $id_graph,
|
'id_graph' => $id_graph,
|
||||||
'type_report' => $type_report,
|
'type_report' => $type_report,
|
||||||
|
'labels' => $content['style']['label'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$return['chart'] = graphic_combined_module(
|
$return['chart'] = graphic_combined_module(
|
||||||
|
@ -9340,15 +9344,34 @@ function reporting_get_agent_module_info($id_agent)
|
||||||
|
|
||||||
$return = [];
|
$return = [];
|
||||||
$return['last_contact'] = 0;
|
$return['last_contact'] = 0;
|
||||||
// Last agent contact
|
// Last agent contact.
|
||||||
$return['status'] = STATUS_AGENT_NO_DATA;
|
$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_status'] = 'notfired';
|
||||||
$return['alert_value'] = STATUS_ALERT_NOT_FIRED;
|
$return['alert_value'] = STATUS_ALERT_NOT_FIRED;
|
||||||
$return['alert_img'] = ui_print_status_image(STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true);
|
$return['alert_img'] = ui_print_status_image(
|
||||||
$return['agent_group'] = agents_get_agent_group($id_agent);
|
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;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9361,7 +9384,7 @@ function reporting_get_agent_module_info($id_agent)
|
||||||
|
|
||||||
$now = get_system_time();
|
$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);
|
$agent = db_get_row('tagente', 'id_agente', $id_agent);
|
||||||
|
|
||||||
$return['total_count'] = $agent['total_count'];
|
$return['total_count'] = $agent['total_count'];
|
||||||
|
@ -9375,28 +9398,52 @@ function reporting_get_agent_module_info($id_agent)
|
||||||
if ($return['total_count'] > 0) {
|
if ($return['total_count'] > 0) {
|
||||||
if ($return['critical_count'] > 0) {
|
if ($return['critical_count'] > 0) {
|
||||||
$return['status'] = STATUS_AGENT_CRITICAL;
|
$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) {
|
} else if ($return['warning_count'] > 0) {
|
||||||
$return['status'] = STATUS_AGENT_WARNING;
|
$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) {
|
} else if ($return['unknown_count'] > 0) {
|
||||||
$return['status'] = STATUS_AGENT_DOWN;
|
$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 {
|
} else {
|
||||||
$return['status'] = STATUS_AGENT_OK;
|
$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) {
|
if ($return['fired_count'] > 0) {
|
||||||
$return['alert_status'] = 'fired';
|
$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;
|
$return['alert_value'] = STATUS_ALERT_FIRED;
|
||||||
} else if (groups_give_disabled_group($return['agent_group'])) {
|
} else if (groups_give_disabled_group($return['agent_group'])) {
|
||||||
$return['alert_status'] = 'disabled';
|
$return['alert_status'] = 'disabled';
|
||||||
$return['alert_value'] = STATUS_ALERT_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;
|
return $return;
|
||||||
|
@ -11616,7 +11663,7 @@ function reporting_translate_sla_status_for_graph($status)
|
||||||
*
|
*
|
||||||
* @return html Return table of header.
|
* @return html Return table of header.
|
||||||
*/
|
*/
|
||||||
function reporting_header_table_for_pdf(string $title='', string $description='')
|
function reporting_header_table_for_pdf($title='', $description='')
|
||||||
{
|
{
|
||||||
$result_pdf .= '<pagebreak>';
|
$result_pdf .= '<pagebreak>';
|
||||||
$result_pdf .= '<table class="header_table databox">';
|
$result_pdf .= '<table class="header_table databox">';
|
||||||
|
|
|
@ -1026,11 +1026,9 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table0 = new stdClass();
|
$table0 = new stdClass();
|
||||||
$table0->width = '99%';
|
$table0->width = '99%';
|
||||||
$table0->class = 'table-beauty';
|
|
||||||
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
||||||
$pdf_export = html_print_table($table0, true);
|
$pdf_export = html_print_table($table0, true);
|
||||||
|
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1046,7 +1044,6 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
||||||
$table1->data[0][0] = $item['chart']['by_agent'];
|
$table1->data[0][0] = $item['chart']['by_agent'];
|
||||||
|
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1064,7 +1061,6 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
||||||
$table1->data[0][0] = $item['chart']['by_user_validator'];
|
$table1->data[0][0] = $item['chart']['by_user_validator'];
|
||||||
|
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1082,7 +1078,6 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
||||||
$table1->data[0][0] = $item['chart']['by_criticity'];
|
$table1->data[0][0] = $item['chart']['by_criticity'];
|
||||||
|
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1100,7 +1095,6 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
||||||
$table1->data[0][0] = $item['chart']['validated_vs_unvalidated'];
|
$table1->data[0][0] = $item['chart']['validated_vs_unvalidated'];
|
||||||
|
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1117,7 +1111,6 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table0 = new stdClass();
|
$table0 = new stdClass();
|
||||||
$table0->width = '99%';
|
$table0->width = '99%';
|
||||||
$table0->class = 'table-beauty';
|
|
||||||
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
||||||
$pdf_export = html_print_table($table0, true);
|
$pdf_export = html_print_table($table0, true);
|
||||||
|
|
||||||
|
@ -1233,11 +1226,9 @@ function reporting_html_event_report_module($table, $item, $pdf=0)
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table0 = new stdClass();
|
$table0 = new stdClass();
|
||||||
$table0->width = '99%';
|
$table0->width = '99%';
|
||||||
$table0->class = 'table-beauty';
|
|
||||||
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
||||||
$pdf_export = html_print_table($table0, true);
|
$pdf_export = html_print_table($table0, true);
|
||||||
|
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1253,7 +1244,6 @@ function reporting_html_event_report_module($table, $item, $pdf=0)
|
||||||
$table1->data[0][0] = $item['chart']['by_agent'];
|
$table1->data[0][0] = $item['chart']['by_agent'];
|
||||||
|
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1271,7 +1261,6 @@ function reporting_html_event_report_module($table, $item, $pdf=0)
|
||||||
$table1->data[0][0] = $item['chart']['by_user_validator'];
|
$table1->data[0][0] = $item['chart']['by_user_validator'];
|
||||||
|
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1289,7 +1278,6 @@ function reporting_html_event_report_module($table, $item, $pdf=0)
|
||||||
$table1->data[0][0] = $item['chart']['by_criticity'];
|
$table1->data[0][0] = $item['chart']['by_criticity'];
|
||||||
|
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1307,7 +1295,6 @@ function reporting_html_event_report_module($table, $item, $pdf=0)
|
||||||
$table1->data[0][0] = $item['chart']['validated_vs_unvalidated'];
|
$table1->data[0][0] = $item['chart']['validated_vs_unvalidated'];
|
||||||
|
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1326,7 +1313,6 @@ function reporting_html_event_report_module($table, $item, $pdf=0)
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table0 = new stdClass();
|
$table0 = new stdClass();
|
||||||
$table0->width = '99%';
|
$table0->width = '99%';
|
||||||
$table0->class = 'table-beauty';
|
|
||||||
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
||||||
$pdf_export = html_print_table($table0, true);
|
$pdf_export = html_print_table($table0, true);
|
||||||
|
|
||||||
|
@ -2021,11 +2007,9 @@ function reporting_html_event_report_agent($table, $item, $pdf=0)
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table0 = new stdClass();
|
$table0 = new stdClass();
|
||||||
$table0->width = '99%';
|
$table0->width = '99%';
|
||||||
$table0->class = 'table-beauty';
|
|
||||||
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
||||||
$pdf_export = html_print_table($table0, true);
|
$pdf_export = html_print_table($table0, true);
|
||||||
|
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -2042,7 +2026,6 @@ function reporting_html_event_report_agent($table, $item, $pdf=0)
|
||||||
$table1->data[0][0] = $item['chart']['by_user_validator'];
|
$table1->data[0][0] = $item['chart']['by_user_validator'];
|
||||||
|
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -2060,7 +2043,6 @@ function reporting_html_event_report_agent($table, $item, $pdf=0)
|
||||||
$table1->data[0][0] = $item['chart']['by_criticity'];
|
$table1->data[0][0] = $item['chart']['by_criticity'];
|
||||||
|
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -2078,7 +2060,6 @@ function reporting_html_event_report_agent($table, $item, $pdf=0)
|
||||||
$table1->data[0][0] = $item['chart']['validated_vs_unvalidated'];
|
$table1->data[0][0] = $item['chart']['validated_vs_unvalidated'];
|
||||||
|
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty';
|
|
||||||
$pdf_export .= html_print_table($table1, true);
|
$pdf_export .= html_print_table($table1, true);
|
||||||
$pdf_export .= '<br>';
|
$pdf_export .= '<br>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -2095,7 +2076,6 @@ function reporting_html_event_report_agent($table, $item, $pdf=0)
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table0 = new stdClass();
|
$table0 = new stdClass();
|
||||||
$table0->width = '99%';
|
$table0->width = '99%';
|
||||||
$table0->class = 'table-beauty';
|
|
||||||
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
$table0->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
||||||
$pdf_export = html_print_table($table0, true);
|
$pdf_export = html_print_table($table0, true);
|
||||||
|
|
||||||
|
@ -2438,7 +2418,7 @@ function reporting_html_alert_report($table, $item, $pdf=0)
|
||||||
|
|
||||||
$table->data['alerts']['cell'] = html_print_table($table1, true);
|
$table->data['alerts']['cell'] = html_print_table($table1, true);
|
||||||
if ($pdf) {
|
if ($pdf) {
|
||||||
$table1->class = 'table-beauty pdf_alert_table';
|
$table1->class = 'pdf_alert_table';
|
||||||
return html_print_table($table1, true);
|
return html_print_table($table1, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4937,7 +4917,7 @@ function reporting_html_planned_downtimes_table($planned_downtimes)
|
||||||
|
|
||||||
if ($for_pdf) {
|
if ($for_pdf) {
|
||||||
$table->titlestyle = 'background: #373737; color: #FFF; display: table-cell; font-size: 12px; border: 1px solid grey';
|
$table->titlestyle = 'background: #373737; color: #FFF; display: table-cell; font-size: 12px; border: 1px solid grey';
|
||||||
$table->class = 'table_sla table_beauty';
|
$table->class = 'table_sla';
|
||||||
|
|
||||||
for ($i = 0; $i < count($table->head); $i++) {
|
for ($i = 0; $i < count($table->head); $i++) {
|
||||||
$table->headstyle[$i] = 'background: #666; color: #FFF; display: table-cell; font-size: 11px; border: 1px solid grey';
|
$table->headstyle[$i] = 'background: #666; color: #FFF; display: table-cell; font-size: 11px; border: 1px solid grey';
|
||||||
|
|
|
@ -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
|
$filter[] = '(UPPER(name) LIKE UPPER (\'%'.$tag_name_description.'%\') OR
|
||||||
UPPER(dbms_lob.substr(description, 4000, 1)) LIKE UPPER (\'%'.$tag_name_description.'%\'))';
|
UPPER(dbms_lob.substr(description, 4000, 1)) LIKE UPPER (\'%'.$tag_name_description.'%\'))';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default order
|
// Default order.
|
||||||
set_unless_defined($filter['order'], 'name');
|
set_unless_defined($filter['order'], 'name');
|
||||||
|
|
||||||
$fields = '*';
|
$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) {
|
if ($count) {
|
||||||
unset($filter['order']);
|
unset($filter['order']);
|
||||||
unset($filter['limit']);
|
unset($filter['limit']);
|
||||||
|
@ -120,7 +124,7 @@ function tags_create_tag($values)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No create tag if the tag exists
|
// No create tag if the tag exists.
|
||||||
if (tags_get_id($values['name'])) {
|
if (tags_get_id($values['name'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -365,7 +369,7 @@ function tags_insert_module_tag($id_agent_module, $tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
// Protect against default insert
|
// Protect against default insert.
|
||||||
if (empty($tag)) {
|
if (empty($tag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -396,7 +400,7 @@ function tags_insert_policy_module_tag($id_agent_module, $tags)
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
// Protect against default insert
|
// Protect against default insert.
|
||||||
if (empty($tag)) {
|
if (empty($tag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -439,7 +443,7 @@ function tags_update_module_tag(
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($update_policy_tags) {
|
if ($update_policy_tags) {
|
||||||
// First delete module tag entries
|
// First delete module tag entries.
|
||||||
$result_tag = db_process_sql_delete(
|
$result_tag = db_process_sql_delete(
|
||||||
'ttag_module',
|
'ttag_module',
|
||||||
['id_agente_modulo' => $id_agent_module]
|
['id_agente_modulo' => $id_agent_module]
|
||||||
|
@ -456,7 +460,7 @@ function tags_update_module_tag(
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
// Protect against default insert
|
// Protect against default insert.
|
||||||
if (empty($tag)) {
|
if (empty($tag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -494,7 +498,7 @@ function tags_update_policy_module_tag($id_policy_module, $tags, $autocommit=fal
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
// Protect against default insert
|
// Protect against default insert.
|
||||||
if (empty($tag)) {
|
if (empty($tag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -759,11 +763,14 @@ function tags_get_acl_tags(
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id_group == 0) {
|
if ($id_group == 0) {
|
||||||
// Don't filter
|
// Don't filter.
|
||||||
$id_group = [];
|
$id_group = [];
|
||||||
} else if (empty($id_group)) {
|
} else if (empty($id_group)) {
|
||||||
return ERR_WRONG_PARAMETERS;
|
return ERR_WRONG_PARAMETERS;
|
||||||
|
@ -789,12 +796,12 @@ function tags_get_acl_tags(
|
||||||
|
|
||||||
switch ($return_mode) {
|
switch ($return_mode) {
|
||||||
case 'data':
|
case 'data':
|
||||||
// Stop here and return the array
|
// Stop here and return the array.
|
||||||
return $acltags;
|
return $acltags;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'module_condition':
|
case 'module_condition':
|
||||||
// Return the condition of the tags for tagente_modulo table
|
// Return the condition of the tags for tagente_modulo table.
|
||||||
$condition = tags_get_acl_tags_module_condition(
|
$condition = tags_get_acl_tags_module_condition(
|
||||||
$acltags,
|
$acltags,
|
||||||
$query_table,
|
$query_table,
|
||||||
|
@ -806,13 +813,17 @@ function tags_get_acl_tags(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'event_condition':
|
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);
|
$condition = tags_get_acl_tags_event_condition($acltags, $meta, $force_group_and_tag);
|
||||||
|
|
||||||
if (!empty($condition)) {
|
if (!empty($condition)) {
|
||||||
return " $query_prefix ".'('.$condition.')';
|
return " $query_prefix ".'('.$condition.')';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
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);
|
$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;
|
global $config;
|
||||||
$condition = [];
|
$condition = [];
|
||||||
|
|
||||||
// Get all tags of the system
|
// Get all tags of the system.
|
||||||
$all_tags = tags_get_all_tags(false);
|
$all_tags = tags_get_all_tags(false);
|
||||||
|
|
||||||
$without_tags = [];
|
$without_tags = [];
|
||||||
foreach ($acltags as $group_id => $group_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)) {
|
if (empty($group_tags)) {
|
||||||
$without_tags[] = $group_id;
|
$without_tags[] = $group_id;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group condition (The module belongs to an agent of the group X)
|
// 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)";
|
$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 = '';
|
||||||
$tags_condition_array = [];
|
$tags_condition_array = [];
|
||||||
|
|
||||||
foreach ($group_tags as $tag) {
|
foreach ($group_tags as $tag) {
|
||||||
// If the tag ID doesnt exist, ignore
|
// If the tag ID doesnt exist, ignore.
|
||||||
if (!isset($all_tags[$tag])) {
|
if (!isset($all_tags[$tag])) {
|
||||||
continue;
|
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])."%'";
|
$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)) {
|
if (empty($tags_condition_array)) {
|
||||||
$tags_condition_array[] = '1=0';
|
$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;
|
global $config;
|
||||||
|
|
||||||
// users_is_strict_acl
|
// users_is_strict_acl.
|
||||||
if ($id_user === false) {
|
if ($id_user === false) {
|
||||||
$id_user = $config['id_user'];
|
$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();
|
$all_tags = tags_get_all_tags();
|
||||||
|
|
||||||
// If at least one of the profiles of this access flag hasent
|
// 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);
|
$acl_column = get_acl_column($access);
|
||||||
|
|
||||||
if (empty($acl_column)) {
|
if (empty($acl_column)) {
|
||||||
|
@ -1045,6 +1056,10 @@ function tags_get_user_tags($id_user=false, $access='AR', $return_tag_any=false)
|
||||||
$acl_column
|
$acl_column
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profiles_without_tags = db_get_value_sql($query);
|
$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');
|
$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) {
|
if ($tags_user === ERR_WRONG_PARAMETERS || $tags_user === ERR_ACL) {
|
||||||
return [];
|
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 = [];
|
$user_tags_id = [];
|
||||||
|
|
||||||
foreach ($tags as $t) {
|
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 = [];
|
$user_tags = [];
|
||||||
foreach ($user_tags_id as $id) {
|
foreach ($user_tags_id as $id) {
|
||||||
if (!isset($all_tags[$id])) {
|
if (!isset($all_tags[$id])) {
|
||||||
|
@ -1104,16 +1119,16 @@ function tags_get_tags_for_module_search($id_user=false, $access='AR')
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// users_is_strict_acl
|
// users_is_strict_acl.
|
||||||
if ($id_user === false) {
|
if ($id_user === false) {
|
||||||
$id_user = $config['id_user'];
|
$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();
|
$all_tags = tags_get_all_tags();
|
||||||
|
|
||||||
// If at least one of the profiles of this access flag hasent
|
// 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);
|
$acl_column = get_acl_column($access);
|
||||||
|
|
||||||
if (empty($acl_column)) {
|
if (empty($acl_column)) {
|
||||||
|
@ -1149,6 +1164,10 @@ function tags_get_tags_for_module_search($id_user=false, $access='AR')
|
||||||
$acl_column
|
$acl_column
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profiles_without_tags = db_get_value_sql($query);
|
$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;
|
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');
|
$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) {
|
if ($tags_user === ERR_WRONG_PARAMETERS || $tags_user === ERR_ACL) {
|
||||||
return [];
|
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 = [];
|
$user_tags_id = [];
|
||||||
|
|
||||||
foreach ($tags as $t) {
|
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 = [];
|
$user_tags = [];
|
||||||
foreach ($user_tags_id as $id) {
|
foreach ($user_tags_id as $id) {
|
||||||
if (!isset($all_tags[$id])) {
|
if (!isset($all_tags[$id])) {
|
||||||
|
@ -1217,12 +1236,12 @@ function tags_check_acl_by_module(
|
||||||
|
|
||||||
$acl_column = get_acl_column($access);
|
$acl_column = get_acl_column($access);
|
||||||
foreach ($groups as $group) {
|
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])) {
|
if (!isset($user_groups[$group])) {
|
||||||
continue;
|
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])) {
|
if (empty($user_groups[$group]['tags'][$acl_column])) {
|
||||||
return true;
|
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=[])
|
function tags_checks_event_acl($id_user, $id_group, $access, $tags=[], $childrens_ids=[])
|
||||||
{
|
{
|
||||||
global $config;
|
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);
|
$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) {
|
if ($tags_user === ERR_WRONG_PARAMETERS || $tags_user === ERR_ACL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check user without tags
|
// check user without tags.
|
||||||
$sql = "SELECT id_usuario FROM tusuario_perfil
|
$sql = "SELECT id_usuario FROM tusuario_perfil
|
||||||
WHERE id_usuario = '".$config['id_user']."' AND tags = ''
|
WHERE id_usuario = '".$config['id_user']."' AND tags = ''
|
||||||
AND id_perfil IN (
|
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)
|
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)) {
|
if (empty($id_tag)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1392,12 +1411,12 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||||
$agent_name_filter = '';
|
$agent_name_filter = '';
|
||||||
$agent_status = AGENT_STATUS_ALL;
|
$agent_status = AGENT_STATUS_ALL;
|
||||||
if (!empty($agent_filter)) {
|
if (!empty($agent_filter)) {
|
||||||
// Name
|
// Name.
|
||||||
if (isset($agent_filter['name']) && !empty($agent_filter['name'])) {
|
if (isset($agent_filter['name']) && !empty($agent_filter['name'])) {
|
||||||
$agent_name_filter = "AND ta.nombre LIKE '%".$agent_filter['name']."%'";
|
$agent_name_filter = "AND ta.nombre LIKE '%".$agent_filter['name']."%'";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status
|
// Status.
|
||||||
if (isset($agent_filter['status'])) {
|
if (isset($agent_filter['status'])) {
|
||||||
if (is_array($agent_filter['status'])) {
|
if (is_array($agent_filter['status'])) {
|
||||||
$agent_status = array_unique($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_filter = '';
|
||||||
$module_status_array = [];
|
$module_status_array = [];
|
||||||
if (!empty($module_filter)) {
|
if (!empty($module_filter)) {
|
||||||
// IMPORTANT: The module filters will force the realtime search
|
// IMPORTANT: The module filters will force the realtime search.
|
||||||
$realtime = true;
|
$realtime = true;
|
||||||
|
|
||||||
// Name
|
// Name.
|
||||||
if (isset($module_filter['name']) && !empty($module_filter['name'])) {
|
if (isset($module_filter['name']) && !empty($module_filter['name'])) {
|
||||||
$module_name_filter = "AND tam.nombre LIKE '%".$module_filter['name']."%'";
|
$module_name_filter = "AND tam.nombre LIKE '%".$module_filter['name']."%'";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status
|
// Status.
|
||||||
if (isset($module_filter['status'])) {
|
if (isset($module_filter['status'])) {
|
||||||
$module_status = $module_filter['status'];
|
$module_status = $module_filter['status'];
|
||||||
if (is_array($module_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_ALERT;
|
||||||
$module_status_array[] = AGENT_MODULE_STATUS_NORMAL;
|
$module_status_array[] = AGENT_MODULE_STATUS_NORMAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1517,7 +1540,7 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||||
$unknown = 0;
|
$unknown = 0;
|
||||||
$not_init = 0;
|
$not_init = 0;
|
||||||
$normal = 0;
|
$normal = 0;
|
||||||
// Without module filter
|
// Without module filter.
|
||||||
if (empty($module_status_array)) {
|
if (empty($module_status_array)) {
|
||||||
$total = (int) tags_get_total_monitors($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
$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);
|
$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);
|
$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);
|
$normal = (int) tags_get_normal_monitors($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
||||||
}
|
}
|
||||||
// With module filter
|
|
||||||
|
// With module filter.
|
||||||
else {
|
else {
|
||||||
foreach ($module_status_array as $status) {
|
foreach ($module_status_array as $status) {
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
|
@ -1553,6 +1577,10 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||||
case AGENT_MODULE_STATUS_NORMAL:
|
case AGENT_MODULE_STATUS_NORMAL:
|
||||||
$normal = (int) tags_get_normal_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);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1592,7 +1620,7 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// The status doesn't exist
|
// The status doesn't exist.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1617,7 +1645,7 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||||
$count ++;
|
$count ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Invalid status
|
// Invalid status.
|
||||||
else {
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1625,12 +1653,12 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$status_filter = '';
|
$status_filter = '';
|
||||||
// Transform the element into a one element array
|
// Transform the element into a one element array.
|
||||||
if (!is_array($agent_status)) {
|
if (!is_array($agent_status)) {
|
||||||
$agent_status = [$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) {
|
foreach ($agent_status as $status) {
|
||||||
switch ($agent_status) {
|
switch ($agent_status) {
|
||||||
case AGENT_STATUS_ALL:
|
case AGENT_STATUS_ALL:
|
||||||
|
@ -1666,7 +1694,7 @@ function tags_get_agents_counter($id_tag, $groups_and_tags=[], $agent_filter=[],
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// The type doesn't exist
|
// The type doesn't exist.
|
||||||
return 0;
|
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)
|
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;
|
$agent_filter['status'] = AGENT_STATUS_ALL;
|
||||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
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)
|
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;
|
$agent_filter['status'] = AGENT_STATUS_NORMAL;
|
||||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
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)
|
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;
|
$agent_filter['status'] = AGENT_STATUS_WARNING;
|
||||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
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)
|
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;
|
$agent_filter['status'] = AGENT_STATUS_CRITICAL;
|
||||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
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)
|
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;
|
$agent_filter['status'] = AGENT_STATUS_UNKNOWN;
|
||||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
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)
|
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;
|
$agent_filter['status'] = AGENT_STATUS_NOT_INIT;
|
||||||
return tags_get_agents_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter, $realtime);
|
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=[])
|
function tags_get_monitors_counter($id_tag, $groups_and_tags=[], $agent_filter=[], $module_filter=[])
|
||||||
{
|
{
|
||||||
// Avoid mysql error
|
// Avoid mysql error.
|
||||||
if (empty($id_tag)) {
|
if (empty($id_tag)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1885,12 +1913,12 @@ function tags_get_monitors_counter($id_tag, $groups_and_tags=[], $agent_filter=[
|
||||||
$agent_name_filter = '';
|
$agent_name_filter = '';
|
||||||
$agents_clause = '';
|
$agents_clause = '';
|
||||||
if (!empty($agent_filter)) {
|
if (!empty($agent_filter)) {
|
||||||
// Name
|
// Name.
|
||||||
if (isset($agent_filter['name']) && !empty($agent_filter['name'])) {
|
if (isset($agent_filter['name']) && !empty($agent_filter['name'])) {
|
||||||
$agent_name_filter = "AND ta.nombre LIKE '%".$agent_filter['name']."%'";
|
$agent_name_filter = "AND ta.nombre LIKE '%".$agent_filter['name']."%'";
|
||||||
}
|
}
|
||||||
|
|
||||||
// ID
|
// ID.
|
||||||
if (isset($agent_filter['id'])) {
|
if (isset($agent_filter['id'])) {
|
||||||
if (is_array($agent_filter['id'])) {
|
if (is_array($agent_filter['id'])) {
|
||||||
$agents = array_unique($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 = '';
|
$module_status_array = '';
|
||||||
$modules_clause = '';
|
$modules_clause = '';
|
||||||
if (!empty($module_filter)) {
|
if (!empty($module_filter)) {
|
||||||
// Name
|
// Name.
|
||||||
if (isset($module_filter['name']) && !empty($module_filter['name'])) {
|
if (isset($module_filter['name']) && !empty($module_filter['name'])) {
|
||||||
$module_name_filter = "AND tam.nombre LIKE '%".$module_filter['name']."%'";
|
$module_name_filter = "AND tam.nombre LIKE '%".$module_filter['name']."%'";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status
|
// Status.
|
||||||
if (isset($module_filter['status'])) {
|
if (isset($module_filter['status'])) {
|
||||||
$module_status = $module_filter['status'];
|
$module_status = $module_filter['status'];
|
||||||
if (is_array($module_status)) {
|
if (is_array($module_status)) {
|
||||||
|
@ -1965,7 +1993,7 @@ function tags_get_monitors_counter($id_tag, $groups_and_tags=[], $agent_filter=[
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// The status doesn't exist
|
// The status doesn't exist.
|
||||||
return false;
|
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=[])
|
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;
|
$module_filter['status'] = AGENT_MODULE_STATUS_ALL;
|
||||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
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=[])
|
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;
|
$module_filter['status'] = AGENT_MODULE_STATUS_NORMAL;
|
||||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
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=[])
|
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;
|
$module_filter['status'] = AGENT_MODULE_STATUS_CRITICAL_BAD;
|
||||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
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=[])
|
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;
|
$module_filter['status'] = AGENT_MODULE_STATUS_WARNING;
|
||||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
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=[])
|
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;
|
$module_filter['status'] = AGENT_MODULE_STATUS_NOT_INIT;
|
||||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
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=[])
|
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;
|
$module_filter['status'] = AGENT_MODULE_STATUS_UNKNOWN;
|
||||||
return tags_get_monitors_counter($id_tag, $groups_and_tags, $agent_filter, $module_filter);
|
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)
|
function tags_monitors_fired_alerts($id_tag, $groups_and_tags=[], $id_agente=false)
|
||||||
{
|
{
|
||||||
// Avoid mysql error
|
// Avoid mysql error.
|
||||||
if (empty($id_tag)) {
|
if (empty($id_tag)) {
|
||||||
return;
|
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)
|
function tags_get_monitors_alerts($id_tag, $groups_and_tags=[], $id_agente=false)
|
||||||
{
|
{
|
||||||
// Avoid mysql error
|
// Avoid mysql error.
|
||||||
if (empty($id_tag)) {
|
if (empty($id_tag)) {
|
||||||
return;
|
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)
|
function __add_acltags(&$acltags, $group_id, $tags_str)
|
||||||
{
|
{
|
||||||
if (!isset($acltags[$group_id])) {
|
if (!isset($acltags[$group_id])) {
|
||||||
// Add the new element
|
// Add the new element.
|
||||||
$acltags[$group_id] = $tags_str;
|
$acltags[$group_id] = $tags_str;
|
||||||
} else {
|
} 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];
|
$existing_tags = $acltags[$group_id];
|
||||||
|
|
||||||
if (!empty($existing_tags)) {
|
if (!empty($existing_tags)) {
|
||||||
$existing_tags_array = explode(',', $existing_tags);
|
$existing_tags_array = explode(',', $existing_tags);
|
||||||
|
|
||||||
// Store the empty tags
|
// Store the empty tags.
|
||||||
if (empty($tags_str)) {
|
if (empty($tags_str)) {
|
||||||
$acltags[$group_id] = '';
|
$acltags[$group_id] = '';
|
||||||
}
|
}
|
||||||
// Merge the old and new tabs
|
// Merge the old and new tabs.
|
||||||
else {
|
else {
|
||||||
$new_tags_array = explode(',', $tags_str);
|
$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);
|
$propagate = (bool) db_get_value('propagate', 'tgrupo', 'id_grupo', $group_id);
|
||||||
if ($propagate) {
|
if ($propagate) {
|
||||||
$sql = "SELECT id_grupo FROM tgrupo WHERE parent = $group_id";
|
$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) {
|
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);
|
__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)
|
function tags_get_user_groups_and_tags($id_user=false, $access='AR', $strict_user=false)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
@ -2499,7 +2527,7 @@ function tags_get_agent_modules($id_agent, $id_tag=false, $groups_and_tags=[], $
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// Avoid mysql error
|
// Avoid mysql error.
|
||||||
if (empty($id_agent)) {
|
if (empty($id_agent)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2437,7 +2437,7 @@ function ui_print_status_image($type, $title='', $return=false, $options=false,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function ui_toggle($code, $name, $title='', $hidden_default=true, $return=false)
|
function ui_toggle($code, $name, $title='', $hidden_default=true, $return=false, $toggle_class='')
|
||||||
{
|
{
|
||||||
// Generate unique Id
|
// Generate unique Id
|
||||||
$uniqid = uniqid('');
|
$uniqid = uniqid('');
|
||||||
|
@ -2458,12 +2458,11 @@ function ui_toggle($code, $name, $title='', $hidden_default=true, $return=false)
|
||||||
// Link to toggle
|
// Link to toggle
|
||||||
$output = '';
|
$output = '';
|
||||||
$output .= '<a href="javascript:" id="tgl_ctrl_'.$uniqid.'">'.html_print_image($original, true, ['title' => $title, 'id' => 'image_'.$uniqid]).' <b>'.$name.'</b></a>';
|
$output .= '<a href="javascript:" id="tgl_ctrl_'.$uniqid.'">'.html_print_image($original, true, ['title' => $title, 'id' => 'image_'.$uniqid]).' <b>'.$name.'</b></a>';
|
||||||
$output .= '<br />';
|
// $output .= '<br />';
|
||||||
|
|
||||||
// if (!defined("METACONSOLE"))
|
// if (!defined("METACONSOLE"))
|
||||||
// $output .= '<br />';
|
// $output .= '<br />';
|
||||||
// Code into a div
|
// Code into a div
|
||||||
$output .= "<div id='tgl_div_".$uniqid."' style='".$style."'>\n";
|
$output .= "<div id='tgl_div_".$uniqid."' style='".$style."' class='".$toggle_class."'>\n";
|
||||||
$output .= $code;
|
$output .= $code;
|
||||||
$output .= '</div>';
|
$output .= '</div>';
|
||||||
|
|
||||||
|
|
|
@ -397,7 +397,7 @@ function update_manager_check_online_free_packages($is_ajax=true)
|
||||||
<?php
|
<?php
|
||||||
$baseurl = ui_get_full_url(false, false, false, false);
|
$baseurl = ui_get_full_url(false, false, false, false);
|
||||||
echo '<p><b>There is a new version:</b> '.$result[0]['version'].'</p>';
|
echo '<p><b>There is a new version:</b> '.$result[0]['version'].'</p>';
|
||||||
echo "<a href='javascript: update_last_package(\"".base64_encode($result[0]['file_name']).'", "'.$result[0]['version'].'", "'.$baseurl."\");'>".__('Update to the last version').'</a>';
|
echo "<a class='update_manager_button' href='javascript: update_last_package(\"".base64_encode($result[0]['file_name']).'", "'.$result[0]['version'].'", "'.$baseurl."\");'>".__('Update').'</a>';
|
||||||
} else {
|
} else {
|
||||||
echo __('There is no update available.');
|
echo __('There is no update available.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -3961,38 +3961,54 @@ function visual_map_translate_module_status($module_status)
|
||||||
* layouts), and makes an AND operation to be sure that all the items
|
* layouts), and makes an AND operation to be sure that all the items
|
||||||
* are OK. If any of them is down, then result is down (0)
|
* are OK. If any of them is down, then result is down (0)
|
||||||
*
|
*
|
||||||
* @param int Id of the layout
|
* @param integer $layout_id Id of the layout.
|
||||||
* @param array Information about the status calculation of the item
|
* @param array $status_data Information about the status calculation of the
|
||||||
* @param int Depth (for recursion control)
|
* item.
|
||||||
|
* @param integer $depth Depth (for recursion control).
|
||||||
*
|
*
|
||||||
* @return boolean The status of the given layout. True if it's OK, false if not.
|
* @return integer The status of the given layout.
|
||||||
*/
|
*/
|
||||||
function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
|
function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// TODO: Implement this limit into the setup
|
// TODO: Implement this limit into the setup.
|
||||||
if ($depth > 10) {
|
if ($depth > 10) {
|
||||||
return VISUAL_MAP_STATUS_UNKNOWN;
|
return VISUAL_MAP_STATUS_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
$layout_items = db_get_all_rows_filter('tlayout_data', ['id_layout' => $layout_id]);
|
$layout_items = db_get_all_rows_filter(
|
||||||
|
'tlayout_data',
|
||||||
|
['id_layout' => $layout_id]
|
||||||
|
);
|
||||||
|
|
||||||
if ($layout_items === false) {
|
if ($layout_items === false) {
|
||||||
return VISUAL_MAP_STATUS_UNKNOWN;
|
return VISUAL_MAP_STATUS_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for valid items to retrieve the status for
|
// Check for valid items to retrieve the status for.
|
||||||
$valid_layout_items = [];
|
$valid_layout_items = [];
|
||||||
foreach ($layout_items as $layout_item_data) {
|
foreach ($layout_items as $layout_item_data) {
|
||||||
if (($layout_item_data['type'] == GROUP_ITEM
|
if (($layout_item_data['type'] == GROUP_ITEM
|
||||||
&& !empty($layout_item_data['id_group'])
|
&& !empty($layout_item_data['id_group'])
|
||||||
&& check_acl($config['id_user'], $layout_item_data['id_group'], 'VR')
|
&& check_acl(
|
||||||
&& check_acl($config['id_user'], $layout_item_data['element_group'], 'VR'))
|
$config['id_user'],
|
||||||
|
$layout_item_data['id_group'],
|
||||||
|
'VR'
|
||||||
|
)
|
||||||
|
&& check_acl(
|
||||||
|
$config['id_user'],
|
||||||
|
$layout_item_data['element_group'],
|
||||||
|
'VR'
|
||||||
|
))
|
||||||
|| ((!empty($layout_item_data['id_layout_linked'])
|
|| ((!empty($layout_item_data['id_layout_linked'])
|
||||||
|| !empty($layout_item_data['id_agente_modulo'])
|
|| !empty($layout_item_data['id_agente_modulo'])
|
||||||
|| !empty($layout_item_data['id_agent']))
|
|| !empty($layout_item_data['id_agent']))
|
||||||
&& check_acl($config['id_user'], $layout_item_data['element_group'], 'VR'))
|
&& check_acl(
|
||||||
|
$config['id_user'],
|
||||||
|
$layout_item_data['element_group'],
|
||||||
|
'VR'
|
||||||
|
))
|
||||||
) {
|
) {
|
||||||
$valid_layout_items[] = $layout_item_data;
|
$valid_layout_items[] = $layout_item_data;
|
||||||
}
|
}
|
||||||
|
@ -4002,7 +4018,7 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
|
||||||
return VISUAL_MAP_STATUS_UNKNOWN;
|
return VISUAL_MAP_STATUS_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort by node id to reduce the number of connections
|
// Sort by node id to reduce the number of connections.
|
||||||
if (is_metaconsole()) {
|
if (is_metaconsole()) {
|
||||||
sort_by_column($valid_layout_items, 'id_metaconsole');
|
sort_by_column($valid_layout_items, 'id_metaconsole');
|
||||||
}
|
}
|
||||||
|
@ -4021,14 +4037,14 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
|
||||||
|
|
||||||
if (empty($node_id) && $meta_connected_to) {
|
if (empty($node_id) && $meta_connected_to) {
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
// Restore db connection
|
// Restore db connection.
|
||||||
$meta_connected_to = null;
|
$meta_connected_to = null;
|
||||||
} else if (!empty($node_id) && ( empty($meta_connected_to)
|
} else if (!empty($node_id)
|
||||||
|| $meta_connected_to != $node_id)
|
&& (empty($meta_connected_to) || $meta_connected_to != $node_id)
|
||||||
) {
|
) {
|
||||||
if (!empty($meta_connected_to)) {
|
if (!empty($meta_connected_to)) {
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
// Restore db connection
|
// Restore db connection.
|
||||||
}
|
}
|
||||||
|
|
||||||
$connection = metaconsole_get_connection_by_id($node_id);
|
$connection = metaconsole_get_connection_by_id($node_id);
|
||||||
|
@ -4042,64 +4058,78 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
|
||||||
|
|
||||||
$status = VISUAL_MAP_STATUS_NORMAL;
|
$status = VISUAL_MAP_STATUS_NORMAL;
|
||||||
|
|
||||||
$ent_element_status = enterprise_hook('enterprise_visual_map_get_status_element', [$layoutData]);
|
$ent_element_status = enterprise_hook(
|
||||||
|
'enterprise_visual_map_get_status_element',
|
||||||
|
[$layoutData]
|
||||||
|
);
|
||||||
if ($ent_element_status === ENTERPRISE_NOT_HOOK) {
|
if ($ent_element_status === ENTERPRISE_NOT_HOOK) {
|
||||||
$ent_element_status = false;
|
$ent_element_status = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enterprise element
|
|
||||||
if ($ent_element_status !== false) {
|
if ($ent_element_status !== false) {
|
||||||
|
// Enterprise element.
|
||||||
$status = $ent_element_status;
|
$status = $ent_element_status;
|
||||||
}
|
} else {
|
||||||
// Other
|
// Other.
|
||||||
else {
|
|
||||||
switch ($layout_item_data['type']) {
|
switch ($layout_item_data['type']) {
|
||||||
case STATIC_GRAPH:
|
case STATIC_GRAPH:
|
||||||
case PERCENTILE_BAR:
|
case PERCENTILE_BAR:
|
||||||
case PERCENTILE_BUBBLE:
|
case PERCENTILE_BUBBLE:
|
||||||
case CIRCULAR_PROGRESS_BAR:
|
case CIRCULAR_PROGRESS_BAR:
|
||||||
case CIRCULAR_INTERIOR_PROGRESS_BAR:
|
case CIRCULAR_INTERIOR_PROGRESS_BAR:
|
||||||
// Linked layout
|
|
||||||
if (!empty($layout_item_data['id_layout_linked'])) {
|
if (!empty($layout_item_data['id_layout_linked'])) {
|
||||||
$status = visual_map_get_layout_status($layout_item_data['id_layout_linked'], $layout_item_data, ($depth + 1));
|
// Linked layout.
|
||||||
}
|
$status = visual_map_get_layout_status(
|
||||||
// Module
|
$layout_item_data['id_layout_linked'],
|
||||||
else if (!empty($layout_item_data['id_agente_modulo'])) {
|
$layout_item_data,
|
||||||
$module_status = modules_get_agentmodule_status($layout_item_data['id_agente_modulo']);
|
($depth + 1)
|
||||||
$status = visual_map_translate_module_status($module_status);
|
);
|
||||||
}
|
} else if (!empty($layout_item_data['id_agente_modulo'])) {
|
||||||
// Agent
|
// Module.
|
||||||
else if (!empty($layout_item_data['id_agent'])) {
|
$module_status = modules_get_agentmodule_status(
|
||||||
$agent_status = agents_get_status($layout_item_data['id_agent'], true);
|
$layout_item_data['id_agente_modulo']
|
||||||
$status = visual_map_translate_agent_status($agent_status);
|
);
|
||||||
}
|
$status = visual_map_translate_module_status(
|
||||||
// Unknown
|
$module_status
|
||||||
else {
|
);
|
||||||
|
} else if (!empty($layout_item_data['id_agent'])) {
|
||||||
|
// Agent.
|
||||||
|
$agent = db_get_row('tagente', 'id_agente', $layout_item_data['id_agent']);
|
||||||
|
$agent_status = agents_get_status_from_counts($agent);
|
||||||
|
$status = visual_map_translate_agent_status(
|
||||||
|
$agent_status
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Unknown.
|
||||||
$status = VISUAL_MAP_STATUS_UNKNOWN;
|
$status = VISUAL_MAP_STATUS_UNKNOWN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GROUP_ITEM:
|
case GROUP_ITEM:
|
||||||
$group_status = groups_get_status($layout_item_data['id_group']);
|
$group_status = groups_get_status(
|
||||||
|
$layout_item_data['id_group']
|
||||||
|
);
|
||||||
$status = visual_map_translate_agent_status($group_status);
|
$status = visual_map_translate_agent_status($group_status);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// If it's a graph, a progress bar or a data tag, ALWAYS report status OK
|
// If it's a graph, a progress bar or a data tag,
|
||||||
// (=0) to avoid confussions here.
|
// ALWAYS report status OK (=0) to avoid confussions here.
|
||||||
$status = VISUAL_MAP_STATUS_NORMAL;
|
$status = VISUAL_MAP_STATUS_NORMAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// When the status calculation type is 'default', only one critical element is required to
|
// When the status calculation type is 'default', only one critical
|
||||||
// set the layout status as critical, so we can return the critical status right now.
|
// element is required to set the layout status as critical, so we can
|
||||||
if ($status_data['linked_layout_status_type'] === 'default' && ( $status == VISUAL_MAP_STATUS_CRITICAL_BAD
|
// return the critical status right now.
|
||||||
|
if ($status_data['linked_layout_status_type'] === 'default'
|
||||||
|
&& ($status == VISUAL_MAP_STATUS_CRITICAL_BAD
|
||||||
|| $status == VISUAL_MAP_STATUS_CRITICAL_ALERT)
|
|| $status == VISUAL_MAP_STATUS_CRITICAL_ALERT)
|
||||||
) {
|
) {
|
||||||
if (is_metaconsole() && $meta_connected_to) {
|
if (is_metaconsole() && $meta_connected_to) {
|
||||||
|
// Restore db connection.
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
// Restore db connection
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $status;
|
return $status;
|
||||||
|
@ -4113,11 +4143,11 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_metaconsole() && $meta_connected_to) {
|
if (is_metaconsole() && $meta_connected_to) {
|
||||||
|
// Restore db connection.
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
// Restore db connection
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status calculation
|
// Status calculation.
|
||||||
switch ($status_data['linked_layout_status_type']) {
|
switch ($status_data['linked_layout_status_type']) {
|
||||||
default:
|
default:
|
||||||
case 'default':
|
case 'default':
|
||||||
|
@ -4149,7 +4179,7 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
|
||||||
if ($num_items_critical > 0
|
if ($num_items_critical > 0
|
||||||
&& ((($num_items_critical_alert + $num_items_critical) * 100) / $num_items) >= $weight
|
&& ((($num_items_critical_alert + $num_items_critical) * 100) / $num_items) >= $weight
|
||||||
) {
|
) {
|
||||||
return $num_items_critical_alert > 0 ? VISUAL_MAP_STATUS_CRITICAL_ALERT : VISUAL_MAP_STATUS_CRITICAL_BAD;
|
return ($num_items_critical_alert > 0) ? VISUAL_MAP_STATUS_CRITICAL_ALERT : VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||||
} else if ($num_items_warning > 0
|
} else if ($num_items_warning > 0
|
||||||
&& (($num_items_warning * 100) / $num_items) >= $weight
|
&& (($num_items_warning * 100) / $num_items) >= $weight
|
||||||
) {
|
) {
|
||||||
|
@ -4525,3 +4555,43 @@ function visual_map_get_color_cloud_element($data)
|
||||||
<?php
|
<?php
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the Visual Console Client files (js & css).
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function visual_map_load_client_resources()
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$baseUrl = ui_get_full_url(false, false, false, false);
|
||||||
|
$vcClientPath = 'include/visual-console-client';
|
||||||
|
$dir = $config['homedir'].'/'.$vcClientPath;
|
||||||
|
if (is_dir($dir)) {
|
||||||
|
$dh = opendir($dir);
|
||||||
|
if ($dh) {
|
||||||
|
while (($file = readdir($dh)) !== false) {
|
||||||
|
if ($file === '.' || $file === '..') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
preg_match('/.*.js$/', $file, $match, PREG_OFFSET_CAPTURE);
|
||||||
|
if (empty($match) === false) {
|
||||||
|
$url = $baseUrl.$vcClientPath.'/'.$match[0][0];
|
||||||
|
echo '<script type="text/javascript" src="'.$url.'"></script>';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
preg_match('/.*.css$/', $file, $match, PREG_OFFSET_CAPTURE);
|
||||||
|
if (empty($match) === false) {
|
||||||
|
$url = $baseUrl.$vcClientPath.'/'.$match[0][0];
|
||||||
|
echo '<link type="text/css" rel="stylesheet" href="'.$url.'" />';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir($dh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -688,7 +688,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background)
|
||||||
'percentile_item',
|
'percentile_item',
|
||||||
'datos',
|
'datos',
|
||||||
];
|
];
|
||||||
$form_items['percentile_item_row_6']['html'] = '<td align="left">'.__('Label color').'</td>
|
$form_items['percentile_item_row_6']['html'] = '<td align="left">'.__('Value color').'</td>
|
||||||
<td align="left">'.html_print_input_text_extended(
|
<td align="left">'.html_print_input_text_extended(
|
||||||
'percentile_label_color',
|
'percentile_label_color',
|
||||||
'#ffffff',
|
'#ffffff',
|
||||||
|
@ -1394,6 +1394,9 @@ function visual_map_editor_print_hack_translate_strings()
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready (function () {
|
$(document).ready (function () {
|
||||||
$("#map_linked").change(function () {
|
$("#map_linked").change(function () {
|
||||||
|
$("option[value=" + this.value + "]", this)
|
||||||
|
.attr("selected", true).siblings()
|
||||||
|
.removeAttr("selected")
|
||||||
$("#text-agent").val("");
|
$("#text-agent").val("");
|
||||||
$("input[name=id_agent]").val(0);
|
$("input[name=id_agent]").val(0);
|
||||||
$("#module").empty();
|
$("#module").empty();
|
||||||
|
|
|
@ -2133,7 +2133,7 @@ function pandoraFlotArea(
|
||||||
var plot = $.plot($("#" + graph_id), datas, options);
|
var plot = $.plot($("#" + graph_id), datas, options);
|
||||||
|
|
||||||
// Re-calculate the graph height with the legend height
|
// Re-calculate the graph height with the legend height
|
||||||
if (dashboard || vconsole) {
|
if (dashboard) {
|
||||||
$acum = 0;
|
$acum = 0;
|
||||||
if (dashboard) $acum = 35;
|
if (dashboard) $acum = 35;
|
||||||
var hDiff =
|
var hDiff =
|
||||||
|
|
|
@ -1748,7 +1748,9 @@ function round_with_decimals(value, multiplier) {
|
||||||
if (typeof multiplier === "undefined") multiplier = 1;
|
if (typeof multiplier === "undefined") multiplier = 1;
|
||||||
|
|
||||||
// Return non numeric types without modification
|
// Return non numeric types without modification
|
||||||
if (typeof value !== "number") return value;
|
if (typeof value !== "number" || Number.isNaN(value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
if (value * multiplier == 0) return 0;
|
if (value * multiplier == 0) return 0;
|
||||||
if (Math.abs(value) * multiplier >= 1) {
|
if (Math.abs(value) * multiplier >= 1) {
|
||||||
|
|
|
@ -365,9 +365,9 @@ function get_event_name(event_id, meta, history) {
|
||||||
|
|
||||||
function add_row_param(id_table, param) {
|
function add_row_param(id_table, param) {
|
||||||
$("#" + id_table).append(
|
$("#" + id_table).append(
|
||||||
'<tr class="params_rows"><td style="text-align:left; padding-left:40px;">' +
|
'<tr class="params_rows"><td style="text-align:left; padding-left:40px; font-weight: normal; font-style: italic;">' +
|
||||||
param +
|
param +
|
||||||
'</td><td style="text-align:left"><input type="text" name="' +
|
'</td><td style="text-align:left" colspan="2"><input type="text" name="' +
|
||||||
param +
|
param +
|
||||||
'" id="' +
|
'" id="' +
|
||||||
param +
|
param +
|
||||||
|
|
|
@ -1,3 +1,268 @@
|
||||||
|
// TODO: Add Artica ST header.
|
||||||
|
/* globals jQuery, VisualConsole */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* *********************
|
||||||
|
* * New VC functions. *
|
||||||
|
* *********************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a Visual Console client.
|
||||||
|
* @param {HTMLElement} container Node which will be used to contain the VC.
|
||||||
|
* @param {object} props VC container properties.
|
||||||
|
* @param {object[]} items List of item definitions.
|
||||||
|
* @param {string | null} baseUrl Base URL to perform API requests.
|
||||||
|
* @param {number | null} updateInterval Time in milliseconds between VC updates.
|
||||||
|
* @param {function | null} onUpdate Callback which will be execuded when the Visual Console.
|
||||||
|
* is updated. It will receive two arguments with the old and the new Visual Console's
|
||||||
|
* data structure.
|
||||||
|
* @return {VisualConsole | null} The Visual Console instance or a null value.
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
function createVisualConsole(
|
||||||
|
container,
|
||||||
|
props,
|
||||||
|
items,
|
||||||
|
baseUrl,
|
||||||
|
updateInterval,
|
||||||
|
onUpdate
|
||||||
|
) {
|
||||||
|
var visualConsole = null;
|
||||||
|
var linkedVCRequest = null;
|
||||||
|
var updateVCRequest = null;
|
||||||
|
|
||||||
|
if (container == null || props == null || items == null) return null;
|
||||||
|
if (baseUrl == null) baseUrl = "";
|
||||||
|
|
||||||
|
// Code which will be executed between intervals.
|
||||||
|
var intervalRef = null;
|
||||||
|
var stopInterval = function() {
|
||||||
|
if (intervalRef !== null) window.clearInterval(intervalRef);
|
||||||
|
};
|
||||||
|
var startInterval = function() {
|
||||||
|
if (updateInterval == null || updateInterval <= 0) return;
|
||||||
|
stopInterval();
|
||||||
|
|
||||||
|
intervalRef = window.setInterval(function() {
|
||||||
|
if (updateVCRequest !== null) updateVCRequest.abort();
|
||||||
|
updateVCRequest = loadVisualConsoleData(
|
||||||
|
baseUrl,
|
||||||
|
visualConsole.props.id,
|
||||||
|
function(error, data) {
|
||||||
|
if (error) {
|
||||||
|
console.log(
|
||||||
|
"[ERROR]",
|
||||||
|
"[VISUAL-CONSOLE-CLIENT]",
|
||||||
|
"[API]",
|
||||||
|
error.message
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace Visual Console.
|
||||||
|
if (data != null && data.props != null && data.items != null) {
|
||||||
|
try {
|
||||||
|
var props =
|
||||||
|
typeof data.props === "string"
|
||||||
|
? JSON.parse(data.props)
|
||||||
|
: data.props;
|
||||||
|
var items =
|
||||||
|
typeof data.items === "string"
|
||||||
|
? JSON.parse(data.items)
|
||||||
|
: data.items;
|
||||||
|
|
||||||
|
var prevProps = visualConsole.props;
|
||||||
|
// Update the data structure.
|
||||||
|
visualConsole.props = props;
|
||||||
|
// Update the items.
|
||||||
|
visualConsole.updateElements(items);
|
||||||
|
// Emit the VC update event.
|
||||||
|
if (onUpdate) onUpdate(prevProps, visualConsole.props);
|
||||||
|
} catch (ignored) {} // eslint-disable-line no-empty
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, updateInterval);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initialize the Visual Console.
|
||||||
|
try {
|
||||||
|
visualConsole = new VisualConsole(container, props, items);
|
||||||
|
// VC Item clicked.
|
||||||
|
visualConsole.onClick(function(e) {
|
||||||
|
// Override the link to another VC if it isn't on remote console.
|
||||||
|
if (
|
||||||
|
e.data &&
|
||||||
|
e.data.linkedLayoutId != null &&
|
||||||
|
e.data.linkedLayoutId > 0 &&
|
||||||
|
e.data.link != null &&
|
||||||
|
e.data.link.length > 0 &&
|
||||||
|
(e.data.linkedLayoutAgentId == null || e.data.linkedLayoutAgentId === 0)
|
||||||
|
) {
|
||||||
|
// Stop the current link behavior.
|
||||||
|
e.nativeEvent.preventDefault();
|
||||||
|
|
||||||
|
// Fetch and update the old VC with the new.
|
||||||
|
if (linkedVCRequest !== null) linkedVCRequest.abort();
|
||||||
|
linkedVCRequest = loadVisualConsoleData(
|
||||||
|
baseUrl,
|
||||||
|
e.data.linkedLayoutId,
|
||||||
|
function(error, data) {
|
||||||
|
if (error) {
|
||||||
|
console.log(
|
||||||
|
"[ERROR]",
|
||||||
|
"[VISUAL-CONSOLE-CLIENT]",
|
||||||
|
"[API]",
|
||||||
|
error.message
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace Visual Console.
|
||||||
|
if (data != null && data.props != null && data.items != null) {
|
||||||
|
// Cancel the old VC updates.
|
||||||
|
stopInterval();
|
||||||
|
|
||||||
|
try {
|
||||||
|
var props =
|
||||||
|
typeof data.props === "string"
|
||||||
|
? JSON.parse(data.props)
|
||||||
|
: data.props;
|
||||||
|
var items =
|
||||||
|
typeof data.items === "string"
|
||||||
|
? JSON.parse(data.items)
|
||||||
|
: data.items;
|
||||||
|
|
||||||
|
if (updateVCRequest !== null) updateVCRequest.abort();
|
||||||
|
// Save the old props.
|
||||||
|
var prevProps = visualConsole.props;
|
||||||
|
// Update the data structure.
|
||||||
|
visualConsole.props = props;
|
||||||
|
// Update the items.
|
||||||
|
visualConsole.updateElements(items);
|
||||||
|
// Emit the VC update event.
|
||||||
|
if (onUpdate) onUpdate(prevProps, visualConsole.props);
|
||||||
|
} catch (ignored) {} // eslint-disable-line no-empty
|
||||||
|
|
||||||
|
// Restart the updates.
|
||||||
|
startInterval();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start an interval to update the Visual Console.
|
||||||
|
startInterval();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", "[VISUAL-CONSOLE-CLIENT]", error.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return visualConsole;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a Visual Console's structure and its items.
|
||||||
|
* @param {string} baseUrl Base URL to build the API path.
|
||||||
|
* @param {number} vcId Identifier of the Visual Console.
|
||||||
|
* @param {function} callback Function to be executed on request success or fail.
|
||||||
|
* On success, the function will receive an object with the next properties:
|
||||||
|
* - `props`: object with the Visual Console's data structure.
|
||||||
|
* - `items`: array of data structures of the Visual Console's items.
|
||||||
|
* @return {Object} Cancellable. Object which include and .abort([statusText]) function.
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
function loadVisualConsoleData(baseUrl, vcId, callback) {
|
||||||
|
// var apiPath = baseUrl + "/include/rest-api";
|
||||||
|
var apiPath = baseUrl + "/ajax.php";
|
||||||
|
var vcJqXHR = null;
|
||||||
|
var itemsJqXHR = null;
|
||||||
|
|
||||||
|
// Initialize the final result.
|
||||||
|
var result = {
|
||||||
|
props: null,
|
||||||
|
items: null
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cancel the ajax requests.
|
||||||
|
var abort = function(textStatus) {
|
||||||
|
if (textStatus == null) textStatus = "abort";
|
||||||
|
|
||||||
|
// -- XMLHttpRequest.readyState --
|
||||||
|
// Value State Description
|
||||||
|
// 0 UNSENT Client has been created. open() not called yet.
|
||||||
|
// 4 DONE The operation is complete.
|
||||||
|
|
||||||
|
if (vcJqXHR.readyState !== 0 && vcJqXHR.readyState !== 4)
|
||||||
|
vcJqXHR.abort(textStatus);
|
||||||
|
if (itemsJqXHR.readyState !== 0 && itemsJqXHR.readyState !== 4)
|
||||||
|
itemsJqXHR.abort(textStatus);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if the required data is complete.
|
||||||
|
var checkResult = function() {
|
||||||
|
return result.props !== null && result.items !== null;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Failed request handler.
|
||||||
|
var handleFail = function(jqXHR, textStatus, errorThrown) {
|
||||||
|
abort();
|
||||||
|
// Manually aborted or not.
|
||||||
|
if (textStatus === "abort") {
|
||||||
|
callback();
|
||||||
|
} else {
|
||||||
|
var error = new Error(errorThrown);
|
||||||
|
error.request = jqXHR;
|
||||||
|
callback(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Curried function which handle success.
|
||||||
|
var handleSuccess = function(key) {
|
||||||
|
// Actual request handler.
|
||||||
|
return function(data) {
|
||||||
|
result[key] = data;
|
||||||
|
if (checkResult()) callback(null, result);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Visual Console container request.
|
||||||
|
vcJqXHR = jQuery
|
||||||
|
// .get(apiPath + "/visual-consoles/" + vcId, null, "json")
|
||||||
|
.get(
|
||||||
|
apiPath,
|
||||||
|
{
|
||||||
|
page: "include/rest-api/index",
|
||||||
|
getVisualConsole: 1,
|
||||||
|
visualConsoleId: vcId
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
)
|
||||||
|
.done(handleSuccess("props"))
|
||||||
|
.fail(handleFail);
|
||||||
|
// Visual Console items request.
|
||||||
|
itemsJqXHR = jQuery
|
||||||
|
// .get(apiPath + "/visual-consoles/" + vcId + "/items", null, "json")
|
||||||
|
.get(
|
||||||
|
apiPath,
|
||||||
|
{
|
||||||
|
page: "include/rest-api/index",
|
||||||
|
getVisualConsoleItems: 1,
|
||||||
|
visualConsoleId: vcId
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
)
|
||||||
|
.done(handleSuccess("items"))
|
||||||
|
.fail(handleFail);
|
||||||
|
|
||||||
|
// Abortable.
|
||||||
|
return {
|
||||||
|
abort: abort
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Delete the functions below when you can.
|
||||||
/**************************************
|
/**************************************
|
||||||
These functions require jQuery library
|
These functions require jQuery library
|
||||||
**************************************/
|
**************************************/
|
||||||
|
|
|
@ -747,9 +747,11 @@ var TreeController = {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
winopeng(
|
winopeng_var(
|
||||||
element.moduleGraph.url,
|
element.moduleGraph.url,
|
||||||
element.moduleGraph.handle
|
element.moduleGraph.handle,
|
||||||
|
1000,
|
||||||
|
650
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// console.log(error);
|
// console.log(error);
|
||||||
|
|
|
@ -326,20 +326,20 @@ function install_package(package, homeurl) {
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_accept_package_mr_fail_text =
|
var dialog_accept_package_mr_fail_text =
|
||||||
"<div>";
|
"<div class='update_popup'>";
|
||||||
dialog_accept_package_mr_fail_text =
|
dialog_accept_package_mr_fail_text =
|
||||||
dialog_accept_package_mr_fail_text +
|
dialog_accept_package_mr_fail_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>INFO</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_info_mr.png'></div>";
|
|
||||||
dialog_accept_package_mr_fail_text =
|
dialog_accept_package_mr_fail_text =
|
||||||
dialog_accept_package_mr_fail_text +
|
dialog_accept_package_mr_fail_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>INFO</strong></h3>";
|
"<p>" +
|
||||||
dialog_accept_package_mr_fail_text =
|
|
||||||
dialog_accept_package_mr_fail_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
mr_not_accepted_code_yes +
|
mr_not_accepted_code_yes +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_accept_package_mr_fail_text =
|
||||||
|
dialog_accept_package_mr_fail_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_info_mr.png'></div>";
|
||||||
dialog_accept_package_mr_fail_text =
|
dialog_accept_package_mr_fail_text =
|
||||||
dialog_accept_package_mr_fail_text +
|
dialog_accept_package_mr_fail_text +
|
||||||
"</div>";
|
"</div>";
|
||||||
|
@ -397,20 +397,21 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_success_pkg_text = "<div>";
|
var dialog_success_pkg_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_success_pkg_text =
|
dialog_success_pkg_text =
|
||||||
dialog_success_pkg_text +
|
dialog_success_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>SUCCESS</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_exito_mr.png'></div>";
|
|
||||||
dialog_success_pkg_text =
|
dialog_success_pkg_text =
|
||||||
dialog_success_pkg_text +
|
dialog_success_pkg_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>SUCCESS</strong></h3>";
|
"<p>" +
|
||||||
dialog_success_pkg_text =
|
|
||||||
dialog_success_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
package_success +
|
package_success +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_success_pkg_text =
|
||||||
|
dialog_success_pkg_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_success_mr.png'></div>";
|
||||||
dialog_success_pkg_text =
|
dialog_success_pkg_text =
|
||||||
dialog_success_pkg_text + "</div>";
|
dialog_success_pkg_text + "</div>";
|
||||||
|
|
||||||
|
@ -456,20 +457,21 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_error_pkg_text = "<div>";
|
var dialog_error_pkg_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_error_pkg_text =
|
dialog_error_pkg_text =
|
||||||
dialog_error_pkg_text +
|
dialog_error_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>ERROR</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_error_mr.png'></div>";
|
|
||||||
dialog_error_pkg_text =
|
dialog_error_pkg_text =
|
||||||
dialog_error_pkg_text +
|
dialog_error_pkg_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
|
"<p>" +
|
||||||
dialog_error_pkg_text =
|
|
||||||
dialog_error_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
package_error +
|
package_error +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_error_pkg_text =
|
||||||
|
dialog_error_pkg_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_error_mr.png'></div>";
|
||||||
dialog_error_pkg_text =
|
dialog_error_pkg_text =
|
||||||
dialog_error_pkg_text + "</div>";
|
dialog_error_pkg_text + "</div>";
|
||||||
|
|
||||||
|
@ -533,20 +535,21 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_cancel_pkg_text = "<div>";
|
var dialog_cancel_pkg_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_cancel_pkg_text =
|
dialog_cancel_pkg_text =
|
||||||
dialog_cancel_pkg_text +
|
dialog_cancel_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>INFO</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_info_mr.png'></div>";
|
|
||||||
dialog_cancel_pkg_text =
|
dialog_cancel_pkg_text =
|
||||||
dialog_cancel_pkg_text +
|
dialog_cancel_pkg_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>INFO</strong></h3>";
|
"<p>" +
|
||||||
dialog_cancel_pkg_text =
|
|
||||||
dialog_cancel_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
package_cancel +
|
package_cancel +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_cancel_pkg_text =
|
||||||
|
dialog_cancel_pkg_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_info_mr.png'></div>";
|
||||||
dialog_cancel_pkg_text =
|
dialog_cancel_pkg_text =
|
||||||
dialog_cancel_pkg_text + "</div>";
|
dialog_cancel_pkg_text + "</div>";
|
||||||
|
|
||||||
|
@ -571,20 +574,21 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_bad_message_text = "<div>";
|
var dialog_bad_message_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_bad_message_text =
|
dialog_bad_message_text =
|
||||||
dialog_bad_message_text +
|
dialog_bad_message_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>ERROR</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_error_mr.png'></div>";
|
|
||||||
dialog_bad_message_text =
|
dialog_bad_message_text =
|
||||||
dialog_bad_message_text +
|
dialog_bad_message_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
|
"<p>" +
|
||||||
dialog_bad_message_text =
|
|
||||||
dialog_bad_message_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
bad_mr_file +
|
bad_mr_file +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_bad_message_text =
|
||||||
|
dialog_bad_message_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_error_mr.png'></div>";
|
||||||
dialog_bad_message_text =
|
dialog_bad_message_text =
|
||||||
dialog_bad_message_text + "</div>";
|
dialog_bad_message_text + "</div>";
|
||||||
|
|
||||||
|
@ -616,20 +620,21 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_success_mr_text = "<div>";
|
var dialog_success_mr_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_success_mr_text =
|
dialog_success_mr_text =
|
||||||
dialog_success_mr_text +
|
dialog_success_mr_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>SUCCESS</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_exito_mr.png'></div>";
|
|
||||||
dialog_success_mr_text =
|
dialog_success_mr_text =
|
||||||
dialog_success_mr_text +
|
dialog_success_mr_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>SUCCESS</strong></h3>";
|
"<p>" +
|
||||||
dialog_success_mr_text =
|
|
||||||
dialog_success_mr_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
mr_success +
|
mr_success +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_success_mr_text =
|
||||||
|
dialog_success_mr_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_success_mr.png'></div>";
|
||||||
dialog_success_mr_text =
|
dialog_success_mr_text =
|
||||||
dialog_success_mr_text + "</div>";
|
dialog_success_mr_text + "</div>";
|
||||||
|
|
||||||
|
@ -684,20 +689,21 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_success_pkg_text = "<div>";
|
var dialog_success_pkg_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_success_pkg_text =
|
dialog_success_pkg_text =
|
||||||
dialog_success_pkg_text +
|
dialog_success_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>SUCCESS</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_exito_mr.png'></div>";
|
|
||||||
dialog_success_pkg_text =
|
dialog_success_pkg_text =
|
||||||
dialog_success_pkg_text +
|
dialog_success_pkg_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>SUCCESS</strong></h3>";
|
"<p>" +
|
||||||
dialog_success_pkg_text =
|
|
||||||
dialog_success_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
package_success +
|
package_success +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_success_pkg_text =
|
||||||
|
dialog_success_pkg_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_success_mr.png'></div>";
|
||||||
dialog_success_pkg_text =
|
dialog_success_pkg_text =
|
||||||
dialog_success_pkg_text + "</div>";
|
dialog_success_pkg_text + "</div>";
|
||||||
|
|
||||||
|
@ -743,20 +749,21 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_error_pkg_text = "<div>";
|
var dialog_error_pkg_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_error_pkg_text =
|
dialog_error_pkg_text =
|
||||||
dialog_error_pkg_text +
|
dialog_error_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>ERROR</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_error_mr.png'></div>";
|
|
||||||
dialog_error_pkg_text =
|
dialog_error_pkg_text =
|
||||||
dialog_error_pkg_text +
|
dialog_error_pkg_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
|
"<p>" +
|
||||||
dialog_error_pkg_text =
|
|
||||||
dialog_error_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
package_error +
|
package_error +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_error_pkg_text =
|
||||||
|
dialog_error_pkg_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_error_mr.png'></div>";
|
||||||
dialog_error_pkg_text =
|
dialog_error_pkg_text =
|
||||||
dialog_error_pkg_text + "</div>";
|
dialog_error_pkg_text + "</div>";
|
||||||
|
|
||||||
|
@ -814,20 +821,21 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_error_mr_text = "<div>";
|
var dialog_error_mr_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_error_mr_text =
|
dialog_error_mr_text =
|
||||||
dialog_error_mr_text +
|
dialog_error_mr_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>ERROR</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_error_mr.png'></div>";
|
|
||||||
dialog_error_mr_text =
|
dialog_error_mr_text =
|
||||||
dialog_error_mr_text +
|
dialog_error_mr_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
|
"<p>" +
|
||||||
dialog_error_mr_text =
|
|
||||||
dialog_error_mr_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
mr_error +
|
mr_error +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_error_mr_text =
|
||||||
|
dialog_error_mr_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_error_mr.png'></div>";
|
||||||
dialog_error_mr_text =
|
dialog_error_mr_text =
|
||||||
dialog_error_mr_text + "</div>";
|
dialog_error_mr_text + "</div>";
|
||||||
|
|
||||||
|
@ -874,20 +882,21 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_cancel_mr_text = "<div>";
|
var dialog_cancel_mr_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_cancel_mr_text =
|
dialog_cancel_mr_text =
|
||||||
dialog_cancel_mr_text +
|
dialog_cancel_mr_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>INFO</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_info_mr.png'></div>";
|
|
||||||
dialog_cancel_mr_text =
|
dialog_cancel_mr_text =
|
||||||
dialog_cancel_mr_text +
|
dialog_cancel_mr_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>INFO</strong></h3>";
|
"<p>" +
|
||||||
dialog_cancel_mr_text =
|
|
||||||
dialog_cancel_mr_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
mr_cancel +
|
mr_cancel +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_cancel_mr_text =
|
||||||
|
dialog_cancel_mr_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_info_mr.png'></div>";
|
||||||
dialog_cancel_mr_text =
|
dialog_cancel_mr_text =
|
||||||
dialog_cancel_mr_text + "</div>";
|
dialog_cancel_mr_text + "</div>";
|
||||||
|
|
||||||
|
@ -910,34 +919,33 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
$("button:contains(Apply MR)").attr("id", "apply_rr_button");
|
$("button:contains(Apply MR)")
|
||||||
|
.attr("id", "apply_rr_button")
|
||||||
|
.addClass("success_button");
|
||||||
$("button:contains(Cancel)").attr("id", "cancel_rr_button");
|
$("button:contains(Cancel)").attr("id", "cancel_rr_button");
|
||||||
|
|
||||||
var dialog_have_mr_text = "<div>";
|
var dialog_have_mr_text = "<div class='update_popup'>";
|
||||||
dialog_have_mr_text =
|
dialog_have_mr_text =
|
||||||
dialog_have_mr_text +
|
dialog_have_mr_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>" +
|
||||||
home_url +
|
|
||||||
"images/icono_warning_mr.png'></div>";
|
|
||||||
dialog_have_mr_text =
|
|
||||||
dialog_have_mr_text +
|
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>" +
|
|
||||||
mr_available_header +
|
mr_available_header +
|
||||||
"</strong></h3>";
|
"</h3>";
|
||||||
|
dialog_have_mr_text =
|
||||||
|
dialog_have_mr_text + "<p>" + text1_mr_file + "</p>";
|
||||||
dialog_have_mr_text =
|
dialog_have_mr_text =
|
||||||
dialog_have_mr_text +
|
dialog_have_mr_text +
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
"<p>" +
|
||||||
text1_mr_file +
|
|
||||||
"</p>";
|
|
||||||
dialog_have_mr_text =
|
|
||||||
dialog_have_mr_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
text2_mr_file +
|
text2_mr_file +
|
||||||
"<a style='font-family:Verdana bold; font-size:12pt; color:#82B92E'href=\"index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list\">" +
|
'<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list">' +
|
||||||
text3_mr_file +
|
text3_mr_file +
|
||||||
"</a>" +
|
"</a>" +
|
||||||
text4_mr_file +
|
text4_mr_file +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_have_mr_text =
|
||||||
|
dialog_have_mr_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_warning_db.png'></div>";
|
||||||
dialog_have_mr_text = dialog_have_mr_text + "</div>";
|
dialog_have_mr_text = dialog_have_mr_text + "</div>";
|
||||||
|
|
||||||
$("#mr_dialog2").html(dialog_have_mr_text);
|
$("#mr_dialog2").html(dialog_have_mr_text);
|
||||||
|
@ -992,20 +1000,21 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_success_pkg_text = "<div>";
|
var dialog_success_pkg_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_success_pkg_text =
|
dialog_success_pkg_text =
|
||||||
dialog_success_pkg_text +
|
dialog_success_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>SUCCESS</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_exito_mr.png'></div>";
|
|
||||||
dialog_success_pkg_text =
|
dialog_success_pkg_text =
|
||||||
dialog_success_pkg_text +
|
dialog_success_pkg_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>SUCCESS</strong></h3>";
|
"<p>" +
|
||||||
dialog_success_pkg_text =
|
|
||||||
dialog_success_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
package_success +
|
package_success +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_success_pkg_text =
|
||||||
|
dialog_success_pkg_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_success_mr.png'></div>";
|
||||||
dialog_success_pkg_text =
|
dialog_success_pkg_text =
|
||||||
dialog_success_pkg_text + "</div>";
|
dialog_success_pkg_text + "</div>";
|
||||||
|
|
||||||
|
@ -1047,20 +1056,20 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_error_pkg_text = "<div>";
|
var dialog_error_pkg_text = "<div class='update_popup'>";
|
||||||
dialog_error_pkg_text =
|
dialog_error_pkg_text =
|
||||||
dialog_error_pkg_text +
|
dialog_error_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>ERROR</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_error_mr.png'></div>";
|
|
||||||
dialog_error_pkg_text =
|
dialog_error_pkg_text =
|
||||||
dialog_error_pkg_text +
|
dialog_error_pkg_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
|
"<p>" +
|
||||||
dialog_error_pkg_text =
|
|
||||||
dialog_error_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
package_error +
|
package_error +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_error_pkg_text =
|
||||||
|
dialog_error_pkg_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_error_mr.png'></div>";
|
||||||
dialog_error_pkg_text = dialog_error_pkg_text + "</div>";
|
dialog_error_pkg_text = dialog_error_pkg_text + "</div>";
|
||||||
|
|
||||||
$("#error_pkg").html(dialog_error_pkg_text);
|
$("#error_pkg").html(dialog_error_pkg_text);
|
||||||
|
@ -1124,20 +1133,16 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_cancel_pkg_text = "<div>";
|
var dialog_cancel_pkg_text = "<div class='update_popup'>";
|
||||||
|
dialog_cancel_pkg_text =
|
||||||
|
dialog_cancel_pkg_text + "<div class='update_text'><h3>INFO</h3>";
|
||||||
|
dialog_cancel_pkg_text =
|
||||||
|
dialog_cancel_pkg_text + "<p>" + package_cancel + "</p></div>";
|
||||||
dialog_cancel_pkg_text =
|
dialog_cancel_pkg_text =
|
||||||
dialog_cancel_pkg_text +
|
dialog_cancel_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_icon'><img src='" +
|
||||||
home_url +
|
home_url +
|
||||||
"images/icono_info_mr.png'></div>";
|
"images/icon_info_mr.png'></div>";
|
||||||
dialog_cancel_pkg_text =
|
|
||||||
dialog_cancel_pkg_text +
|
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>INFO</strong></h3>";
|
|
||||||
dialog_cancel_pkg_text =
|
|
||||||
dialog_cancel_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
package_cancel +
|
|
||||||
"</p></div>";
|
|
||||||
dialog_cancel_pkg_text = dialog_cancel_pkg_text + "</div>";
|
dialog_cancel_pkg_text = dialog_cancel_pkg_text + "</div>";
|
||||||
|
|
||||||
$("#cancel_pkg").html(dialog_cancel_pkg_text);
|
$("#cancel_pkg").html(dialog_cancel_pkg_text);
|
||||||
|
@ -1214,22 +1219,18 @@ function install_package(package, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_text = "<div>";
|
var dialog_text = "<div class='update_popup'>";
|
||||||
dialog_text =
|
dialog_text =
|
||||||
dialog_text +
|
dialog_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>" +
|
||||||
home_url +
|
|
||||||
"images/icono_info_mr.png'></div>";
|
|
||||||
dialog_text =
|
|
||||||
dialog_text +
|
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>" +
|
|
||||||
text1_package_file +
|
text1_package_file +
|
||||||
"</strong></h3>";
|
"</h3>";
|
||||||
|
dialog_text = dialog_text + "<p>" + text2_package_file + "</p></div>";
|
||||||
dialog_text =
|
dialog_text =
|
||||||
dialog_text +
|
dialog_text +
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
"<div class='update_icon'><img src='" +
|
||||||
text2_package_file +
|
home_url +
|
||||||
"</p></div>";
|
"images/icon_info_mr.png'></div>";
|
||||||
dialog_text = dialog_text + "</div>";
|
dialog_text = dialog_text + "</div>";
|
||||||
|
|
||||||
$("#pkg_apply_dialog").html(dialog_text);
|
$("#pkg_apply_dialog").html(dialog_text);
|
||||||
|
@ -1522,20 +1523,20 @@ function install_free_package_prev_step(package, version, homeurl) {
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_accept_package_mr_fail_text =
|
var dialog_accept_package_mr_fail_text =
|
||||||
"<div>";
|
"<div class='update_popup'>";
|
||||||
dialog_accept_package_mr_fail_text =
|
dialog_accept_package_mr_fail_text =
|
||||||
dialog_accept_package_mr_fail_text +
|
dialog_accept_package_mr_fail_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>INFO</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_info_mr.png'></div>";
|
|
||||||
dialog_accept_package_mr_fail_text =
|
dialog_accept_package_mr_fail_text =
|
||||||
dialog_accept_package_mr_fail_text +
|
dialog_accept_package_mr_fail_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>INFO</strong></h3>";
|
"<p>" +
|
||||||
dialog_accept_package_mr_fail_text =
|
|
||||||
dialog_accept_package_mr_fail_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
mr_not_accepted_code_yes +
|
mr_not_accepted_code_yes +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_accept_package_mr_fail_text =
|
||||||
|
dialog_accept_package_mr_fail_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_info_mr.png'></div>";
|
||||||
dialog_accept_package_mr_fail_text =
|
dialog_accept_package_mr_fail_text =
|
||||||
dialog_accept_package_mr_fail_text +
|
dialog_accept_package_mr_fail_text +
|
||||||
"</div>";
|
"</div>";
|
||||||
|
@ -1616,20 +1617,21 @@ function install_free_package_prev_step(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_cancel_pkg_text = "<div>";
|
var dialog_cancel_pkg_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_cancel_pkg_text =
|
dialog_cancel_pkg_text =
|
||||||
dialog_cancel_pkg_text +
|
dialog_cancel_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>INFO</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_info_mr.png'></div>";
|
|
||||||
dialog_cancel_pkg_text =
|
dialog_cancel_pkg_text =
|
||||||
dialog_cancel_pkg_text +
|
dialog_cancel_pkg_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>INFO</strong></h3>";
|
"<p>" +
|
||||||
dialog_cancel_pkg_text =
|
|
||||||
dialog_cancel_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
package_cancel +
|
package_cancel +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_cancel_pkg_text =
|
||||||
|
dialog_cancel_pkg_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_info_mr.png'></div>";
|
||||||
dialog_cancel_pkg_text =
|
dialog_cancel_pkg_text =
|
||||||
dialog_cancel_pkg_text + "</div>";
|
dialog_cancel_pkg_text + "</div>";
|
||||||
|
|
||||||
|
@ -1646,20 +1648,21 @@ function install_free_package_prev_step(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_bad_message_text = "<div>";
|
var dialog_bad_message_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_bad_message_text =
|
dialog_bad_message_text =
|
||||||
dialog_bad_message_text +
|
dialog_bad_message_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>ERROR</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_error_mr.png'></div>";
|
|
||||||
dialog_bad_message_text =
|
dialog_bad_message_text =
|
||||||
dialog_bad_message_text +
|
dialog_bad_message_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
|
"<p>" +
|
||||||
dialog_bad_message_text =
|
|
||||||
dialog_bad_message_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
bad_mr_file +
|
bad_mr_file +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_bad_message_text =
|
||||||
|
dialog_bad_message_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_error_mr.png'></div>";
|
||||||
dialog_bad_message_text =
|
dialog_bad_message_text =
|
||||||
dialog_bad_message_text + "</div>";
|
dialog_bad_message_text + "</div>";
|
||||||
|
|
||||||
|
@ -1691,20 +1694,21 @@ function install_free_package_prev_step(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_success_mr_text = "<div>";
|
var dialog_success_mr_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_success_mr_text =
|
dialog_success_mr_text =
|
||||||
dialog_success_mr_text +
|
dialog_success_mr_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>SUCCESS</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_exito_mr.png'></div>";
|
|
||||||
dialog_success_mr_text =
|
dialog_success_mr_text =
|
||||||
dialog_success_mr_text +
|
dialog_success_mr_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>SUCCESS</strong></h3>";
|
"<p>" +
|
||||||
dialog_success_mr_text =
|
|
||||||
dialog_success_mr_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
mr_success +
|
mr_success +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_success_mr_text =
|
||||||
|
dialog_success_mr_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_success_mr.png'></div>";
|
||||||
dialog_success_mr_text =
|
dialog_success_mr_text =
|
||||||
dialog_success_mr_text + "</div>";
|
dialog_success_mr_text + "</div>";
|
||||||
|
|
||||||
|
@ -1774,20 +1778,21 @@ function install_free_package_prev_step(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_error_mr_text = "<div>";
|
var dialog_error_mr_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_error_mr_text =
|
dialog_error_mr_text =
|
||||||
dialog_error_mr_text +
|
dialog_error_mr_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>ERROR</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_error_mr.png'></div>";
|
|
||||||
dialog_error_mr_text =
|
dialog_error_mr_text =
|
||||||
dialog_error_mr_text +
|
dialog_error_mr_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
|
"<p>" +
|
||||||
dialog_error_mr_text =
|
|
||||||
dialog_error_mr_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
mr_error +
|
mr_error +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_error_mr_text =
|
||||||
|
dialog_error_mr_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_error_mr.png'></div>";
|
||||||
dialog_error_mr_text =
|
dialog_error_mr_text =
|
||||||
dialog_error_mr_text + "</div>";
|
dialog_error_mr_text + "</div>";
|
||||||
|
|
||||||
|
@ -1827,20 +1832,21 @@ function install_free_package_prev_step(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_cancel_mr_text = "<div>";
|
var dialog_cancel_mr_text =
|
||||||
|
"<div class='update_popup'>";
|
||||||
dialog_cancel_mr_text =
|
dialog_cancel_mr_text =
|
||||||
dialog_cancel_mr_text +
|
dialog_cancel_mr_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>INFO</h3>";
|
||||||
home_url +
|
|
||||||
"images/icono_info_mr.png'></div>";
|
|
||||||
dialog_cancel_mr_text =
|
dialog_cancel_mr_text =
|
||||||
dialog_cancel_mr_text +
|
dialog_cancel_mr_text +
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>INFO</strong></h3>";
|
"<p>" +
|
||||||
dialog_cancel_mr_text =
|
|
||||||
dialog_cancel_mr_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
mr_cancel +
|
mr_cancel +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_cancel_mr_text =
|
||||||
|
dialog_cancel_mr_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_info_mr.png'></div>";
|
||||||
dialog_cancel_mr_text =
|
dialog_cancel_mr_text =
|
||||||
dialog_cancel_mr_text + "</div>";
|
dialog_cancel_mr_text + "</div>";
|
||||||
|
|
||||||
|
@ -1855,34 +1861,33 @@ function install_free_package_prev_step(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
$("button:contains(Apply MR)").attr("id", "apply_rr_button");
|
$("button:contains(Apply MR)")
|
||||||
|
.attr("id", "apply_rr_button")
|
||||||
|
.addClass("success_button");
|
||||||
$("button:contains(Cancel)").attr("id", "cancel_rr_button");
|
$("button:contains(Cancel)").attr("id", "cancel_rr_button");
|
||||||
|
|
||||||
var dialog_have_mr_text = "<div>";
|
var dialog_have_mr_text = "<div class='update_popup'>";
|
||||||
dialog_have_mr_text =
|
dialog_have_mr_text =
|
||||||
dialog_have_mr_text +
|
dialog_have_mr_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>" +
|
||||||
home_url +
|
|
||||||
"images/icono_warning_mr.png'></div>";
|
|
||||||
dialog_have_mr_text =
|
|
||||||
dialog_have_mr_text +
|
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>" +
|
|
||||||
mr_available_header +
|
mr_available_header +
|
||||||
"</strong></h3>";
|
"</h3>";
|
||||||
|
dialog_have_mr_text =
|
||||||
|
dialog_have_mr_text + "<p>" + text1_mr_file + "</p>";
|
||||||
dialog_have_mr_text =
|
dialog_have_mr_text =
|
||||||
dialog_have_mr_text +
|
dialog_have_mr_text +
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
"<p>" +
|
||||||
text1_mr_file +
|
|
||||||
"</p>";
|
|
||||||
dialog_have_mr_text =
|
|
||||||
dialog_have_mr_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
text2_mr_file +
|
text2_mr_file +
|
||||||
"<a style='font-family:Verdana bold; font-size:12pt; color:#82B92E'href=\"index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list\">" +
|
'<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list">' +
|
||||||
text3_mr_file +
|
text3_mr_file +
|
||||||
"</a>" +
|
"</a>" +
|
||||||
text4_mr_file +
|
text4_mr_file +
|
||||||
"</p></div>";
|
"</p></div>";
|
||||||
|
dialog_have_mr_text =
|
||||||
|
dialog_have_mr_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
|
home_url +
|
||||||
|
"images/icon_warning_db.png'></div>";
|
||||||
dialog_have_mr_text = dialog_have_mr_text + "</div>";
|
dialog_have_mr_text = dialog_have_mr_text + "</div>";
|
||||||
|
|
||||||
$("#mr_dialog2").html(dialog_have_mr_text);
|
$("#mr_dialog2").html(dialog_have_mr_text);
|
||||||
|
@ -1950,20 +1955,16 @@ function install_free_package_prev_step(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_cancel_pkg_text = "<div>";
|
var dialog_cancel_pkg_text = "<div class='update_popup'>";
|
||||||
|
dialog_cancel_pkg_text =
|
||||||
|
dialog_cancel_pkg_text + "<div class='update_text'><h3>INFO</h3>";
|
||||||
|
dialog_cancel_pkg_text =
|
||||||
|
dialog_cancel_pkg_text + "<p>" + package_cancel + "</p></div>";
|
||||||
dialog_cancel_pkg_text =
|
dialog_cancel_pkg_text =
|
||||||
dialog_cancel_pkg_text +
|
dialog_cancel_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_icon'><img src='" +
|
||||||
home_url +
|
home_url +
|
||||||
"images/icono_info_mr.png'></div>";
|
"images/icon_info_mr.png'></div>";
|
||||||
dialog_cancel_pkg_text =
|
|
||||||
dialog_cancel_pkg_text +
|
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>INFO</strong></h3>";
|
|
||||||
dialog_cancel_pkg_text =
|
|
||||||
dialog_cancel_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
package_cancel +
|
|
||||||
"</p></div>";
|
|
||||||
dialog_cancel_pkg_text = dialog_cancel_pkg_text + "</div>";
|
dialog_cancel_pkg_text = dialog_cancel_pkg_text + "</div>";
|
||||||
|
|
||||||
$("#cancel_pkg").html(dialog_cancel_pkg_text);
|
$("#cancel_pkg").html(dialog_cancel_pkg_text);
|
||||||
|
@ -1977,22 +1978,18 @@ function install_free_package_prev_step(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_text = "<div>";
|
var dialog_text = "<div class='update_popup'>";
|
||||||
dialog_text =
|
dialog_text =
|
||||||
dialog_text +
|
dialog_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>" +
|
||||||
home_url +
|
|
||||||
"images/icono_info_mr.png'></div>";
|
|
||||||
dialog_text =
|
|
||||||
dialog_text +
|
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>" +
|
|
||||||
text1_package_file +
|
text1_package_file +
|
||||||
"</strong></h3>";
|
"</h3>";
|
||||||
|
dialog_text = dialog_text + "<p>" + text2_package_file + "</p></div>";
|
||||||
dialog_text =
|
dialog_text =
|
||||||
dialog_text +
|
dialog_text +
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
"<div class='update_icon'><img src='" +
|
||||||
text2_package_file +
|
home_url +
|
||||||
"</p></div>";
|
"images/icon_info_mr.png'></div>";
|
||||||
dialog_text = dialog_text + "</div>";
|
dialog_text = dialog_text + "</div>";
|
||||||
|
|
||||||
$("#pkg_apply_dialog").html(dialog_text);
|
$("#pkg_apply_dialog").html(dialog_text);
|
||||||
|
@ -2039,20 +2036,16 @@ function install_free_package(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_error_pkg_text = "<div>";
|
var dialog_error_pkg_text = "<div class='update_popup'>";
|
||||||
|
dialog_error_pkg_text =
|
||||||
|
dialog_error_pkg_text + "<div class='update_text'><h3>ERROR</h3>";
|
||||||
|
dialog_error_pkg_text =
|
||||||
|
dialog_error_pkg_text + "<p>" + data["message"] + "</p></div>";
|
||||||
dialog_error_pkg_text =
|
dialog_error_pkg_text =
|
||||||
dialog_error_pkg_text +
|
dialog_error_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_icon'><img src='" +
|
||||||
home_url +
|
home_url +
|
||||||
"images/icono_error_mr.png'></div>";
|
"images/icon_error_mr.png'></div>";
|
||||||
dialog_error_pkg_text =
|
|
||||||
dialog_error_pkg_text +
|
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
|
|
||||||
dialog_error_pkg_text =
|
|
||||||
dialog_error_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
data["message"] +
|
|
||||||
"</p></div>";
|
|
||||||
dialog_error_pkg_text = dialog_error_pkg_text + "</div>";
|
dialog_error_pkg_text = dialog_error_pkg_text + "</div>";
|
||||||
|
|
||||||
$("#error_pkg").html(dialog_error_pkg_text);
|
$("#error_pkg").html(dialog_error_pkg_text);
|
||||||
|
@ -2092,20 +2085,17 @@ function install_free_package(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_success_pkg_text = "<div>";
|
var dialog_success_pkg_text = "<div class='update_popup'>";
|
||||||
dialog_success_pkg_text =
|
dialog_success_pkg_text =
|
||||||
dialog_success_pkg_text +
|
dialog_success_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_text'><h3>SUCCESS</h3>";
|
||||||
|
dialog_success_pkg_text =
|
||||||
|
dialog_success_pkg_text + "<p>" + data["message"] + "</p></div>";
|
||||||
|
dialog_success_pkg_text =
|
||||||
|
dialog_success_pkg_text +
|
||||||
|
"<div class='update_icon'><img src='" +
|
||||||
home_url +
|
home_url +
|
||||||
"images/icono_exito_mr.png'></div>";
|
"images/icon_success_mr.png'></div>";
|
||||||
dialog_success_pkg_text =
|
|
||||||
dialog_success_pkg_text +
|
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>SUCCESS</strong></h3>";
|
|
||||||
dialog_success_pkg_text =
|
|
||||||
dialog_success_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
data["message"] +
|
|
||||||
"</p></div>";
|
|
||||||
dialog_success_pkg_text = dialog_success_pkg_text + "</div>";
|
dialog_success_pkg_text = dialog_success_pkg_text + "</div>";
|
||||||
|
|
||||||
$("#success_pkg").html(dialog_success_pkg_text);
|
$("#success_pkg").html(dialog_success_pkg_text);
|
||||||
|
@ -2142,20 +2132,16 @@ function install_free_package(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_error_pkg_text = "<div>";
|
var dialog_error_pkg_text = "<div class='update_popup'>";
|
||||||
|
dialog_error_pkg_text =
|
||||||
|
dialog_error_pkg_text + "<div class='update_text'><h3>ERROR</h3>";
|
||||||
|
dialog_error_pkg_text =
|
||||||
|
dialog_error_pkg_text + "<p>" + data["message"] + "</p></div>";
|
||||||
dialog_error_pkg_text =
|
dialog_error_pkg_text =
|
||||||
dialog_error_pkg_text +
|
dialog_error_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_icon'><img src='" +
|
||||||
home_url +
|
home_url +
|
||||||
"images/icono_error_mr.png'></div>";
|
"images/icon_error_mr.png'></div>";
|
||||||
dialog_error_pkg_text =
|
|
||||||
dialog_error_pkg_text +
|
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
|
|
||||||
dialog_error_pkg_text =
|
|
||||||
dialog_error_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
data["message"] +
|
|
||||||
"</p></div>";
|
|
||||||
dialog_error_pkg_text = dialog_error_pkg_text + "</div>";
|
dialog_error_pkg_text = dialog_error_pkg_text + "</div>";
|
||||||
|
|
||||||
$("#error_pkg").html(dialog_error_pkg_text);
|
$("#error_pkg").html(dialog_error_pkg_text);
|
||||||
|
@ -2193,20 +2179,16 @@ function install_free_package(package, version, homeurl) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog_error_pkg_text = "<div>";
|
var dialog_error_pkg_text = "<div class='update_popup'>";
|
||||||
|
dialog_error_pkg_text =
|
||||||
|
dialog_error_pkg_text + "<div class='update_text'><h3>ERROR</h3>";
|
||||||
|
dialog_error_pkg_text =
|
||||||
|
dialog_error_pkg_text + "<p>" + data["message"] + "</p></div>";
|
||||||
dialog_error_pkg_text =
|
dialog_error_pkg_text =
|
||||||
dialog_error_pkg_text +
|
dialog_error_pkg_text +
|
||||||
"<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='" +
|
"<div class='update_icon'><img src='" +
|
||||||
home_url +
|
home_url +
|
||||||
"images/icono_error_mr.png'></div>";
|
"images/icon_error_mr.png'></div>";
|
||||||
dialog_error_pkg_text =
|
|
||||||
dialog_error_pkg_text +
|
|
||||||
"<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
|
|
||||||
dialog_error_pkg_text =
|
|
||||||
dialog_error_pkg_text +
|
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>" +
|
|
||||||
data["message"] +
|
|
||||||
"</p></div>";
|
|
||||||
dialog_error_pkg_text = dialog_error_pkg_text + "</div>";
|
dialog_error_pkg_text = dialog_error_pkg_text + "</div>";
|
||||||
|
|
||||||
$("#error_pkg").html(dialog_error_pkg_text);
|
$("#error_pkg").html(dialog_error_pkg_text);
|
||||||
|
@ -2246,13 +2228,7 @@ function apply_minor_release(n_mr, pkg, ent, off, homeurl) {
|
||||||
$("#mr_dialog2").html(data);
|
$("#mr_dialog2").html(data);
|
||||||
error["error"] = true;
|
error["error"] = true;
|
||||||
} else {
|
} else {
|
||||||
$("#mr_dialog2").append(
|
$("#mr_dialog2").append("<p>- " + applying_mr + " #" + mr + "</p>");
|
||||||
"<p style='font-family:Verdana; font-size:12pt;'>- " +
|
|
||||||
applying_mr +
|
|
||||||
" #" +
|
|
||||||
mr +
|
|
||||||
"</p>"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
if (!is_ajax()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once $config['homedir'].'/vendor/autoload.php';
|
||||||
|
|
||||||
|
use Models\VisualConsole\Container as VisualConsole;
|
||||||
|
|
||||||
|
$visualConsoleId = (int) get_parameter('visualConsoleId');
|
||||||
|
$getVisualConsole = (bool) get_parameter('getVisualConsole');
|
||||||
|
$getVisualConsoleItems = (bool) get_parameter('getVisualConsoleItems');
|
||||||
|
|
||||||
|
// Check groups can access user.
|
||||||
|
$aclUserGroups = [];
|
||||||
|
if (!users_can_manage_group_all('AR')) {
|
||||||
|
$aclUserGroups = array_keys(users_get_groups(false, 'AR'));
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_clean();
|
||||||
|
|
||||||
|
if ($getVisualConsole === true) {
|
||||||
|
$visualConsole = VisualConsole::fromDB(['id' => $visualConsoleId]);
|
||||||
|
$visualConsoleData = $visualConsole->toArray();
|
||||||
|
$groupId = $visualConsoleData['groupId'];
|
||||||
|
|
||||||
|
// ACL.
|
||||||
|
$aclRead = check_acl($config['id_user'], $groupId, 'VR');
|
||||||
|
$aclWrite = check_acl($config['id_user'], $groupId, 'VW');
|
||||||
|
$aclManage = check_acl($config['id_user'], $groupId, 'VM');
|
||||||
|
|
||||||
|
if (!$aclRead && !$aclWrite && !$aclManage) {
|
||||||
|
db_pandora_audit(
|
||||||
|
'ACL Violation',
|
||||||
|
'Trying to access visual console without group access'
|
||||||
|
);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $visualConsole;
|
||||||
|
} else if ($getVisualConsoleItems === true) {
|
||||||
|
$vcItems = VisualConsole::getItemsFromDB($visualConsoleId, $aclUserGroups);
|
||||||
|
echo '['.implode($vcItems, ',').']';
|
||||||
|
}
|
||||||
|
|
||||||
|
exit;
|
|
@ -0,0 +1,231 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class should be extended to add functionalities to
|
||||||
|
* fetch, validate, transform and represent data entities.
|
||||||
|
*/
|
||||||
|
abstract class Model
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal data of the model.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $data;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the received data structure to ensure if we can extract the
|
||||||
|
* values required to build the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException If any input value is considered
|
||||||
|
* invalid.
|
||||||
|
*
|
||||||
|
* @abstract
|
||||||
|
*/
|
||||||
|
abstract protected function validateData(array $data): void;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @abstract
|
||||||
|
*/
|
||||||
|
abstract protected function decode(array $data): array;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor of the model. It won't be public. The instances
|
||||||
|
* will be created through factories which start with from*.
|
||||||
|
*
|
||||||
|
* @param array $unknownData Input data structure.
|
||||||
|
*/
|
||||||
|
protected function __construct(array $unknownData)
|
||||||
|
{
|
||||||
|
$this->validateData($unknownData);
|
||||||
|
$this->data = $this->decode($unknownData);
|
||||||
|
// Sort alphabetically.
|
||||||
|
ksort($this->data, (SORT_NATURAL | SORT_FLAG_CASE));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instance the class with the unknown input data.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown data structure.
|
||||||
|
*
|
||||||
|
* @return self Instance of the model.
|
||||||
|
*/
|
||||||
|
public static function fromArray(array $data)
|
||||||
|
{
|
||||||
|
// The reserved word static refers to the invoked class at runtime.
|
||||||
|
return new static($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter to retrieve the modeled element.
|
||||||
|
*
|
||||||
|
* @return array The modeled element data structure stored into the DB.
|
||||||
|
* @throws \Exception When the data cannot be retrieved from the DB.
|
||||||
|
*
|
||||||
|
* @abstract
|
||||||
|
*/
|
||||||
|
abstract protected static function fetchDataFromDB(array $filter);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a model's instance from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter to retrieve the modeled element.
|
||||||
|
*
|
||||||
|
* @return self A modeled element's instance.
|
||||||
|
*/
|
||||||
|
public static function fromDB(array $filter): self
|
||||||
|
{
|
||||||
|
// The reserved word static refers to the invoked class at runtime.
|
||||||
|
return static::fromArray(static::fetchDataFromDB($filter));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON representation of the model.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function toArray(): array
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON representation of the model.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function toJson(): string
|
||||||
|
{
|
||||||
|
return \json_encode($this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text representation of the model.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function __toString(): string
|
||||||
|
{
|
||||||
|
return $this->toJson();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -------------
|
||||||
|
* - UTILITIES -
|
||||||
|
* -------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From a unknown value, it will try to extract a valid boolean value.
|
||||||
|
*
|
||||||
|
* @param mixed $value Unknown input.
|
||||||
|
*
|
||||||
|
* @return boolean Valid boolean value.
|
||||||
|
*/
|
||||||
|
protected static function parseBool($value): bool
|
||||||
|
{
|
||||||
|
if (\is_bool($value) === true) {
|
||||||
|
return $value;
|
||||||
|
} else if (\is_numeric($value) === true) {
|
||||||
|
return $value > 0;
|
||||||
|
} else if (\is_string($value) === true) {
|
||||||
|
return $value === '1' || $value === 'true';
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a not empty string or a default value from a unknown value.
|
||||||
|
*
|
||||||
|
* @param mixed $val Input value.
|
||||||
|
* @param mixed $def Default value.
|
||||||
|
*
|
||||||
|
* @return mixed A valid string (not empty) extracted from the input
|
||||||
|
* or the default value.
|
||||||
|
*/
|
||||||
|
protected static function notEmptyStringOr($val, $def)
|
||||||
|
{
|
||||||
|
return (\is_string($val) === true && strlen($val) > 0) ? $val : $def;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a valid integer or a default value from a unknown value.
|
||||||
|
*
|
||||||
|
* @param mixed $val Input value.
|
||||||
|
* @param mixed $def Default value.
|
||||||
|
*
|
||||||
|
* @return mixed A valid int extracted from the input or the default value.
|
||||||
|
*/
|
||||||
|
protected static function parseIntOr($val, $def)
|
||||||
|
{
|
||||||
|
return (is_numeric($val) === true) ? (int) $val : $def;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a valid float or a default value from a unknown value.
|
||||||
|
*
|
||||||
|
* @param mixed $val Input value.
|
||||||
|
* @param mixed $def Default value.
|
||||||
|
*
|
||||||
|
* @return mixed A valid float extracted from the input or the
|
||||||
|
* default value.
|
||||||
|
*/
|
||||||
|
protected static function parseFloatOr($val, $def)
|
||||||
|
{
|
||||||
|
return (is_numeric($val) === true) ? (float) $val : $def;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a value from a dictionary from a possible pool of keys.
|
||||||
|
*
|
||||||
|
* @param array $dict Input array.
|
||||||
|
* @param array $keys Possible keys.
|
||||||
|
*
|
||||||
|
* @return mixed The first value found with the pool of keys or null.
|
||||||
|
*/
|
||||||
|
protected static function issetInArray(array $dict, array $keys)
|
||||||
|
{
|
||||||
|
foreach ($keys as $key => $value) {
|
||||||
|
if (isset($dict[$value]) === true) {
|
||||||
|
return $dict[$value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,376 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole;
|
||||||
|
use Models\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a Visual Console.
|
||||||
|
*/
|
||||||
|
final class Container extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the received data structure to ensure if we can extract the
|
||||||
|
* values required to build the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException If any input value is considered
|
||||||
|
* invalid.
|
||||||
|
*
|
||||||
|
* @overrides Model::validateData.
|
||||||
|
*/
|
||||||
|
protected function validateData(array $data): void
|
||||||
|
{
|
||||||
|
if (isset($data['id']) === false
|
||||||
|
|| \is_numeric($data['id']) === false
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the Id property is required and should be integer'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data['name']) === false
|
||||||
|
|| \is_string($data['name']) === false
|
||||||
|
|| empty($data['name']) === true
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the name property is required and should be string'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data['width']) === false
|
||||||
|
|| \is_numeric($data['width']) === false
|
||||||
|
|| $data['width'] <= 0
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the width property is required and should greater than 0'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data['height']) === false
|
||||||
|
|| \is_numeric($data['height']) === false
|
||||||
|
|| $data['height'] <= 0
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the height property is required and should greater than 0'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static::extractGroupId($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Model::decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => (int) $data['id'],
|
||||||
|
'name' => $data['name'],
|
||||||
|
'groupId' => static::extractGroupId($data),
|
||||||
|
'backgroundImage' => static::extractBackgroundImage($data),
|
||||||
|
'backgroundColor' => static::extractBackgroundColor($data),
|
||||||
|
'isFavorite' => static::extractFavorite($data),
|
||||||
|
'width' => (int) $data['width'],
|
||||||
|
'height' => (int) $data['height'],
|
||||||
|
'backgroundURL' => static::extractBackgroundUrl($data),
|
||||||
|
'relationLineWidth' => (int) $data['relationLineWidth'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a group Id value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return integer Valid identifier of a group.
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException When a valid group Id can't be found.
|
||||||
|
*/
|
||||||
|
private static function extractGroupId(array $data): int
|
||||||
|
{
|
||||||
|
$groupId = static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['id_group', 'groupId']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($groupId === null || $groupId < 0) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the group Id property is required and should be integer'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a image name value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the image name (not empty) or null.
|
||||||
|
*/
|
||||||
|
private static function extractBackgroundImage(array $data)
|
||||||
|
{
|
||||||
|
$backgroundImage = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['background', 'backgroundURL']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
return ($backgroundImage === 'None.png') ? null : $backgroundImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a image url value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the image url (not empty) or null.
|
||||||
|
*/
|
||||||
|
private static function extractBackgroundUrl(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['backgroundURL']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a background color value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the color (not empty) or null.
|
||||||
|
*/
|
||||||
|
private static function extractBackgroundColor(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray(
|
||||||
|
$data,
|
||||||
|
[
|
||||||
|
'backgroundColor',
|
||||||
|
'background_color',
|
||||||
|
]
|
||||||
|
),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the "is favorite" switch value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return boolean If the item is favorite or not.
|
||||||
|
*/
|
||||||
|
private static function extractFavorite(array $data): bool
|
||||||
|
{
|
||||||
|
return static::parseBool(
|
||||||
|
static::issetInArray($data, ['is_favourite', 'isFavorite'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a container data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console.
|
||||||
|
*
|
||||||
|
* @return self A Visual Console Container instance.
|
||||||
|
* @throws \Exception When the data cannot be retrieved from the DB.
|
||||||
|
*
|
||||||
|
* @override Model::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter)
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$row = \db_get_row_filter('tlayout', $filter);
|
||||||
|
|
||||||
|
if ($row === false) {
|
||||||
|
throw new \Exception('error fetching the data from the DB');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load side libraries.
|
||||||
|
global $config;
|
||||||
|
include_once $config['homedir'].'/include/functions_io.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_ui.php';
|
||||||
|
|
||||||
|
// Clean HTML entities.
|
||||||
|
$row = \io_safe_output($row);
|
||||||
|
|
||||||
|
$row['relationLineWidth'] = (int) $config['vc_line_thickness'];
|
||||||
|
|
||||||
|
$backgroundUrl = static::extractBackgroundUrl($row);
|
||||||
|
$backgroundImage = static::extractBackgroundImage($row);
|
||||||
|
|
||||||
|
if ($backgroundUrl === null && $backgroundImage !== null) {
|
||||||
|
$row['backgroundURL'] = ui_get_full_url(
|
||||||
|
'images/console/background/'.$backgroundImage,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return \io_safe_output($row);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a item's class.
|
||||||
|
*
|
||||||
|
* @param integer $type Type of the item of the Visual Console.
|
||||||
|
*
|
||||||
|
* @return mixed A reference to the item's class.
|
||||||
|
*/
|
||||||
|
public static function getItemClass(int $type)
|
||||||
|
{
|
||||||
|
switch ($type) {
|
||||||
|
case STATIC_GRAPH:
|
||||||
|
return Items\StaticGraph::class;
|
||||||
|
|
||||||
|
case MODULE_GRAPH:
|
||||||
|
return Items\ModuleGraph::class;
|
||||||
|
|
||||||
|
case SIMPLE_VALUE:
|
||||||
|
case SIMPLE_VALUE_MAX:
|
||||||
|
case SIMPLE_VALUE_MIN:
|
||||||
|
case SIMPLE_VALUE_AVG:
|
||||||
|
return Items\SimpleValue::class;
|
||||||
|
|
||||||
|
case PERCENTILE_BAR:
|
||||||
|
case PERCENTILE_BUBBLE:
|
||||||
|
case CIRCULAR_PROGRESS_BAR:
|
||||||
|
case CIRCULAR_INTERIOR_PROGRESS_BAR:
|
||||||
|
return Items\Percentile::class;
|
||||||
|
|
||||||
|
case LABEL:
|
||||||
|
return Items\Label::class;
|
||||||
|
|
||||||
|
case ICON:
|
||||||
|
return Items\Icon::class;
|
||||||
|
|
||||||
|
// Enterprise item. It may not exist.
|
||||||
|
case SERVICE:
|
||||||
|
return \class_exists('\Enterprise\Models\VisualConsole\Items\Service') ? \Enterprise\Models\VisualConsole\Items\Service::class : Item::class;
|
||||||
|
|
||||||
|
case GROUP_ITEM:
|
||||||
|
return Items\Group::class;
|
||||||
|
|
||||||
|
case BOX_ITEM:
|
||||||
|
return Items\Box::class;
|
||||||
|
|
||||||
|
case LINE_ITEM:
|
||||||
|
return Items\Line::class;
|
||||||
|
|
||||||
|
case AUTO_SLA_GRAPH:
|
||||||
|
return Items\EventsHistory::class;
|
||||||
|
|
||||||
|
case DONUT_GRAPH:
|
||||||
|
return Items\DonutGraph::class;
|
||||||
|
|
||||||
|
case BARS_GRAPH:
|
||||||
|
return Items\BarsGraph::class;
|
||||||
|
|
||||||
|
case CLOCK:
|
||||||
|
return Items\Clock::class;
|
||||||
|
|
||||||
|
case COLOR_CLOUD:
|
||||||
|
return Items\ColorCloud::class;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Item::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a list of items which belong to the Visual Console.
|
||||||
|
*
|
||||||
|
* @param integer $layoutId Identifier of the Visual Console.
|
||||||
|
* @param array $groupsFilter Groups can access user.
|
||||||
|
*
|
||||||
|
* @return array A list of items.
|
||||||
|
* @throws \Exception When the data cannot be retrieved from the DB.
|
||||||
|
*/
|
||||||
|
public static function getItemsFromDB(
|
||||||
|
int $layoutId,
|
||||||
|
array $groupsFilter=[]
|
||||||
|
): array {
|
||||||
|
// Default filter.
|
||||||
|
$filter = ['id_layout' => $layoutId];
|
||||||
|
$fields = [
|
||||||
|
'id',
|
||||||
|
'type',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Override the filter if the groups filter is not empty.
|
||||||
|
if (count($groupsFilter) > 0) {
|
||||||
|
// Filter group for elements groups.
|
||||||
|
$filter = [];
|
||||||
|
$filter[] = \db_format_array_where_clause_sql(
|
||||||
|
[
|
||||||
|
'id_layout' => $layoutId,
|
||||||
|
'element_group' => $groupsFilter,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Filter groups for type groups.
|
||||||
|
// Only true condition if type is GROUP_ITEM.
|
||||||
|
$filter[] = '('.\db_format_array_where_clause_sql(
|
||||||
|
[
|
||||||
|
'type' => GROUP_ITEM,
|
||||||
|
'id_group' => $groupsFilter,
|
||||||
|
]
|
||||||
|
).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows = \db_get_all_rows_filter(
|
||||||
|
'tlayout_data',
|
||||||
|
$filter,
|
||||||
|
$fields,
|
||||||
|
'OR'
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($rows === false) {
|
||||||
|
$rows = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = [];
|
||||||
|
|
||||||
|
foreach ($rows as $data) {
|
||||||
|
$itemId = (int) $data['id'];
|
||||||
|
$itemType = (int) $data['type'];
|
||||||
|
$class = static::getItemClass($itemType);
|
||||||
|
|
||||||
|
try {
|
||||||
|
array_push($items, $class::fromDB(['id' => $itemId]));
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
// TODO: Log this?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,346 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a bars graph item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class BarsGraph extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked module.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedModule = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable validation, extraction and encodeing of the HTML output.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useHtmlOutput = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item::decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::decode($data);
|
||||||
|
$return['type'] = BARS_GRAPH;
|
||||||
|
$return['gridColor'] = $this->extractGridColor($data);
|
||||||
|
$return['backgroundColor'] = $this->extractBackgroundColor($data);
|
||||||
|
$return['typeGraph'] = $this->extractTypeGraph($data);
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a grid color value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the grid color (not empty) or null.
|
||||||
|
*/
|
||||||
|
private function extractGridColor(array $data): string
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['gridColor', 'border_color']),
|
||||||
|
'#000000'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a background color value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string One of 'white', 'black' or 'transparent'.
|
||||||
|
* 'white' by default.
|
||||||
|
*/
|
||||||
|
private function extractBackgroundColor(array $data): string
|
||||||
|
{
|
||||||
|
$backgroundColor = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['backgroundColor', 'image']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
switch ($backgroundColor) {
|
||||||
|
case 'black':
|
||||||
|
case 'transparent':
|
||||||
|
return $backgroundColor;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'white';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a type graph value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string One of 'vertical' or 'horizontal'. 'vertical' by default.
|
||||||
|
*/
|
||||||
|
private function extractTypeGraph(array $data): string
|
||||||
|
{
|
||||||
|
$typeGraph = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['typeGraph', 'type_graph']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
switch ($typeGraph) {
|
||||||
|
case 'horizontal':
|
||||||
|
return 'horizontal';
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'vertical';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a vc item data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console Item.
|
||||||
|
*
|
||||||
|
* @return array The Visual Console Item data structure stored into the DB.
|
||||||
|
* @throws \InvalidArgumentException When an agent Id cannot be found.
|
||||||
|
*
|
||||||
|
* @override Item::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$data = parent::fetchDataFromDB($filter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve extra data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load config.
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
// Load side libraries.
|
||||||
|
include_once $config['homedir'].'/include/functions_ui.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_visual_map.php';
|
||||||
|
include_once $config['homedir'].'/include/graphs/fgraph.php';
|
||||||
|
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
\enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract needed properties.
|
||||||
|
$gridColor = static::extractGridColor($data);
|
||||||
|
$backGroundColor = static::extractBackgroundColor($data);
|
||||||
|
$typeGraph = static::extractTypeGraph($data);
|
||||||
|
|
||||||
|
// Get the linked agent and module Ids.
|
||||||
|
$linkedModule = static::extractLinkedModule($data);
|
||||||
|
$agentId = $linkedModule['agentId'];
|
||||||
|
$moduleId = $linkedModule['moduleId'];
|
||||||
|
$metaconsoleId = $linkedModule['metaconsoleId'];
|
||||||
|
|
||||||
|
if ($agentId === null) {
|
||||||
|
throw new \InvalidArgumentException('missing agent Id');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($moduleId === null) {
|
||||||
|
throw new \InvalidArgumentException('missing module Id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add colors that will use the graphics.
|
||||||
|
$color = [];
|
||||||
|
|
||||||
|
$color[0] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color1'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[1] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color2'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[2] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color3'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[3] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color4'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[4] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color5'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[5] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color6'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[6] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color7'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[7] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color8'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[8] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color9'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[9] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color10'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[11] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => COL_GRAPH9,
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[12] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => COL_GRAPH10,
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[13] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => COL_GRAPH11,
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[14] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => COL_GRAPH12,
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
$color[15] = [
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => COL_GRAPH13,
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Maybe connect to node.
|
||||||
|
$nodeConnected = false;
|
||||||
|
if (\is_metaconsole() === true && $metaconsoleId !== null) {
|
||||||
|
$nodeConnected = \metaconsole_connect(
|
||||||
|
null,
|
||||||
|
$metaconsoleId
|
||||||
|
) === NOERR;
|
||||||
|
|
||||||
|
if ($nodeConnected === false) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'error connecting to the node'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$moduleData = \get_bars_module_data($moduleId);
|
||||||
|
|
||||||
|
$waterMark = [
|
||||||
|
'file' => $config['homedir'].'/images/logo_vertical_water.png',
|
||||||
|
'url' => \ui_get_full_url(
|
||||||
|
'images/logo_vertical_water.png',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ((int) $data['width'] === 0 || (int) $data['height'] === 0) {
|
||||||
|
$width = 400;
|
||||||
|
$height = 400;
|
||||||
|
} else {
|
||||||
|
$width = (int) $data['width'];
|
||||||
|
$height = (int) $data['height'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($typeGraph === 'horizontal') {
|
||||||
|
$graph = \hbar_graph(
|
||||||
|
$moduleData,
|
||||||
|
$width,
|
||||||
|
$height,
|
||||||
|
$color,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
\ui_get_full_url(
|
||||||
|
'images/image_problem_area.png',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
$waterMark,
|
||||||
|
$config['fontpath'],
|
||||||
|
6,
|
||||||
|
'',
|
||||||
|
0,
|
||||||
|
$config['homeurl'],
|
||||||
|
$backGroundColor,
|
||||||
|
$gridColor
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$graph = \vbar_graph(
|
||||||
|
$moduleData,
|
||||||
|
$width,
|
||||||
|
$height,
|
||||||
|
$color,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
\ui_get_full_url(
|
||||||
|
'images/image_problem_area.png',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
$waterMark,
|
||||||
|
$config['fontpath'],
|
||||||
|
6,
|
||||||
|
'',
|
||||||
|
0,
|
||||||
|
$config['homeurl'],
|
||||||
|
$backGroundColor,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
$gridColor
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore connection.
|
||||||
|
if ($nodeConnected === true) {
|
||||||
|
\metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['html'] = $graph;
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a Box item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class Box extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item::decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$boxData = parent::decode($data);
|
||||||
|
$boxData['type'] = BOX_ITEM;
|
||||||
|
$boxData['parentId'] = null;
|
||||||
|
$boxData['aclGroupId'] = null;
|
||||||
|
$boxData['borderWidth'] = $this->extractBorderWidth($data);
|
||||||
|
$boxData['borderColor'] = $this->extractBorderColor($data);
|
||||||
|
$boxData['fillColor'] = $this->extractFillColor($data);
|
||||||
|
return $boxData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a border width value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return integer Valid border width. 0 by default.
|
||||||
|
*/
|
||||||
|
private function extractBorderWidth(array $data): int
|
||||||
|
{
|
||||||
|
return static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['borderWidth', 'border_width']),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a border color value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the border color (not empty) or null.
|
||||||
|
*/
|
||||||
|
private function extractBorderColor(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['borderColor', 'border_color']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a fill color value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the fill color (not empty) or null.
|
||||||
|
*/
|
||||||
|
private function extractFillColor(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['fillColor', 'fill_color']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,154 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a clock item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class Clock extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked visual console.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedVisualConsole = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
* @throws \InvalidArgumentException When there is a problem with
|
||||||
|
* the time management.
|
||||||
|
*
|
||||||
|
* @overrides Item::decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$clockData = parent::decode($data);
|
||||||
|
$clockData['type'] = CLOCK;
|
||||||
|
$clockData['clockType'] = static::extractClockType($data);
|
||||||
|
$clockData['clockFormat'] = static::extractClockFormat($data);
|
||||||
|
$clockData['clockTimezone'] = static::extractClockTimezone($data);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$timezone = new \DateTimeZone($clockData['clockTimezone']);
|
||||||
|
$timezoneUTC = new \DateTimeZone('UTC');
|
||||||
|
$dateTimeUtc = new \DateTime('now', $timezoneUTC);
|
||||||
|
$clockData['clockTimezoneOffset'] = $timezone->getOffset(
|
||||||
|
$dateTimeUtc
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
throw new \InvalidArgumentException($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// $clockData['showClockTimezone'] = static::parseBool(
|
||||||
|
// static::issetInArray($data, ['showClockTimezone'])
|
||||||
|
// );
|
||||||
|
// TODO: Remove the true by default when added into the editor.
|
||||||
|
$clockData['showClockTimezone'] = true;
|
||||||
|
$clockData['color'] = static::extractColor($data);
|
||||||
|
return $clockData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a clock type value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string One of 'digital' or 'analogic'. 'analogic' by default.
|
||||||
|
*/
|
||||||
|
private static function extractClockType(array $data): string
|
||||||
|
{
|
||||||
|
$clockType = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['clockType', 'clock_animation']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
switch ($clockType) {
|
||||||
|
case 'digital':
|
||||||
|
case 'digital_1':
|
||||||
|
return 'digital';
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'analogic';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a clock format value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string One of 'time' or 'datetime'. 'datetime' by default.
|
||||||
|
*/
|
||||||
|
private static function extractClockFormat(array $data): string
|
||||||
|
{
|
||||||
|
$clockFormat = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['clockFormat', 'time_format']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
switch ($clockFormat) {
|
||||||
|
case 'time':
|
||||||
|
return 'time';
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'datetime';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a clock timezone value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws \InvalidArgumentException When a valid clock timezone cannot be
|
||||||
|
* extracted.
|
||||||
|
*/
|
||||||
|
private static function extractClockTimezone(array $data): string
|
||||||
|
{
|
||||||
|
$clockTimezone = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['clockTimezone', 'timezone']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($clockTimezone === null) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the clockTimezone property is required and should be string'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $clockTimezone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the color value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed returns a color or null.
|
||||||
|
*/
|
||||||
|
private static function extractColor(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['color', 'fill_color']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,281 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a color cloud item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class ColorCloud extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked visual console.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedVisualConsole = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked module.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedModule = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item->decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$decodedData = parent::decode($data);
|
||||||
|
$decodedData['type'] = COLOR_CLOUD;
|
||||||
|
$decodedData['label'] = null;
|
||||||
|
$decodedData['defaultColor'] = static::extractDefaultColor($data);
|
||||||
|
$decodedData['colorRanges'] = static::extractColorRanges($data);
|
||||||
|
$decodedData['color'] = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['color']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
return $decodedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the default color value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string Default color.
|
||||||
|
* @throws \InvalidArgumentException If the default color cannot be
|
||||||
|
* extracted.
|
||||||
|
*/
|
||||||
|
private static function extractDefaultColor(array $data): string
|
||||||
|
{
|
||||||
|
if (isset($data['defaultColor'])) {
|
||||||
|
$defaultColor = static::notEmptyStringOr(
|
||||||
|
$data['defaultColor'],
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($defaultColor === null) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the default color property is required and should be a not empty string'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $defaultColor;
|
||||||
|
} else {
|
||||||
|
$dynamicData = static::extractDynamicData($data);
|
||||||
|
return $dynamicData['defaultColor'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a list of color ranges.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return array Color ranges list.
|
||||||
|
* @throws \InvalidArgumentException If any of the color ranges is invalid.
|
||||||
|
*/
|
||||||
|
private static function extractColorRanges(array $data): array
|
||||||
|
{
|
||||||
|
if (isset($data['colorRanges']) && \is_array($data['colorRanges'])) {
|
||||||
|
// Validate the color ranges.
|
||||||
|
foreach ($data['colorRanges'] as $colorRange) {
|
||||||
|
if (\is_numeric($colorRange['fromValue']) === false
|
||||||
|
|| \is_numeric($colorRange['toValue']) === false
|
||||||
|
|| static::notEmptyStringOr($colorRange['color'], null) === null
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('invalid color range');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data['colorRanges'];
|
||||||
|
} else if (isset($data['label']) === true) {
|
||||||
|
$dynamicData = static::extractDynamicData($data);
|
||||||
|
return $dynamicData['colorRanges'];
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a dynamic data structure from the 'label' field.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return array Dynamic data structure.
|
||||||
|
* @throws \InvalidArgumentException If the structure cannot be built.
|
||||||
|
*
|
||||||
|
* @example [
|
||||||
|
* 'defaultColor' => '#FFF',
|
||||||
|
* 'colorRanges' => [
|
||||||
|
* [
|
||||||
|
* 'fromValue' => 50.0,
|
||||||
|
* 'toValue' => 150.5,
|
||||||
|
* 'color' => '#000',
|
||||||
|
* ],
|
||||||
|
* [
|
||||||
|
* 'fromValue' => 200.0,
|
||||||
|
* 'toValue' => 300.5,
|
||||||
|
* 'color' => '#F0F0F0',
|
||||||
|
* ],
|
||||||
|
* ]
|
||||||
|
* ]
|
||||||
|
*/
|
||||||
|
private static function extractDynamicData(array $data): array
|
||||||
|
{
|
||||||
|
$dynamicDataEncoded = static::notEmptyStringOr($data['label'], null);
|
||||||
|
|
||||||
|
if ($dynamicDataEncoded === null) {
|
||||||
|
throw new \InvalidArgumentException('dynamic data not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dynamicData = \json_decode($dynamicDataEncoded, true);
|
||||||
|
|
||||||
|
$result['defaultColor'] = $dynamicData['default_color'];
|
||||||
|
$result['colorRanges'] = [];
|
||||||
|
|
||||||
|
if (\is_array($dynamicData['color_ranges']) === true) {
|
||||||
|
foreach ($dynamicData['color_ranges'] as $colorRange) {
|
||||||
|
if (\is_numeric($colorRange['from_value']) === true
|
||||||
|
&& \is_numeric($colorRange['to_value']) === true
|
||||||
|
&& static::notEmptyStringOr(
|
||||||
|
$colorRange['color'],
|
||||||
|
null
|
||||||
|
) !== null
|
||||||
|
) {
|
||||||
|
$result['colorRanges'][] = [
|
||||||
|
'color' => $colorRange['color'],
|
||||||
|
'fromValue' => (float) $colorRange['from_value'],
|
||||||
|
'toValue' => (float) $colorRange['to_value'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
throw new \InvalidArgumentException('invalid dynamic data');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a vc item data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console Item.
|
||||||
|
*
|
||||||
|
* @return array The Visual Console Item data structure stored into the DB.
|
||||||
|
* @throws \InvalidArgumentException When an agent Id cannot be found.
|
||||||
|
*
|
||||||
|
* @override Item::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$data = parent::fetchDataFromDB($filter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve extra data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load side libraries.
|
||||||
|
global $config;
|
||||||
|
include_once $config['homedir'].'/include/functions_modules.php';
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
\enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the linked module Id.
|
||||||
|
$linkedModule = static::extractLinkedModule($data);
|
||||||
|
$moduleId = $linkedModule['moduleId'];
|
||||||
|
$metaconsoleId = $linkedModule['metaconsoleId'];
|
||||||
|
|
||||||
|
if ($moduleId === null) {
|
||||||
|
throw new \InvalidArgumentException('missing module Id');
|
||||||
|
}
|
||||||
|
|
||||||
|
$dynamicData = static::extractDynamicData($data);
|
||||||
|
// Set the initial color.
|
||||||
|
$data['color'] = $dynamicData['defaultColor'];
|
||||||
|
|
||||||
|
// Search for a matching color range.
|
||||||
|
if (empty($dynamicData['colorRanges']) === false) {
|
||||||
|
// Connect to node.
|
||||||
|
$nodeConnected = false;
|
||||||
|
if (\is_metaconsole() === true && $metaconsoleId !== null) {
|
||||||
|
$nodeConnected = \metaconsole_connect(
|
||||||
|
null,
|
||||||
|
$metaconsoleId
|
||||||
|
) === NOERR;
|
||||||
|
|
||||||
|
if ($nodeConnected === false) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'error connecting to the node'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch module value.
|
||||||
|
$value = false;
|
||||||
|
if ($metaconsoleId === null
|
||||||
|
|| ($metaconsoleId !== null && $nodeConnected)
|
||||||
|
) {
|
||||||
|
$value = \modules_get_last_value($moduleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore connection.
|
||||||
|
if ($nodeConnected === true) {
|
||||||
|
\metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value found.
|
||||||
|
if ($value !== false) {
|
||||||
|
/*
|
||||||
|
* TODO: It would be ok to give support to string values in the
|
||||||
|
* future?
|
||||||
|
*
|
||||||
|
* It can be done by matching the range value with the value
|
||||||
|
* if it is a string. I think the function to retrieve the value
|
||||||
|
* only supports numeric values.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$value = (float) $value;
|
||||||
|
foreach ($dynamicData['colorRanges'] as $colorRange) {
|
||||||
|
if ($colorRange['fromValue'] <= $value
|
||||||
|
&& $colorRange['toValue'] >= $value
|
||||||
|
) {
|
||||||
|
// Range matched. Use the range color.
|
||||||
|
$data['color'] = $colorRange['color'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,193 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a Donut Graph item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class DonutGraph extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked visual console.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedVisualConsole = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked module.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedModule = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable validation, extraction and encodeing of the HTML output.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useHtmlOutput = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item::decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::decode($data);
|
||||||
|
$return['type'] = DONUT_GRAPH;
|
||||||
|
$return['legendBackgroundColor'] = static::extractLegendBackgroundColor(
|
||||||
|
$data
|
||||||
|
);
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a border color value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the border color (not empty) or null.
|
||||||
|
*/
|
||||||
|
private static function extractLegendBackgroundColor(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray(
|
||||||
|
$data,
|
||||||
|
[
|
||||||
|
'legendBackgroundColor',
|
||||||
|
'border_color',
|
||||||
|
]
|
||||||
|
),
|
||||||
|
'#000000'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a vc item data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console Item.
|
||||||
|
*
|
||||||
|
* @return array The Visual Console Item data structure stored into the DB.
|
||||||
|
* @throws \InvalidArgumentException When an agent Id cannot be found.
|
||||||
|
*
|
||||||
|
* @override Item::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$data = parent::fetchDataFromDB($filter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve extra data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load side libraries.
|
||||||
|
global $config;
|
||||||
|
include_once $config['homedir'].'/include/functions_visual_map.php';
|
||||||
|
include_once $config['homedir'].'/include/graphs/functions_d3.php';
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
\enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract needed properties.
|
||||||
|
$legendBackGroundColor = static::extractLegendBackgroundColor($data);
|
||||||
|
// Get the linked agent and module Ids.
|
||||||
|
$linkedModule = static::extractLinkedModule($data);
|
||||||
|
$agentId = $linkedModule['agentId'];
|
||||||
|
$moduleId = $linkedModule['moduleId'];
|
||||||
|
$metaconsoleId = $linkedModule['metaconsoleId'];
|
||||||
|
|
||||||
|
if ($agentId === null) {
|
||||||
|
throw new \InvalidArgumentException('missing agent Id');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($moduleId === null) {
|
||||||
|
throw new \InvalidArgumentException('missing module Id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maybe connect to node.
|
||||||
|
$nodeConnected = false;
|
||||||
|
if (\is_metaconsole() === true && $metaconsoleId !== null) {
|
||||||
|
$nodeConnected = \metaconsole_connect(
|
||||||
|
null,
|
||||||
|
$metaconsoleId
|
||||||
|
) === NOERR;
|
||||||
|
|
||||||
|
if ($nodeConnected === false) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'error connecting to the node'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = sprintf(
|
||||||
|
'SELECT COUNT(tam.id_agente_modulo)
|
||||||
|
FROM tagente_modulo tam
|
||||||
|
INNER JOIN ttipo_modulo ttm
|
||||||
|
ON tam.id_tipo_modulo = ttm.id_tipo
|
||||||
|
WHERE tam.id_agente = %d
|
||||||
|
AND tam.id_agente_modulo = %d
|
||||||
|
AND ttm.nombre LIKE \'%%_string\'',
|
||||||
|
$agentId,
|
||||||
|
$moduleId
|
||||||
|
);
|
||||||
|
$isString = (bool) \db_get_value_sql($sql);
|
||||||
|
|
||||||
|
// Restore connection.
|
||||||
|
if ($nodeConnected === true) {
|
||||||
|
\metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isString === true) {
|
||||||
|
$graphData = \get_donut_module_data($moduleId);
|
||||||
|
|
||||||
|
$width = (int) $data['width'];
|
||||||
|
$height = (int) $data['height'];
|
||||||
|
|
||||||
|
// Default width.
|
||||||
|
if ($width <= 0) {
|
||||||
|
$width = 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default height.
|
||||||
|
if ($height <= 0) {
|
||||||
|
$height = 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['html'] = \d3_donut_graph(
|
||||||
|
(int) $data['id'],
|
||||||
|
$width,
|
||||||
|
$height,
|
||||||
|
$graphData,
|
||||||
|
$legendBackGroundColor
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$src = 'images/console/signes/wrong_donut_graph.png';
|
||||||
|
if (\is_metaconsole() === true && $metaconsoleId !== null) {
|
||||||
|
$src = '../../'.$src;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['html'] = '<img src="'.$src.'">';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a events history item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class EventsHistory extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked module.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedModule = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked visual console.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedVisualConsole = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable validation, extraction and encodeing of the HTML output.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useHtmlOutput = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item::decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::decode($data);
|
||||||
|
$return['type'] = AUTO_SLA_GRAPH;
|
||||||
|
$return['maxTime'] = static::extractMaxTime($data);
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a graph period value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed The time in seconds of the graph period or null.
|
||||||
|
*/
|
||||||
|
private static function extractMaxTime(array $data)
|
||||||
|
{
|
||||||
|
return static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['maxTime', 'period']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a vc item data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console Item.
|
||||||
|
*
|
||||||
|
* @return array The Visual Console Item data structure stored into the DB.
|
||||||
|
* @throws \InvalidArgumentException When an agent Id cannot be found.
|
||||||
|
*
|
||||||
|
* @override Item::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$data = parent::fetchDataFromDB($filter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve extra data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load side libraries.
|
||||||
|
global $config;
|
||||||
|
include_once $config['homedir'].'/include/functions_graph.php';
|
||||||
|
|
||||||
|
// Get the linked agent and module Ids.
|
||||||
|
$linkedModule = static::extractLinkedModule($data);
|
||||||
|
$agentId = static::parseIntOr($linkedModule['agentId'], null);
|
||||||
|
$moduleId = static::parseIntOr($linkedModule['moduleId'], null);
|
||||||
|
|
||||||
|
if ($agentId === null) {
|
||||||
|
throw new \InvalidArgumentException('missing agent Id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default size.
|
||||||
|
if ($data['width'] == 0 || $data['height'] == 0) {
|
||||||
|
$data['width'] = 500;
|
||||||
|
$data['height'] = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the same HTML output as the old VC.
|
||||||
|
$html = \graph_graphic_moduleevents(
|
||||||
|
$agentId,
|
||||||
|
$moduleId,
|
||||||
|
(int) $data['width'],
|
||||||
|
(int) $data['height'],
|
||||||
|
static::extractMaxTime($data),
|
||||||
|
'',
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['html'] = $html;
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,455 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a group item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class Group extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked visual console.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedVisualConsole = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable the validation, extraction and encoding of HTML output.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useHtmlOutput = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item::decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::decode($data);
|
||||||
|
$return['type'] = GROUP_ITEM;
|
||||||
|
$return['groupId'] = static::extractGroupId($data);
|
||||||
|
$return['imageSrc'] = static::extractImageSrc($data);
|
||||||
|
$return['statusImageSrc'] = static::extractStatusImageSrc($data);
|
||||||
|
$return['showStatistics'] = static::extractShowStatistics($data);
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a group Id value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return integer Valid identifier of a group.
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException When a valid group Id can't be found.
|
||||||
|
*/
|
||||||
|
private static function extractGroupId(array $data): int
|
||||||
|
{
|
||||||
|
$groupId = static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['groupId', 'id_group']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($groupId === null || $groupId < 0) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the group Id property is required and should be integer'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a image src value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the image url (not empty) or null.
|
||||||
|
*/
|
||||||
|
private static function extractImageSrc(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['imageSrc', 'image']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a status image src value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the status image url (not empty)
|
||||||
|
* or null.
|
||||||
|
*/
|
||||||
|
private static function extractStatusImageSrc(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['statusImageSrc']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the "show statistics" switch value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return boolean If the statistics should be shown or not.
|
||||||
|
*/
|
||||||
|
private static function extractShowStatistics(array $data): bool
|
||||||
|
{
|
||||||
|
return static::parseBool(
|
||||||
|
static::issetInArray($data, ['showStatistics', 'show_statistics'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a vc item data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console Item.
|
||||||
|
*
|
||||||
|
* @return array The Visual Console Item data structure stored into the DB.
|
||||||
|
* @throws \InvalidArgumentException When an agent Id cannot be found.
|
||||||
|
*
|
||||||
|
* @override Item::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$data = parent::fetchDataFromDB($filter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve extra data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load side libraries.
|
||||||
|
global $config;
|
||||||
|
include_once $config['homedir'].'/include/functions_groups.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_visual_map.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_ui.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_agents.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_users.php';
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
\enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
$groupId = static::extractGroupId($data);
|
||||||
|
$showStatistics = static::extractShowStatistics($data);
|
||||||
|
|
||||||
|
if ($showStatistics === true) {
|
||||||
|
$isMetaconsole = \is_metaconsole();
|
||||||
|
// Retrieve the agent stats.
|
||||||
|
$agentsCritical = \agents_get_agents(
|
||||||
|
[
|
||||||
|
'id_grupo' => $groupId,
|
||||||
|
'status' => AGENT_STATUS_CRITICAL,
|
||||||
|
],
|
||||||
|
['COUNT(*) AS total'],
|
||||||
|
'AR',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
$isMetaconsole
|
||||||
|
);
|
||||||
|
$numCritical = $agentsCritical[0]['total'];
|
||||||
|
$agentsWarning = \agents_get_agents(
|
||||||
|
[
|
||||||
|
'id_grupo' => $groupId,
|
||||||
|
'status' => AGENT_STATUS_WARNING,
|
||||||
|
],
|
||||||
|
['COUNT(*) AS total'],
|
||||||
|
'AR',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
$isMetaconsole
|
||||||
|
);
|
||||||
|
$numWarning = $agentsWarning[0]['total'];
|
||||||
|
$agentsUnknown = \agents_get_agents(
|
||||||
|
[
|
||||||
|
'id_grupo' => $groupId,
|
||||||
|
'status' => AGENT_STATUS_UNKNOWN,
|
||||||
|
],
|
||||||
|
['COUNT(*) AS total'],
|
||||||
|
'AR',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
$isMetaconsole
|
||||||
|
);
|
||||||
|
$numUnknown = $agentsUnknown[0]['total'];
|
||||||
|
$agentsOk = \agents_get_agents(
|
||||||
|
[
|
||||||
|
'id_grupo' => $groupId,
|
||||||
|
'status' => AGENT_STATUS_OK,
|
||||||
|
],
|
||||||
|
['COUNT(*) AS total'],
|
||||||
|
'AR',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
$isMetaconsole
|
||||||
|
);
|
||||||
|
$numNormal = $agentsOk[0]['total'];
|
||||||
|
|
||||||
|
$numTotal = ($numCritical + $numWarning + $numUnknown + $numNormal);
|
||||||
|
$agentStats = [
|
||||||
|
'critical' => ($numCritical / $numTotal * 100),
|
||||||
|
'warning' => ($numWarning / $numTotal * 100),
|
||||||
|
'normal' => ($numNormal / $numTotal * 100),
|
||||||
|
'unknown' => ($numUnknown / $numTotal * 100),
|
||||||
|
];
|
||||||
|
|
||||||
|
$groupName = \groups_get_name($groupId, true);
|
||||||
|
$data['html'] = static::printStatsTable(
|
||||||
|
$groupName,
|
||||||
|
$agentStats,
|
||||||
|
(int) $data['width'],
|
||||||
|
(int) $data['height']
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (\is_metaconsole()) {
|
||||||
|
$groupFilter = $groupId;
|
||||||
|
if ($groupId === 0) {
|
||||||
|
$groupFilter = implode(
|
||||||
|
',',
|
||||||
|
array_keys(\users_get_groups())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = sprintf(
|
||||||
|
'SELECT
|
||||||
|
SUM(fired_count) AS fired,
|
||||||
|
SUM(critical_count) AS critical,
|
||||||
|
SUM(warning_count) AS warning,
|
||||||
|
SUM(unknown_count) AS unknown
|
||||||
|
FROM tmetaconsole_agent
|
||||||
|
LEFT JOIN tmetaconsole_agent_secondary_group tasg
|
||||||
|
ON id_agente = tasg.id_agent
|
||||||
|
WHERE id_grupo IN (%s)
|
||||||
|
OR tasg.id_group IN (%s)',
|
||||||
|
$groupFilter,
|
||||||
|
$groupFilter
|
||||||
|
);
|
||||||
|
|
||||||
|
$countStatus = \db_get_row_sql($sql);
|
||||||
|
|
||||||
|
if ($countStatus['fired'] > 0) {
|
||||||
|
$status = AGENT_STATUS_ALERT_FIRED;
|
||||||
|
} else if ($countStatus['critical'] > 0) {
|
||||||
|
$status = AGENT_STATUS_CRITICAL;
|
||||||
|
} else if ($countStatus['warning'] > 0) {
|
||||||
|
$status = AGENT_STATUS_WARNING;
|
||||||
|
} else if ($countStatus['unknown'] > 0) {
|
||||||
|
$status = AGENT_STATUS_UNKNOWN;
|
||||||
|
} else {
|
||||||
|
$status = AGENT_STATUS_NORMAL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Get the status img src.
|
||||||
|
$status = \groups_get_status($groupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$imagePath = \visual_map_get_image_status_element($data, $status);
|
||||||
|
$data['statusImageSrc'] = \ui_get_full_url(
|
||||||
|
$imagePath,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
// If the width or the height are equal to 0 we will extract them
|
||||||
|
// from the real image size.
|
||||||
|
$width = (int) $data['width'];
|
||||||
|
$height = (int) $data['height'];
|
||||||
|
if ($width === 0 || $height === 0) {
|
||||||
|
// TODO: This will be the default behaviour after we finish the
|
||||||
|
// builder. Don't delete this code.
|
||||||
|
// $sizeImage = getimagesize($config['homedir'].'/'.$imagePath);
|
||||||
|
// $data['width'] = $sizeImage[0];
|
||||||
|
// $data['height'] = $sizeImage[1];
|
||||||
|
$sizeImage = getimagesize($config['homedir'].'/'.$imagePath);
|
||||||
|
$imageHeight = $sizeImage[1];
|
||||||
|
|
||||||
|
if ($width === 0) {
|
||||||
|
$data['width'] = 70;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($height === 0) {
|
||||||
|
$data['height'] = ($imageHeight > 70) ? 70 : $imageHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['html'] = '<img src="'.$data['statusImageSrc'].'">';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTML representation for the agent stats of a group.
|
||||||
|
*
|
||||||
|
* @param string $groupName Group name.
|
||||||
|
* @param array $agentStats Data structure with the agent statistics.
|
||||||
|
* @param integer $width Width.
|
||||||
|
* @param integer $height Height.
|
||||||
|
*
|
||||||
|
* @return string HTML representation.
|
||||||
|
*/
|
||||||
|
private static function printStatsTable(
|
||||||
|
string $groupName,
|
||||||
|
array $agentStats,
|
||||||
|
int $width=520,
|
||||||
|
int $height=80
|
||||||
|
): string {
|
||||||
|
$width = ($width > 0) ? $width : 520;
|
||||||
|
$height = ($height > 0) ? $height : 80;
|
||||||
|
|
||||||
|
$tableStyle = \join(
|
||||||
|
[
|
||||||
|
'width:'.$width.'px;',
|
||||||
|
'height:'.$height.'px;',
|
||||||
|
'text-align:center;',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$headStyle = \join(
|
||||||
|
[
|
||||||
|
'text-align:center;',
|
||||||
|
'background-color:#9d9ea0;',
|
||||||
|
'color:black;',
|
||||||
|
'font-weight:bold;',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$valueStyle = \join(
|
||||||
|
[
|
||||||
|
'margin-left: 2%;',
|
||||||
|
'color: #FFF;',
|
||||||
|
'font-size: 12px;',
|
||||||
|
'display: inline;',
|
||||||
|
'background-color: #FC4444;',
|
||||||
|
'position: relative;',
|
||||||
|
'height: 80%;',
|
||||||
|
'width: 9.4%;',
|
||||||
|
'height: 80%;',
|
||||||
|
'border-radius: 2px;',
|
||||||
|
'text-align: center;',
|
||||||
|
'padding: 5px;',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$nameStyle = \join(
|
||||||
|
[
|
||||||
|
'background-color: white;',
|
||||||
|
'color: black;',
|
||||||
|
'font-size: 12px;',
|
||||||
|
'display: inline;',
|
||||||
|
'display: inline;',
|
||||||
|
'position:relative;',
|
||||||
|
'width: 9.4%;',
|
||||||
|
'height: 80%;',
|
||||||
|
'border-radius: 2px;',
|
||||||
|
'text-align: center;',
|
||||||
|
'padding: 5px;',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$html = '<table class="databox" style="'.$tableStyle.'">';
|
||||||
|
$html .= '<tr style="height:10%;">';
|
||||||
|
$html .= '<th style="'.$headStyle.'">'.$groupName.'</th>';
|
||||||
|
$html .= '</tr>';
|
||||||
|
$html .= '<tr style="background-color:whitesmoke;height:90%;">';
|
||||||
|
$html .= '<td>';
|
||||||
|
|
||||||
|
// Critical.
|
||||||
|
$html .= '<div style="'.$valueStyle.'background-color: #FC4444;">';
|
||||||
|
$html .= \number_format($agentStats['critical']).'%';
|
||||||
|
$html .= '</div>';
|
||||||
|
$html .= '<div style="'.$nameStyle.'">'.__('Critical').'</div>';
|
||||||
|
// Warning.
|
||||||
|
$html .= '<div style="'.$valueStyle.'background-color: #f8db3f;">';
|
||||||
|
$html .= \number_format($agentStats['warning']).'%';
|
||||||
|
$html .= '</div>';
|
||||||
|
$html .= '<div style="'.$nameStyle.'">'.__('Warning').'</div>';
|
||||||
|
// Normal.
|
||||||
|
$html .= '<div style="'.$valueStyle.'background-color: #84b83c;">';
|
||||||
|
$html .= \number_format($agentStats['normal']).'%';
|
||||||
|
$html .= '</div>';
|
||||||
|
$html .= '<div style="'.$nameStyle.'">'.__('Normal').'</div>';
|
||||||
|
// Unknown.
|
||||||
|
$html .= '<div style="'.$valueStyle.'background-color: #9d9ea0;">';
|
||||||
|
$html .= \number_format($agentStats['unknown']).'%';
|
||||||
|
$html .= '</div>';
|
||||||
|
$html .= '<div style="'.$nameStyle.'">'.__('Unknown').'</div>';
|
||||||
|
|
||||||
|
$html .= '</td>';
|
||||||
|
$html .= '</tr>';
|
||||||
|
$html .= '</table>';
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a link to something related with the item.
|
||||||
|
*
|
||||||
|
* @param array $data Visual Console Item's data structure.
|
||||||
|
*
|
||||||
|
* @return mixed The link or a null value.
|
||||||
|
*
|
||||||
|
* @override Item::buildLink.
|
||||||
|
*/
|
||||||
|
protected static function buildLink(array $data)
|
||||||
|
{
|
||||||
|
// This will return the link to a linked VC if this item has one.
|
||||||
|
$link = parent::buildLink($data);
|
||||||
|
if ($link !== null) {
|
||||||
|
return $link;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$groupId = static::extractGroupId($data);
|
||||||
|
$baseUrl = $config['homeurl'].'index.php';
|
||||||
|
|
||||||
|
if (\is_metaconsole()) {
|
||||||
|
return $baseUrl.'?'.http_build_query(
|
||||||
|
[
|
||||||
|
'sec' => 'monitoring',
|
||||||
|
'sec2' => 'operation/tree',
|
||||||
|
'group_id' => $groupId,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $baseUrl.'?'.http_build_query(
|
||||||
|
[
|
||||||
|
'sec' => 'estado',
|
||||||
|
'sec2' => 'operation/agentes/estado_agente',
|
||||||
|
'group_id' => $groupId,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,144 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a group item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class Icon extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked visual console.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedVisualConsole = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item::decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::decode($data);
|
||||||
|
$return['type'] = ICON;
|
||||||
|
$return['image'] = static::extractImage($data);
|
||||||
|
$return['imageSrc'] = static::extractImageSrc($data);
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a image value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the image url (not empty) or null.
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException When a valid image can't be found.
|
||||||
|
*/
|
||||||
|
private static function extractImage(array $data)
|
||||||
|
{
|
||||||
|
$image = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['image']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($image === null) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the image property is required and should be a non empty string'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $image;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a image src value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the image url (not empty) or null.
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException When a valid image src can't be found.
|
||||||
|
*/
|
||||||
|
private static function extractImageSrc(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['imageSrc']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 'images/console/icons/'.$imageSrc.'.png'
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a vc item data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console Item.
|
||||||
|
*
|
||||||
|
* @return array The Visual Console Item data structure stored into the DB.
|
||||||
|
* @throws \InvalidArgumentException When an agent Id cannot be found.
|
||||||
|
*
|
||||||
|
* @override Item::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$data = parent::fetchDataFromDB($filter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve extra data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load side libraries.
|
||||||
|
global $config;
|
||||||
|
include_once $config['homedir'].'/include/functions_ui.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_visual_map.php';
|
||||||
|
|
||||||
|
// Get the img src.
|
||||||
|
$imagePath = \visual_map_get_image_status_element($data);
|
||||||
|
$data['imageSrc'] = \ui_get_full_url($imagePath, false, false, false);
|
||||||
|
|
||||||
|
// If the width or the height are equal to 0 we will extract them
|
||||||
|
// from the real image size.
|
||||||
|
$width = (int) $data['width'];
|
||||||
|
$height = (int) $data['height'];
|
||||||
|
if ($width === 0 || $height === 0) {
|
||||||
|
// TODO: This will be the default behaviour after we finish the
|
||||||
|
// builder. Don't delete this code.
|
||||||
|
// $sizeImage = getimagesize($config['homedir'].'/'.$imagePath);
|
||||||
|
// $data['width'] = $sizeImage[0];
|
||||||
|
// $data['height'] = $sizeImage[1];
|
||||||
|
$sizeImage = getimagesize($config['homedir'].'/'.$imagePath);
|
||||||
|
$imageHeight = $sizeImage[1];
|
||||||
|
|
||||||
|
if ($width === 0) {
|
||||||
|
$data['width'] = 70;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($height === 0) {
|
||||||
|
$data['height'] = ($imageHeight > 70) ? 70 : $imageHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a label item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class Label extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked visual console.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedVisualConsole = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the received data structure to ensure if we can extract the
|
||||||
|
* values required to build the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException If any input value is considered
|
||||||
|
* invalid.
|
||||||
|
*
|
||||||
|
* @overrides Item->validateData.
|
||||||
|
*/
|
||||||
|
protected function validateData(array $data): void
|
||||||
|
{
|
||||||
|
parent::validateData($data);
|
||||||
|
if (static::notEmptyStringOr(static::issetInArray($data, ['label']), null) === null) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the label property is required and should be a not empty string'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item->decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::decode($data);
|
||||||
|
$return['type'] = LABEL;
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,209 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a line item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class Line extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the received data structure to ensure if we can extract the
|
||||||
|
* values required to build the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws \InvalidArgumentException If any input value is considered
|
||||||
|
* invalid.
|
||||||
|
*
|
||||||
|
* @overrides Model->validateData.
|
||||||
|
*/
|
||||||
|
protected function validateData(array $data): void
|
||||||
|
{
|
||||||
|
if (isset($data['id']) === false
|
||||||
|
|| \is_numeric($data['id']) === false
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the Id property is required and should be integer'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data['type']) === false
|
||||||
|
|| \is_numeric($data['type']) === false
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the Id property is required and should be integer'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Model->decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => (int) $data['id'],
|
||||||
|
'type' => LINE_ITEM,
|
||||||
|
'startX' => static::extractStartX($data),
|
||||||
|
'startY' => static::extractStartY($data),
|
||||||
|
'endX' => static::extractEndX($data),
|
||||||
|
'endY' => static::extractEndY($data),
|
||||||
|
'isOnTop' => static::extractIsOnTop($data),
|
||||||
|
'borderWidth' => static::extractBorderWidth($data),
|
||||||
|
'borderColor' => static::extractBorderColor($data),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a x axis value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return integer Valid x axis of the start position of the line.
|
||||||
|
*/
|
||||||
|
private static function extractStartX(array $data): int
|
||||||
|
{
|
||||||
|
return static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['startX', 'pos_x']),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a y axis value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return integer Valid y axis of the start position of the line.
|
||||||
|
*/
|
||||||
|
private static function extractStartY(array $data): int
|
||||||
|
{
|
||||||
|
return static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['startY', 'pos_y']),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a x axis value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return integer Valid x axis of the end position of the line.
|
||||||
|
*/
|
||||||
|
private static function extractEndX(array $data): int
|
||||||
|
{
|
||||||
|
return static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['endX', 'width']),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a y axis value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return integer Valid y axis of the end position of the line.
|
||||||
|
*/
|
||||||
|
private static function extractEndY(array $data): int
|
||||||
|
{
|
||||||
|
return static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['endY', 'height']),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a conditional value which tells if the item has visual priority.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return boolean If the item is on top or not.
|
||||||
|
*/
|
||||||
|
private static function extractIsOnTop(array $data): bool
|
||||||
|
{
|
||||||
|
return static::parseBool(
|
||||||
|
static::issetInArray($data, ['isOnTop', 'show_on_top'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a border width value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return integer Valid border width. 0 by default and minimum value.
|
||||||
|
*/
|
||||||
|
private static function extractBorderWidth(array $data): int
|
||||||
|
{
|
||||||
|
$borderWidth = static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['borderWidth', 'border_width']),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
return ($borderWidth >= 0) ? $borderWidth : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a border color value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the border color (not empty) or null.
|
||||||
|
*/
|
||||||
|
private static function extractBorderColor(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['borderColor', 'border_color']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a vc item data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console Item.
|
||||||
|
*
|
||||||
|
* @return array The Visual Console line data structure stored into the DB.
|
||||||
|
* @throws \Exception When the data cannot be retrieved from the DB.
|
||||||
|
*
|
||||||
|
* @override Model::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$row = \db_get_row_filter('tlayout_data', $filter);
|
||||||
|
|
||||||
|
if ($row === false) {
|
||||||
|
throw new \Exception('error fetching the data from the DB');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,274 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a module graph item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class ModuleGraph extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked module.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedModule = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked visual console.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedVisualConsole = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable validation, extraction and encodeing of the HTML output.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useHtmlOutput = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item::decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::decode($data);
|
||||||
|
$return['type'] = MODULE_GRAPH;
|
||||||
|
$return['backgroundType'] = static::extractBackgroundType($data);
|
||||||
|
$return['period'] = static::extractPeriod($data);
|
||||||
|
|
||||||
|
$customGraphId = static::extractCustomGraphId($data);
|
||||||
|
|
||||||
|
if (empty($customGraphId) === false) {
|
||||||
|
$return['customGraphId'] = $customGraphId;
|
||||||
|
} else {
|
||||||
|
$return['graphType'] = static::extractGraphType($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a background type value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string 'transparent', 'white' or 'black'. 'transparent' by default.
|
||||||
|
*/
|
||||||
|
private static function extractBackgroundType(array $data): string
|
||||||
|
{
|
||||||
|
$value = static::issetInArray($data, ['backgroundType', 'image']);
|
||||||
|
|
||||||
|
switch ($value) {
|
||||||
|
case 'transparent':
|
||||||
|
case 'white':
|
||||||
|
case 'black':
|
||||||
|
return $value;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'transparent';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a graph period value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed The time in seconds of the graph period or null.
|
||||||
|
*/
|
||||||
|
private static function extractPeriod(array $data)
|
||||||
|
{
|
||||||
|
return static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['period']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a custom graph Id value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed The custom graph Id (int) or null.
|
||||||
|
*/
|
||||||
|
private static function extractCustomGraphId(array $data)
|
||||||
|
{
|
||||||
|
return static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['customGraphId', 'id_custom_graph']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a graph type value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string 'line' or 'area'. 'line' by default.
|
||||||
|
*/
|
||||||
|
private static function extractGraphType(array $data): string
|
||||||
|
{
|
||||||
|
$value = static::issetInArray($data, ['graphType', 'type_graph']);
|
||||||
|
|
||||||
|
switch ($value) {
|
||||||
|
case 'line':
|
||||||
|
case 'area':
|
||||||
|
return $value;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'line';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a vc item data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console Item.
|
||||||
|
*
|
||||||
|
* @return array The Visual Console Item data structure stored into the DB.
|
||||||
|
* @throws \InvalidArgumentException When an agent Id cannot be found.
|
||||||
|
*
|
||||||
|
* @override Item::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$data = parent::fetchDataFromDB($filter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve extra data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load side libraries.
|
||||||
|
global $config;
|
||||||
|
include_once $config['homedir'].'/include/functions_graph.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_modules.php';
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
\enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
$imageOnly = false;
|
||||||
|
|
||||||
|
$backgroundType = static::extractBackgroundType($data);
|
||||||
|
$period = static::extractPeriod($data);
|
||||||
|
$customGraphId = static::extractCustomGraphId($data);
|
||||||
|
$graphType = static::extractGraphType($data);
|
||||||
|
$linkedModule = static::extractLinkedModule($data);
|
||||||
|
$moduleId = $linkedModule['moduleId'];
|
||||||
|
$metaconsoleId = $linkedModule['metaconsoleId'];
|
||||||
|
|
||||||
|
// Maybe connect to node.
|
||||||
|
$nodeConnected = false;
|
||||||
|
if (\is_metaconsole() === true && $metaconsoleId !== null) {
|
||||||
|
$nodeConnected = \metaconsole_connect(
|
||||||
|
null,
|
||||||
|
$metaconsoleId
|
||||||
|
) === NOERR;
|
||||||
|
|
||||||
|
if ($nodeConnected === false) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'error connecting to the node'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* About the 30 substraction to the graph height:
|
||||||
|
* The function which generates the graph doesn't respect the
|
||||||
|
* required height. It uses it for the canvas (the graph itself and
|
||||||
|
* their axes), but then it adds the legend. One item of the legend
|
||||||
|
* (one dataset) is about 30px, so we need to substract that height
|
||||||
|
* from the canvas to try to fit the element's height.
|
||||||
|
*
|
||||||
|
* PD: The custom graphs can have more datasets, but we only substract
|
||||||
|
* the height of one of it to replicate the legacy functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom graph.
|
||||||
|
if (empty($customGraphId) === false) {
|
||||||
|
$customGraph = \db_get_row_filter(
|
||||||
|
'tgraph',
|
||||||
|
'id_graph',
|
||||||
|
$customGraphId
|
||||||
|
);
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'period' => $period,
|
||||||
|
'width' => $data['width'],
|
||||||
|
'height' => ($data['height'] - 30),
|
||||||
|
'title' => '',
|
||||||
|
'unit_name' => null,
|
||||||
|
'show_alerts' => false,
|
||||||
|
'only_image' => $imageOnly,
|
||||||
|
'vconsole' => true,
|
||||||
|
'backgroundColor' => $backgroundType,
|
||||||
|
];
|
||||||
|
|
||||||
|
$paramsCombined = [
|
||||||
|
'id_graph' => $customGraphId,
|
||||||
|
'stacked' => $customGraph['stacked'],
|
||||||
|
'summatory' => $customGraph['summatory_series'],
|
||||||
|
'average' => $customGraph['average_series'],
|
||||||
|
'modules_series' => $customGraph['modules_series'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$data['html'] = \graphic_combined_module(
|
||||||
|
false,
|
||||||
|
$params,
|
||||||
|
$paramsCombined
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Module graph.
|
||||||
|
if ($moduleId === null) {
|
||||||
|
throw new \InvalidArgumentException('missing module Id');
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'agent_module_id' => $moduleId,
|
||||||
|
'period' => $period,
|
||||||
|
'show_events' => false,
|
||||||
|
'width' => $data['width'],
|
||||||
|
'height' => ($data['height'] - 30),
|
||||||
|
'title' => \modules_get_agentmodule_name($moduleId),
|
||||||
|
'unit' => \modules_get_unit($moduleId),
|
||||||
|
'only_image' => $imageOnly,
|
||||||
|
'menu' => false,
|
||||||
|
'backgroundColor' => $backgroundType,
|
||||||
|
'type_graph' => $graphType,
|
||||||
|
'vconsole' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
$data['html'] = \grafico_modulo_sparse($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore connection.
|
||||||
|
if ($nodeConnected === true) {
|
||||||
|
\metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,249 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a percentile item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class Percentile extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked module.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedModule = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked visual console.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedVisualConsole = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item::decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::decode($data);
|
||||||
|
$return['type'] = PERCENTILE_BAR;
|
||||||
|
$return['percentileType'] = static::extractPercentileType($data);
|
||||||
|
$return['valueType'] = static::extractValueType($data);
|
||||||
|
// TODO: Add min value to the database.
|
||||||
|
$return['minValue'] = static::parseFloatOr(
|
||||||
|
static::issetInArray($data, ['minValue']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
$return['maxValue'] = static::parseFloatOr(
|
||||||
|
static::issetInArray($data, ['maxValue', 'height']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
$return['color'] = static::extractColor($data);
|
||||||
|
$return['labelColor'] = static::extractLabelColor($data);
|
||||||
|
$return['value'] = static::parseFloatOr(
|
||||||
|
static::issetInArray($data, ['value']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
$return['unit'] = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['unit']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a percentile type value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string 'progress-bar', 'bubble', 'circular-progress-bar'
|
||||||
|
* or 'circular-progress-bar-alt'. 'progress-bar' by default.
|
||||||
|
*/
|
||||||
|
private static function extractPercentileType(array $data): string
|
||||||
|
{
|
||||||
|
if (isset($data['percentileType']) === true) {
|
||||||
|
switch ($data['percentileType']) {
|
||||||
|
case 'progress-bar':
|
||||||
|
case 'bubble':
|
||||||
|
case 'circular-progress-bar':
|
||||||
|
case 'circular-progress-bar-alt':
|
||||||
|
return $data['percentileType'];
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'progress-bar';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($data['type']) {
|
||||||
|
case PERCENTILE_BUBBLE:
|
||||||
|
return 'bubble';
|
||||||
|
|
||||||
|
case CIRCULAR_PROGRESS_BAR:
|
||||||
|
return 'circular-progress-bar';
|
||||||
|
|
||||||
|
case CIRCULAR_INTERIOR_PROGRESS_BAR:
|
||||||
|
return 'circular-progress-bar-alt';
|
||||||
|
|
||||||
|
default:
|
||||||
|
case PERCENTILE_BAR:
|
||||||
|
return 'progress-bar';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a value type value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string 'percent' or 'value'. 'percent' by default.
|
||||||
|
*/
|
||||||
|
private static function extractValueType(array $data): string
|
||||||
|
{
|
||||||
|
$rawValueType = static::issetInArray($data, ['valueType', 'image']);
|
||||||
|
|
||||||
|
switch ($rawValueType) {
|
||||||
|
case 'percent':
|
||||||
|
case 'value':
|
||||||
|
return $rawValueType;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'percent';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a color value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed The color or null.
|
||||||
|
*/
|
||||||
|
private static function extractColor(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['color', 'border_color']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a label color value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed The label color or null.
|
||||||
|
*/
|
||||||
|
private static function extractLabelColor(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['labelColor', 'fill_color']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a vc item data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console Item.
|
||||||
|
*
|
||||||
|
* @return array The Visual Console Item data structure stored into the DB.
|
||||||
|
* @throws \InvalidArgumentException When an agent Id cannot be found.
|
||||||
|
*
|
||||||
|
* @override Item::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$data = parent::fetchDataFromDB($filter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve extra data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load side libraries.
|
||||||
|
global $config;
|
||||||
|
include_once $config['homedir'].'/include/functions_graph.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_modules.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_io.php';
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
\enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the linked module Id.
|
||||||
|
$linkedModule = static::extractLinkedModule($data);
|
||||||
|
$moduleId = static::parseIntOr($linkedModule['moduleId'], null);
|
||||||
|
$metaconsoleId = static::parseIntOr(
|
||||||
|
$linkedModule['metaconsoleId'],
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
// Get the value type.
|
||||||
|
$valueType = static::extractValueType($data);
|
||||||
|
|
||||||
|
if ($moduleId === null) {
|
||||||
|
throw new \InvalidArgumentException('missing module Id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maybe connect to node.
|
||||||
|
$nodeConnected = false;
|
||||||
|
if (\is_metaconsole() === true && $metaconsoleId !== null) {
|
||||||
|
$nodeConnected = \metaconsole_connect(
|
||||||
|
null,
|
||||||
|
$metaconsoleId
|
||||||
|
) === NOERR;
|
||||||
|
|
||||||
|
if ($nodeConnected === false) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'error connecting to the node'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$moduleValue = \modules_get_last_value($moduleId);
|
||||||
|
if ($moduleValue === false) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'error fetching the module value'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cast to float.
|
||||||
|
$moduleValue = (float) $moduleValue;
|
||||||
|
|
||||||
|
// Store the module value.
|
||||||
|
$data['value'] = $moduleValue;
|
||||||
|
|
||||||
|
$unit = \modules_get_unit($moduleId);
|
||||||
|
if (empty($unit) === false) {
|
||||||
|
$data['unit'] = \io_safe_output($unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore connection.
|
||||||
|
if ($nodeConnected === true) {
|
||||||
|
\metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,239 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a simple value item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class SimpleValue extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked visual console.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedVisualConsole = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked module.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedModule = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the received data structure to ensure if we can extract the
|
||||||
|
* values required to build the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException If any input value is considered
|
||||||
|
* invalid.
|
||||||
|
*
|
||||||
|
* @overrides Item->validateData.
|
||||||
|
*/
|
||||||
|
protected function validateData(array $data): void
|
||||||
|
{
|
||||||
|
parent::validateData($data);
|
||||||
|
if (isset($data['value']) === false) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the value property is required and should be string'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item->decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::decode($data);
|
||||||
|
$return['type'] = SIMPLE_VALUE;
|
||||||
|
$return['processValue'] = static::extractProcessValue($data);
|
||||||
|
$return['valueType'] = static::extractValueType($data);
|
||||||
|
$return['value'] = $data['value'];
|
||||||
|
|
||||||
|
if ($return['processValue'] !== 'none') {
|
||||||
|
$return['period'] = static::extractPeriod($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the size, as this element always have a dynamic size.
|
||||||
|
$return['width'] = 0;
|
||||||
|
$return['height'] = 0;
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a process value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string One of 'none', 'avg', 'max' or 'min'. 'none' by default.
|
||||||
|
*/
|
||||||
|
private static function extractProcessValue(array $data): string
|
||||||
|
{
|
||||||
|
if (isset($data['processValue'])) {
|
||||||
|
switch ($data['processValue']) {
|
||||||
|
case 'none':
|
||||||
|
case 'avg':
|
||||||
|
case 'max':
|
||||||
|
case 'min':
|
||||||
|
return $data['processValue'];
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'none';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch ($data['type']) {
|
||||||
|
case SIMPLE_VALUE_MAX:
|
||||||
|
return 'max';
|
||||||
|
|
||||||
|
case SIMPLE_VALUE_MIN:
|
||||||
|
return 'min';
|
||||||
|
|
||||||
|
case SIMPLE_VALUE_AVG:
|
||||||
|
return 'avg';
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the value of period.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return integer The period in seconds. 0 is the minimum value.
|
||||||
|
*/
|
||||||
|
private static function extractPeriod(array $data): int
|
||||||
|
{
|
||||||
|
$period = static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['period']),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
return ($period >= 0) ? $period : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a value type.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string One of 'string' or 'image'. 'string' by default.
|
||||||
|
*/
|
||||||
|
private static function extractValueType(array $data): string
|
||||||
|
{
|
||||||
|
switch ($data['valueType']) {
|
||||||
|
case 'string':
|
||||||
|
case 'image':
|
||||||
|
return $data['valueType'];
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'string';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a vc item data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console Item.
|
||||||
|
*
|
||||||
|
* @return array The Visual Console Item data structure stored into the DB.
|
||||||
|
* @throws \InvalidArgumentException When a module Id cannot be found.
|
||||||
|
*
|
||||||
|
* @override Item::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$data = parent::fetchDataFromDB($filter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve extra data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load side libraries.
|
||||||
|
global $config;
|
||||||
|
include_once $config['homedir'].'/include/functions_visual_map.php';
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
\enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the linked module Id.
|
||||||
|
$linkedModule = static::extractLinkedModule($data);
|
||||||
|
$moduleId = static::parseIntOr($linkedModule['moduleId'], null);
|
||||||
|
$metaconsoleId = static::parseIntOr(
|
||||||
|
$linkedModule['metaconsoleId'],
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($moduleId === null) {
|
||||||
|
throw new \InvalidArgumentException('missing module Id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maybe connect to node.
|
||||||
|
$nodeConnected = false;
|
||||||
|
if (\is_metaconsole() === true && $metaconsoleId !== null) {
|
||||||
|
$nodeConnected = \metaconsole_connect(
|
||||||
|
null,
|
||||||
|
$metaconsoleId
|
||||||
|
) === NOERR;
|
||||||
|
|
||||||
|
if ($nodeConnected === false) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'error connecting to the node'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the formatted value.
|
||||||
|
$value = \visual_map_get_simple_value(
|
||||||
|
$data['type'],
|
||||||
|
$moduleId,
|
||||||
|
static::extractPeriod($data)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Restore connection.
|
||||||
|
if ($nodeConnected === true) {
|
||||||
|
\metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some modules are image based. Extract the base64 image if needed.
|
||||||
|
$matches = [];
|
||||||
|
if (\preg_match('/src=\"(data:image.*)"/', $value, $matches) === 1) {
|
||||||
|
$data['valueType'] = 'image';
|
||||||
|
$data['value'] = $matches[1];
|
||||||
|
} else {
|
||||||
|
$data['valueType'] = 'string';
|
||||||
|
$data['value'] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,256 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Models\VisualConsole\Items;
|
||||||
|
use Models\VisualConsole\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a static graph item of the Visual Console.
|
||||||
|
*/
|
||||||
|
final class StaticGraph extends Item
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked visual console.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedVisualConsole = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable the fetching, validation and extraction of information
|
||||||
|
* about the linked module.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $useLinkedModule = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid representation of the model.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing the model.
|
||||||
|
*
|
||||||
|
* @overrides Item->decode.
|
||||||
|
*/
|
||||||
|
protected function decode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::decode($data);
|
||||||
|
$return['type'] = STATIC_GRAPH;
|
||||||
|
$return['imageSrc'] = static::extractImageSrc($data);
|
||||||
|
$return['showLastValueTooltip'] = static::extractShowLastValueTooltip(
|
||||||
|
$data
|
||||||
|
);
|
||||||
|
$return['statusImageSrc'] = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['statusImageSrc']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
$return['lastValue'] = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['lastValue']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a image src value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed String representing the image url (not empty) or null.
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException When a valid image src can't be found.
|
||||||
|
*/
|
||||||
|
private static function extractImageSrc(array $data): string
|
||||||
|
{
|
||||||
|
$imageSrc = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['imageSrc', 'image']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($imageSrc === null) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'the image src property is required and should be a non empty string'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $imageSrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the value of showLastValueTooltip and
|
||||||
|
* return 'default', 'enabled' or 'disabled'.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function extractShowLastValueTooltip(array $data): string
|
||||||
|
{
|
||||||
|
$showLastValueTooltip = static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['showLastValueTooltip']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($showLastValueTooltip === null) {
|
||||||
|
$showLastValueTooltip = static::parseIntOr(
|
||||||
|
static::issetInArray($data, ['show_last_value']),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
switch ($showLastValueTooltip) {
|
||||||
|
case 1:
|
||||||
|
return 'enabled';
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
return 'disabled';
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'default';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch ($showLastValueTooltip) {
|
||||||
|
case 'enabled':
|
||||||
|
return 'enabled';
|
||||||
|
|
||||||
|
case 'disabled':
|
||||||
|
return 'disabled';
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'default';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a vc item data structure from the database using a filter.
|
||||||
|
*
|
||||||
|
* @param array $filter Filter of the Visual Console Item.
|
||||||
|
*
|
||||||
|
* @return array The Visual Console Item data structure stored into the DB.
|
||||||
|
* @throws \InvalidArgumentException When an agent Id cannot be found.
|
||||||
|
*
|
||||||
|
* @override Item::fetchDataFromDB.
|
||||||
|
*/
|
||||||
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
|
{
|
||||||
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
|
// a proper mock.
|
||||||
|
$data = parent::fetchDataFromDB($filter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve extra data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load side libraries.
|
||||||
|
global $config;
|
||||||
|
include_once $config['homedir'].'/include/functions_ui.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_io.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_visual_map.php';
|
||||||
|
include_once $config['homedir'].'/include/functions_modules.php';
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
\enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the linked module Id.
|
||||||
|
$linkedModule = static::extractLinkedModule($data);
|
||||||
|
$moduleId = $linkedModule['moduleId'];
|
||||||
|
$metaconsoleId = $linkedModule['metaconsoleId'];
|
||||||
|
|
||||||
|
if ($moduleId === null) {
|
||||||
|
throw new \InvalidArgumentException('missing module Id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the img src.
|
||||||
|
// There's no need to connect to the metaconsole before searching for
|
||||||
|
// the image status cause the function itself does that for us.
|
||||||
|
$imagePath = \visual_map_get_image_status_element($data);
|
||||||
|
$data['statusImageSrc'] = \ui_get_full_url(
|
||||||
|
$imagePath,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
// If the width or the height are equal to 0 we will extract them
|
||||||
|
// from the real image size.
|
||||||
|
$width = (int) $data['width'];
|
||||||
|
$height = (int) $data['height'];
|
||||||
|
if ($width === 0 || $height === 0) {
|
||||||
|
// TODO: This will be the default behaviour after we finish the
|
||||||
|
// builder. Don't delete this code.
|
||||||
|
// $sizeImage = getimagesize($config['homedir'].'/'.$imagePath);
|
||||||
|
// $data['width'] = $sizeImage[0];
|
||||||
|
// $data['height'] = $sizeImage[1];
|
||||||
|
// Default value. Will be replaced by a dynamic image size
|
||||||
|
// calculation after the phase 3.
|
||||||
|
$sizeImage = getimagesize($config['homedir'].'/'.$imagePath);
|
||||||
|
$imageHeight = $sizeImage[1];
|
||||||
|
|
||||||
|
if ($width === 0) {
|
||||||
|
$data['width'] = 70;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($height === 0) {
|
||||||
|
$data['height'] = ($imageHeight > 70) ? 70 : $imageHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get last value.
|
||||||
|
$showLastValueTooltip = static::extractShowLastValueTooltip($data);
|
||||||
|
if ($showLastValueTooltip !== 'disabled' && $moduleId > 0) {
|
||||||
|
// Maybe connect to node.
|
||||||
|
$nodeConnected = false;
|
||||||
|
if (\is_metaconsole() === true && $metaconsoleId !== null) {
|
||||||
|
$nodeConnected = \metaconsole_connect(
|
||||||
|
null,
|
||||||
|
$metaconsoleId
|
||||||
|
) === NOERR;
|
||||||
|
|
||||||
|
if ($nodeConnected === false) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'error connecting to the node'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$imgTitle = '';
|
||||||
|
|
||||||
|
$unit = \trim(\io_safe_output(\modules_get_unit($moduleId)));
|
||||||
|
$value = \modules_get_last_value($moduleId);
|
||||||
|
|
||||||
|
$isBooleanModule = \modules_is_boolean($moduleId);
|
||||||
|
if (!$isBooleanModule
|
||||||
|
|| ($isBooleanModule && $showLastValueTooltip !== 'default')
|
||||||
|
) {
|
||||||
|
if (is_numeric($value)) {
|
||||||
|
$imgTitle .= __('Last value: ').\remove_right_zeros($value);
|
||||||
|
} else {
|
||||||
|
$imgTitle .= __('Last value: ').$value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($unit) === false && empty($imgTitle) === false) {
|
||||||
|
$imgTitle .= ' '.$unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['lastValue'] = $imgTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore connection.
|
||||||
|
if ($nodeConnected === true) {
|
||||||
|
\metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -162,7 +162,7 @@ span.breadcrumb_link {
|
||||||
|
|
||||||
.edit_discovery_info {
|
.edit_discovery_info {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: flex-start;
|
||||||
padding-top: 25px;
|
padding-top: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,63 +181,41 @@ span.breadcrumb_link {
|
||||||
|
|
||||||
label {
|
label {
|
||||||
color: #343434 !important;
|
color: #343434 !important;
|
||||||
font-size: 1.5em;
|
|
||||||
font-family: "lato-bolder", "Open Sans", sans-serif !important;
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin: 0px 0px 5px 0px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.discovery_full_width_input {
|
.discovery_full_width_input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
li > input[type="text"],
|
||||||
font-family: "lato-bolder", "Open Sans", sans-serif !important;
|
li > input[type="password"],
|
||||||
font-size: 1.6em !important;
|
.discovery_text_input > input[type="password"],
|
||||||
color: #686868;
|
.discovery_text_input > input[type="text"],
|
||||||
|
#interval_manual > input[type="text"] {
|
||||||
|
background-color: transparent !important;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0 !important;
|
||||||
|
border-bottom: 1px solid #343434;
|
||||||
|
padding: 0px 0px 2px 0px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
select > option {
|
#interval_manual > input[type="text"] {
|
||||||
font-family: "lato-bolder", "Open Sans", sans-serif !important;
|
|
||||||
font-size: 1em !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
li > input[type=text], li > input[type=password], .discovery_text_input > input[type=password], .discovery_text_input > input[type=text], #interval_manual > input[type=text] {
|
|
||||||
background-color: transparent !important;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0 !important;
|
|
||||||
border-bottom: 1px solid #343434;
|
|
||||||
padding: 0px 0px 2px 0px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
margin-bottom: 4px;
|
|
||||||
font-family: "lato-bolder", "Open Sans", sans-serif !important;
|
|
||||||
font-size: 1.6em;
|
|
||||||
}
|
|
||||||
|
|
||||||
li > input[type=text]:focus, li > input[type=password]:focus, .discovery_text_input > input[type=password]:focus, .discovery_text_input > input[type=text]:focus, #interval_manual > input[type=text]:focus {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
#interval_manual > input[type=text] {
|
|
||||||
width: 50px;
|
width: 50px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.discovery_list_input {
|
.discovery_list_input {
|
||||||
font-family: "lato-bolder", "Open Sans", sans-serif !important;
|
|
||||||
font-size: 1.6em !important;
|
|
||||||
color: #686868;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 240px;
|
border: 1px solid #cbcbcb;
|
||||||
border: 1px solid #CBCBCB;
|
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.discovery_list_input option {
|
.discovery_list_input option {
|
||||||
font-family: "lato-bolder", "Open Sans", sans-serif !important;
|
text-align: center;
|
||||||
font-size: 1.1em !important;
|
|
||||||
padding-left: 30%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.discovery_list_input option:checked {
|
.discovery_list_input option:checked {
|
||||||
|
@ -253,11 +231,9 @@ li > input[type=text]:focus, li > input[type=password]:focus, .discovery_text_in
|
||||||
max-height: 100px;
|
max-height: 100px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
|
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
|
||||||
-moz-box-sizing: border-box; /* Firefox, other Gecko */
|
-moz-box-sizing: border-box; /* Firefox, other Gecko */
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
resize: none;
|
resize: none;
|
||||||
font-family: "lato-bolder", "Open Sans", sans-serif !important;
|
|
||||||
font-size: 1.4em !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a.tip {
|
a.tip {
|
||||||
|
@ -270,4 +246,4 @@ a.tip {
|
||||||
|
|
||||||
.discovery_interval_select_width {
|
.discovery_interval_select_width {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,6 +266,38 @@ th {
|
||||||
letter-spacing: 0.3pt;
|
letter-spacing: 0.3pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove background when autocomplete */
|
||||||
|
input:-webkit-autofill,
|
||||||
|
input:-webkit-autofill:hover,
|
||||||
|
input:-webkit-autofill:focus textarea:-webkit-autofill,
|
||||||
|
textarea:-webkit-autofill:hover textarea:-webkit-autofill:focus,
|
||||||
|
select:-webkit-autofill,
|
||||||
|
select:-webkit-autofill:hover,
|
||||||
|
select:-webkit-autofill:focus {
|
||||||
|
-webkit-box-shadow: 0 0 0px 1000px #ffffff inset !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* All select type multiple */
|
||||||
|
select[multiple] option:checked,
|
||||||
|
select[multiple] option:checked {
|
||||||
|
background: #82b92e linear-gradient(0deg, #82b92e 0%, #82b92e 100%);
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
select option:checked,
|
||||||
|
select option:checked {
|
||||||
|
background-color: #82b92e;
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
select > option:hover {
|
||||||
|
background-color: #cbcbcb;
|
||||||
|
}
|
||||||
|
|
||||||
|
select:-internal-list-box {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
/* --- Font ttf --- */
|
/* --- Font ttf --- */
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "DejaVuSerif-BoldFont";
|
font-family: "DejaVuSerif-BoldFont";
|
||||||
|
@ -3598,6 +3630,78 @@ div.simple_value > a > span.text p {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.events_show_more_table {
|
||||||
|
border-spacing: 0px;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Modal window - Show More */
|
||||||
|
table.events_show_more_table tr:nth-child(odd) td {
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
table.events_show_more_table tr:nth-child(even) td {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
border-top: 1px solid #cacaca;
|
||||||
|
border-bottom: 1px solid #cacaca;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.events_show_more_table tr td {
|
||||||
|
height: 22px;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.events_show_more_table tr td:first-child {
|
||||||
|
width: 35%;
|
||||||
|
font-weight: bold;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.events_tabs {
|
||||||
|
background: #ffffff !important;
|
||||||
|
border: 0px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.events_tabs:before,
|
||||||
|
ul.events_tabs:after {
|
||||||
|
content: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.events_tabs > li {
|
||||||
|
margin: 0 !important;
|
||||||
|
width: 20%;
|
||||||
|
text-align: center;
|
||||||
|
float: none !important;
|
||||||
|
outline-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.events_tabs > li.ui-state-default {
|
||||||
|
background: #fff !important;
|
||||||
|
border: none !important;
|
||||||
|
border-bottom: 2px solid black !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.events_tabs > li a {
|
||||||
|
text-align: center;
|
||||||
|
float: none !important;
|
||||||
|
padding: 8px !important;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.events_tabs > li span {
|
||||||
|
position: relative;
|
||||||
|
top: -6px;
|
||||||
|
left: 5px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.events_tabs > li.ui-tabs-active {
|
||||||
|
border-bottom: 2px solid #82b92e !important;
|
||||||
|
border-top: 2px solid #82b92e !important;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ---------------------------------------------------------------------
|
* ---------------------------------------------------------------------
|
||||||
* - modal window and edit user -
|
* - modal window and edit user -
|
||||||
|
@ -4939,28 +5043,6 @@ input:checked + .p-slider:before {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
select#autorefresh_list_out[multiple] option:checked,
|
|
||||||
select#autorefresh_list[multiple] option:checked {
|
|
||||||
background: #82b92e linear-gradient(0deg, #82b92e 0%, #82b92e 100%);
|
|
||||||
color: #fff !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
select#autorefresh_list_out option:checked,
|
|
||||||
select#autorefresh_list option:checked {
|
|
||||||
background-color: #82b92e;
|
|
||||||
color: #fff !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
select#autorefresh_list_out > option:hover,
|
|
||||||
select#autorefresh_list > option:hover {
|
|
||||||
background-color: #cbcbcb;
|
|
||||||
}
|
|
||||||
|
|
||||||
select#autorefresh_list_out:-internal-list-box,
|
|
||||||
select#autorefresh_list:-internal-list-box {
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.autorefresh_select .autorefresh_select_list_out,
|
.autorefresh_select .autorefresh_select_list_out,
|
||||||
.autorefresh_select .autorefresh_select_list {
|
.autorefresh_select .autorefresh_select_list {
|
||||||
width: 45%;
|
width: 45%;
|
||||||
|
@ -5438,3 +5520,339 @@ table.info_table.policy_sub_table {
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
* - Layout for the new forms
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
.first_row {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label_simple_one_item {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label_simple_items {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label_simple_items > * {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input_label {
|
||||||
|
color: #343434 !important;
|
||||||
|
font-weight: bold;
|
||||||
|
padding-right: 10px;
|
||||||
|
margin: 0px 0px 5px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input_label_simple {
|
||||||
|
margin-bottom: 0;
|
||||||
|
margin-top: 0;
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label_select_parent {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label_select_child_left {
|
||||||
|
width: 80%;
|
||||||
|
min-width: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label_select_child_right {
|
||||||
|
width: 20%;
|
||||||
|
min-width: 140px;
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label_select_child_icons {
|
||||||
|
text-align: right;
|
||||||
|
width: 5%;
|
||||||
|
min-width: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Inputs type text shown as a black line */
|
||||||
|
.agent_options input[type="text"] {
|
||||||
|
background-color: transparent !important;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0 !important;
|
||||||
|
border-bottom: 1px solid #343434;
|
||||||
|
padding: 2px 5px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: left bottom 2px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
* - Create/Update Agent - agent_manager.php
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
.agent_options {
|
||||||
|
width: 100%;
|
||||||
|
margin-right: 0px;
|
||||||
|
display: flex;
|
||||||
|
flex-flow: row wrap;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent_options_update {
|
||||||
|
width: 85%;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent_options_column_left,
|
||||||
|
.agent_options_column_right {
|
||||||
|
width: 50%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent_options_column_left {
|
||||||
|
padding-right: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent_qr {
|
||||||
|
width: 15%;
|
||||||
|
text-align: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 20px 0px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
min-width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a#qr_code_agent_view {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.first_row .agent_options_column_right select,
|
||||||
|
.first_row .agent_options_column_right input,
|
||||||
|
.first_row .agent_options_column_left select#grupo {
|
||||||
|
width: 95%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.first_row .agent_options_column_left .p-switch {
|
||||||
|
margin-right: 5px;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent_options_column_left input#text-direccion,
|
||||||
|
.agent_options_column_left select#address_list,
|
||||||
|
.agent_options_column_left input#text-agente,
|
||||||
|
.agent_options_column_left input#text-alias {
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent_options_agent_name > * {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom_fields_table {
|
||||||
|
border-spacing: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom_fields_table tr.datos {
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom_fields_table tr.datos2 {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom_fields_table tr td {
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom_fields_table tr.datos2 td div.field_title {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom_fields_table tr.datos2 td {
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom_fields_table tr.datos td {
|
||||||
|
padding: 15px 10px;
|
||||||
|
border-bottom-left-radius: 4px;
|
||||||
|
border-bottom-right-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom_fields_table .custom_field_row_opened td {
|
||||||
|
border-bottom-left-radius: 0px !important;
|
||||||
|
border-bottom-right-radius: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.secondary_groups_select {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.secondary_groups_select .secondary_groups_select_arrows input {
|
||||||
|
display: grid;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.secondary_groups_select .secondary_groups_list_left {
|
||||||
|
text-align: right;
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.secondary_groups_select .secondary_groups_list_right {
|
||||||
|
text-align: left;
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.secondary_groups_select .secondary_groups_select_arrows {
|
||||||
|
padding: 0 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.secondary_groups_select_arrows a {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent_options_adv .agent_options_column_right .label_select select,
|
||||||
|
.agent_options_adv .agent_options_column_right .label_select input[type="text"],
|
||||||
|
.agent_options_adv #text-custom_id,
|
||||||
|
.agent_options_adv #cps {
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent_options_adv .label_select_simple.label_simple_one_item .p-switch {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
* - CLASSES FOR THE NEW TOGGLES -
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
.ui_toggle {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui_toggle > a:first-child {
|
||||||
|
background-color: #fff;
|
||||||
|
border: 1px solid #f3f3f3;
|
||||||
|
border-top-left-radius: 4px;
|
||||||
|
border-top-right-radius: 4px;
|
||||||
|
padding: 5px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.white_box_opened {
|
||||||
|
border-top-left-radius: 0px;
|
||||||
|
border-top-right-radius: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
* - SWITCH RADIO BUTTONS -
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
.switch_radio_button {
|
||||||
|
display: flex;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch_radio_button input {
|
||||||
|
position: absolute !important;
|
||||||
|
clip: rect(0, 0, 0, 0);
|
||||||
|
height: 1px;
|
||||||
|
width: 1px;
|
||||||
|
border: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch_radio_button label {
|
||||||
|
background-color: #fff;
|
||||||
|
color: rgba(0, 0, 0, 0.6);
|
||||||
|
line-height: 1;
|
||||||
|
text-align: center;
|
||||||
|
padding: 7px 14px;
|
||||||
|
margin-right: -1px;
|
||||||
|
border: 1px solid #cbcbcb;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: all 0.1s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch_radio_button label:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch_radio_button input:checked + label {
|
||||||
|
background-color: #82b92e;
|
||||||
|
box-shadow: none;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch_radio_button label:last-child {
|
||||||
|
margin-right: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
* - MODULE GRAPHS
|
||||||
|
* ---------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
.module_graph_menu_dropdown {
|
||||||
|
padding-top: 20px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 1001;
|
||||||
|
}
|
||||||
|
|
||||||
|
.module_graph_menu_content,
|
||||||
|
.module_graph_menu_header {
|
||||||
|
width: 92%;
|
||||||
|
border: 1px solid #e2e2e2;
|
||||||
|
margin: 0 auto;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.module_graph_menu_header {
|
||||||
|
border-top-left-radius: 4px;
|
||||||
|
border-top-right-radius: 4px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.module_graph_menu_header span > img {
|
||||||
|
vertical-align: middle;
|
||||||
|
padding-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.module_graph_menu_content {
|
||||||
|
border-bottom-left-radius: 4px;
|
||||||
|
border-bottom-right-radius: 4px;
|
||||||
|
padding: 15px;
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ ul.wizard {
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.wizard li {
|
ul.wizard li {
|
||||||
padding: 10px;
|
padding-bottom: 10px;
|
||||||
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.wizard li > label:not(.p-switch) {
|
ul.wizard li > label:not(.p-switch) {
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
#visual-console-container {
|
||||||
|
margin: 0px auto;
|
||||||
|
position: relative;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 100% 100%;
|
||||||
|
background-position: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.visual-console-item {
|
||||||
|
position: absolute;
|
||||||
|
display: -webkit-box;
|
||||||
|
display: -ms-flexbox;
|
||||||
|
display: flex;
|
||||||
|
-webkit-box-orient: initial;
|
||||||
|
-webkit-box-direction: initial;
|
||||||
|
-ms-flex-direction: initial;
|
||||||
|
flex-direction: initial;
|
||||||
|
justify-items: center;
|
||||||
|
-webkit-box-align: center;
|
||||||
|
-ms-flex-align: center;
|
||||||
|
align-items: center;
|
||||||
|
-webkit-user-select: text;
|
||||||
|
-moz-user-select: text;
|
||||||
|
-ms-user-select: text;
|
||||||
|
user-select: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: Alarm Clock;
|
||||||
|
src: url(alarm-clock.ttf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Digital clock */
|
||||||
|
|
||||||
|
.visual-console-item .digital-clock {
|
||||||
|
display: -webkit-box;
|
||||||
|
display: -ms-flexbox;
|
||||||
|
display: flex;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-box-direction: normal;
|
||||||
|
-ms-flex-direction: column;
|
||||||
|
flex-direction: column;
|
||||||
|
-webkit-box-pack: center;
|
||||||
|
-ms-flex-pack: center;
|
||||||
|
justify-content: center;
|
||||||
|
justify-items: center;
|
||||||
|
-ms-flex-line-pack: center;
|
||||||
|
align-content: center;
|
||||||
|
-webkit-box-align: center;
|
||||||
|
-ms-flex-align: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.visual-console-item .digital-clock > span {
|
||||||
|
font-family: "Alarm Clock", "Courier New", Courier, monospace;
|
||||||
|
font-size: 50px;
|
||||||
|
|
||||||
|
/* To improve legibility */
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
text-shadow: rgba(0, 0, 0, 0.01) 0 0 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.visual-console-item .digital-clock > span.date {
|
||||||
|
font-size: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.visual-console-item .digital-clock > span.timezone {
|
||||||
|
font-size: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Analog clock */
|
||||||
|
|
||||||
|
.visual-console-item .analogic-clock .hour-hand {
|
||||||
|
-webkit-animation: rotate-hour 43200s infinite linear;
|
||||||
|
animation: rotate-hour 43200s infinite linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
.visual-console-item .analogic-clock .minute-hand {
|
||||||
|
-webkit-animation: rotate-minute 3600s infinite linear;
|
||||||
|
animation: rotate-minute 3600s infinite linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
.visual-console-item .analogic-clock .second-hand {
|
||||||
|
-webkit-animation: rotate-second 60s infinite linear;
|
||||||
|
animation: rotate-second 60s infinite linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*# sourceMappingURL=vc.main.css.map*/
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"sources":["webpack:///main.css","webpack:///styles.css"],"names":[],"mappings":"AAAA;EACE,gBAAgB;EAChB,kBAAkB;EAClB,4BAA4B;EAC5B,0BAA0B;EAC1B,2BAA2B;AAC7B;;AAEA;EACE,kBAAkB;EAClB,oBAAa;EAAb,oBAAa;EAAb,aAAa;EACb,2BAAuB;EAAvB,8BAAuB;MAAvB,2BAAuB;UAAvB,uBAAuB;EACvB,qBAAqB;EACrB,yBAAmB;MAAnB,sBAAmB;UAAnB,mBAAmB;EACnB,yBAAiB;KAAjB,sBAAiB;MAAjB,qBAAiB;UAAjB,iBAAiB;AACnB;;ACfA;EACE,wBAAwB;EACxB,0BAA2B;AAC7B;;AAEA,kBAAkB;;AAElB;EACE,oBAAa;EAAb,oBAAa;EAAb,aAAa;EACb,4BAAsB;EAAtB,6BAAsB;MAAtB,0BAAsB;UAAtB,sBAAsB;EACtB,wBAAuB;MAAvB,qBAAuB;UAAvB,uBAAuB;EACvB,qBAAqB;EACrB,0BAAqB;MAArB,qBAAqB;EACrB,yBAAmB;MAAnB,sBAAmB;UAAnB,mBAAmB;AACrB;;AAEA;EACE,6DAA6D;EAC7D,eAAe;;EAEf,0BAA0B;EAC1B,mCAAmC;EACnC,kCAAkC;EAClC,kCAAkC;EAClC,wCAAwC;AAC1C;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,eAAe;AACjB;;AAEA,iBAAiB;;AAEjB;EACE,qDAA6C;UAA7C,6CAA6C;AAC/C;;AAEA;EACE,sDAA8C;UAA9C,8CAA8C;AAChD;;AAEA;EACE,oDAA4C;UAA5C,4CAA4C;AAC9C","file":"vc.main.css","sourcesContent":["#visual-console-container {\n margin: 0px auto;\n position: relative;\n background-repeat: no-repeat;\n background-size: 100% 100%;\n background-position: center;\n}\n\n.visual-console-item {\n position: absolute;\n display: flex;\n flex-direction: initial;\n justify-items: center;\n align-items: center;\n user-select: text;\n}\n","@font-face {\n font-family: Alarm Clock;\n src: url(./alarm-clock.ttf);\n}\n\n/* Digital clock */\n\n.visual-console-item .digital-clock {\n display: flex;\n flex-direction: column;\n justify-content: center;\n justify-items: center;\n align-content: center;\n align-items: center;\n}\n\n.visual-console-item .digital-clock > span {\n font-family: \"Alarm Clock\", \"Courier New\", Courier, monospace;\n font-size: 50px;\n\n /* To improve legibility */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n text-shadow: rgba(0, 0, 0, 0.01) 0 0 1px;\n}\n\n.visual-console-item .digital-clock > span.date {\n font-size: 25px;\n}\n\n.visual-console-item .digital-clock > span.timezone {\n font-size: 25px;\n}\n\n/* Analog clock */\n\n.visual-console-item .analogic-clock .hour-hand {\n animation: rotate-hour 43200s infinite linear;\n}\n\n.visual-console-item .analogic-clock .minute-hand {\n animation: rotate-minute 3600s infinite linear;\n}\n\n.visual-console-item .analogic-clock .second-hand {\n animation: rotate-second 60s infinite linear;\n}\n"],"sourceRoot":""}
|