diff --git a/extras/android-event-viewer/.idea/misc.xml b/extras/android-event-viewer/.idea/misc.xml index 38041c7cc6..a4aaf9f97e 100644 --- a/extras/android-event-viewer/.idea/misc.xml +++ b/extras/android-event-viewer/.idea/misc.xml @@ -1,8 +1,5 @@ - - - - - - - - - - - - - - + diff --git a/extras/android-event-viewer/app/build.gradle b/extras/android-event-viewer/app/build.gradle index 92924f93b3..d9a280d817 100644 --- a/extras/android-event-viewer/app/build.gradle +++ b/extras/android-event-viewer/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 8 - buildToolsVersion "25.0.2" + buildToolsVersion "26.0.2" defaultConfig { applicationId "pandroid_event_viewer.pandorafms" diff --git a/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/EventList.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/EventList.java index 15ca771bad..b208855e0b 100644 --- a/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/EventList.java +++ b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/EventList.java @@ -159,8 +159,14 @@ public class EventList extends ListActivity { } }); - - + ImageButton btnSettings = (ImageButton) findViewById(R.id.settings_icon_button_list); + // Open the settings + btnSettings.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + startActivity(new Intent(v.getContext(), Options.class)); + } + }); + registerReceiver(onBroadcast, new IntentFilter("eventlist.java")); this.toggleLoadingLayout(); diff --git a/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Main.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Main.java index 6ab57371e9..2548b8023b 100644 --- a/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Main.java +++ b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Main.java @@ -96,10 +96,29 @@ public class Main extends Activity { Activity.MODE_PRIVATE); setContentView(R.layout.main); + final ImageButton btnSettings = (ImageButton) findViewById(R.id.settings_icon_button_main); + final ImageButton btnFilter = (ImageButton) findViewById(R.id.filter_icon_button_main); final Button buttonSetAsFilterWatcher = (Button) findViewById(R.id.button_set_as_filter_watcher); final ImageButton buttonSearch = (ImageButton) findViewById(R.id.refresh_icon_button_main); final ImageButton buttonDeleteProfile = (ImageButton) findViewById(R.id.button_delete_profile); final ImageButton buttonSaveProfile = (ImageButton) findViewById(R.id.button_save_profile); + + // Open the settings + btnSettings.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + startActivity(new Intent(v.getContext(), Options.class)); + } + }); + + // Go to the events list + btnFilter.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + Activity a = (Activity) v.getContext(); + TabActivity ta = (TabActivity) a.getParent(); + ta.getTabHost().setCurrentTab(1); + } + }); + // Check if the user preferences it is set. if (object.user.length() == 0 || object.password.length() == 0 || object.url.length() == 0) { diff --git a/extras/android-event-viewer/app/src/main/res/layout/list_view_layout.xml b/extras/android-event-viewer/app/src/main/res/layout/list_view_layout.xml index 9b32dfe1dc..b0135b4489 100644 --- a/extras/android-event-viewer/app/src/main/res/layout/list_view_layout.xml +++ b/extras/android-event-viewer/app/src/main/res/layout/list_view_layout.xml @@ -63,8 +63,22 @@ android:layout_weight="0" android:padding="0dp" android:src="@drawable/filter_icon_button" + android:background="@null" /> + + + + + android:tint="@android:color/white" + android:src="@android:drawable/ic_menu_preferences" /> + + + + + + /dev/null diff --git a/pandora_agents/unix/Darwin/pandora_agent.conf b/pandora_agents/unix/Darwin/pandora_agent.conf index 463753cce4..d7647191a4 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.713, GNU/Linux +# Version 7.0NG.716, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index dfed2140ba..2625ca7542 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.713, FreeBSD Version +# Version 7.0NG.716, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index 961acd9c83..2387412e15 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.713, HP-UX Version +# Version 7.0NG.716, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index c9ebc00767..da5c2b2c18 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.713, GNU/Linux +# Version 7.0NG.716, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf index e234318c7e..a0717d889e 100644 --- a/pandora_agents/unix/NT4/pandora_agent.conf +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.713, GNU/Linux +# Version 7.0NG.716, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index 9b9a078a9d..0cc5dc41cc 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.713, NetBSD Version +# Version 7.0NG.716, NetBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index c11f852b29..ac8ece9b0c 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.713, Solaris Version +# Version 7.0NG.716, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index f4780c18a7..7c1cbe610c 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -40,8 +40,8 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '7.0NG.713'; -use constant AGENT_BUILD => '171018'; +use constant AGENT_VERSION => '7.0NG.716'; +use constant AGENT_BUILD => '171130'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -1244,7 +1244,11 @@ sub check_collections () { # Delete old collections if there are no broker agents if ($BrokerEnabled == 0) { - opendir (DIR, "$ConfDir/collections") || return; + if(!opendir (DIR, "$ConfDir/collections")){ + log_message ('Collection', "Could not open dir $ConfDir/collections"); + return; + } + while (defined (my $file_name = readdir(DIR))) { next if ($file_name eq '.' || $file_name eq '..'); @@ -1252,8 +1256,14 @@ sub check_collections () { $file_name =~ s/\.md5$//; if (! defined ($Collections{$file_name})) { - rmrf ("$ConfDir/collections/$file_name"); - unlink ("$ConfDir/collections/$file_name.md5"); + if(opendir (DIR_check, "$ConfDir/collections/$file_name")){ + closedir (DIR_check); + rmrf ("$ConfDir/collections/$file_name"); + unlink ("$ConfDir/collections/$file_name.md5"); + } + else { + log_message ('Collection', "Could not open dir $ConfDir/collections/$file_name"); + } } } closedir (DIR); @@ -1272,7 +1282,11 @@ sub check_collections () { # Get remote md5 error ("File '$Conf{'temporal'}/$collection_md5_file' already exists as a symlink and could not be removed: $!.") if (-l "$Conf{'temporal'}/$collection_md5_file" && !unlink("$Conf{'temporal'}/$collection_md5_file")); - next unless (recv_file ($collection_md5_file, $Conf{'server_path_md5'}) == 0); + if(recv_file ($collection_md5_file, $Conf{'server_path_md5'}) != 0){ + log_message ('Collection', "Could not write $collection_md5_file on " . $Conf{'server_path_md5'}); + next; + } + open (MD5_FILE, "< $Conf{'temporal'}/$collection_md5_file") || error ("Could not open file '$Conf{'temporal'}/$collection_md5_file' for reading: $!."); my $remote_collection_md5 = ; close (MD5_FILE); @@ -1284,13 +1298,20 @@ sub check_collections () { $local_collection_md5 = ; close MD5_FILE; } + else{ + log_message ('Collection', "Could not open dir $ConfDir/collections/$collection_md5_file"); + next; + } # Check for changes $local_collection_md5 = $remote_collection_md5 unless defined ($local_collection_md5); next if ($local_collection_md5 eq $remote_collection_md5); # Download and unzip - next unless (recv_file ($collection_file, $Conf{'server_path_zip'}) == 0); + if(recv_file ($collection_md5_file, $Conf{'server_path_md5'}) != 0){ + log_message ('Collection', "Could not write $collection_file on " . $Conf{'server_path_zip'}); + next; + } rmrf ("$ConfDir/collections/$collection"); `unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>$DevNull`; unlink ("$Conf{'temporal'}/$collection_file"); @@ -1579,6 +1600,9 @@ sub guess_os_version ($) { # AIX } elsif ($os eq 'aix') { $os_version = "$2.$1" if (`uname -rv` =~ /\s*(\d)\s+(\d)\s*/); + # Darwin + } elsif ($os eq 'darwin') { + $os_version = `defaults read loginwindow SystemVersionStampAsString`; # Windows } elsif ($os =~ /win/i) { $os_version = `ver`; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 5d0e1e4d5e..582cba7a4c 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.713 -%define release 171018 +%define version 7.0NG.716 +%define release 171130 Summary: Pandora FMS Linux agent, PERL version Name: %{name} @@ -24,7 +24,7 @@ Requires(preun): chkconfig /bin/rm /usr/sbin/userdel Requires: fileutils textutils unzip Requires: util-linux procps grep Requires: /sbin/ip /bin/awk -Requires: perl perl(Sys::Syslog) perl(IO::Socket::SSL) +Requires: perl perl(Sys::Syslog) # Required by plugins #Requires: sh-utils sed passwd net-tools rpm AutoReq: 0 diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index ae5a512cd6..1e91878da6 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.713 -%define release 171018 +%define version 7.0NG.716 +%define release 171130 Summary: Pandora FMS Linux agent, PERL version Name: %{name} @@ -67,6 +67,7 @@ then fi %post +mkdir -p /var/log/pandora chown pandora:root /var/log/pandora if [ ! -d /etc/pandora ] ; then mkdir -p /etc/pandora @@ -91,6 +92,9 @@ if [ ! -e /etc/pandora/collections ]; then fi cp -aRf /usr/share/pandora_agent/pandora_agent_logrotate /etc/logrotate.d/pandora_agent +# Enable the service on SystemD +systemctl enable pandora_agent_daemon.service + mkdir -p /var/spool/pandora/data_out chkconfig pandora_agent_daemon on diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 37de832d91..696fa280a0 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -9,8 +9,8 @@ # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.713" -PI_BUILD="171018" +PI_VERSION="7.0NG.716" +PI_BUILD="171130" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/plugins/route_parser b/pandora_agents/unix/plugins/route_parser new file mode 100644 index 0000000000..40cfcea36f --- /dev/null +++ b/pandora_agents/unix/plugins/route_parser @@ -0,0 +1,780 @@ +#!/usr/bin/perl +# +# Dynamic route parser +# Combines MTR and Ping features +# +# + +use strict; +use warnings; +use POSIX qw(strftime); +use Scalar::Util qw(looks_like_number); +use Socket; + +my $HELP=< 1 } @{$array}; + if (exists($params{$value})) { + return 1; + } + return 0; +} + +################################################################################ +# Check if a given variable contents a number +################################################################################ +sub to_number($) { + my $n = shift; + + if(empty($n)) { + return undef; + } + + if ($n =~ /[\d+,]*\d+\.\d+/) { + # American notation + $n =~ s/,//g; + } + elsif ($n =~ /[\d+\.]*\d+,\d+/) { + # Spanish notation + $n =~ s/\.//g; + $n =~ s/,/./g; + } + if(looks_like_number($n)) { + return $n; + } + return undef; +} + +################################################################################ +# Erase blank spaces before and after the string +################################################################################ +sub trim($){ + my $string = shift; + if (empty ($string)){ + return ""; + } + + $string =~ s/\r//g; + + chomp ($string); + $string =~ s/^\s+//g; + $string =~ s/\s+$//g; + + return $string; +} + +################################################################################ +# Empty +################################################################################ +sub empty($){ + my $str = shift; + + if (! (defined ($str)) ){ + return 1; + } + + if(looks_like_number($str)){ + return 0; + } + + if (ref ($str) eq "ARRAY") { + return (($#{$str}<0)?1:0); + } + + if (ref ($str) eq "HASH") { + my @tmp = keys %{$str}; + return (($#tmp<0)?1:0); + } + + if ($str =~ /^\ *[\n\r]{0,2}\ *$/) { + return 1; + } + return 0; +} + +################################################################################ +# is Enabled +################################################################################ +sub is_enabled($){ + my $value = shift; + + if ((defined ($value)) && ($value > 0)){ + # return true + return 1; + } + #return false + return 0; + +} + +################################################################################ +# print_module +################################################################################ +sub print_module ($$;$){ + my $config = shift; + my $data = shift; + my $not_print_flag = shift; + + if ((ref($data) ne "HASH") || (!defined $data->{name})) { + return undef; + } + + my $xml_module = ""; + # If not a string type, remove all blank spaces! + if ($data->{type} !~ m/string/){ + $data->{value} = trim($data->{value}); + } + + $data->{tags} = $data->{tags}?$data->{tags}:($config->{MODULE_TAG_LIST}?$config->{MODULE_TAG_LIST}:undef); + $data->{interval} = $data->{interval}?$data->{interval}:($config->{MODULE_INTERVAL}?$config->{MODULE_INTERVAL}:undef); + $data->{module_group} = $data->{module_group}?$data->{module_group}:($config->{MODULE_GROUP}?$config->{MODULE_GROUP}:undef); + + # Global instructions (if defined) + $data->{unknown_instructions} = $config->{unknown_instructions} unless (defined($data->{unknown_instructions}) || (!defined($config->{unknown_instructions}))); + $data->{warning_instructions} = $config->{warning_instructions} unless (defined($data->{warning_instructions}) || (!defined($config->{warning_instructions}))); + $data->{critical_instructions} = $config->{critical_instructions} unless (defined($data->{critical_instructions}) || (!defined($config->{critical_instructions}))); + + $xml_module .= "\n"; + $xml_module .= "\t{name} . "]]>\n"; + $xml_module .= "\t" . $data->{type} . "\n"; + + if (ref ($data->{value}) eq "ARRAY") { + $xml_module .= "\t\n"; + foreach (@{$data->{value}}) { + $xml_module .= "\t{value} . "]]>\n"; + } + $xml_module .= "\t\n"; + } + else { + $xml_module .= "\t{value} . "]]>\n"; + } + + if ( !(empty($data->{desc}))) { + $xml_module .= "\t{desc} . "]]>\n"; + } + if ( !(empty ($data->{unit})) ) { + $xml_module .= "\t{unit} . "]]>\n"; + } + if (! (empty($data->{interval})) ) { + $xml_module .= "\t{interval} . "]]>\n"; + } + if (! (empty($data->{tags})) ) { + $xml_module .= "\t" . $data->{tags} . "\n"; + } + if (! (empty($data->{module_group})) ) { + $xml_module .= "\t" . $data->{module_group} . "\n"; + } + if (! (empty($data->{module_parent})) ) { + $xml_module .= "\t" . $data->{module_parent} . "\n"; + } + if (! (empty($data->{wmin})) ) { + $xml_module .= "\t{wmin} . "]]>\n"; + } + if (! (empty($data->{wmax})) ) { + $xml_module .= "\t{wmax} . "]]>\n"; + } + if (! (empty ($data->{cmin})) ) { + $xml_module .= "\t{cmin} . "]]>\n"; + } + if (! (empty ($data->{cmax})) ){ + $xml_module .= "\t{cmax} . "]]>\n"; + } + if (! (empty ($data->{wstr}))) { + $xml_module .= "\t{wstr} . "]]>\n"; + } + if (! (empty ($data->{cstr}))) { + $xml_module .= "\t{cstr} . "]]>\n"; + } + if (! (empty ($data->{cinv}))) { + $xml_module .= "\t{cinv} . "]]>\n"; + } + if (! (empty ($data->{winv}))) { + $xml_module .= "\t{winv} . "]]>\n"; + } + if (! (empty ($data->{max}))) { + $xml_module .= "\t{max} . "]]>\n"; + } + if (! (empty ($data->{min}))) { + $xml_module .= "\t{min} . "]]>\n"; + } + if (! (empty ($data->{post_process}))) { + $xml_module .= "\t{post_process} . "]]>\n"; + } + if (! (empty ($data->{disabled}))) { + $xml_module .= "\t{disabled} . "]]>\n"; + } + if (! (empty ($data->{min_ff_event}))) { + $xml_module .= "\t{min_ff_event} . "]]>\n"; + } + if (! (empty ($data->{status}))) { + $xml_module .= "\t{status} . "]]>\n"; + } + if (! (empty ($data->{timestamp}))) { + $xml_module .= "\t{timestamp} . "]]>\n"; + } + if (! (empty ($data->{custom_id}))) { + $xml_module .= "\t{custom_id} . "]]>\n"; + } + if (! (empty ($data->{critical_instructions}))) { + $xml_module .= "\t{critical_instructions} . "]]>\n"; + } + if (! (empty ($data->{warning_instructions}))) { + $xml_module .= "\t{warning_instructions} . "]]>\n"; + } + if (! (empty ($data->{unknown_instructions}))) { + $xml_module .= "\t{unknown_instructions} . "]]>\n"; + } + if (! (empty ($data->{quiet}))) { + $xml_module .= "\t{quiet} . "]]>\n"; + } + if (! (empty ($data->{module_ff_interval}))) { + $xml_module .= "\t{module_ff_interval} . "]]>\n"; + } + if (! (empty ($data->{crontab}))) { + $xml_module .= "\t{crontab} . "]]>\n"; + } + if (! (empty ($data->{min_ff_event_normal}))) { + $xml_module .= "\t{min_ff_event_normal} . "]]>\n"; + } + if (! (empty ($data->{min_ff_event_warning}))) { + $xml_module .= "\t{min_ff_event_warning} . "]]>\n"; + } + if (! (empty ($data->{min_ff_event_critical}))) { + $xml_module .= "\t{min_ff_event_critical} . "]]>\n"; + } + if (! (empty ($data->{ff_timeout}))) { + $xml_module .= "\t{ff_timeout} . "]]>\n"; + } + if (! (empty ($data->{each_ff}))) { + $xml_module .= "\t{each_ff} . "]]>\n"; + } + if (! (empty ($data->{parent_unlink}))) { + $xml_module .= "\t{parent_unlink} . "]]>\n"; + } + if (! (empty ($data->{alerts}))) { + foreach my $alert (@{$data->{alerts}}){ + $xml_module .= "\t\n"; + } + } + if (defined ($config->{global_alerts})){ + foreach my $alert (@{$config->{global_alerts}}){ + $xml_module .= "\t\n"; + } + } + + $xml_module .= "\n"; + + if (empty ($not_print_flag)) { + print $xml_module; + } + + return $xml_module; +} + +################################################################################ +# General arguments parser +################################################################################ +sub parse_arguments($) { + my $raw = shift; + my @args; + if (defined($raw)){ + @args = @{$raw}; + } + else { + return {}; + } + + my %data; + for (my $i = 0; $i < $#args; $i+=2) { + my $key = trim($args[$i]); + + $key =~ s/^-//; + $data{$key} = trim($args[$i+1]); + } + + return \%data; + +} + +################################################################################ +# General configuration file parser +# +# log=/PATH/TO/LOG/FILE +# +################################################################################ +sub parse_configuration($;$$){ + my $conf_file = shift; + my $separator; + $separator = shift or $separator = "="; + my $custom_eval = shift; + my $_CFILE; + + my $_config; + + if (empty($conf_file)) { + return { + error => "Configuration file not specified" + }; + } + + if( !open ($_CFILE,"<", "$conf_file")) { + return { + error => "Cannot open configuration file" + }; + } + + while (my $line = <$_CFILE>){ + if (($line =~ /^ *\r*\n*$/) + || ($line =~ /^#/ )){ + # skip blank lines and comments + next; + } + my @parsed = split /$separator/, $line, 2; + if ($line =~ /^\s*global_alerts/){ + push (@{$_config->{global_alerts}}, trim($parsed[1])); + next; + } + if (ref ($custom_eval) eq "ARRAY") { + my $f = 0; + foreach my $item (@{$custom_eval}) { + if ($line =~ /$item->{exp}/) { + $f = 1; + my $aux; + eval { + $aux = $item->{target}->($item->{exp},$line); + }; + + if (empty($_config)) { + $_config = $aux; + } + elsif (!empty($aux) && (ref ($aux) eq "HASH")) { + $_config = merge_hashes($_config, $aux); + } + } + } + + if (is_enabled($f)){ + next; + } + } + $_config->{trim($parsed[0])} = trim($parsed[1]); + } + close ($_CFILE); + + return $_config; +} + +################################################################################ +# End of import +################################################################################ + + +########################################################################## +# Show a message to STDERR +########################################################################## +sub msg { + my $msg = shift; + print STDERR strftime ("%Y-%m-%d %H:%M:%S", localtime()) . ": $msg\n"; +} + + +sub get_next { + my ($route, $step) = @_; + return $route->{'next'}->{$step}; +} + +########################################################################## +# Extract route steps & timming from mtr output +########################################################################## +sub get_steps { + my ($conf) = @_; + my $target = $conf->{'t'}; + + return [] if empty($target); + + my $mtr_r = ""; + my $ping_r = ""; + + my @route_raw; + my @ping_raw; + + + if ($^O =~ /win/i){ + $ping_r = trim(`ping -r 9 $target -n 1 | tr "Routea:->-" " " | gawk "/^[0-9\. ]*\$/ {if (\$1 != \\"\\"){ print \$1\";\"0}}"`) unless is_enabled($conf->{'-no-ping'}); + + @ping_raw = split /\n/, $ping_r; + + if ($#ping_raw < 0) { + $mtr_r = trim(`mtr -n -o A -c $conf->{'c'} -r $target 2>/NUL | gawk "{print \$2";"\$3}"`) unless is_enabled($conf->{'-no-mtr'}); + } + } + else { + $ping_r = trim(`for x in \$(ping -n -c 1 -R $target 2>/dev/null | tr -s "R:" " " | awk '/^[0-9\. \t]*\$/ {if (\$1 != ""){print \$1}}'); do echo -n \$x";"; ping -c $conf->{'c'} \$x 2>/dev/null | grep rtt |awk '{print \$4}'| cut -f2 -d"/"; done`) unless is_enabled($conf->{'-no-ping'}); + + @ping_raw = split /\n/, $ping_r; + + if ($#ping_raw < 0) { + $mtr_r = trim(`mtr -n -c $conf->{'c'} -r $target -o A 2>/dev/null | awk '/^[0-9\\|\\-\\. \\t]*\$/ {print \$2\";\"\$3}'`) unless is_enabled($conf->{'-no-mtr'}); + } + + } + + @route_raw = split /\n/, $mtr_r; + + my @modules; + my @steps; + my $route; + + if ($#ping_raw >= 0) { + # PING mode + + my $rng = scalar @ping_raw; + my $checked; + my $j; + + if (is_enabled($conf->{'s'})) { + # Symmetric routing + + if ($^O =~ /win/i){ + $j = 1; + } + else { + $j = 0; + } + + for (my $i=0; $i< ($rng/2); $i++) { + my ($step,$time) = split /;/, $ping_raw[$i]; + my $_r; + + if (defined($checked->{$step})) { + $j-=2; + next; + } + $checked->{$step} = 1; + + $_r->{'step'} = $step; + if ($^O =~ /win/i) { + $_r->{'time'} = trim(`ping -n $conf->{'c'} $_r->{'step'} | grep -e "Av" -e "Me" | gawk "{print \$NF}" | tr -d "ms"`) unless ((!defined($_r->{'step'}) || ($_r->{'step'} eq ""))); + } + else { + $_r->{'time'} = $time; + } + + if ((!defined($_r->{'step'}) || ($_r->{'step'} eq ""))) { + $_r->{'step'} = "???"; + } + + $steps[$j] = $_r; + $j+=2; + } + + if ($^O =~ /win/i){ + $j = 0; + } + else { + $j = 1; + } + for (my $i=$rng-1; $i>= ($rng/2); $i--) { + my ($step,$time) = split /;/, $ping_raw[$i]; + my $_r; + + if (defined($checked->{$step})) { + $j-=2 if $j>2; + next; + } + + $_r->{'step'} = $step; + if ($^O =~ /win/i) { + $_r->{'time'} = trim(`ping -n $conf->{'c'} $_r->{'step'} | grep -e "Av" -e "Me" | gawk "{print \$NF}" | tr -d "ms"`) unless ((!defined($_r->{'step'}) || ($_r->{'step'} eq ""))); + } + else { + $_r->{'time'} = $time; + } + + + if ((!defined($_r->{'step'}) || ($_r->{'step'} eq ""))) { + $_r->{'step'} = "???"; + } + + $steps[$j] = $_r; + $j+=2; + } + } + else { + # Asymmetric routing + + for (my $i=0; $i< $rng; $i++) { + my ($step,$time) = split /;/, $ping_raw[$i]; + my $_r; + + if (defined($checked->{$step})) { + # target reached + last; + } + + $checked->{$step} = 1; + + $_r->{'step'} = $step; + if ($^O =~ /win/i) { + $_r->{'time'} = trim(`ping -n $conf->{'c'} $_r->{'step'} | grep -e "Av" -e "Me" | gawk "{print \$NF}" | tr -d "ms"`) unless ((!defined($_r->{'step'}) || ($_r->{'step'} eq ""))); + } + else { + $_r->{'time'} = $time; + } + + if ((!defined($_r->{'step'}) || ($_r->{'step'} eq ""))) { + $_r->{'step'} = "???"; + } + + $steps[$i] = $_r; + } + } + + my $__origin; + + if ($^O !~ /win/i){ + $__origin = shift @steps; + } + + my $gw; + + if ($^O =~ /win/i) { + ($gw->{'step'},$__origin->{'step'}) = split /;/, trim(`route print -4 | gawk "BEGIN {min=10000} /^\\ *0.0.0.0/ {met=\$NF;if(met{'time'} = trim(`ping -n $conf->{'c'} $gw->{'step'} 2>/NUL | grep ms | grep -v TTL | gawk "{print \$NF}" | tr -d "ms"`); + $__origin->{'time'} = 0; + } + else { + $gw->{'step'} = trim(`route -n | awk 'BEGIN {min=100000} /^0/ {met=\$5; if(min>met){gw=\$2;min=met} } END { print gw}'`); + $gw->{'time'} = trim(`ping -c $conf->{'c'} $gw->{'step'} 2>/dev/null | grep rtt |awk '{print \$4}'| cut -f2 -d"/"`); + } + + unshift (@steps,($__origin,$gw)); + + my $unknown_count = 0; + my $previous = undef; + + for(my $i=0; $i <= $#steps; $i++) { + my $host = $steps[$i]->{'step'}; + my $time = to_number($steps[$i]->{'time'}); + my $preffix = 'RouteStep_'; + my $desc = ''; + + if (!defined($time)) { + next; + } + + if ($host eq "???") { + $host = "Hidden_" . (++$unknown_count); + } + if (($i == $#steps) && in_array($conf->{'target_ip'},$host)) { + $preffix = 'RouteStepTarget_'; + } + elsif($i == $#steps) { + $desc = 'Step unreachable'; + } + + push @modules, { + name => $preffix . $host, + type => "generic_data", + value => $time, + unit => 'ms', + desc => $desc, + module_parent => $previous, + parent_unlink => (empty($previous)?'1':undef) + }; + + $previous = $preffix . $host; + } + + return \@modules; + } + else { + # MTR mode + + if ($#route_raw < 0) { + # Empty output + msg("Failed to analyze [$target]"); + return []; + + } + + for (my $i=0; $i <= $#route_raw; $i++) { + my $line = $route_raw[$i]; + if (trim($line) =~ /(.*?);(.*)/) { + my $host = $1; + my $time = to_number($2); + my $preffix = 'RouteStep_'; + my $desc = ''; + my $item; + my $_r; + + if (!defined($time)) { + next; + } + + $_r->{'step'} = $host; + $_r->{'time'} = $time; + + push @steps, $_r; + } + } + + my $__origin; + + if ($^O !~ /win/i){ + $__origin = shift @steps; + } + + my $gw; + + if ($^O =~ /win/i) { + ($gw->{'step'},$__origin->{'step'}) = split /;/, trim(`route print -4 | gawk "BEGIN {min=10000} /^\\ *0.0.0.0/ {met=\$NF;if(met{'time'} = trim(`ping -n $conf->{'c'} $gw->{'step'} 2>/NUL | grep ms | grep -v TTL | gawk "{print \$NF}" | tr -d "ms"`); + $__origin->{'time'} = 0; + } + else { + $gw->{'step'} = trim(`route -n | awk 'BEGIN {min=100000} /^0/ {met=\$5; if(min>met){gw=\$2;min=met} } END { print gw}'`); + $gw->{'time'} = trim(`ping -c $conf->{'c'} $gw->{'step'} 2>/dev/null | grep rtt |awk '{print \$4}'| cut -f2 -d"/"`); + + my $__xorigin = trim(`ip a show dev \`route -n | awk 'BEGIN {min=100000} /^0/ {met=\$5; if(min>met){iface=\$NF;min=met} } END { print iface}'\` | grep -w inet | awk '{print \$2}' | cut -d'/' -f1`); + + if ($__xorigin ne $__origin->{'step'}) { + unshift(@steps, $__origin); + $__origin = {}; + $__origin->{'step'} = $__xorigin; + $__origin->{'time'} = 0; + } + } + + unshift (@steps,($__origin,$gw)); + + my $unknown_count = 0; + my $previous = undef; + + for(my $i=0; $i <= $#steps; $i++) { + my $host = $steps[$i]->{'step'}; + my $time = to_number($steps[$i]->{'time'}); + my $preffix = 'RouteStep_'; + my $desc = ''; + + if (!defined($time)) { + next; + } + + if ($host eq "???") { + $host = "Hidden_" . (++$unknown_count); + } + if (($i == $#steps) && in_array($conf->{'target_ip'},$host)) { + $preffix = 'RouteStepTarget_'; + } + elsif($i == $#steps) { + $desc = 'Step unreachable'; + } + + push @modules, { + name => $preffix . $host, + type => "generic_data", + value => $time, + unit => 'ms', + desc => $desc, + module_parent => $previous, + parent_unlink => (empty($previous)?'1':undef) + }; + + $previous = $preffix . $host; + } + } + + return \@modules; +} + + +########################################################################## +########################################################################## +# MAIN +########################################################################## +########################################################################## + +if ($#ARGV < 0) { + print STDERR $HELP; + exit 1; +} + +my $conf; +my $file_conf = {}; +my $args_conf = {}; + +if (-e $ARGV[0]) { + $file_conf = parse_configuration($ARGV[0]); + shift @ARGV; +} + +$args_conf = parse_arguments(\@ARGV); +$conf = merge_hashes($file_conf,$args_conf); + +if (!defined $conf->{'t'}) { + print STDERR $HELP; + exit 1; +} + +my @targets = gethostbyname($conf->{'t'}); +@targets = map { inet_ntoa($_) } @targets[4 .. $#targets]; +if (empty(\@targets)) { + print STDERR "Cannot resolve $conf->{'t'} \n"; + exit 2; +} + + +$conf->{'target_ip'} = \@targets; + +$conf->{'c'} = 4 unless looks_like_number($conf->{'c'}); +$conf->{'s'} = 1 unless looks_like_number($conf->{'s'}); + + +my $results = get_steps($conf); + +foreach (@{$results}) { + print_module($conf, $_); +} + + + diff --git a/pandora_agents/win32/Makefile.am b/pandora_agents/win32/Makefile.am index 6e47cafcc1..d41c722ced 100644 --- a/pandora_agents/win32/Makefile.am +++ b/pandora_agents/win32/Makefile.am @@ -3,7 +3,7 @@ if DEBUG PandoraAgent_SOURCES = misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc debug_new.cpp PandoraAgent_CXXFLAGS=-g -O0 else -PandoraAgent_SOURCES = misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc +PandoraAgent_SOURCES = misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_logchannel.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc PandoraAgent_CXXFLAGS=-O2 endif diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index d8cd441060..5cbf2b0876 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent -# (c) 2006-2014 Artica Soluciones Tecnologicas -# Version 7.0NG.713 +# (c) 2006-2017 Artica Soluciones Tecnologicas +# Version 7.0NG.716 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software @@ -21,6 +21,13 @@ server_ip $ServerIP$ server_path /var/spool/pandora/data_in temporal "%ProgramFiles%\pandora_agent\temp" +# Group assigned for this agent (descriptive, p.e: Servers) +group $GroupName$ + +# If set to 1 allows the agent to be configured via the web console +# (only works on enterprise version). Set to 0 to disable it +remote_config 0 + #include "C:\Archivos de programa\pandora_agent\pandora_agent_alt.conf" #broker_agent name_agent @@ -43,15 +50,10 @@ agent_name_cmd __rand__ # address: Enforce to server a ip address to this agent # You can also try to detect the first IP using "auto", for example - address auto - # or setting a fixed IP address, like for example: #address 192.168.36.73 -# Group assigned for this agent (descriptive, p.e: Servers) -group Servers - # This limits operation if temporal dir has not enough free disk. #temporal_min_size 1024 @@ -80,10 +82,6 @@ server_port 41121 # Debug mode renames XML in the temp folder and continues running # debug 1 -# If set to 1 allows the agent to be configured via the web console -# (only works on enterprise version). Set to 0 to disable it -remote_config 0 - # XML encoding (ISO-8859-1 by default). Most windows servers experience problems when you set to UTF-8. Other special codepages may be specified here. #encoding ISO-8859-1 @@ -102,6 +100,10 @@ xml_buffer 1 # Agent mode: Learn (default), No-learn, Autodisable # agent_mode autodisable +# EHorus configuration file default full path. +#It try to find the EKID and set it like a custom field. +ehorus_conf "C:\Program Files\ehorus_agent\ehorus_agent.conf" + # Secondary server configuration # ============================== @@ -127,74 +129,166 @@ xml_buffer 1 #process_firefox_stop killall firefox #service_messenger 1 +############################################### # Module Definition # Check online documentation and module library at http://pandorafms.org # ================= -# Get Network information using Agent plugin -module_plugin cscript //B "%ProgramFiles%\Pandora_Agent\util\nettraffic.vbs" - -# Get disk occupation (percent) -module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df_percent.vbs" - -# External inventory plugin -module_begin -module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\software_installed.vbs" -module_interval 288 -# 288 x 5min = 24 hr, one execution per day, using module_interval -module_end - -# CPU Load - +# CPU Load using WMI module_begin module_name CPU Load module_type generic_data -#module_wmiquery SELECT LoadPercentage FROM Win32_Processor -#module_wmicolumn LoadPercentage -module_cpuusage all -module_description CPU Load (%) -module_unit % -module_min_warning 80 +module_wmiquery SELECT LoadPercentage FROM Win32_Processor +module_wmicolumn LoadPercentage +module_max 100 +module_min 0 +module_description User CPU Usage (%) +module_min_warning 70 module_max_warning 90 module_min_critical 91 module_max_critical 100 +module_unit % +module_group System module_end -# Number processes +# Basic info about TCP Connection module_begin -module_name Number processes -module_type generic_data -module_exec tasklist | gawk "NR > 3 {print$0}" | wc -l -module_description Number of processes running -module_min_warning 175 -module_max_warning 249 -module_min_critical 250 -module_max_critical 300 +module_name TCP_Connections +module_type generic_data +module_exec netstat -an | find /c /v "estab" +module_description Total number of TCP connections active +module_group Networking module_end +# Example plugin to retrieve drive usage +module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df_percent_used.vbs" + +# Example plugin to retrieve memory usage +module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\mem_percent_used.vbs" + +# Example plugin to retrieve network usage +module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\network.vbs" + +## Windows inventory module (This information will be displayed only in enterprise version) +## Please check the WMI is healthy before activate this functionality + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cpuinfo.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\moboinfo.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\diskdrives.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cdromdrives.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\videocardinfo.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\ifaces.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\monitors.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\printers.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\raminfo.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\software_installed.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\userslogged.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productkey.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productID.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +######################################### +# EXAMPLES # +######################################### + +# Example: get Network information using Agent plugin +#module_plugin cscript //B "%ProgramFiles%\Pandora_Agent\util\nettraffic.vbs" + +# External inventory plugin +#module_begin +#module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\software_installed.vbs" +#module_interval 288 +## 288 x 5min = 24 hr, one execution per day, using module_interval +#module_end + # Free Memory -module_begin -module_name FreeMemory -module_type generic_data -module_freepercentmemory -module_unit % -module_description Free memory (%). -module_min_warning 21 -module_max_warning 30 -module_min_critical 0 -module_max_critical 20 -module_end +#module_begin +#module_name FreeMemory +#module_type generic_data +#module_freepercentmemory +#module_description Free memory (%). +#module_min_warning 21 +#module_max_warning 30 +#module_min_critical 0 +#module_max_critical 20 +#module_end # Log events +#module_begin +#module_name System Events (TermService) +#module_type async_string +#module_logevent +#module_description Log Events coming from Terminal Service +#module_source System +#module_application TermService +#module_end -module_begin -module_name Security Events (Invalid Login) -module_type async_string -module_description Security log events for invalid login attempt -module_logevent -module_source Security -module_eventcode 529 -module_end +#module_begin +#module_name Security Events (Invalid Login) +#module_type async_string +#module_description Security log events for invalid login attempt +#module_logevent +#module_source Security +#module_eventcode 529 +#module_end + +# Check if Dhcp service is enabled +#module_begin +#module_name DHCP Enabled +#module_type generic_proc +#module_service Dhcp +#module_description Check DCHP service enabled +#module_end #Antivirus monitoring #This modules checks the antivirus is running on your system, if there is and antivirus @@ -207,72 +301,51 @@ module_end #module_description Last update for Antivirus Signature file #module_end -## Windows inventory module (This information will be displayed only in enterprise version) -## Please check the WMI is healthy before activate this functionality +# Number processes +#module_begin +#module_name Number processes +#module_type generic_data +#module_exec tasklist | gawk "NR > 3 {print$0}" | wc -l +#module_description Number of processes running +#module_min_warning 175 +#module_max_warning 249 +#module_min_critical 250 +#module_max_critical 300 +#module_end -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cpuinfo.vbs" -# module_crontab * 12-15 * * 1 -# module_end +# Example plugin to retrieve drive usage +#module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs" -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\moboinfo.vbs" -# module_crontab * 12-15 * * 1 -# module_end +# Free space on disk C: (%) +#module_begin +#module_name FreeDiskC +#module_type generic_data +#module_freepercentdisk C: +#module_description Free space on drive C: (%) +#module_min_warning 31 +#module_max_warning 40 +#module_min_critical 0 +#module_max_critical 30 +#module_end -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\diskdrives.vbs" -# module_crontab * 12-15 * * 1 -# module_end +# CPU usage percentage +#module_begin +#module_name CPUUse +#module_type generic_data +#module_cpuusage all +#module_description CPU# usage +#module_min_warning 70 +#module_max_warning 90 +#module_min_critical 91 +#module_max_critical 100 +#module_end +# Free space on disk D: (%) # module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cdromdrives.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\videocardinfo.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\ifaces.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\monitors.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\printers.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\raminfo.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\software_installed.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\userslogged.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productkey.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productID.vbs" -# module_crontab * 12-15 * * 1 +# module_name FreeDiskD +# module_type generic_data +# module_freepercentdisk D: +# module_description Free space on drive D: (%) # module_end ## Plugin example for custom fields (version, architecture, IP, IPv6, MAC) @@ -281,10 +354,9 @@ module_end # module_crontab * 12-15 * * 1 # module_end -# ---------------------------------------------------------------------------------------------------- -# This samples below need to be reconfigured and uncommented. Please read documentation -# on how to setup pandora fms windows agent at http://wiki.pandorafms.com -# ---------------------------------------------------------------------------------------------------- +# Example plugin to retrieve last 5 min events in log4x format +# module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\logevent_log4x.vbs" Aplicacion System 300 + # Sample on how to get a value from registry # This returns the last time user launch microsoft Windows update #module_begin @@ -391,11 +463,11 @@ module_end #module_description Postcondition test module #module_end -#Example of when module_native_encoding is necessary -#Dont uncomment module_native_encoding tag to see the difference +# Example of native encoding. #module_begin -#module_name Accent_example +#module_name Written Accent #module_type generic_data_string #module_exec echo Bordón #module_native_encoding OEM #module_end + diff --git a/pandora_agents/win32/bin/util/mtr.exe b/pandora_agents/win32/bin/util/mtr.exe new file mode 100644 index 0000000000..3646ca89aa Binary files /dev/null and b/pandora_agents/win32/bin/util/mtr.exe differ diff --git a/pandora_agents/win32/bin/util/route_parser.exe b/pandora_agents/win32/bin/util/route_parser.exe new file mode 100644 index 0000000000..4da75a272a Binary files /dev/null and b/pandora_agents/win32/bin/util/route_parser.exe differ diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index f70866d914..d3ca83843f 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -3,7 +3,7 @@ AllowLanguageSelection {Yes} AppName -{Pandora FMS Windows Agent v7.0NG.713} +{Pandora FMS Windows Agent v7.0NG.716} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{171018} +{171130} ViewReadme {Yes} diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index 296f42f2ea..99b0d47f88 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -248,7 +248,9 @@ Pandora_Module::parseModuleKindFromString (string kind) { } else if (kind == module_inventory_str) { return MODULE_INVENTORY; } else if (kind == module_logevent_str) { - return MODULE_LOGEVENT; + return MODULE_LOGEVENT; + } else if (kind == module_logchannel_str) { + return MODULE_LOGCHANNEL; } else if (kind == module_wmiquery_str) { return MODULE_WMIQUERY; } else if (kind == module_perfcounter_str) { diff --git a/pandora_agents/win32/modules/pandora_module.h b/pandora_agents/win32/modules/pandora_module.h index b2606d2442..2fbeb52e41 100644 --- a/pandora_agents/win32/modules/pandora_module.h +++ b/pandora_agents/win32/modules/pandora_module.h @@ -86,6 +86,7 @@ namespace Pandora_Modules { MODULE_FREEMEMORY_PERCENT, /**< The module checks the amount of * freememory in the system */ MODULE_LOGEVENT, /**< The module checks for log events */ + MODULE_LOGCHANNEL, /**< The module checks for log events on channel using XML functions*/ MODULE_WMIQUERY, /**< The module runs WQL queries */ MODULE_PERFCOUNTER, /**< The module reads performance counters */ MODULE_TCPCHECK, /**< The module checks whether a tcp port is open */ @@ -126,6 +127,7 @@ namespace Pandora_Modules { const string module_cpuusage_str = "module_cpuusage"; const string module_inventory_str = "module_inventory"; const string module_logevent_str = "module_logevent"; + const string module_logchannel_str = "module_logchannel"; const string module_wmiquery_str = "module_wmiquery"; const string module_perfcounter_str = "module_perfcounter"; const string module_tcpcheck_str = "module_tcpcheck"; diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index db33c1315a..90c82d5457 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -31,6 +31,7 @@ #include "pandora_module_cpuusage.h" #include "pandora_module_inventory.h" #include "pandora_module_logevent.h" +#include "pandora_module_logchannel.h" #include "pandora_module_wmiquery.h" #include "pandora_module_perfcounter.h" #include "pandora_module_tcpcheck.h" @@ -69,6 +70,7 @@ using namespace Pandora_Strutils; #define TOKEN_MIN_FF_EVENT ("module_min_ff_event ") #define TOKEN_DESCRIPTION ("module_description ") #define TOKEN_LOGEVENT ("module_logevent") +#define TOKEN_LOGCHANNEL ("module_logchannel") #define TOKEN_SOURCE ("module_source ") #define TOKEN_EVENTTYPE ("module_eventtype ") #define TOKEN_EVENTCODE ("module_eventcode ") @@ -121,6 +123,7 @@ using namespace Pandora_Strutils; #define TOKEN_MACRO ("module_macro") #define TOKEN_NATIVE_ENCODING ("module_native_encoding") #define TOKEN_ALERT_TEMPLATE ("module_alert_template") +#define TOKEN_USER_SESSION ("module_user_session ") string parseLine (string line, string token) { @@ -157,8 +160,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { string module_freedisk_percent, module_freememory_percent; string module_dsn, module_freememory; string module_logevent, module_source, module_eventtype, module_eventcode; + string module_logchannel; string module_pattern, module_application, module_async; - string module_watchdog, module_start_command; + string module_watchdog, module_start_command, module_user_session; string module_wmiquery, module_wmicolumn; string module_retries, module_startdelay, module_retrydelay; string module_perfcounter, module_tcpcheck; @@ -195,6 +199,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_proc = ""; module_service = ""; module_logevent = ""; + module_logchannel = ""; module_source = ""; module_eventtype = ""; module_eventcode = ""; @@ -253,6 +258,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_ff_interval = ""; module_native_encoding = ""; module_alert_template = ""; + module_user_session = ""; macro = ""; stringtok (tokens, definition, "\n"); @@ -342,6 +348,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { if (module_logevent == "") { module_logevent = parseLine (line, TOKEN_LOGEVENT); } + if (module_logchannel == "") { + module_logchannel = parseLine (line, TOKEN_LOGCHANNEL); + } if (module_source == "") { module_source = parseLine (line, TOKEN_SOURCE); } @@ -507,6 +516,10 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { if (module_alert_template == "") { module_alert_template = parseLine (line, TOKEN_ALERT_TEMPLATE); module_alert_template.erase (0,1); + } + + if (module_user_session == "") { + module_user_session = parseLine (line, TOKEN_USER_SESSION); } if (macro == "") { @@ -724,6 +737,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { } } + if (module_logchannel != "") { + pos_macro = module_logchannel.find(macro_name); + if (pos_macro != string::npos){ + module_logchannel.replace(pos_macro, macro_name.size(), macro_value); + } + } + if (module_source != "") { pos_macro = module_source.find(macro_name); if (pos_macro != string::npos){ @@ -1085,6 +1105,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_alert_template.replace(pos_macro, macro_name.size(), macro_value); } } + + if (module_user_session != "") { + pos_macro = module_user_session.find(macro_name); + if (pos_macro != string::npos){ + module_user_session.replace(pos_macro, macro_name.size(), macro_value); + } + } } } } @@ -1121,6 +1148,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_proc->setRetries (atoi(module_retries.c_str ())); module_proc->setStartDelay (atoi(module_startdelay.c_str ())); module_proc->setRetryDelay (atoi(module_retrydelay.c_str ())); + module_proc->setUserSession (is_enabled(module_user_session)); } } } else if (module_service != "") { @@ -1142,7 +1170,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { try { char buffer[100]; unsigned long memory = Pandora_Wmi::getDiskFreeSpace(module_freedisk_percent); - if (sprintf(buffer, "Free memory %s %dMB", + if (sprintf(buffer, "Free space on drive %s %dMB", module_freedisk_percent.c_str(), memory) > 0) { module->setDescription(buffer); } @@ -1173,6 +1201,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_eventcode, module_pattern, module_application); + } + else if (module_logchannel != "") { + module = new Pandora_Module_Logchannel (module_name, + module_source, + module_eventtype, + module_eventcode, + module_pattern); } else if (module_wmiquery != "") { module = new Pandora_Module_WMIQuery (module_name, module_wmiquery, module_wmicolumn); diff --git a/pandora_agents/win32/modules/pandora_module_list.cc b/pandora_agents/win32/modules/pandora_module_list.cc index 516b2296c8..305ee901d7 100644 --- a/pandora_agents/win32/modules/pandora_module_list.cc +++ b/pandora_agents/win32/modules/pandora_module_list.cc @@ -30,12 +30,13 @@ #include "pandora_module_cpuusage.h" #include "pandora_module_inventory.h" #include "pandora_module_logevent.h" +#include "pandora_module_logchannel.h" #include "pandora_module_wmiquery.h" #include "pandora_module_perfcounter.h" #include "pandora_module_tcpcheck.h" #include "pandora_module_regexp.h" #include "pandora_module_plugin.h" -#include "pandora_module_ping.h" +#include "pandora_module_ping.h" #include "pandora_module_snmpget.h" #include @@ -226,12 +227,13 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition) Pandora_Module_Freememory *module_freememory; Pandora_Module_Freememory_Percent *module_freememory_percent; Pandora_Module_Logevent *module_logevent; + Pandora_Module_Logchannel *module_logchannel; Pandora_Module_WMIQuery *module_wmiquery; Pandora_Module_Perfcounter *module_perfcounter; Pandora_Module_Tcpcheck *module_tcpcheck; Pandora_Module_Regexp *module_regexp; Pandora_Module_Plugin *module_plugin; - Pandora_Module_Ping *module_ping; + Pandora_Module_Ping *module_ping; Pandora_Module_SNMPGet *module_snmpget; module = Pandora_Module_Factory::getModuleFromDefinition (definition); @@ -288,6 +290,10 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition) module_logevent = (Pandora_Module_Logevent *) module; modules->push_back (module_logevent); break; + case MODULE_LOGCHANNEL: + module_logchannel = (Pandora_Module_Logchannel *) module; + modules->push_back (module_logchannel); + break; case MODULE_WMIQUERY: module_wmiquery = (Pandora_Module_WMIQuery *) module; modules->push_back (module_wmiquery); @@ -315,7 +321,7 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition) case MODULE_SNMPGET: module_snmpget = (Pandora_Module_SNMPGet *) module; modules->push_back (module_snmpget); - break; + break; default: break; } diff --git a/pandora_agents/win32/modules/pandora_module_logchannel.cc b/pandora_agents/win32/modules/pandora_module_logchannel.cc new file mode 100755 index 0000000000..2c7c056565 --- /dev/null +++ b/pandora_agents/win32/modules/pandora_module_logchannel.cc @@ -0,0 +1,582 @@ +/* Pandora logchannel module. This module checks for log events that match a given + pattern using XML functions provided by wevtapi. + + Copyright (C) 2017 Artica ST. + Written by Fermin Hernandez. + + 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; either version 2, or (at your option) + any later version. + + 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. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include +#include +#include +#include + +#include "pandora_module_logchannel.h" +#include "../windows/pandora_wmi.h" +#include "../pandora_windows_service.h" +#include "pandora_module_logchannel.h" +#include "pandora_strutils.h" + +using namespace Pandora; +using namespace Pandora_Modules; +using namespace Pandora_Strutils; + +// Pointers to Wevtapi.dll functions +static HINSTANCE WINEVENT = NULL; +static EvtQueryT EvtQueryF = NULL; +static EvtNextT EvtNextF = NULL; +static EvtSeekT EvtSeekF = NULL; +static EvtCreateRenderContextT EvtCreateRenderContextF = NULL; +static EvtRenderT EvtRenderF = NULL; +static EvtCloseT EvtCloseF = NULL; +static EvtFormatMessageT EvtFormatMessageF = NULL; +static EvtOpenPublisherMetadataT EvtOpenPublisherMetadataF = NULL; +static EvtCreateBookmarkT EvtCreateBookmarkF = NULL; +static EvtUpdateBookmarkT EvtUpdateBookmarkF = NULL; + +/** + * Creates a Pandora_Module_Logchannel object. + * + * @param name Module name. + * @param service_name Service internal name to check. + */ +Pandora_Module_Logchannel::Pandora_Module_Logchannel (string name, string source, string type, string id, string pattern) + : Pandora_Module (name) { + int i; + vector query; + vector::iterator query_it; + string upper_type = type; + + // Convert the type string to uppercase + for (i = 0; i < type.length(); i++) { + upper_type[i] = toupper(type[i]); + } + + // Set the type filter + int type_number = -1; + if (upper_type.compare("ERROR") == 0) { + type_number = EVENTLOG_ERROR_TYPE; + } else if (upper_type.compare("WARNING") == 0) { + type_number = EVENTLOG_WARNING_TYPE; + } else if (upper_type.compare("INFORMATION") == 0) { + type_number = EVENTLOG_INFORMATION_TYPE; + } else if (upper_type.compare("AUDIT SUCCESS") == 0) { + type_number = EVENTLOG_AUDIT_SUCCESS; + } else if (upper_type.compare("AUDIT FAILURE") == 0) { + type_number = EVENTLOG_AUDIT_FAILURE; + } + // Append type to log query + if (type_number != -1) { + wstringstream ss; + ss << L"*[System[Level='" << type_number << L"']]"; + query.push_back(ss.str()); + } + + // Set the id + int id_number = strtoul (id.c_str (), NULL, 0); + if (id_number != 0) { + wstringstream ss; + ss << L"*[System[EventID='" << id_number << L"']]"; + query.push_back(ss.str()); + } + + // Fill the filter + if (query.size() == 0) { + this->filter = L"*"; + } else { + int i = 0; + // Add filters with and + wstring item_query; + while (query.size() > 1) { + item_query = query.back(); + query.pop_back(); + this->filter += item_query + L" and "; + } + // Append the last value without the and + item_query = query.back(); + this->filter += item_query; + } + + this->source = source; + this->pattern = pattern; + if (! pattern.empty ()) { + // Compile the regular expression + if (regcomp (&this->regexp, pattern.c_str (), REG_EXTENDED) != 0) { + pandoraLog ("Invalid regular expression %s", pattern.c_str ()); + } + } + this->bookmark_xml = L""; + this->setKind (module_logchannel_str); + + // Load Wevtapi.dll and some functions + if (WINEVENT == NULL) { + WINEVENT = LoadLibrary("Wevtapi.dll"); + if (WINEVENT == NULL) { + + // Log to the bedug log, since this is not an error + pandoraLog ("Library Wevtapi.dll not available"); + return; + } + + EvtQueryF = (EvtQueryT) GetProcAddress (WINEVENT, "EvtQuery"); + if (EvtQueryF == NULL) { + pandoraLog ("Error loading function EvtQuery from Wevtapi.dll"); + FreeLibrary (WINEVENT); + WINEVENT = NULL; + return; + } + EvtNextF = (EvtNextT) GetProcAddress (WINEVENT, "EvtNext"); + if (EvtNextF == NULL) { + pandoraLog ("Error loading function EvtNext from Wevtapi.dll"); + FreeLibrary (WINEVENT); + WINEVENT = NULL; + return; + } + EvtSeekF = (EvtSeekT) GetProcAddress (WINEVENT, "EvtSeek"); + if (EvtSeekF == NULL) { + pandoraLog ("Error loading function EvtSeek from Wevtapi.dll"); + FreeLibrary (WINEVENT); + WINEVENT = NULL; + return; + } + EvtCreateRenderContextF = (EvtCreateRenderContextT) GetProcAddress (WINEVENT, "EvtCreateRenderContext"); + if (EvtCreateRenderContextF == NULL) { + pandoraLog ("Error loading function EvtCreateRenderContext from Wevtapi.dll"); + FreeLibrary (WINEVENT); + WINEVENT = NULL; + return; + } + EvtRenderF = (EvtRenderT) GetProcAddress (WINEVENT, "EvtRender"); + if (EvtRenderF == NULL) { + pandoraLog ("Error loading function EvtRender from Wevtapi.dll"); + FreeLibrary (WINEVENT); + WINEVENT = NULL; + return; + } + EvtCloseF = (EvtCloseT) GetProcAddress (WINEVENT, "EvtClose"); + if (EvtCloseF == NULL) { + pandoraLog ("Error loading function EvtClose from Wevtapi.dll"); + FreeLibrary (WINEVENT); + WINEVENT = NULL; + return; + } + EvtFormatMessageF = (EvtFormatMessageT) GetProcAddress (WINEVENT, "EvtFormatMessage"); + if (EvtFormatMessageF == NULL) { + pandoraLog ("Error loading function EvtFormatMessage from Wevtapi.dll"); + FreeLibrary (WINEVENT); + WINEVENT = NULL; + return; + } + EvtOpenPublisherMetadataF = (EvtOpenPublisherMetadataT) GetProcAddress (WINEVENT, "EvtOpenPublisherMetadata"); + if (EvtOpenPublisherMetadataF == NULL) { + pandoraLog ("Error loading function EvtOpenPublisherMetadata from Wevtapi.dll"); + FreeLibrary (WINEVENT); + WINEVENT = NULL; + return; + } + EvtCreateBookmarkF = (EvtCreateBookmarkT) GetProcAddress (WINEVENT, "EvtCreateBookmark"); + if (EvtCreateBookmarkF == NULL) { + pandoraLog ("Error loading function EvtCreateBookmark from Wevtapi.dll"); + FreeLibrary (WINEVENT); + WINEVENT = NULL; + return; + } + EvtUpdateBookmarkF = (EvtUpdateBookmarkT) GetProcAddress (WINEVENT, "EvtUpdateBookmark"); + if (EvtUpdateBookmarkF == NULL) { + pandoraLog ("Error loading function EvtUpdateBookmark from Wevtapi.dll"); + FreeLibrary (WINEVENT); + WINEVENT = NULL; + return; + } + } +} + +void +Pandora_Module_Logchannel::run () { + list event_list; + list::iterator event; + SYSTEMTIME system_time; + + // Run + try { + Pandora_Module::run (); + } catch (Interval_Not_Fulfilled e) { + return; + } + + // Initialize log event query + this->initializeLogChannel(); + + // Read events on a list + this->getLogEvents (event_list); + + // Return if no data stored on list + if (event_list.size () < 1) return; + + for (event = event_list.begin (); event != event_list.end(); ++event) { + // Store the data + this->setOutput (event->message, &(event->timestamp)); + } +} + +/** + * Fill the first bookmark of events. + */ +void +Pandora_Module_Logchannel::initializeLogChannel () { + EVT_HANDLE hEvents[1]; + EVT_HANDLE hResults; + EVT_HANDLE hBookmark; + DWORD dwReturned = 0; + + // Check whether the first bookmark is set + if (!this->bookmark_xml.empty()) return; + + // Open the event log with a query + hResults = EvtQueryF ( + NULL, + strAnsiToUnicode (this->source.c_str()).c_str(), + this->filter.c_str(), + EvtOpenChannelPath | EvtQueryForwardDirection + ); + if (hResults == NULL) { + pandoraDebug ("Could not open event log channel. Error: '%d'", GetLastError()); + return; + } + + // Put the events on the last event + if (!EvtSeekF(hResults, 0, NULL, 0, EvtSeekRelativeToLast)) { + pandoraDebug("Cannot positionate the event at first. 'Error %d'.", GetLastError()); + EvtCloseF(hResults); + return; + } + // Read next event to positionate the bookmark + if (!EvtNextF(hResults, 1, hEvents, INFINITE, 0, &dwReturned)) { + if (GetLastError() != ERROR_NO_MORE_ITEMS) { + pandoraDebug ("EvtNext (initializeLogChannel) error: %d", GetLastError()); + EvtCloseF(hResults); + return; + } + } + // If no events read, do not use bookmark to read all events + if (dwReturned == 0) { + pandoraDebug("No events found positionating bookmark."); + EvtCloseF(hResults); + return; + } + // Create the bookmar + pandoraDebug("Creating bookmark to channel %s", this->source.c_str()); + hBookmark = EvtCreateBookmarkF(NULL); + if (hBookmark == NULL) { + pandoraDebug("EvtCreateBookmark (initializeLogChannel) failed %d", GetLastError()); + EvtCloseF(hResults); + EvtCloseF(hEvents[0]); + return; + } + if (!EvtUpdateBookmarkF(hBookmark, hEvents[0])) { + pandoraDebug("EvtUpdateBookmarkF (initializeLogChannel) failed %d", GetLastError()); + EvtCloseF(hResults); + EvtCloseF(hEvents[0]); + EvtCloseF(hBookmark); + return; + } + // Save the bookmark like an XML. + this->updateBookmarkXML(hBookmark); + + // Clean tasks + EvtCloseF(hResults); + EvtCloseF(hBookmark); + EvtCloseF(hEvents[0]); +} + +/** + * Update the bookmark XML. Returns false if fails + */ +bool +Pandora_Module_Logchannel::updateBookmarkXML (EVT_HANDLE hBookmark) { + LPWSTR pBookmarkXml = NULL; + DWORD dwBufferSize = 0; + DWORD dwBufferUsed = 0; + DWORD dwPropertyCount = 0; + DWORD status = 0; + + if (!EvtRenderF(NULL, hBookmark, EvtRenderBookmark, dwBufferSize, pBookmarkXml, &dwBufferUsed, &dwPropertyCount)){ + if (ERROR_INSUFFICIENT_BUFFER == (status = GetLastError())){ + dwBufferSize = dwBufferUsed; + pBookmarkXml = (LPWSTR)malloc(dwBufferSize); + if (pBookmarkXml){ + EvtRenderF(NULL, hBookmark, EvtRenderBookmark, dwBufferSize, pBookmarkXml, &dwBufferUsed, &dwPropertyCount); + } + else{ + pandoraDebug("Error loading the bookmark. Cannot load enough memory"); + this->cleanBookmark(); + free(pBookmarkXml); + return false; + } + } + if (ERROR_SUCCESS != (status = GetLastError())){ + pandoraDebug("EvtRender (updateBookmarkXML) failed with %d\n", GetLastError()); + this->cleanBookmark(); + free(pBookmarkXml); + return false; + } + } + this->bookmark_xml = pBookmarkXml; + free(pBookmarkXml); + return true; +} + +/** + * Clean the bookmark XML. + */ +void +Pandora_Module_Logchannel::cleanBookmark () { + this->bookmark_xml = L""; +} + +/** + * Reads available events from the event log. + */ +void +Pandora_Module_Logchannel::getLogEvents (list &event_list) { + EVT_HANDLE hResults = NULL; + EVT_HANDLE hBookmark = NULL; + EVT_HANDLE hEvents[1]; + EVT_HANDLE hContext = NULL; + PEVT_VARIANT pRenderedValues = NULL; + EVT_HANDLE hProviderMetadata = NULL; + LPWSTR pwsMessage = NULL; + LPWSTR ppValues[] = {L"Event/System/Provider/@Name", L"Event/System/TimeCreated/@SystemTime"}; + DWORD count = sizeof(ppValues)/sizeof(LPWSTR); + DWORD dwReturned = 0; + DWORD dwBufferSize = 0; + DWORD dwBufferUsed = 0; + DWORD dwPropertyCount = 0; + DWORD status = ERROR_SUCCESS; + SYSTEMTIME eventTime; + FILETIME lft, ft; + bool update_bookmark = false; + + // An empty bookmark XML means that log cannot be open + if (this->bookmark_xml.empty()) return; + + // Open the event log with a query + hResults = EvtQueryF ( + NULL, + strAnsiToUnicode (this->source.c_str()).c_str(), + this->filter.c_str(), + EvtOpenChannelPath | EvtQueryForwardDirection + ); + if (hResults == NULL) { + pandoraDebug ("Could not open event log channel '%s'. Error: '%d'", this->source.c_str(), GetLastError()); + EvtCloseF(hResults); + this->cleanBookmark(); + return; + } + + // Seek on the bookmark + hBookmark = EvtCreateBookmarkF(this->bookmark_xml.c_str()); + if (hBookmark == NULL) { + pandoraDebug("Cannot read the string bookmark. Error: %d.", GetLastError()); + EvtCloseF(hResults); + this->cleanBookmark(); + return; + } + if (!EvtSeekF(hResults, 1, hBookmark, 0, EvtSeekRelativeToBookmark)) { + pandoraDebug("Cannot positionate the event at bookmark. Error %d.", GetLastError()); + EvtCloseF(hResults); + EvtCloseF(hBookmark); + this->cleanBookmark(); + return; + } + + // Read events one by one + hEvents[0] = NULL; + while (EvtNextF(hResults, 1, hEvents, INFINITE, 0, &dwReturned)) { + hContext = EvtCreateRenderContextF(count, (LPCWSTR*)ppValues, EvtRenderContextValues); + if (NULL == hContext) { + pandoraDebug ("EvtCreateRenderContext error: %d", GetLastError()); + EvtCloseF(hResults); + EvtCloseF(hBookmark); + EvtCloseF(hEvents[0]); + this->cleanBookmark(); + return; + } + + // Reinitialize the buffers + dwBufferSize = 0; + dwBufferUsed = 0; + if (! EvtRenderF(hContext, hEvents[0], EvtRenderEventValues, dwBufferSize, pRenderedValues, &dwBufferUsed, &dwPropertyCount)) { + if ((status = GetLastError()) == ERROR_INSUFFICIENT_BUFFER) { + dwBufferSize = dwBufferUsed; + pRenderedValues = (PEVT_VARIANT)malloc(dwBufferSize); + if (pRenderedValues) { + EvtRenderF(hContext, hEvents[0], EvtRenderEventValues, dwBufferSize, pRenderedValues, &dwBufferUsed, &dwPropertyCount); + } + else { + pandoraDebug ("EvtRender error: %d", status); + EvtCloseF(hResults); + EvtCloseF(hBookmark); + EvtCloseF(hEvents[0]); + EvtCloseF(hContext); + this->cleanBookmark(); + return; + } + } + + if ((status = GetLastError()) != ERROR_SUCCESS) { + pandoraDebug ("EvtRender error getting buffer size: %d", status); + EvtCloseF(hResults); + EvtCloseF(hBookmark); + EvtCloseF(hEvents[0]); + EvtCloseF(hContext); + this->cleanBookmark(); + return; + } + } + + // Get the SYSTEMTIME of log + ULONGLONG ullTimeStamp = pRenderedValues[1].FileTimeVal; + ft.dwHighDateTime = (DWORD)((ullTimeStamp >> 32) & 0xFFFFFFFF); + ft.dwLowDateTime = (DWORD)(ullTimeStamp & 0xFFFFFFFF); + // Time format conversions + if (!FileTimeToLocalFileTime(&ft, &lft)){ + pandoraDebug("UTC FILETIME to LOCAL FILETIME error: %d.", GetLastError()); + } else if (!FileTimeToSystemTime(&lft, &eventTime)){ + pandoraDebug("FILETIME to SYSTEMTIME error: %d.", GetLastError()); + } + + // Get the handle to the provider's metadata that contains the message strings + hProviderMetadata = EvtOpenPublisherMetadataF(NULL, pRenderedValues[0].StringVal, NULL, 0, 0); + if (hProviderMetadata == NULL) { + pandoraDebug ("EvtOpenPublisherMetadata error: %d", GetLastError()); + EvtCloseF(hResults); + EvtCloseF(hBookmark); + EvtCloseF(hEvents[0]); + EvtCloseF(hContext); + free(pRenderedValues); + this->cleanBookmark(); + return; + } + + // Read the event message + pwsMessage = GetMessageString(hProviderMetadata, hEvents[0], EvtFormatMessageEvent); + if (pwsMessage == NULL) { + EvtCloseF(hResults); + EvtCloseF(hBookmark); + EvtCloseF(hEvents[0]); + EvtCloseF(hContext); + free(pRenderedValues); + EvtCloseF(hProviderMetadata); + this->cleanBookmark(); + return; + } + + // Check the regex and save the message if pass the regex + if (this->pattern.empty () || regexec (&this->regexp, strUnicodeToAnsi(pwsMessage).c_str (), 0, NULL, 0) == 0){ + // Save the event message + LogChannelList event_item; + event_item.message = strUnicodeToAnsi(pwsMessage); + event_item.timestamp= eventTime; + event_list.push_back (event_item); + } + + // Clean up some used vars + EvtCloseF(hContext); + free(pRenderedValues); + EvtCloseF(hProviderMetadata); + free(pwsMessage); + + // Update the bookmark + if (!EvtUpdateBookmarkF(hBookmark, hEvents[0])) { + pandoraDebug("EvtUpdateBookmarkF (getLogEvents) failed %d", GetLastError()); + EvtCloseF(hResults); + EvtCloseF(hBookmark); + EvtCloseF(hEvents[0]); + this->cleanBookmark(); + return; + } + + // Cleanup current event and read the next log + EvtCloseF(hEvents[0]); + hEvents[0] = NULL; + + // Information token to update bookmark + update_bookmark = true; + } + status = GetLastError(); + if (status != ERROR_NO_MORE_ITEMS) { + pandoraDebug ("EvtNext getLogEvents error: %d", GetLastError()); + EvtCloseF(hResults); + EvtCloseF(hBookmark); + this->cleanBookmark(); + return; + } + + // Update bookmark if there is new events + if (update_bookmark) this->updateBookmarkXML(hBookmark); + + // Clean handlers + EvtCloseF(hResults); + EvtCloseF(hBookmark); +} + +// Gets the specified message string from the event. If the event does not +// contain the specified message, the function returns NULL. +// See http://msdn.microsoft.com/en-us/library/windows/desktop/dd996923(v=vs.85).aspx +LPWSTR +Pandora_Module_Logchannel::GetMessageString(EVT_HANDLE hMetadata, EVT_HANDLE hEvent, EVT_FORMAT_MESSAGE_FLAGS FormatId) { + LPWSTR pBuffer = NULL; + DWORD dwBufferSize = 0; + DWORD dwBufferUsed = 0; + DWORD status = 0; + + if (!EvtFormatMessageF(hMetadata, hEvent, 0, 0, NULL, FormatId, dwBufferSize, pBuffer, &dwBufferUsed)) { + status = GetLastError(); + if (ERROR_INSUFFICIENT_BUFFER == status) { + // An event can contain one or more keywords. The function returns keywords + // as a list of keyword strings. To process the list, you need to know the + // size of the buffer, so you know when you have read the last string, or you + // can terminate the list of strings with a second null terminator character + // as this example does. + if ((EvtFormatMessageKeyword == FormatId)) { + pBuffer[dwBufferSize-1] = L'\0'; + } + else { + dwBufferSize = dwBufferUsed; + } + pBuffer = (LPWSTR)malloc(dwBufferSize * sizeof(WCHAR)); + + if (pBuffer) { + EvtFormatMessageF(hMetadata, hEvent, 0, 0, NULL, FormatId, dwBufferSize, pBuffer, &dwBufferUsed); + + // Add the second null terminator character. + if ((EvtFormatMessageKeyword == FormatId)) { + pBuffer[dwBufferUsed-1] = L'\0'; + } + } + else { + return NULL; + } + } + else { + pandoraDebug ("EvtFormatMessage error: %d", status); + return NULL; + } + } + + return pBuffer; +} \ No newline at end of file diff --git a/pandora_agents/win32/modules/pandora_module_logchannel.h b/pandora_agents/win32/modules/pandora_module_logchannel.h new file mode 100755 index 0000000000..14617037c6 --- /dev/null +++ b/pandora_agents/win32/modules/pandora_module_logchannel.h @@ -0,0 +1,76 @@ +/* Pandora logchannel module. This module checks for log events that match a given + pattern using XML functions provided by wevtapi. + + Copyright (C) 2017 Artica ST. + Written by Fermin Hernandez. + + 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; either version 2, or (at your option) + any later version. + + 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. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef __PANDORA_MODULE_LOGCHANNEL_H__ +#define __PANDORA_MODULE_LOGCHANNEL_H__ + +#include "pandora_module.h" +#include "boost/regex.h" +#include "../windows/winevt.h" + +// Log event read buffer size +#define BUFFER_SIZE 1024 + +// Types for pointers to Wevtapi.dll functions +typedef EVT_HANDLE WINAPI (*EvtQueryT) (EVT_HANDLE Session, LPCWSTR Path, LPCWSTR Query, DWORD Flags); +typedef WINBOOL WINAPI (*EvtNextT) (EVT_HANDLE ResultSet, DWORD EventArraySize, EVT_HANDLE* EventArray, DWORD Timeout, DWORD Flags, PDWORD Returned); +typedef WINBOOL WINAPI (*EvtSeekT) (EVT_HANDLE ResultSet, LONGLONG Position, EVT_HANDLE Bookmark, DWORD Timeout, DWORD Flags); +typedef EVT_HANDLE WINAPI (*EvtCreateRenderContextT) (DWORD ValuePathsCount, LPCWSTR *ValuePaths, DWORD Flags); +typedef WINBOOL WINAPI (*EvtRenderT) (EVT_HANDLE Context, EVT_HANDLE Fragment, DWORD Flags, DWORD BufferSize, PVOID Buffer, PDWORD BufferUsed, PDWORD PropertyCount); +typedef WINBOOL WINAPI (*EvtCloseT) (EVT_HANDLE Object); +typedef WINBOOL WINAPI (*EvtFormatMessageT) (EVT_HANDLE PublisherMetadata, EVT_HANDLE Event, DWORD MessageId, DWORD ValueCount, PEVT_VARIANT Values, DWORD Flags, DWORD BufferSize, LPWSTR Buffer, PDWORD BufferUsed); +typedef EVT_HANDLE WINAPI (*EvtOpenPublisherMetadataT) (EVT_HANDLE Session, LPCWSTR PublisherIdentity, LPCWSTR LogFilePath, LCID Locale, DWORD Flags); +typedef EVT_HANDLE WINAPI (*EvtCreateBookmarkT) (LPCWSTR BookmarkXml); +typedef WINBOOL WINAPI (*EvtUpdateBookmarkT) (EVT_HANDLE Bookmark, EVT_HANDLE Event); + +namespace Pandora_Modules { + + /** + * This module checks for log events that match a given + * pattern. Events can be filtered by source and type. + */ + + class Pandora_Module_Logchannel : public Pandora_Module { + struct LogChannelList { + string message; + SYSTEMTIME timestamp; + }; + private: + regex_t regexp; + string source; + string pattern; + wstring filter; + wstring bookmark_xml; + HANDLE messages_dll; + + void initializeLogChannel (); + bool updateBookmarkXML (EVT_HANDLE hBookmark); + void getLogEvents (list &event_list); + void cleanBookmark (); + LPWSTR GetMessageString(EVT_HANDLE hMetadata, EVT_HANDLE hEvent, EVT_FORMAT_MESSAGE_FLAGS FormatId); + + public: + Pandora_Module_Logchannel (string name, string source, string type, string id, string pattern); + void run (); + }; +} + +#endif diff --git a/pandora_agents/win32/modules/pandora_module_proc.cc b/pandora_agents/win32/modules/pandora_module_proc.cc index e8eed1f97d..1c06e1001d 100644 --- a/pandora_agents/win32/modules/pandora_module_proc.cc +++ b/pandora_agents/win32/modules/pandora_module_proc.cc @@ -48,6 +48,7 @@ Pandora_Module_Proc::Pandora_Module_Proc (string name, string process_name) this->setKind (module_proc_str); this->watchdog = false; + this->user_session = false; this->start_command = ""; this->retries = 3; this->start_delay = 5000; @@ -95,6 +96,11 @@ Pandora_Module_Proc::getRetryDelay () const { return this->retry_delay; } +bool +Pandora_Module_Proc::getUserSession () const { + return this->user_session; +} + void Pandora_Module_Proc::setWatchdog (bool watchdog) { this->watchdog = watchdog; @@ -131,6 +137,11 @@ Pandora_Module_Proc::setRetryDelay (int mseconds) { this->retry_delay = mseconds; } +void +Pandora_Module_Proc::setUserSession (bool usession) { + this->user_session = usession; +} + void async_run (Pandora_Module_Proc *module) { HANDLE *processes = NULL; @@ -156,7 +167,7 @@ async_run (Pandora_Module_Proc *module) { } Sleep (module->getRetryDelay ()); - Pandora_Wmi::runProgram (module->getStartCommand ()); + Pandora_Wmi::runProgram (module->getStartCommand (), NULL, module->getUserSession()); Sleep (module->getStartDelay ()); counter++; continue; diff --git a/pandora_agents/win32/modules/pandora_module_proc.h b/pandora_agents/win32/modules/pandora_module_proc.h index edab85cb88..0286efcf5c 100644 --- a/pandora_agents/win32/modules/pandora_module_proc.h +++ b/pandora_agents/win32/modules/pandora_module_proc.h @@ -32,6 +32,7 @@ namespace Pandora_Modules { string process_name; HANDLE thread; bool watchdog; + bool user_session; string start_command; int retries; int start_delay; @@ -46,12 +47,14 @@ namespace Pandora_Modules { int getRetries () const; int getStartDelay () const; int getRetryDelay () const; + bool getUserSession () const; void setWatchdog (bool watchdog); void setStartCommand (string command); void setRetries (int retries); void setStartDelay (int mseconds); void setRetryDelay (int mseconds); + void setUserSession (bool usession); void run (); }; diff --git a/pandora_agents/win32/modules/pandora_module_service.cc b/pandora_agents/win32/modules/pandora_module_service.cc index c3f2259773..11abf8b2fa 100644 --- a/pandora_agents/win32/modules/pandora_module_service.cc +++ b/pandora_agents/win32/modules/pandora_module_service.cc @@ -124,7 +124,6 @@ async_run (Pandora_Module_Service *module) { // If time out and polling, // check the service status actively if (result == WAIT_TIMEOUT && polling) { - pandoraLog("Timeout. Polling"); module->execute_async_service(prev_res, module, modules); } continue; diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 2a7d6d2be0..7b1eb275ba 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.713(Build 171018)") +#define PANDORA_VERSION ("7.0NG.716(Build 171130)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index d908daef30..9bc83625c4 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.713(Build 171018))" + VALUE "ProductVersion", "(7.0NG.716(Build 171130))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_agents/win32/windows/pandora_wmi.cc b/pandora_agents/win32/windows/pandora_wmi.cc index e4763cc433..fb572bddcb 100644 --- a/pandora_agents/win32/windows/pandora_wmi.cc +++ b/pandora_agents/win32/windows/pandora_wmi.cc @@ -369,16 +369,16 @@ Pandora_Wmi::getOSName () { dhGetValue (L"%s", &name, quickfix, L".Caption"); - if (name != NULL) { - // Remove the (R) character. - for (int i = 0; i < strlen(name); i++) { - if ((unsigned char)name[i] == 0xAE) { - name[i] = ' '; - } - } - ret = name; - dhFreeString (name); - } + if (name != NULL) { + // Remove the (R) character. + for (int i = 0; i < strlen(name); i++) { + if ((unsigned char)name[i] == 0xAE) { + name[i] = ' '; + } + } + ret = name; + dhFreeString (name); + } } NEXT_THROW (quickfix); } catch (string errstr) { @@ -411,12 +411,12 @@ Pandora_Wmi::getOSVersion () { L".CSDVersion"); if (version != NULL) { - // Remove the (R) character. - for (int i = 0; i < strlen(version); i++) { - if ((unsigned char)version[i] == 0xAE) { - version[i] = ' '; - } - } + // Remove the (R) character. + for (int i = 0; i < strlen(version); i++) { + if ((unsigned char)version[i] == 0xAE) { + version[i] = ' '; + } + } ret = version; dhFreeString (version); } @@ -501,7 +501,7 @@ Pandora_Wmi::getSystemName () { * @param flags Process creation flags */ bool -Pandora_Wmi::runProgram (string command, DWORD flags) { +Pandora_Wmi::runProgram (string command, DWORD flags, BOOL user_session) { PROCESS_INFORMATION process_info; STARTUPINFO startup_info; bool success; @@ -514,11 +514,75 @@ Pandora_Wmi::runProgram (string command, DWORD flags) { startup_info.cb = sizeof (startup_info); ZeroMemory (&process_info, sizeof (process_info)); - pandoraDebug ("Start process \"%s\".", command.c_str ()); - cmd = strdup (command.c_str ()); - success = CreateProcess (NULL, cmd, NULL, NULL, FALSE, flags, - NULL, NULL, &startup_info, &process_info); - pandoraFree (cmd); + if (user_session) { + DWORD sessionId = WTSGetActiveConsoleSessionId(); + startup_info.cb = sizeof(STARTUPINFO); + startup_info.hStdError = 0; + startup_info.hStdInput = 0; + startup_info.hStdOutput = 0; + if ( + startup_info.hStdError != 0 + || startup_info.hStdInput != 0 + || startup_info.hStdOutput != 0 + ) { + startup_info.dwFlags |= STARTF_USESTDHANDLES; + } + + HANDLE procHandle = GetCurrentProcess(); + HANDLE token, userToken; + + // Tray to open the process + if (OpenProcessToken(procHandle, TOKEN_DUPLICATE, &token) == 0) { + pandoraDebug ("Open Process Token fails with error %d.", GetLastError()); + return false; + } + + // Duplicate token + if (DuplicateTokenEx(token, + MAXIMUM_ALLOWED, + 0, + SecurityImpersonation, + TokenPrimary, + &userToken) == 0) { + pandoraDebug ("Duplicate token fails with error %d.", GetLastError()); + return false; + } + + // Set Token Information + if (SetTokenInformation(userToken, + (TOKEN_INFORMATION_CLASS)TokenSessionId, + &sessionId, + sizeof(sessionId)) == 0) { + // Error 1314 will be thrown if agent is not running as service. + if (GetLastError() != 1314) { + pandoraDebug ("Set token information fails with error %d.", GetLastError()); + return false; + } + } + + LPSTR command_exec = (LPSTR)command.c_str(); + + // Create Process As User + // Changed inherit and command + success = CreateProcessAsUser( + userToken, + 0, + command_exec, + 0, + 0, + FALSE, + flags, + 0, + NULL, + &startup_info, + &process_info); + } else { + pandoraDebug ("Start process \"%s\".", command.c_str ()); + cmd = strdup (command.c_str ()); + success = CreateProcess (NULL, cmd, NULL, NULL, FALSE, flags, + NULL, NULL, &startup_info, &process_info); + pandoraFree (cmd); + } if (success) { pandoraDebug ("The process \"%s\" was started.", command.c_str ()); @@ -949,7 +1013,7 @@ getIPs(VARIANT *ip_array){ if (V_VT(&pvArray[i]) == VT_BSTR) { if (i > 0) { ret += " , "; - } + } LPSTR szStringA; ret += Pandora_Strutils::strUnicodeToAnsi( V_BSTR(&pvArray[i])); } diff --git a/pandora_agents/win32/windows/pandora_wmi.h b/pandora_agents/win32/windows/pandora_wmi.h index 601499f4a1..de4f3db81b 100644 --- a/pandora_agents/win32/windows/pandora_wmi.h +++ b/pandora_agents/win32/windows/pandora_wmi.h @@ -53,7 +53,7 @@ namespace Pandora_Wmi { string getOSBuild (); string getSystemName (); string getSystemAddress (); - bool runProgram (string command, DWORD flags = 0); + bool runProgram (string command, DWORD flags = 0, BOOL user_session = false); bool startService (string service_name); bool stopService (string service_name); void runWMIQuery (string wmi_query, diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index d7223d3088..b9efaf31e9 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.713-171018 +Version: 7.0NG.716-171130 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index d2d407b819..43009ec1fd 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.713-171018" +pandora_version="7.0NG.716-171130" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/agents_alerts.php b/pandora_console/extensions/agents_alerts.php index 97f1bc7589..f5cad20d74 100755 --- a/pandora_console/extensions/agents_alerts.php +++ b/pandora_console/extensions/agents_alerts.php @@ -546,9 +546,11 @@ ui_require_jquery_file('pandora'); }); $('#group_id').change(function(){ - var regx = /&group_id=\d*/g; - var url = location.href.replace(regx, ""); - location.href = url+"&group_id="+$("#group_id").val(); + if(location.href.indexOf("extensions/agents_modules") == -1){ + var regx = /&group_id=\d*/g; + var url = location.href.replace(regx, ""); + location.href = url+"&group_id="+$("#group_id").val(); + } }); }); diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index cb6fe8cd42..6e6cf9a92e 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -66,11 +66,14 @@ function mainAgentsModules() { $modulegroup = get_parameter('modulegroup', 0); $refr = get_parameter('refresh', 0); // By default 30 seconds + $recursion = get_parameter('recursion', 0); $group_id = (int)get_parameter('group_id', 0); $offset = (int)get_parameter('offset', 0); $hor_offset = (int)get_parameter('hor_offset', 0); $block = $config['block_size']; - $agents_id = (array)get_parameter('id_agents2', -1); + if(get_parameter('modulegroup') != null){ + $agents_id = (array)get_parameter('id_agents2', -1); + } $selection_a_m = (int)get_parameter('selection_agent_module'); $modules_selected = (array)get_parameter('module', 0); $update_item = (string)get_parameter('edit_item',''); @@ -139,6 +142,8 @@ function mainAgentsModules() { $filter_groups_label = ''.__('Group').''; $filter_groups = html_print_select_groups(false, "AR", true, 'group_id', $group_id, '', '', '', true, false, true, '', false , 'width: auto;'); + $filter_recursion_label = ''.__('Recursion').''; + $filter_recursion = html_print_checkbox('recursion', 1, 0, true); //groups module $filter_module_groups_label = ''.__('Module group').''; $filter_module_groups = html_print_select_from_sql ("SELECT * FROM tmodule_group ORDER BY name", @@ -245,12 +250,12 @@ function mainAgentsModules() { if($config['pure'] != 1){ echo '
'; + . ui_get_url_refresh (array ('offset' => $offset, 'hor_offset' => $offset, 'group_id' => $group_id, 'modulegroup' => $modulegroup)).'">'; echo ''; echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; echo ""; @@ -375,9 +380,14 @@ function mainAgentsModules() { } if ($group_id > 0) { - $filter_groups['id_grupo'] = $group_id; + if($recursion){ + $filter_groups['id_grupo'] = array_merge($group_id, + groups_get_id_recursive($group_id, true)); + } + else{ + $filter_groups['id_grupo'] = $group_id; + } } - $agents = agents_get_agents ($filter_groups); $nagents = count($agents); @@ -675,12 +685,14 @@ $ignored_params['refresh']=''; } $("#group_id").change (function () { + jQuery.post ("ajax.php", {"page" : "operation/agentes/ver_agente", "get_agents_group_json" : 1, "id_group" : this.value, "privilege" : "AW", - "keys_prefix" : "_" + "keys_prefix" : "_", + "recursion" : $('#checkbox-recursion').is(':checked') }, function (data, status) { $("#id_agents2").html(''); @@ -699,7 +711,34 @@ $ignored_params['refresh']=''; "json" ); }); - + + $("#checkbox-recursion").change (function () { + jQuery.post ("ajax.php", + {"page" : "operation/agentes/ver_agente", + "get_agents_group_json" : 1, + "id_group" : $("#group_id").val(), + "privilege" : "AW", + "keys_prefix" : "_", + "recursion" : $('#checkbox-recursion').is(':checked') + }, + function (data, status) { + $("#id_agents2").html(''); + $("#module").html(''); + jQuery.each (data, function (id, value) { + // Remove keys_prefix from the index + id = id.substring(1); + + option = $("") + .attr ("value", value["id_agente"]) + .html (value["alias"]); + $("#id_agents").append (option); + $("#id_agents2").append (option); + }); + }, + "json" + ); + }); + $("#modulegroup").change (function () { jQuery.post ("ajax.php", {"page" : "operation/agentes/ver_agente", diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index 2b0e281993..d184850a34 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -259,80 +259,60 @@ function extension_db_check_tables_differences($connection_test, $field_system = $fields_system[$name_field]; $diff = array_diff($field_test, $field_system); + if (!empty($diff)) { - foreach ($diff as $config_field => $value) { - switch ($config_field) { - case 'type': - ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be set the type with %s.', - $name_field, $table, $value)); - ui_print_info_message( - __('You can execute this SQL query for to fix.') . "
" . - '
' .
-										"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " " . $value . ";" .
-									'
' - ); - break; - case 'null': - ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be null: (%s).', - $name_field, $table, $value)); + $info_message = ""; + $error_message = ""; + if($diff['type']){ + $error_message .= "Unsuccessful the field ".$name_field." in the table ".$table." must be set the type with ".$diff['type']."
"; + } + + if($diff['null']){ + $error_message .= "Unsuccessful the field $name_field in the table $table must be null: (".$diff['null'].").
"; + } + + if($diff['default']){ + $error_message .= "Unsuccessful the field $name_field in the table $table must be set ".$diff['default']." as default value.
"; + } + + if($field_test['null'] == "YES" || !isset($field_test['null']) || $field_test['null'] == ""){ + $null_defect = " NULL"; + } + else{ + $null_defect = " NOT NULL"; + } + + if(!isset($field_test['default']) || $field_test['default'] == ""){ + $default_value = ""; + } + else{ + $default_value = " DEFAULT ".$field_test['default']; + } + + if($diff['type'] || $diff['null'] || $diff['default']){ + $info_message .= "ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " " . $field_test['type'] . $null_defect . $default_value.";"; + } + + if($diff['key']){ + $error_message .= "Unsuccessful the field $name_field in the table $table must be set the key as defined in the SQL file.
"; + $info_message .= "

Please check the SQL file for to know the kind of key needed."; + } + + if($diff['extra']){ + $error_message .= "Unsuccessful the field $name_field in the table $table must be set as defined in the SQL file.
"; + $info_message .= "

Please check the SQL file for to know the kind of extra config needed."; + } + + ui_print_error_message( + __($error_message)); - if ($value == "YES") { - ui_print_info_message( - __('You can execute this SQL query for to fix.') . "
" . - '
' .
-											"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " "  . $field_test['type'] . " NULL;" .
-										'
' - ); - } - else { - ui_print_info_message( - __('You can execute this SQL query for to fix.') . "
" . - '
' .
-											"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " " . $field_test['type'] . " NOT NULL;" .
-										'
' - ); - } + ui_print_info_message( + __($info_message)); - break; - case 'key': - ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be set the key as defined in the SQL file.', - $name_field, $table)); - ui_print_info_message( - __('Please check the SQL file for to know the kind of key needed.')); - break; - case 'default': - if($field_test['null'] == "YES" || !isset($field_test['null']) || $field_test['null'] == ""){ - $null_defect = " NULL"; - } - else{ - $null_defect = " NOT NULL"; - } - ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be set %s as default value.', - $name_field, $table, $value)); - ui_print_info_message( - __('You can execute this SQL query for to fix.') . "
" . - '
' .
-											"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " "  . $field_test['type'] . $null_defect . " DEFAULT " . $value . ";" .
-										'
' - ); - break; - case 'extra': - ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be set as defined in the SQL file.', - $name_field, $table)); - ui_print_info_message( - __('Please check the SQL file for to know the kind of extra config needed.')); - break; } } } } - } - } if ($correct_fields) { ui_print_success_message( @@ -366,4 +346,4 @@ function extension_db_status_execute_sql_file($url, $connection) { extensions_add_godmode_function('extension_db_status'); extensions_add_godmode_menu_option(__('DB Schema check'), 'DM', 'gextensions', null, "v1r1", 'gdbman'); -?> \ No newline at end of file +?> diff --git a/pandora_console/extensions/pandora_logs.php b/pandora_console/extensions/pandora_logs.php index f20bcab720..4241018a16 100644 --- a/pandora_console/extensions/pandora_logs.php +++ b/pandora_console/extensions/pandora_logs.php @@ -69,9 +69,9 @@ function pandoralogs_extension_main () { ui_print_page_header (__("System logfile viewer"), "images/extensions.png", false, "", true, "" ); - echo "

" . __('This tool is used just to view your Pandora FMS system logfiles directly from console') . "

"; + echo "

" . __('Use this tool to view your Pandora FMS logfiles directly on the console') . "

"; - echo "

" . __('You can control the size information to show in general setup (Log size limit in view extension), actually ') . $config['max_log_size'] * 1000 . "B" . "

"; + echo "

" . __('You can choose the amount of information shown in general setup (Log size limit in system logs viewer extension), ' . $config['max_log_size'] * 1000 . 'B at the moment') . "

"; $logs_directory = (!empty($config["server_log_dir"])) ? io_safe_output($config["server_log_dir"]) : "/var/log/pandora"; diff --git a/pandora_console/extras/mr/10.sql b/pandora_console/extras/mr/10.sql new file mode 100644 index 0000000000..e27f4fccf1 --- /dev/null +++ b/pandora_console/extras/mr/10.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + +ALTER TABLE tsnmp_filter ADD unified_filters_id int(10) NOT NULL DEFAULT 0; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/mr/8.sql b/pandora_console/extras/mr/8.sql new file mode 100644 index 0000000000..402fb7e82c --- /dev/null +++ b/pandora_console/extras/mr/8.sql @@ -0,0 +1,21 @@ +START TRANSACTION; +ALTER TABLE tusuario ADD COLUMN `time_autorefresh` int(5) unsigned NOT NULL default '30'; +ALTER TABLE treport_content ADD COLUMN lapse_calc tinyint(1) default '0'; +ALTER TABLE treport_content ADD COLUMN lapse int(11) default '300'; +ALTER TABLE treport_content ADD COLUMN visual_format tinyint(1) default '0'; +ALTER TABLE treport_content_template ADD COLUMN lapse_calc tinyint(1) default '0'; +ALTER TABLE treport_content_template ADD COLUMN lapse int(11) default '300'; +ALTER TABLE treport_content_template ADD COLUMN visual_format tinyint(1) default '0'; + +UPDATE `talert_commands` +SET `description` = 'This alert send an email using internal Pandora FMS Server SMTP capabilities (defined in each server, using: _field1_ as destination email address, and _field2_ as subject for message. _field3_ as text of message. _field4_ as content type (text/plain or html/text).', + `fields_descriptions` = '[\"Destination address\",\"Subject\",\"Text\",\"Content Type\",\"\",\"\",\"\",\"\",\"\",\"\"]', + `fields_values` = '[\"\",\"\",\"_html_editor_\",\"_content_type_\",\"\",\"\",\"\",\"\",\"\",\"\"]' +WHERE id=1; + +UPDATE `talert_actions` +SET `field4` = 'text/html', + `field4_recovery` = 'text/html' +WHERE id = 1; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/mr/9.sql b/pandora_console/extras/mr/9.sql new file mode 100644 index 0000000000..dbf0456323 --- /dev/null +++ b/pandora_console/extras/mr/9.sql @@ -0,0 +1,24 @@ +START TRANSACTION; + +SET @st_oum708 = (SELECT IF( + (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'tuser_task_scheduled') > 0, + "ALTER TABLE tuser_task_scheduled MODIFY args TEXT NOT NULL", + "SELECT 1" +)); + +PREPARE pr_oum708 FROM @st_oum708; +EXECUTE pr_oum708; +DEALLOCATE PREPARE pr_oum708; + +ALTER TABLE tagente ADD COLUMN `safe_mode_module` int(10) unsigned NOT NULL default '0'; +ALTER TABLE tmetaconsole_agent ADD COLUMN `safe_mode_module` int(10) unsigned NOT NULL default '0'; + +alter table tlayout_data add column element_group int(10) not null default 0; + +alter table tlayout_data add column id_layout_linked_weight int(10) not null default 0; + +ALTER TABLE tlayout_data ADD COLUMN show_on_top tinyint(1) default 0; + +ALTER TABLE `tdashboard` ADD COLUMN `cells_slideshow` TINYINT(1) NOT NULL default 0; + +COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 16b084f83b..40983967e8 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -726,6 +726,9 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` ( `each_agent` tinyint(1) default 1, `historical_db` tinyint(1) UNSIGNED NOT NULL default 0, `hide_no_data` tinyint(1) default 0, + `lapse_calc` tinyint(1) UNSIGNED NOT NULL default '0', + `lapse` int(11) UNSIGNED NOT NULL default '300', + `visual_format` tinyint(1) UNSIGNED NOT NULL default '0', PRIMARY KEY(`id_rc`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -1135,6 +1138,10 @@ ALTER TABLE talert_actions ADD COLUMN `field15_recovery` TEXT NOT NULL DEFAULT " -- --------------------------------------------------------------------- UPDATE `talert_commands` SET `fields_descriptions` = '[\"Integria IMS API path\",\"Integria IMS API pass\",\"Integria IMS user\",\"Integria IMS user pass\",\"Ticket title\",\"Ticket group ID\",\"Ticket priority\",\"Email copy\",\"Ticket owner\",\"Ticket description\"]', `fields_values` = '[\"\",\"\",\"\",\"\",\"\",\"\",\"10,Maintenance;0,Informative;1,Low;2,Medium;3,Serious;4,Very Serious\",\"\",\"\",\"\"]' WHERE `id` = 11 AND `name` = 'Integria IMS Ticket'; +UPDATE `talert_commands` SET `description` = 'This alert send an email using internal Pandora FMS Server SMTP capabilities (defined in each server, using: _field1_ as destination email address, and _field2_ as subject for message. _field3_ as text of message. _field4_ as content type (text/plain or html/text).', `fields_descriptions` = '[\"Destination address\",\"Subject\",\"Text\",\"Content Type\",\"\",\"\",\"\",\"\",\"\",\"\"]', `fields_values` = '[\"\",\"\",\"_html_editor_\",\"_content_type_\",\"\",\"\",\"\",\"\",\"\",\"\"]' WHERE id=1; + +UPDATE `talert_actions` SET `field4` = 'text/html', `field4_recovery` = 'text/html' WHERE id = 1; + -- --------------------------------------------------------------------- -- Table `tmap` -- --------------------------------------------------------------------- @@ -1151,10 +1158,10 @@ 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 ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 4); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 9); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '708'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '716'); -- --------------------------------------------------------------------- -- Table `tplanned_downtime_agents` @@ -1184,6 +1191,7 @@ ALTER TABLE tusuario ADD COLUMN `id_filter` int(10) UNSIGNED NULL DEFAULT NULL; ALTER TABLE tusuario ADD CONSTRAINT `fk_id_filter` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter(`id_filter`) ON DELETE SET NULL; ALTER TABLE tusuario ADD COLUMN `session_time` int(10) signed NOT NULL default '0'; alter table tusuario add autorefresh_white_list text not null default ''; +ALTER TABLE tusuario ADD COLUMN `time_autorefresh` int(5) unsigned NOT NULL default '30'; -- --------------------------------------------------------------------- -- Table `tagente_modulo` @@ -1219,6 +1227,7 @@ ALTER TABLE tagente ADD `remote` tinyint(1) NOT NULL default 0; ALTER TABLE tagente ADD COLUMN `cascade_protection_module` int(10) unsigned NOT NULL default '0'; ALTER TABLE tagente ADD COLUMN (alias varchar(600) not null default ''); ALTER TABLE tagente ADD `alias_as_name` int(2) unsigned default '0'; +ALTER TABLE tagente ADD COLUMN `safe_mode_module` int(10) unsigned NOT NULL default '0'; UPDATE tagente SET tagente.alias = tagente.nombre; -- --------------------------------------------------------------------- @@ -1232,6 +1241,9 @@ ALTER TABLE tlayout ADD `background_color` varchar(50) NOT NULL default '#FFF'; ALTER TABLE tlayout_data ADD `type_graph` varchar(50) NOT NULL default 'area'; ALTER TABLE tlayout_data ADD `label_position` varchar(50) NOT NULL default 'down'; ALTER TABLE tlayout_data ADD COLUMN `show_statistics` tinyint(2) NOT NULL default '0'; +ALTER TABLE tlayout_data ADD COLUMN `element_group` int(10) NOT NULL default '0'; +ALTER TABLE tlayout_data ADD COLUMN `id_layout_linked_weight` int(10) NOT NULL default '0'; +ALTER TABLE tlayout_data ADD COLUMN `show_on_top` tinyint(1) NOT NULL default '0'; -- --------------------------------------------------------------------- -- Table `tagent_custom_fields` @@ -1249,6 +1261,8 @@ UPDATE tagente_modulo SET cron_interval = '' WHERE cron_interval LIKE '% %'; -- Table `tgraph` -- --------------------------------------------------------------------- ALTER TABLE tgraph ADD COLUMN `percentil` int(4) unsigned default '0'; +ALTER TABLE tgraph ADD COLUMN `summatory_series` tinyint(1) UNSIGNED NOT NULL default '0'; +ALTER TABLE tgraph ADD COLUMN `average_series` tinyint(1) UNSIGNED NOT NULL default '0'; -- --------------------------------------------------------------------- -- Table `tnetflow_filter` @@ -1270,6 +1284,9 @@ UPDATE treport_custom_sql SET `sql` = 'select t1.alias as agent_n -- --------------------------------------------------------------------- ALTER TABLE treport_content ADD COLUMN `historical_db` tinyint(1) NOT NULL DEFAULT '0'; +ALTER TABLE treport_content ADD COLUMN `lapse_calc` tinyint(1) default '0'; +ALTER TABLE treport_content ADD COLUMN `lapse` int(11) default '300'; +ALTER TABLE treport_content ADD COLUMN `visual_format` tinyint(1) default '0'; -- --------------------------------------------------------------------- -- Table `tmodule_relationship` @@ -1296,6 +1313,7 @@ ALTER TABLE tmetaconsole_agent ADD COLUMN `cascade_protection_module` int(10) de ALTER TABLE tmetaconsole_agent ADD COLUMN `transactional_agent` tinyint(1) NOT NULL default '0'; ALTER TABLE tmetaconsole_agent ADD COLUMN `alias` VARCHAR(600) not null DEFAULT ''; ALTER TABLE tmetaconsole_agent ADD COLUMN `alias_as_name` int(2) unsigned default '0'; +ALTER TABLE tmetaconsole_agent ADD COLUMN `safe_mode_module` int(10) unsigned NOT NULL default '0'; UPDATE `tmetaconsole_agent` SET tmetaconsole_agent.alias = tmetaconsole_agent.nombre; -- --------------------------------------------------------------------- @@ -1327,6 +1345,10 @@ SET @vv1 = (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = IF @vv1>0 THEN ALTER TABLE tbackup ADD COLUMN `filepath` varchar(512) NOT NULL DEFAULT ""; END IF; +SET @vv2 = (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'tuser_task_scheduled'); +IF @vv2>0 THEN + ALTER TABLE tuser_task_scheduled MODIFY args TEXT NOT NULL; +END IF; END; // delimiter ; @@ -1441,3 +1463,7 @@ INSERT INTO tmodule VALUES (8, 'Wux module'); INSERT INTO ttipo_modulo VALUES (25,'web_analysis', 8, 'Web analysis data', 'module-wux.png'); +-- --------------------------------------------------------------------- +-- Table `tdashboard` +-- --------------------------------------------------------------------- +ALTER TABLE `tdashboard` ADD COLUMN `cells_slideshow` TINYINT(1) NOT NULL default 0; diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 46e95a7026..2ac1e34df4 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -191,7 +191,7 @@ config_check(); $_GET['refr'] = null; } - $select = db_process_sql("SELECT autorefresh_white_list FROM tusuario WHERE id_user = '" . $config['id_user'] . "'"); + $select = db_process_sql("SELECT autorefresh_white_list,time_autorefresh FROM tusuario WHERE id_user = '" . $config['id_user'] . "'"); $autorefresh_list = json_decode($select[0]['autorefresh_white_list']); if ($autorefresh_list !== null && array_search($_GET['sec2'], $autorefresh_list) !== false) { @@ -261,7 +261,13 @@ config_check(); if ($check_minor_release_available) { if (users_is_admin($config['id_user'])) { - set_pandora_error_for_header('There are one or more minor releases waiting for update', 'minor release/s available'); + + if($config['language'] == 'es'){ + set_pandora_error_for_header('Hay una o mas revisiones menores en espera para ser actualizadas. '.__('Sobre actualización de revisión menor').'', 'Revisión/es menor/es disponible/s'); + } + else{ + set_pandora_error_for_header('There are one or more minor releases waiting for update. '.__('About minor release update').'', 'minor release/s available'); + } } } echo ''; @@ -382,6 +388,12 @@ config_check(); $do_refresh = false; } } + + $new_dashboard = get_parameter('new_dashboard',0); + + if ($_GET['sec2'] == 'enterprise/dashboard/main_dashboard' && $new_dashboard) { + $do_refresh = false; + } if ($do_refresh) { ?> @@ -389,7 +401,15 @@ config_check(); $("#combo_refr").toggle (); $("#combo_refr").css('padding-right', '9px'); href = $("a.autorefresh").attr ("href"); - $(document).attr ("location", href + "30"); + + var refresh = ''; + $(document).attr ("location", href + refresh); + + data[3][0] = __('Parent'); -$params = array(); -$params['return'] = true; -$params['show_helptip'] = true; -$params['input_name'] = 'id_parent'; -$params['print_hidden_input_idagent'] = true; -$params['hidden_input_idagent_name'] = 'id_agent_parent'; -$params['hidden_input_idagent_value'] = $id_parent; -$params['value'] = db_get_value ("alias","tagente","id_agente",$id_parent); -$params['selectbox_id'] = 'cascade_protection_module'; -$params['javascript_is_function_select'] = true; -$params['cascade_protection'] = true; - -$table->data[3][1] = ui_print_agent_autocomplete_input($params); - -$table->data[3][1] .= html_print_checkbox ("cascade_protection", 1, $cascade_protection, true).__('Cascade protection'). " " . ui_print_help_icon("cascade_protection", true); - -$table->data[3][1] .= "  " . __('Module') . " " . html_print_select ($modules_values, "cascade_protection_module", $cascade_protection_module, "", "", 0, true); - $table->data[4][0] = __('Group'); $table->data[4][1] = html_print_select_groups(false, "AR", false, 'grupo', $grupo, '', '', 0, true); $table->data[4][1] .= ' '; @@ -320,52 +301,87 @@ $table->class = "databox filters"; $table->head = array (); $table->style = array (); $table->style[0] = 'font-weight: bold; '; -$table->style[2] = 'font-weight: bold;'; +$table->style[4] = 'font-weight: bold;'; $table->data = array (); // Custom ID $table->data[0][0] = __('Custom ID'); $table->data[0][1] = html_print_input_text ('custom_id', $custom_id, '', 16, 255, true); +$table->data[1][0] = __('Parent'); +$params = array(); +$params['return'] = true; +$params['show_helptip'] = true; +$params['input_name'] = 'id_parent'; +$params['print_hidden_input_idagent'] = true; +$params['hidden_input_idagent_name'] = 'id_agent_parent'; +$params['hidden_input_idagent_value'] = $id_parent; +$params['value'] = db_get_value ("alias","tagente","id_agente",$id_parent); +$params['selectbox_id'] = 'cascade_protection_module'; +$params['javascript_is_function_select'] = true; +$params['cascade_protection'] = true; + +$table->data[1][1] = ui_print_agent_autocomplete_input($params); +$table->data[1][1] .= html_print_checkbox ("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); + +//safe operation mode +if($id_agente){ + $sql_modules = db_get_all_rows_sql("SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo + WHERE id_agente = " . $id_agente); + $safe_mode_modules = array(); + $safe_mode_modules[0] = __('Any'); + foreach ($sql_modules as $m) { + $safe_mode_modules[$m['id_module']] = $m['name']; + } + + $table->data[2][0] = __('Safe operation mode') + . ui_print_help_tip(__('This mode allow Pandora FMS to disable all modules + of this agent while the selected module is on CRITICAL status'), true); + $table->data[2][1] = html_print_checkbox('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); +} + + // Learn mode / Normal mode -$table->data[1][0] = __('Module definition') . +$table->data[3][0] = __('Module definition') . ui_print_help_icon("module_definition", true); -$table->data[1][1] = __('Learning mode') . ' ' . +$table->data[3][1] = __('Learning mode') . ' ' . html_print_radio_button_extended ("modo", 1, '', $modo, false, 'show_modules_not_learning_mode_context_help();', 'style="margin-right: 40px;"', true); -$table->data[1][1] .= __('Normal mode') . ' ' . +$table->data[3][1] .= __('Normal mode') . ' ' . html_print_radio_button_extended ("modo", 0, '', $modo, false, 'show_modules_not_learning_mode_context_help();', 'style="margin-right: 40px;"', true); -$table->data[1][1] .= __('Autodisable mode') . ' ' . +$table->data[3][1] .= __('Autodisable mode') . ' ' . html_print_radio_button_extended ("modo", 2, '', $modo, false, 'show_modules_not_learning_mode_context_help();', 'style="margin-right: 40px;"', true); // Status (Disabled / Enabled) -$table->data[2][0] = __('Status'); -$table->data[2][1] = __('Disabled') . ' ' . +$table->data[4][0] = __('Status'); +$table->data[4][1] = __('Disabled') . ' ' . html_print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true); -$table->data[2][1] .= __('Active') . ' ' . +$table->data[4][1] .= __('Active') . ' ' . html_print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true); // Remote configuration -$table->data[3][0] = __('Remote configuration'); +$table->data[5][0] = __('Remote configuration'); if (!$new_agent) { - $table->data[3][1] = '' . __('Not available') . ''; + $table->data[5][1] = '' . __('Not available') . ''; if (isset($filename)) { if (file_exists ($filename['md5'])) { - $table->data[3][1] = date ("F d Y H:i:s", fileatime ($filename['md5'])); + $table->data[5][1] = date ("F d Y H:i:s", fileatime ($filename['md5'])); // Delete remote configuration - $table->data[3][1] .= ''; - $table->data[3][1] .= html_print_image( + $table->data[5][1] .= html_print_image( "images/cross.png", true, array ('title' => __('Delete remote configuration file'), 'style' => 'vertical-align: middle;')).''; - $table->data[3][1] .= '' . + $table->data[5][1] .= '' . ui_print_help_tip( __('Delete this conf file implies that for restore you must reactive remote config in the local agent.'), true); @@ -373,7 +389,7 @@ if (!$new_agent) { } } else - $table->data[3][1] = '' . __('Not available') . ''; + $table->data[5][1] = '' . __('Not available') . ''; $listIcons = gis_get_array_list_icons(); @@ -411,23 +427,23 @@ $table->data[0][3] = html_print_select($arraySelectIcon, "icon_path", array("id" => "icon_warning", "style" => "display:".$display_icons.";")); if ($config['activate_gis']) { - $table->data[1][2] = __('Ignore new GIS data:'); - $table->data[1][3] = __('Yes') . ' ' . + $table->data[3][2] = __('Ignore new GIS data:'); + $table->data[3][3] = __('Yes') . ' ' . html_print_radio_button_extended ("update_gis_data", 0, '', $update_gis_data, false, '', 'style="margin-right: 40px;"', true); - $table->data[1][3] .= __('No') . ' ' . + $table->data[3][3] .= __('No') . ' ' . html_print_radio_button_extended ("update_gis_data", 1, '', $update_gis_data, false, '', 'style="margin-right: 40px;"', true); } -$table->data[2][2] = __('Url address'); -$table->data[2][3] = html_print_input_text ('url_description', +$table->data[4][2] = __('Url address'); +$table->data[4][3] = html_print_input_text ('url_description', $url_description, '', 45, 255, true); -$table->data[3][2] = __('Quiet'); -$table->data[3][3] = ui_print_help_tip( +$table->data[5][2] = __('Quiet'); +$table->data[5][3] = ui_print_help_tip( __('The agent still runs but the alerts and events will be stop'), true); -$table->data[3][3] .= html_print_checkbox('quiet', 1, $quiet, true); +$table->data[5][3] .= html_print_checkbox('quiet', 1, $quiet, true); ui_toggle(html_print_table ($table, true), __('Advanced options')); unset($table); @@ -582,6 +598,26 @@ ui_require_jquery_file('bgiframe'); $("#cascade_protection_module").attr("disabled", 'disabled'); } }); + + var safe_mode_checked = $("#checkbox-safe_mode").is(":checked"); + if (safe_mode_checked) { + $("#safe_mode_module").removeAttr("disabled"); + } + else { + $("#safe_mode_module").attr("disabled", 'disabled'); + } + + $("#checkbox-safe_mode").change(function () { + var safe_mode_checked = $("#checkbox-safe_mode").is(":checked"); + + if (safe_mode_checked) { + $("#safe_mode_module").removeAttr("disabled"); + } + else { + $("#safe_mode_module").val(0); + $("#safe_mode_module").attr("disabled", 'disabled'); + } + }); paint_qrcode( "data[0][1] = ''; $table->data[0][2] = ''.__('Modules').''; - $table->data[1][0] = html_print_select ($interfaces_list, 'id_snmp[]', 0, false, '', '', true, true, true, '', false, 'width:200px;'); + $table->data[1][0] = html_print_select ($interfaces_list, 'id_snmp[]', 0, false, '', '', true, true, true, '', false, 'width:500px;'); $table->data[1][1] = html_print_image('images/darrowright.png', true); $table->data[1][2] = html_print_select (array (), 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:200px;'); $table->data[1][2] .= html_print_input_hidden('agent', $id_agent, true); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index e2a264e6e0..1311620c34 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -135,6 +135,8 @@ $id_os = 9; // Windows $custom_id = ""; $cascade_protection = 0; $cascade_protection_modules = 0; +$safe_mode = 0; +$safe_mode_module = 0; $icon_path = ''; $update_gis_data = 0; $unit = ""; @@ -166,6 +168,8 @@ if ($create_agent) { $custom_id = (string) get_parameter_post ("custom_id",''); $cascade_protection = (int) get_parameter_post ("cascade_protection", 0); $cascade_protection_module = (int) get_parameter_post("cascade_protection_module", 0); + $safe_mode = (int) get_parameter_post ("safe_mode", 0); + $safe_mode_module = (int) get_parameter_post ("safe_mode_module", 0); $icon_path = (string) get_parameter_post ("icon_path",''); $update_gis_data = (int) get_parameter_post("update_gis_data", 0); $url_description = (string) get_parameter("url_description"); @@ -228,7 +232,7 @@ if ($create_agent) { if ($id_agente !== false) { // Create custom fields for this agent foreach ($field_values as $key => $value) { - db_process_sql_insert ('tagent_custom_data', + $update_custom = db_process_sql_insert ('tagent_custom_data', array('id_field' => $key, 'id_agent' => $id_agente, 'description' => $value)); } @@ -707,6 +711,7 @@ if ($update_agent) { // if modified some agent paramenter $custom_id = (string) get_parameter_post ("custom_id", ""); $cascade_protection = (int) get_parameter_post ("cascade_protection", 0); $cascade_protection_module = (int) get_parameter ("cascade_protection_module", 0); + $safe_mode_module = (int) get_parameter ("safe_mode_module", 0); $icon_path = (string) get_parameter_post ("icon_path",''); $update_gis_data = (int) get_parameter_post("update_gis_data", 0); $url_description = (string) get_parameter("url_description"); @@ -730,13 +735,17 @@ if ($update_agent) { // if modified some agent paramenter if ($old_value === false) { // Create custom field if not exist - db_process_sql_insert ('tagent_custom_data', + $update_custom = db_process_sql_insert ('tagent_custom_data', array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value)); } else { - db_process_sql_update ('tagent_custom_data', + $update_custom = db_process_sql_update ('tagent_custom_data', array('description' => $value), array('id_field' => $key,'id_agent' => $id_agente)); + + if($update_custom == 1){ + $update_custom_result = 1; + } } } @@ -782,7 +791,8 @@ if ($update_agent) { // if modified some agent paramenter 'update_gis_data' => $update_gis_data, 'url_address' => $url_description, 'url_address' => $url_description, - 'quiet' => $quiet); + 'quiet' => $quiet, + 'safe_mode_module' => $safe_mode_module); if ($config['metaconsole_agent_cache'] == 1) { $values['update_module_count'] = 1; // Force an update of the agent cache. @@ -793,7 +803,9 @@ if ($update_agent) { // if modified some agent paramenter WHERE id_group = ".$group_old); $result = db_process_sql_update ('tagente', $values, array ('id_agente' => $id_agente)); - if ($result == false) { + + + if ($result == false && $update_custom_result == false) { ui_print_error_message( __('There was a problem updating the agent')); } @@ -900,6 +912,8 @@ if ($id_agente) { $update_gis_data = $agent["update_gis_data"]; $url_description = $agent["url_address"]; $quiet = $agent["quiet"]; + $safe_mode_module = $agent["safe_mode_module"]; + $safe_mode = ($safe_mode_module) ? 1 : 0; } $update_module = (bool) get_parameter ('update_module'); diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 3c5406c46c..1f8afb37f4 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -24,6 +24,7 @@ $sortField = get_parameter('sort_field'); $sort = get_parameter('sort', 'none'); $recursion = (bool) get_parameter('recursion',false); $disabled = get_parameter('disabled', 0); +$os = get_parameter('os', 0); if ($ag_group == -1 ) $ag_group = (int) get_parameter ("ag_group", -1); @@ -163,6 +164,20 @@ html_print_select($fields,"disabled",$disabled,'this.form.submit()'); echo ""; +echo ""; + echo ""; -echo ""; -echo ""; +echo ""; echo ''; // Check if there is at least one server of each type available to assign that // kind of modules. If not, do not show server type in combo @@ -119,7 +119,7 @@ if (($policy_page) || (isset($agent))) { // Create module/type combo echo ''; if (!$policy_page) { - echo ''; } - echo ''; - echo ''; echo ''; diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index e2739aee29..921296545d 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -111,12 +111,12 @@ if (is_ajax ()) { else $snmp_community = (string) get_parameter ('snmp_community'); $snmp_version = get_parameter('snmp_version'); - $snmp3_auth_user = get_parameter('snmp3_auth_user'); + $snmp3_auth_user = io_safe_output(get_parameter('snmp3_auth_user')); $snmp3_security_level = get_parameter('snmp3_security_level'); $snmp3_auth_method = get_parameter('snmp3_auth_method'); - $snmp3_auth_pass = get_parameter('snmp3_auth_pass'); + $snmp3_auth_pass = io_safe_output(get_parameter('snmp3_auth_pass')); $snmp3_privacy_method = get_parameter('snmp3_privacy_method'); - $snmp3_privacy_pass = get_parameter('snmp3_privacy_pass'); + $snmp3_privacy_pass = io_safe_output(get_parameter('snmp3_privacy_pass')); $snmp_port = get_parameter('snmp_port'); $snmpwalk = get_snmpwalk($ip_target, $snmp_version, $snmp_community, diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index f66aa17296..473e36dfdc 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -291,7 +291,7 @@ if (modules_is_string_type($id_module_type) || $edit) { $table_simple->data[4][1] .= '
'.__('Inverse interval').''; $table_simple->data[4][1] .= html_print_checkbox ("warning_inverse", 1, $warning_inverse, true, $disabledBecauseInPolicy); if (!modules_is_string_type($id_module_type) || $edit) { - $table_simple->data[4][2] = ' '; + $table_simple->data[4][2] = ''; $table_simple->colspan[4][2] = 2; $table_simple->rowspan[4][2] = 3; } @@ -590,8 +590,7 @@ $table_advanced->colspan[10][1] = 6; if (isset($id_agente) && $moduletype == MODULE_DATA) { $has_remote_conf = enterprise_hook('config_agents_has_remote_configuration',array($agent["id_agente"])); if ($has_remote_conf) { - $table_advanced->data[11][0] = __('Cron from') . - ui_print_help_tip (__('If cron is set the module interval is ignored and the module runs on the specified date and time'), true); + $table_advanced->data[11][0] = __('Cron from') . ui_print_help_icon ('cron', true); $table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, $disabledBecauseInPolicy); $table_advanced->colspan[11][1] = 6; @@ -600,8 +599,7 @@ if (isset($id_agente) && $moduletype == MODULE_DATA) { $table_advanced->colspan[12][1] = 6; } else { - $table_advanced->data[11][0] = __('Cron from') . - ui_print_help_tip (__('If cron is set the module interval is ignored and the module runs on the specified date and time'), true); + $table_advanced->data[11][0] = __('Cron from') . ui_print_help_icon ('cron', true); $table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, true); $table_advanced->colspan[11][1] = 6; @@ -611,8 +609,7 @@ if (isset($id_agente) && $moduletype == MODULE_DATA) { } } else { - $table_advanced->data[11][0] = __('Cron from') . - ui_print_help_tip (__('If cron is set the module interval is ignored and the module runs on the specified date and time'), true); + $table_advanced->data[11][0] = __('Cron from') . ui_print_help_icon ('cron', true); $table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, $disabledBecauseInPolicy); $table_advanced->colspan[11][1] = 6; @@ -1323,8 +1320,8 @@ function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, er .attr("id", "legend_normal") .attr("x", 72) .attr("y", -30) - .attr("width", 10) - .attr("height", 10) + .attr("width", '10px') + .attr("height", '10px') .style("fill", "#82B92E"); //legend Warning text @@ -1343,8 +1340,8 @@ function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, er .attr("id", "legend_warning") .attr("x", 168) .attr("y", -30) - .attr("width", 10) - .attr("height", 10) + .attr("width", '10px') + .attr("height", '10px') .style("fill", "#ffd731"); //legend Critical text @@ -1363,8 +1360,8 @@ function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, er .attr("id", "legend_critical") .attr("x", 258) .attr("y", -30) - .attr("width", 10) - .attr("height", 10) + .attr("width", '10px') + .attr("height", '10px') .style("fill", "#fc4444"); //styles for number and axes @@ -1382,8 +1379,8 @@ function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, er .attr("id", "warning_rect") .attr("x", 3) .attr("y", 0) - .attr("width", 300) - .attr("height", 200) + .attr("width", '300px') + .attr("height", '200px') .style("fill", "#82B92E"); //controls the inverse warning diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index 24d0105d42..b640243cfe 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -398,12 +398,12 @@ function snmpBrowserWindow () { $('#text-target_ip').val($('#text-ip_target').val()); $('#text-community').val($('#text-snmp_community').val()); $('#snmp_browser_version').val($('#snmp_version').val()); - $('#snmp3_browser_auth_user').val($('#snmp3_auth_user').val()); + $('#text-snmp3_browser_auth_user').val($('#text-snmp3_auth_user').val()); $('#snmp3_browser_security_level').val($('#snmp3_security_level').val()); $('#snmp3_browser_auth_method').val($('#snmp3_auth_method').val()); - $('#snmp3_browser_auth_pass').val($('#snmp3_auth_pass').val()); + $('#password-snmp3_browser_auth_pass').val($('#password-snmp3_auth_pass').val()); $('#snmp3_browser_privacy_method').val($('#snmp3_privacy_method').val()); - $('#snmp3_browser_privacy_pass').val($('#snmp3_privacy_pass').val()); + $('#password-snmp3_browser_privacy_pass').val($('#password-snmp3_privacy_pass').val()); $("#snmp_browser_container").show().dialog ({ title: '', diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index d4106e3460..10edc6bead 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -165,8 +165,26 @@ if (is_ajax ()) { $rfield = $editor_type_chkbx; $rfield .= html_print_textarea ('field'.$i.'_recovery_value', 1, 1, '', 'class="fields_recovery"', true); } + elseif(preg_match ("/^_content_type_$/i", $field_value)){ + $editor_type_chkbx = "
"; + $editor_type_chkbx .= __('Text/plain') . ui_print_help_tip (__("For sending emails only text plain"), true); + $editor_type_chkbx .= html_print_radio_button_extended ('field'.$i.'_value', 'text/plain', '', '', false, '', '', true); + $editor_type_chkbx .= "    "; + $editor_type_chkbx .= __('Text/html') . "  "; + $editor_type_chkbx .= html_print_radio_button_extended ('field'.$i.'_value', 'text/html', '', 'text/html', false, '', '', true); + $editor_type_chkbx .= "
"; + $ffield = $editor_type_chkbx; + + $editor_type_chkbx = "
"; + $editor_type_chkbx .= __('Text/plain') . ui_print_help_tip (__("For sending emails only text plain"), true); + $editor_type_chkbx .= html_print_radio_button_extended ('field'.$i.'_recovery_value', 'text/plain', '', '', false, '', '', true); + $editor_type_chkbx .= "    "; + $editor_type_chkbx .= __('Text/html') . "  "; + $editor_type_chkbx .= html_print_radio_button_extended ('field'.$i.'_recovery_value', 'text/html', '', 'text/html', false, '', '', true); + $editor_type_chkbx .= "
"; + $rfield = $editor_type_chkbx; // Select type - else { + }else { $fields_value_select = array(); $fv = explode(';', $field_value); diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 4b57931a2c..8a2a7c6702 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -132,8 +132,8 @@ $form_filter .= ""; $form_filter .= ""; $form_filter .= " @@ -1577,6 +1596,78 @@ You can of course remove the warnings, that's why we include the source and do n ?> + + + + + + + + + + + + + + + + + + + + +
" . $filter_groups_label . "" . $filter_groups . "" . $filter_groups ."   ". $filter_recursion_label . $filter_recursion. "" . $filter_module_groups_label . ""; +echo __('Operative System') . ' '; + +$pre_fields = db_get_all_rows_sql('select distinct(tagente.id_os),tconfig_os.description from tagente,tconfig_os where tagente.id_os = tconfig_os.id_os'); +$fields = array(); + +foreach ($pre_fields as $key => $value) { + $fields[$value['id_os']] = $value['description']; +} + +html_print_select($fields,"os",$os,'this.form.submit()','All',0); + +echo ""; echo __('Recursion') . ' '; html_print_checkbox ("recursion", 1, $recursion, false, false, 'this.form.submit()'); @@ -171,6 +186,8 @@ echo ""; echo __('Search') . ' '; html_print_input_text ("search", $search, '', 12); +echo ui_print_help_tip(__('Search filter by alias, name, description, IP address or custom fields content'), true); + echo ""; echo ""; echo ""; @@ -181,7 +198,7 @@ $order_collation = ""; switch ($config["dbtype"]) { case "mysql": $order_collation = ""; - //$order_collation = "COLLATE utf8_general_ci"; + $order_collation = "COLLATE utf8_general_ci"; break; case "postgresql": case "oracle": @@ -201,13 +218,13 @@ switch ($sortField) { switch ($sort) { case 'up': $selectRemoteUp = $selected; - $order = array('field' => 'remote ' . $order_collation, + $order = array('field' => 'remote ', 'field2' => 'nombre ' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectRemoteDown = $selected; - $order = array('field' => 'remote ' . $order_collation, + $order = array('field' => 'remote ', 'field2' => 'nombre ' . $order_collation, 'order' => 'DESC'); break; @@ -296,20 +313,26 @@ if ($search != "") { }else{ $search_sql = " AND ( nombre " . $order_collation . " LIKE LOWER('%$search%') OR alias " . $order_collation . " - LIKE LOWER('%$search%')) "; + LIKE LOWER('%$search%') OR comentarios " . $order_collation . " LIKE LOWER('%$search%') + OR EXISTS (SELECT * FROM tagent_custom_data + WHERE id_agent = id_agente AND description LIKE '%$search%'))"; } } if ($disabled == 1) { - $search_sql = " AND disabled = ". $disabled . $search_sql; + $search_sql .= " AND disabled = ". $disabled . $search_sql; } else { if ($disabled == 0) { - $search_sql = " AND disabled = 0" . $search_sql; + $search_sql .= " AND disabled = 0" . $search_sql; } } +if($os != 0){ + $search_sql .= " AND id_os = " . $os; +} + // Show only selected groups if ($ag_group > 0) { @@ -540,10 +563,6 @@ if ($agents !== false) { } echo ''; echo ""; - if ($agent['quiet']) { - html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => "")); - echo " "; - } if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) { $main_tab = 'main'; @@ -562,8 +581,10 @@ if ($agents !== false) { ""; echo ""; - $in_planned_downtime = db_get_value_filter('id', 'tplanned_downtime_agents', array('id_agent' => $agent["id_agente"])); - + $in_planned_downtime = db_get_sql('SELECT executed FROM tplanned_downtime + INNER JOIN tplanned_downtime_agents ON tplanned_downtime.id = tplanned_downtime_agents.id_downtime + WHERE tplanned_downtime_agents.id_agent = '. $agent["id_agente"] . ' AND tplanned_downtime.executed = 1'); + if ($agent["disabled"]) { ui_print_help_tip(__('Disabled')); @@ -571,6 +592,11 @@ if ($agents !== false) { echo ""; } } + + if ($agent['quiet']) { + echo " "; + html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => "")); + } if ($in_planned_downtime) { ui_print_help_tip (__('Agent in planned downtime'), false, 'images/minireloj-16.png'); diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 1fbf08bf80..b22bc0f626 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -45,10 +45,10 @@ echo "
"; echo __('Search') . ' ' . html_print_input_text ('search_string', $search_string, '', 15, 255, true); echo ""; +echo ""; html_print_submit_button (__('Filter'), 'filter', false, 'class="sub search"'); echo "
'; + echo ''; echo __('Show in hierachy mode'); if ($checked == "true") { $checked = true; @@ -130,12 +130,12 @@ if (($policy_page) || (isset($agent))) { html_print_checkbox ('status_hierachy_mode', "", $checked, false, false, "onChange=change_mod_filter();"); echo ''; + echo ''; echo __("Type"); html_print_select ($modules, 'moduletype', '', '', '', '', false, false, false, '', false, 'max-width:300px;' ); html_print_input_hidden ('edit_module', 1); echo ''; + echo ''; echo ''; echo '
".__('Enabled / Disabled').""; $ed_list = array (); -$ed_list[0] = __('Enable'); -$ed_list[1] = __('Disable'); +$ed_list[0] = __('Enabled'); +$ed_list[1] = __('Disabled'); $form_filter .= html_print_select ($ed_list, 'enabledisable', $enabledisable, '', __('All'), -1, true); $form_filter .= "".__('Standby').""; $sb_list = array (); diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index bef56c026c..990653f19f 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -305,8 +305,33 @@ $(document).ready (function () { // Replace the old column with the new $table_macros_field.replaceWith(field_row); if (old_value != '' || old_recovery_value != '') { - $("[name=field" + i + "_value]").val(old_value); - $("[name=field" + i + "_recovery_value]").val(old_recovery_value); + var inputType = $("[name=field" + i + "_value]").attr('type') + if (inputType == 'radio') { + if(old_value == 'text/plain'){ + if ($("[name=field" + i + "_value]").val() == 'text/plain') { + $("[name=field" + i + "_value]").attr('checked','checked'); + } + } + else{ + if($("[name=field" + i + "_value]").val() == 'text/html') { + $("[name=field" + i + "_value]").attr('checked','checked'); + } + } + if(old_recovery_value == 'text/plain'){ + if ($("[name=field" + i + "_recovery_value]").val() == 'text/plain') { + $("[name=field" + i + "_recovery_value]").attr('checked','checked'); + } + } + else{ + if ($("[name=field" + i + "_recovery_value]").val() == 'text/html') { + $("[name=field" + i + "_recovery_value]").attr('checked','checked'); + } + } + } + else { + $("[name=field" + i + "_value]").val(old_value); + $("[name=field" + i + "_recovery_value]").val(old_recovery_value); + } } else { $("[name=field" + i + "_value]") diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index 94e834bbf5..f60ba4e5a6 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -30,15 +30,15 @@ $default = (int) get_parameter('default', 0); if ($default != 0) { - $event_fields = io_safe_input('evento,id_agente,estado,timestamp'); - $fields_selected = explode (',', $event_fields); + //$event_fields = io_safe_input('evento,id_agente,estado,timestamp'); + $fields_selected = explode (',', $config['event_fields']); } else if ($update != '') { $fields_selected = (array)get_parameter('fields_selected'); if ($fields_selected[0] == '') { - $event_fields = io_safe_input('evento,id_agente,estado,timestamp'); - $fields_selected = explode (',', $event_fields); + //$event_fields = io_safe_input('evento,id_agente,estado,timestamp'); + $fields_selected = explode (',', $config['event_fields']); } else { $event_fields = implode (',', $fields_selected); @@ -130,7 +130,7 @@ $event = array(); echo '

'.__('Show event fields'); echo ' '; -html_print_image ('images/clean.png', false, array ('title' => __('Load default event fields'), 'onclick' => "if (! confirm ('" . __('Default event fields will be loaded. Do you want to continue?') ."')) return false")); +html_print_image ('images/clean.png', false, array ('title' => __('Load the fields from previous events'), 'onclick' => "if (! confirm ('" . __('Event fields will be loaded. Do you want to continue?') ."')) return false")); echo '

'; $table = new stdClass(); diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index 6009d1b9b8..b1cd1b220c 100755 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -600,7 +600,7 @@ $(document).ready (function () { var params = { "page" : "operation/agentes/ver_agente", "get_agent_modules_json" : 1, - "get_id_and_name" : 1, + "get_distinct_name" : 1, "indexed" : 0, "privilege" : "AW" }; diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 1550e0be93..f37a39e10d 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -503,6 +503,10 @@ $table->data['edit3'][2] = __('SMNP community'); $table->data['edit3'][3] = html_print_input_text ('snmp_community', '', '', 10, 100, true); +$table->data['edit15'][2] = __('SNMP OID'); +$table->data['edit15'][3] = html_print_input_text ('snmp_oid', '', + '', 80, 80, true); + $target_ip_values = array(); $target_ip_values['auto'] = __('Auto'); $target_ip_values['force_pri'] = __('Force primary key'); @@ -736,12 +740,13 @@ $(document).ready (function () { "tr#delete_table-edit11, " + "tr#delete_table-edit12, " + "tr#delete_table-edit13, " + - "tr#delete_table-edit14").hide (); + "tr#delete_table-edit14, " + + "tr#delete_table-edit15").hide (); var params = { "page" : "operation/agentes/ver_agente", "get_agent_modules_json" : 1, - "get_id_and_name" : 1, + "get_distinct_name" : 1, "indexed" : 0 }; @@ -800,7 +805,8 @@ $(document).ready (function () { "tr#delete_table-edit11, " + "tr#delete_table-edit12, " + "tr#delete_table-edit13, " + - "tr#delete_table-edit14").show (); + "tr#delete_table-edit14, " + + "tr#delete_table-edit15").show (); } function clean_lists() { @@ -829,7 +835,8 @@ $(document).ready (function () { "tr#delete_table-edit11, " + "tr#delete_table-edit12, " + "tr#delete_table-edit13, " + - "tr#delete_table-edit14").hide (); + "tr#delete_table-edit14, " + + "tr#delete_table-edit15").hide (); $('input[type=checkbox]').attr('checked', false); $('input[type=checkbox]').attr('disabled', true); @@ -877,7 +884,8 @@ $(document).ready (function () { "tr#delete_table-edit11, " + "tr#delete_table-edit12, " + "tr#delete_table-edit13, " + - "tr#delete_table-edit14").hide (); + "tr#delete_table-edit14, " + + "tr#delete_table-edit15").hide (); } } } @@ -919,7 +927,8 @@ $(document).ready (function () { "tr#delete_table-edit11, " + "tr#delete_table-edit12, " + "tr#delete_table-edit13, " + - "tr#delete_table-edit14").show (); + "tr#delete_table-edit14, " + + "tr#delete_table-edit15").show (); } else { $(".select_agents_row_2").css('display', ''); @@ -942,7 +951,8 @@ $(document).ready (function () { "tr#delete_table-edit11, " + "tr#delete_table-edit12, " + "tr#delete_table-edit13, " + - "tr#delete_table-edit14").hide (); + "tr#delete_table-edit14, " + + "tr#delete_table-edit15").hide (); } } } @@ -1026,7 +1036,8 @@ $(document).ready (function () { "tr#delete_table-edit11, " + "tr#delete_table-edit12, " + "tr#delete_table-edit13, " + - "tr#delete_table-edit14").hide (); + "tr#delete_table-edit14, " + + "tr#delete_table-edit15").hide (); jQuery.post ("ajax.php", {"page" : "operation/agentes/ver_agente", @@ -1158,8 +1169,8 @@ function process_manage_edit ($module_name, $agents_select = null, $module_statu /* List of fields which can be updated */ $fields = array ('dynamic_interval', 'dynamic_max', 'dynamic_min', 'dynamic_two_tailed', 'min_warning', 'max_warning', 'str_warning', 'min_critical', 'max_critical', 'str_critical', 'min_ff_event', - 'module_interval', 'disabled', 'post_process', 'unit_select', - 'snmp_community', 'tcp_send', 'custom_string_1', + 'module_interval', 'disabled', 'post_process', 'unit', + 'snmp_community','snmp_oid','tcp_send', 'custom_string_1', 'plugin_parameter', 'custom_string_2', 'custom_string_3', 'min', 'max', 'id_module_group', 'plugin_user', 'plugin_pass', 'id_export', 'history_data', 'critical_inverse', diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index ec448f0cf4..e2f3cdab26 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -129,7 +129,7 @@ else { } $snmp_version = (string) get_parameter('snmp_version'); -$snmp3_auth_user = (string) get_parameter('snmp3_auth_user'); +$snmp3_auth_user = (string) io_safe_output(get_parameter('snmp3_auth_user')); $snmp3_auth_pass = io_input_password((string) get_parameter('snmp3_auth_pass')); $snmp3_auth_method = (string) get_parameter('snmp3_auth_method'); $snmp3_privacy_method = (string) get_parameter('snmp3_privacy_method'); diff --git a/pandora_console/godmode/modules/manage_network_components_form_common.php b/pandora_console/godmode/modules/manage_network_components_form_common.php index 83b21b225b..b9cc96a468 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_common.php +++ b/pandora_console/godmode/modules/manage_network_components_form_common.php @@ -473,8 +473,8 @@ $next_row++; .attr("id", "legend_normal") .attr("x", 72) .attr("y", -30) - .attr("width", 10) - .attr("height", 10) + .attr("width", '10px') + .attr("height", '10px') .style("fill", "#82B92E"); //legend Warning text diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index a63f4672be..720d8750ba 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -46,6 +46,9 @@ $delete_layout = (bool) get_parameter ('delete_layout'); $refr = (int) get_parameter('refr', $config['vc_refr']); $offset = (int) get_parameter('offset', 0); $pagination = (int) get_parameter ("pagination", $config["block_size"]); +$search = (string) get_parameter("search",""); +$ag_group = (int)get_parameter("ag_group",0); +$recursion = get_parameter("recursion",0); if ($delete_layout || $copy_layout) { // Visual console required @@ -199,6 +202,50 @@ if ($delete_layout || $copy_layout) { } } +if ($ag_group > 0) { + + $ag_groups = array(); + $ag_groups = (array)$ag_group; + if ($recursion) { + $ag_groups = groups_get_id_recursive($ag_group, true); + } +} + +echo " + "; +if(!is_metaconsole()){ + echo ""; +} else { + echo ""; +} + +echo ""; +echo ""; +echo "
"; +echo __('Search') . ' '; +html_print_input_text ("search", $search, '', 50); + +echo ""; + +echo __('Group') . ' '; +$own_info = get_user_info($config['id_user']); +if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW")) + $return_all_group = false; +else + $return_all_group = true; +html_print_select_groups(false, "AR", $return_all_group, "ag_group", $ag_group, 'this.form.submit();', '', 0, false, false, true, '', false); + +echo ""; +echo __('Group Recursion') . ' '; +html_print_checkbox ("recursion", 1, $recursion, false, false, 'this.form.submit()'); + +echo ""; +echo ""; +echo ""; +echo "
"; + $table = new stdClass(); $table->width = '100%'; $table->class = 'databox data'; @@ -228,31 +275,69 @@ $table->align[4] = 'left'; // or has "VR" privileges, otherwise show only maps of user group $filters['offset'] = $offset; $filters['limit'] = $pagination; +if(!empty($search)){ + $filters['name'] = io_safe_input($search); +} + +if($ag_group){ + $filters['group'] = array_flip($ag_groups); +} + $own_info = get_user_info ($config['id_user']); if (!defined('METACONSOLE')) { - $url = 'index.php?sec=network&sec2=godmode/reporting/map_builder&pagination='.$pagination; + $url = 'index.php?sec=network&sec2=godmode/reporting/map_builder&recursion='.$recursion.'&ag_group='.$ag_group.'&search='.$search.'&pagination='.$pagination; } else { - $url = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&pagination='.$pagination; + $url = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&recursion='.$recursion.'&ag_group='.$ag_group.'&search='.$search.'&pagination='.$pagination; } if ($own_info['is_admin'] || $vconsoles_read) { - $maps = visual_map_get_user_layouts (0,false,$filters); - $total_maps = count(visual_map_get_user_layouts()); + if($ag_group){ + $maps = visual_map_get_user_layouts (0,false,$filters,false); + unset($filters['offset']); + unset($filters['limit']); + $total_maps = count(visual_map_get_user_layouts(0,false,$filters,false)); + }else{ + $maps = visual_map_get_user_layouts (0,false,$filters); + unset($filters['offset']); + unset($filters['limit']); + $total_maps = count(visual_map_get_user_layouts(0,false,$filters)); + } } else { $maps = visual_map_get_user_layouts ($config['id_user'], false, $filters, false); + unset($filters['offset']); + unset($filters['limit']); $total_maps = count(visual_map_get_user_layouts ($config['id_user'], false, - false, false)); + $filters, false)); } if (!$maps && !is_metaconsole()) { - require_once ($config['homedir'] . "/general/firts_task/map_builder.php"); + $total = count(visual_map_get_user_layouts ($config['id_user'], false, + false, false)); + if(!$total){ + require_once ($config['homedir'] . "/general/firts_task/map_builder.php"); + } else { + ui_print_info_message( + array( + 'no_close'=>false, + 'message'=> __('No available data to show'))); + } } elseif (!$maps && is_metaconsole()) { - ui_print_info_message( - array( - 'no_close'=>true, - 'message'=> __('There are no visual console defined yet.'))); + $total = count(visual_map_get_user_layouts ($config['id_user'], false, + false, false)); + if(!$total){ + ui_print_info_message( + array( + 'no_close'=>true, + 'message'=> __('There are no visual console defined yet.'))); + }else{ + ui_print_info_message( + array( + 'no_close'=>false, + 'message'=> __('No available data to show'))); + } + } else { ui_pagination ($total_maps, $url, $offset, $pagination); diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 0593021bdc..b1dffe8e5b 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -112,6 +112,10 @@ $netflow_filter = 0; $max_values = 0; $resolution = 0; +$lapse_calc = 0; +$lapse = 300; +$visual_format = 0; + //Others $filter_search = ""; @@ -148,6 +152,7 @@ switch ($action) { case 'network_interfaces_report': case 'availability': case 'event_report_log': + case 'increment': case 'availability_graph': case 'agent_module': $get_data_editor = true; @@ -195,12 +200,6 @@ switch ($action) { $name = $item['name']; switch ($type) { - case 'avg_value': - $period = $item['period']; - $description = $item['description']; - $idAgentModule = $item['id_agent_module']; - $idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); - break; case 'event_report_log': $period = $item['period']; $description = $item['description']; @@ -282,6 +281,13 @@ switch ($action) { $idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); break; + case 'increment': + $description = $item['description']; + $idAgentModule = $item['id_agent_module']; + $idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $period = $item['period']; + break; + case 'SLA_services': $description = $item['description']; $period = $item['period']; @@ -312,6 +318,9 @@ switch ($action) { $idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); $idAgentModule = $item['id_agent_module']; $period = $item['period']; + $lapse = $item['lapse']; + $lapse_calc = $item['lapse_calc']; + $visual_format = $item['visual_format']; break; case 'max_value': $description = $item['description']; @@ -319,6 +328,9 @@ switch ($action) { $idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); $idAgentModule = $item['id_agent_module']; $period = $item['period']; + $lapse = $item['lapse']; + $lapse_calc = $item['lapse_calc']; + $visual_format = $item['visual_format']; break; case 'min_value': $description = $item['description']; @@ -326,6 +338,9 @@ switch ($action) { $idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); $idAgentModule = $item['id_agent_module']; $period = $item['period']; + $lapse = $item['lapse']; + $lapse_calc = $item['lapse_calc']; + $visual_format = $item['visual_format']; break; case 'sumatory': $description = $item['description']; @@ -593,6 +608,7 @@ switch ($action) { case 'MTTR': case 'simple_baseline_graph': case 'event_report_log': + case 'increment': $label = (isset($style['label'])) ? $style['label'] : ''; break; default: @@ -911,6 +927,9 @@ You can of course remove the warnings, that's why we include the source and do n elseif(check_acl ($config['id_user'], 0, "RM")) html_print_select_groups($config['id_user'], "RM", true, 'combo_group', $group, ''); + + echo "   ".__('Recursion').html_print_checkbox('recursion', 1, 0, true); + ?>
+ + + +
+ + + +
+ '; + html_print_radio_button ('visual_format', 1, '', $visual_format_table,'',!$lapse_calc); + echo (''); + echo __('Graph only').''; + html_print_radio_button ('visual_format', 2, '', $visual_format_graph,'',!$lapse_calc); + echo (''); + echo __('Graph and table').''; + html_print_radio_button ('visual_format', 3, '', $visual_format_both,'',!$lapse_calc); + + ?> +
@@ -2001,7 +2092,38 @@ $(document).ready (function () { "get_agents_group_json" : 1, "id_group" : this.value, "privilege" : "AW", - "keys_prefix" : "_" + "keys_prefix" : "_", + "recursion" : $('#checkbox-recursion').is(':checked') + }, + function (data, status) { + $("#id_agents").html(''); + $("#id_agents2").html(''); + $("#module").html(''); + jQuery.each (data, function (id, value) { + // Remove keys_prefix from the index + id = id.substring(1); + + option = $("") + .attr ("value", value["id_agente"]) + .html (value["alias"]); + $("#id_agents").append (option); + $("#id_agents2").append (option); + }); + }, + "json" + ); + } + ); + + $("#checkbox-recursion").change ( + function () { + jQuery.post ("ajax.php", + {"page" : "operation/agentes/ver_agente", + "get_agents_group_json" : 1, + "id_group" : $("#combo_group").val(), + "privilege" : "AW", + "keys_prefix" : "_", + "recursion" : $('#checkbox-recursion').is(':checked') }, function (data, status) { $("#id_agents").html(''); @@ -2177,6 +2299,19 @@ $(document).ready (function () { } }); + $("#checkbox-lapse_calc").change(function () { + + if($(this).is(":checked")){ + $( "#lapse_select" ).prop( "disabled", false ); + $("[name=visual_format]").prop( "disabled", false ); + } + else{ + $( "#lapse_select" ).prop( "disabled", true ); + $("[name=visual_format]").prop( "disabled", true ); + } + + }); + }); function create_custom_graph() { @@ -2658,6 +2793,9 @@ function chooseType() { $("#row_show_in_two_columns").hide(); $("#row_show_in_same_row").hide(); $("#row_historical_db_check").hide(); + $("#row_lapse_calc").hide(); + $("#row_lapse").hide(); + $("#row_visual_format").hide(); $("#row_show_in_landscape").hide(); $('#row_hide_notinit_agents').hide(); $("#row_module_group").hide(); @@ -2729,6 +2867,13 @@ function chooseType() { $("#row_source").show(); $("#row_historical_db_check").hide(); break; + + case 'increment': + $("#row_description").show(); + $("#row_agent").show(); + $("#row_module").show(); + $("#row_period").show(); + break; case 'simple_graph': $("#row_time_compare_overlapped").show(); @@ -2850,6 +2995,9 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_lapse_calc").show(); + $("#row_lapse").show(); + $("#row_visual_format").show(); $("#row_historical_db_check").hide(); break; @@ -2859,6 +3007,9 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_lapse_calc").show(); + $("#row_lapse").show(); + $("#row_visual_format").show(); $("#row_historical_db_check").hide(); break; @@ -2868,6 +3019,9 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_lapse_calc").show(); + $("#row_lapse").show(); + $("#row_visual_format").show(); $("#row_historical_db_check").hide(); break; diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 4dd13e9af0..e52994b810 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1,3 +1,37 @@ + + head[$next] = '' . - __('Op.') . ''; + __('Op.') . ''.html_print_checkbox('all_delete', 0, false, true, false, + 'check_all_checkboxes();'); //$table->size = array (); $table->size[$next] = '10%'; @@ -703,9 +738,13 @@ switch ($action) { $data[$next] .= '
'; $data[$next] .= html_print_input_hidden ('id_report', $report['id_report'], true); $data[$next] .= html_print_input_hidden ('action','delete_report', true); - $data[$next] .= html_print_input_image ('delete', 'images/cross.png', 1, '', + $data[$next] .= html_print_input_image ('delete', 'images/cross.png', 1, 'margin-right: 10px;', true, array ('title' => __('Delete'))); + + $data[$next] .= html_print_checkbox_extended ('massive_report_check', $report['id_report'], false, false, '', 'class="check_delete"', true); + $data[$next] .= '
'; + } } @@ -733,8 +772,19 @@ switch ($action) { else echo '
'; html_print_submit_button (__('Create report'), 'create', false, 'class="sub next"'); - echo "
"; + echo ""; + echo '
'; + + foreach ($reports as $report) { + echo ''; + } + + echo ''; + html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete" style="margin-left:5px;"'); + echo '
'; + echo ""; + } enterprise_hook('close_meta_frame'); @@ -1019,6 +1069,15 @@ switch ($action) { $values['period'] = get_parameter('period'); $good_format = true; break; + case 'min_value': + case 'max_value': + case 'avg_value': + $values['period'] = get_parameter('period'); + $values['lapse_calc'] = get_parameter('lapse_calc'); + $values['lapse'] = get_parameter('lapse'); + $values['visual_format'] = get_parameter('visual_format'); + $good_format = true; + break; default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('radiobutton_max_min_avg',0); @@ -1354,6 +1413,15 @@ switch ($action) { $values['period'] = get_parameter('period'); $good_format = true; break; + case 'min_value': + case 'max_value': + case 'avg_value': + $values['period'] = get_parameter('period'); + $values['lapse_calc'] = get_parameter('lapse_calc'); + $values['lapse'] = get_parameter('lapse'); + $values['visual_format'] = get_parameter('visual_format'); + $good_format = true; + break; default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('radiobutton_max_min_avg',0); @@ -2059,3 +2127,4 @@ switch ($activeTab) { enterprise_hook('close_meta_frame'); ?> + diff --git a/pandora_console/godmode/reporting/visual_console_builder.data.php b/pandora_console/godmode/reporting/visual_console_builder.data.php index 056d44e61d..8d9edddd88 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.data.php +++ b/pandora_console/godmode/reporting/visual_console_builder.data.php @@ -201,7 +201,23 @@ echo ""; diff --git a/pandora_console/godmode/update_manager/update_manager.offline.php b/pandora_console/godmode/update_manager/update_manager.offline.php index 2079678fa8..afad03cc2c 100644 --- a/pandora_console/godmode/update_manager/update_manager.offline.php +++ b/pandora_console/godmode/update_manager/update_manager.offline.php @@ -58,7 +58,14 @@ $baseurl = ui_get_full_url(false, false, false, false); var text1_mr_file = "\n"; var text2_mr_file = "\n"; var text3_mr_file = "\n"; - var text4_mr_file = "\n"; + var text4_mr_file = "
'.__('About minor release update').''; + } + else{ + echo __(' to this process').'

'.__('About minor release update').''; + } + ?>"; var text1_package_file = "\n"; var text2_package_file = "\n"; var applying_mr = "\n"; diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 0f3ce0cb57..cdd4157fca 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -236,6 +236,8 @@ if ($create_user) { case "postgresql": $result = create_user($id, $password_new, $values); if ($result) { + db_process_sql_insert ('tsesion', array('id_sesion' => '','id_usuario' => $id,'ip_origen' => $_SERVER['REMOTE_ADDR'],'accion' => 'Password change', + 'descripcion' => 'Access password updated','fecha' => date("Y-m-d H:i:s"),'utimestamp' => time())); $res = save_pass_history($id, $password_new); } break; @@ -334,6 +336,8 @@ if ($update_user) { else { $res2 = update_user_password ($id, $password_new); if ($res2) { + db_process_sql_insert ('tsesion', array('id_sesion' => '','id_usuario' => $id,'ip_origen' => $_SERVER['REMOTE_ADDR'],'accion' => 'Password change', + 'descripcion' => 'Access password updated','fecha' => date("Y-m-d H:i:s"),'utimestamp' => time())); $res3 = save_pass_history($id, $password_new); } ui_print_result_message ($res1 || $res2, @@ -345,6 +349,8 @@ if ($update_user) { $res2 = update_user_password ($id, $password_new); if ($res2) { $res3 = save_pass_history($id, $password_new); + db_process_sql_insert ('tsesion', array('id_sesion' => '','id_usuario' => $id,'ip_origen' => $_SERVER['REMOTE_ADDR'],'accion' => 'Password change', + 'descripcion' => 'Access password updated','fecha' => date("Y-m-d H:i:s"),'utimestamp' => time())); } ui_print_result_message ($res1 || $res2, __('User info successfully updated'), @@ -565,7 +571,7 @@ $values = array ( 'Tactical view'=>__('Tactical view'), 'Alert detail' => __('Alert detail'), 'Other'=>__('Other')); -if (enterprise_installed()) { +if (enterprise_installed() && !is_metaconsole()) { $values['Dashboard'] = __('Dashboard'); } $table->data[12][1] = html_print_select($values, 'section', io_safe_output($user_info["section"]), 'show_data_section();', '', -1, true, false, false); diff --git a/pandora_console/images/console/signes/barras-no.png b/pandora_console/images/console/signes/barras-no.png new file mode 100644 index 0000000000..c4545405e0 Binary files /dev/null and b/pandora_console/images/console/signes/barras-no.png differ diff --git a/pandora_console/images/console/signes/barras.png b/pandora_console/images/console/signes/barras.png new file mode 100644 index 0000000000..be81fb2212 Binary files /dev/null and b/pandora_console/images/console/signes/barras.png differ diff --git a/pandora_console/images/console/signes/circular-progress-bar-interior.png b/pandora_console/images/console/signes/circular-progress-bar-interior.png new file mode 100644 index 0000000000..221c626f25 Binary files /dev/null and b/pandora_console/images/console/signes/circular-progress-bar-interior.png differ diff --git a/pandora_console/images/console/signes/circular-progress-bar.png b/pandora_console/images/console/signes/circular-progress-bar.png new file mode 100644 index 0000000000..640a8050b4 Binary files /dev/null and b/pandora_console/images/console/signes/circular-progress-bar.png differ diff --git a/pandora_console/images/console/signes/donut-graph.png b/pandora_console/images/console/signes/donut-graph.png new file mode 100644 index 0000000000..57a2d3eb2b Binary files /dev/null and b/pandora_console/images/console/signes/donut-graph.png differ diff --git a/pandora_console/images/console/signes/wrong_donut_graph.png b/pandora_console/images/console/signes/wrong_donut_graph.png new file mode 100644 index 0000000000..8005a9ac46 Binary files /dev/null and b/pandora_console/images/console/signes/wrong_donut_graph.png differ diff --git a/pandora_console/images/groups_small/application_osx_terminal.bad.png b/pandora_console/images/groups_small/application_osx_terminal.bad.png index ccc8f3f04d..3862246d9e 100644 Binary files a/pandora_console/images/groups_small/application_osx_terminal.bad.png and b/pandora_console/images/groups_small/application_osx_terminal.bad.png differ diff --git a/pandora_console/images/groups_small/application_osx_terminal.default.png b/pandora_console/images/groups_small/application_osx_terminal.default.png index 85f0016ce2..7ddaec3117 100644 Binary files a/pandora_console/images/groups_small/application_osx_terminal.default.png and b/pandora_console/images/groups_small/application_osx_terminal.default.png differ diff --git a/pandora_console/images/groups_small/application_osx_terminal.ok.png b/pandora_console/images/groups_small/application_osx_terminal.ok.png index 0678cb09a1..1da9e887bf 100644 Binary files a/pandora_console/images/groups_small/application_osx_terminal.ok.png and b/pandora_console/images/groups_small/application_osx_terminal.ok.png differ diff --git a/pandora_console/images/groups_small/application_osx_terminal.warning.png b/pandora_console/images/groups_small/application_osx_terminal.warning.png index e95f210a5f..41fcb8eaf0 100644 Binary files a/pandora_console/images/groups_small/application_osx_terminal.warning.png and b/pandora_console/images/groups_small/application_osx_terminal.warning.png differ diff --git a/pandora_console/images/groups_small/applications.bad.png b/pandora_console/images/groups_small/applications.bad.png index 1222421693..f3f600e076 100644 Binary files a/pandora_console/images/groups_small/applications.bad.png and b/pandora_console/images/groups_small/applications.bad.png differ diff --git a/pandora_console/images/groups_small/applications.default.png b/pandora_console/images/groups_small/applications.default.png index c15fff887f..5d01354d8d 100644 Binary files a/pandora_console/images/groups_small/applications.default.png and b/pandora_console/images/groups_small/applications.default.png differ diff --git a/pandora_console/images/groups_small/applications.ok.png b/pandora_console/images/groups_small/applications.ok.png index 440fe791d3..b4fc850762 100644 Binary files a/pandora_console/images/groups_small/applications.ok.png and b/pandora_console/images/groups_small/applications.ok.png differ diff --git a/pandora_console/images/groups_small/applications.warning.png b/pandora_console/images/groups_small/applications.warning.png index b708774394..58f6f21c75 100644 Binary files a/pandora_console/images/groups_small/applications.warning.png and b/pandora_console/images/groups_small/applications.warning.png differ diff --git a/pandora_console/images/groups_small/bricks.bad.png b/pandora_console/images/groups_small/bricks.bad.png index 0a0cd5459f..5f22537353 100644 Binary files a/pandora_console/images/groups_small/bricks.bad.png and b/pandora_console/images/groups_small/bricks.bad.png differ diff --git a/pandora_console/images/groups_small/bricks.default.png b/pandora_console/images/groups_small/bricks.default.png index 14d8bab5ca..1fccda728d 100644 Binary files a/pandora_console/images/groups_small/bricks.default.png and b/pandora_console/images/groups_small/bricks.default.png differ diff --git a/pandora_console/images/groups_small/bricks.ok.png b/pandora_console/images/groups_small/bricks.ok.png index 931d1a389c..304efe93df 100644 Binary files a/pandora_console/images/groups_small/bricks.ok.png and b/pandora_console/images/groups_small/bricks.ok.png differ diff --git a/pandora_console/images/groups_small/bricks.png b/pandora_console/images/groups_small/bricks.png index c234efafb6..d197f3fd56 100644 Binary files a/pandora_console/images/groups_small/bricks.png and b/pandora_console/images/groups_small/bricks.png differ diff --git a/pandora_console/images/groups_small/bricks.warning.png b/pandora_console/images/groups_small/bricks.warning.png index bbfeb0ce3f..0345d612f3 100644 Binary files a/pandora_console/images/groups_small/bricks.warning.png and b/pandora_console/images/groups_small/bricks.warning.png differ diff --git a/pandora_console/images/groups_small/chart_organisation.bad.png b/pandora_console/images/groups_small/chart_organisation.bad.png index 410cd5116c..51771a4664 100644 Binary files a/pandora_console/images/groups_small/chart_organisation.bad.png and b/pandora_console/images/groups_small/chart_organisation.bad.png differ diff --git a/pandora_console/images/groups_small/chart_organisation.default.png b/pandora_console/images/groups_small/chart_organisation.default.png index 53619a608b..597c229fa0 100644 Binary files a/pandora_console/images/groups_small/chart_organisation.default.png and b/pandora_console/images/groups_small/chart_organisation.default.png differ diff --git a/pandora_console/images/groups_small/chart_organisation.ok.png b/pandora_console/images/groups_small/chart_organisation.ok.png index ca7f04061b..5d34f43765 100644 Binary files a/pandora_console/images/groups_small/chart_organisation.ok.png and b/pandora_console/images/groups_small/chart_organisation.ok.png differ diff --git a/pandora_console/images/groups_small/chart_organisation.warning.png b/pandora_console/images/groups_small/chart_organisation.warning.png index c9ba529187..7dac5502fc 100644 Binary files a/pandora_console/images/groups_small/chart_organisation.warning.png and b/pandora_console/images/groups_small/chart_organisation.warning.png differ diff --git a/pandora_console/images/groups_small/clock.bad.png b/pandora_console/images/groups_small/clock.bad.png index f281439c87..c1241ce275 100644 Binary files a/pandora_console/images/groups_small/clock.bad.png and b/pandora_console/images/groups_small/clock.bad.png differ diff --git a/pandora_console/images/groups_small/clock.default.png b/pandora_console/images/groups_small/clock.default.png index 2b7a58aa20..b8d58d6dec 100644 Binary files a/pandora_console/images/groups_small/clock.default.png and b/pandora_console/images/groups_small/clock.default.png differ diff --git a/pandora_console/images/groups_small/clock.ok.png b/pandora_console/images/groups_small/clock.ok.png index a3cb173d9e..1ab3c8383f 100644 Binary files a/pandora_console/images/groups_small/clock.ok.png and b/pandora_console/images/groups_small/clock.ok.png differ diff --git a/pandora_console/images/groups_small/clock.warning.png b/pandora_console/images/groups_small/clock.warning.png index 20880b31df..a06ceda51f 100644 Binary files a/pandora_console/images/groups_small/clock.warning.png and b/pandora_console/images/groups_small/clock.warning.png differ diff --git a/pandora_console/images/groups_small/computer.bad.png b/pandora_console/images/groups_small/computer.bad.png index 1807bd726f..531c4c096d 100644 Binary files a/pandora_console/images/groups_small/computer.bad.png and b/pandora_console/images/groups_small/computer.bad.png differ diff --git a/pandora_console/images/groups_small/computer.default.png b/pandora_console/images/groups_small/computer.default.png index e921e34059..c18cd4ada5 100644 Binary files a/pandora_console/images/groups_small/computer.default.png and b/pandora_console/images/groups_small/computer.default.png differ diff --git a/pandora_console/images/groups_small/computer.ok.png b/pandora_console/images/groups_small/computer.ok.png index c00aa7d51c..49fe889ab5 100644 Binary files a/pandora_console/images/groups_small/computer.ok.png and b/pandora_console/images/groups_small/computer.ok.png differ diff --git a/pandora_console/images/groups_small/computer.warning.png b/pandora_console/images/groups_small/computer.warning.png index 51a9acb473..975260e2f4 100644 Binary files a/pandora_console/images/groups_small/computer.warning.png and b/pandora_console/images/groups_small/computer.warning.png differ diff --git a/pandora_console/images/groups_small/database_gear.bad.png b/pandora_console/images/groups_small/database_gear.bad.png index dba81d5102..299b8f99d4 100644 Binary files a/pandora_console/images/groups_small/database_gear.bad.png and b/pandora_console/images/groups_small/database_gear.bad.png differ diff --git a/pandora_console/images/groups_small/database_gear.default.png b/pandora_console/images/groups_small/database_gear.default.png index 8c26e6f6b3..62d3023ed5 100644 Binary files a/pandora_console/images/groups_small/database_gear.default.png and b/pandora_console/images/groups_small/database_gear.default.png differ diff --git a/pandora_console/images/groups_small/database_gear.ok.png b/pandora_console/images/groups_small/database_gear.ok.png index 50641bb9b8..fe084de697 100644 Binary files a/pandora_console/images/groups_small/database_gear.ok.png and b/pandora_console/images/groups_small/database_gear.ok.png differ diff --git a/pandora_console/images/groups_small/database_gear.warning.png b/pandora_console/images/groups_small/database_gear.warning.png index cf74596aa3..c5668bdf55 100644 Binary files a/pandora_console/images/groups_small/database_gear.warning.png and b/pandora_console/images/groups_small/database_gear.warning.png differ diff --git a/pandora_console/images/groups_small/drive.network.bad.png b/pandora_console/images/groups_small/drive.network.bad.png new file mode 100644 index 0000000000..886ca44d2b Binary files /dev/null and b/pandora_console/images/groups_small/drive.network.bad.png differ diff --git a/pandora_console/images/groups_small/drive_network.default.png b/pandora_console/images/groups_small/drive_network.default.png index 428b2eb2a4..2fd2519029 100644 Binary files a/pandora_console/images/groups_small/drive_network.default.png and b/pandora_console/images/groups_small/drive_network.default.png differ diff --git a/pandora_console/images/groups_small/drive_network.ok.png b/pandora_console/images/groups_small/drive_network.ok.png index dbe58f007c..c84acaa7f4 100644 Binary files a/pandora_console/images/groups_small/drive_network.ok.png and b/pandora_console/images/groups_small/drive_network.ok.png differ diff --git a/pandora_console/images/groups_small/drive_network.warning.png b/pandora_console/images/groups_small/drive_network.warning.png index 0dbdd4b2a5..3abda093e3 100644 Binary files a/pandora_console/images/groups_small/drive_network.warning.png and b/pandora_console/images/groups_small/drive_network.warning.png differ diff --git a/pandora_console/images/groups_small/email.bad.png b/pandora_console/images/groups_small/email.bad.png index 064222d63e..78a2ed0913 100644 Binary files a/pandora_console/images/groups_small/email.bad.png and b/pandora_console/images/groups_small/email.bad.png differ diff --git a/pandora_console/images/groups_small/email.default.png b/pandora_console/images/groups_small/email.default.png index 1486cd82a0..e07d9c3022 100644 Binary files a/pandora_console/images/groups_small/email.default.png and b/pandora_console/images/groups_small/email.default.png differ diff --git a/pandora_console/images/groups_small/email.ok.png b/pandora_console/images/groups_small/email.ok.png index 681fc2ddfa..5d5fca4f0c 100644 Binary files a/pandora_console/images/groups_small/email.ok.png and b/pandora_console/images/groups_small/email.ok.png differ diff --git a/pandora_console/images/groups_small/email.warning.png b/pandora_console/images/groups_small/email.warning.png index b08c99d7c1..10662435e1 100644 Binary files a/pandora_console/images/groups_small/email.warning.png and b/pandora_console/images/groups_small/email.warning.png differ diff --git a/pandora_console/images/groups_small/eye.bad.png b/pandora_console/images/groups_small/eye.bad.png index f8191a1b17..9c08baf0a3 100644 Binary files a/pandora_console/images/groups_small/eye.bad.png and b/pandora_console/images/groups_small/eye.bad.png differ diff --git a/pandora_console/images/groups_small/eye.default.png b/pandora_console/images/groups_small/eye.default.png index cd852b7502..a8dc65e8be 100644 Binary files a/pandora_console/images/groups_small/eye.default.png and b/pandora_console/images/groups_small/eye.default.png differ diff --git a/pandora_console/images/groups_small/eye.ok.png b/pandora_console/images/groups_small/eye.ok.png index 0da4304f71..abf8578709 100644 Binary files a/pandora_console/images/groups_small/eye.ok.png and b/pandora_console/images/groups_small/eye.ok.png differ diff --git a/pandora_console/images/groups_small/eye.warning.png b/pandora_console/images/groups_small/eye.warning.png index 65a5722201..2bd3af45f8 100644 Binary files a/pandora_console/images/groups_small/eye.warning.png and b/pandora_console/images/groups_small/eye.warning.png differ diff --git a/pandora_console/images/groups_small/firewall.bad.png b/pandora_console/images/groups_small/firewall.bad.png index d138d12932..63dc452311 100644 Binary files a/pandora_console/images/groups_small/firewall.bad.png and b/pandora_console/images/groups_small/firewall.bad.png differ diff --git a/pandora_console/images/groups_small/firewall.default.png b/pandora_console/images/groups_small/firewall.default.png index 2c35c40139..f5401edbe6 100644 Binary files a/pandora_console/images/groups_small/firewall.default.png and b/pandora_console/images/groups_small/firewall.default.png differ diff --git a/pandora_console/images/groups_small/firewall.ok.png b/pandora_console/images/groups_small/firewall.ok.png index 5c46d05d24..d92731e99c 100644 Binary files a/pandora_console/images/groups_small/firewall.ok.png and b/pandora_console/images/groups_small/firewall.ok.png differ diff --git a/pandora_console/images/groups_small/firewall.warning.png b/pandora_console/images/groups_small/firewall.warning.png index 644ea4d594..0f706a776d 100644 Binary files a/pandora_console/images/groups_small/firewall.warning.png and b/pandora_console/images/groups_small/firewall.warning.png differ diff --git a/pandora_console/images/groups_small/heart.bad.png b/pandora_console/images/groups_small/heart.bad.png index ff3008fcc4..f9da31b2c5 100644 Binary files a/pandora_console/images/groups_small/heart.bad.png and b/pandora_console/images/groups_small/heart.bad.png differ diff --git a/pandora_console/images/groups_small/heart.default.png b/pandora_console/images/groups_small/heart.default.png index a7cfff0cc3..73a101809a 100644 Binary files a/pandora_console/images/groups_small/heart.default.png and b/pandora_console/images/groups_small/heart.default.png differ diff --git a/pandora_console/images/groups_small/heart.ok.png b/pandora_console/images/groups_small/heart.ok.png index 0f0798523d..0b2b4e0653 100644 Binary files a/pandora_console/images/groups_small/heart.ok.png and b/pandora_console/images/groups_small/heart.ok.png differ diff --git a/pandora_console/images/groups_small/heart.warning.png b/pandora_console/images/groups_small/heart.warning.png index 66b8583393..f97cc1251b 100644 Binary files a/pandora_console/images/groups_small/heart.warning.png and b/pandora_console/images/groups_small/heart.warning.png differ diff --git a/pandora_console/images/groups_small/house.bad.png b/pandora_console/images/groups_small/house.bad.png index 815f719f7c..a7dcd9b6fd 100644 Binary files a/pandora_console/images/groups_small/house.bad.png and b/pandora_console/images/groups_small/house.bad.png differ diff --git a/pandora_console/images/groups_small/house.default.png b/pandora_console/images/groups_small/house.default.png index fac912b267..07b9842b2d 100644 Binary files a/pandora_console/images/groups_small/house.default.png and b/pandora_console/images/groups_small/house.default.png differ diff --git a/pandora_console/images/groups_small/house.ok.png b/pandora_console/images/groups_small/house.ok.png index c3a2e9053e..9190bfd075 100644 Binary files a/pandora_console/images/groups_small/house.ok.png and b/pandora_console/images/groups_small/house.ok.png differ diff --git a/pandora_console/images/groups_small/house.warning.png b/pandora_console/images/groups_small/house.warning.png index cf76552f5f..27ba33bca9 100644 Binary files a/pandora_console/images/groups_small/house.warning.png and b/pandora_console/images/groups_small/house.warning.png differ diff --git a/pandora_console/images/groups_small/images.bad.png b/pandora_console/images/groups_small/images.bad.png index 454b36e1d5..cdcb423d83 100644 Binary files a/pandora_console/images/groups_small/images.bad.png and b/pandora_console/images/groups_small/images.bad.png differ diff --git a/pandora_console/images/groups_small/images.default.png b/pandora_console/images/groups_small/images.default.png index 501a97fe27..04b186e57f 100644 Binary files a/pandora_console/images/groups_small/images.default.png and b/pandora_console/images/groups_small/images.default.png differ diff --git a/pandora_console/images/groups_small/images.ok.png b/pandora_console/images/groups_small/images.ok.png index 530af4f4c4..0936d2f2e0 100644 Binary files a/pandora_console/images/groups_small/images.ok.png and b/pandora_console/images/groups_small/images.ok.png differ diff --git a/pandora_console/images/groups_small/images.warning.png b/pandora_console/images/groups_small/images.warning.png index 46cd29d989..f735403dc8 100644 Binary files a/pandora_console/images/groups_small/images.warning.png and b/pandora_console/images/groups_small/images.warning.png differ diff --git a/pandora_console/images/groups_small/lightning.bad.png b/pandora_console/images/groups_small/lightning.bad.png index a6ec10a2bc..dc4de71df3 100644 Binary files a/pandora_console/images/groups_small/lightning.bad.png and b/pandora_console/images/groups_small/lightning.bad.png differ diff --git a/pandora_console/images/groups_small/lightning.default.png b/pandora_console/images/groups_small/lightning.default.png index 47447d48be..b50d496caa 100644 Binary files a/pandora_console/images/groups_small/lightning.default.png and b/pandora_console/images/groups_small/lightning.default.png differ diff --git a/pandora_console/images/groups_small/lightning.ok.png b/pandora_console/images/groups_small/lightning.ok.png index 7dee1c4a81..7b134afecf 100644 Binary files a/pandora_console/images/groups_small/lightning.ok.png and b/pandora_console/images/groups_small/lightning.ok.png differ diff --git a/pandora_console/images/groups_small/lightning.warning.png b/pandora_console/images/groups_small/lightning.warning.png index 020cfe9ac7..3182a8aa72 100644 Binary files a/pandora_console/images/groups_small/lightning.warning.png and b/pandora_console/images/groups_small/lightning.warning.png differ diff --git a/pandora_console/images/groups_small/lock.bad.png b/pandora_console/images/groups_small/lock.bad.png index 29fecde26d..0f25d5361b 100644 Binary files a/pandora_console/images/groups_small/lock.bad.png and b/pandora_console/images/groups_small/lock.bad.png differ diff --git a/pandora_console/images/groups_small/lock.default.png b/pandora_console/images/groups_small/lock.default.png index d462751473..b3958972ed 100644 Binary files a/pandora_console/images/groups_small/lock.default.png and b/pandora_console/images/groups_small/lock.default.png differ diff --git a/pandora_console/images/groups_small/lock.ok.png b/pandora_console/images/groups_small/lock.ok.png index fb9a8749bd..06e639a7bf 100644 Binary files a/pandora_console/images/groups_small/lock.ok.png and b/pandora_console/images/groups_small/lock.ok.png differ diff --git a/pandora_console/images/groups_small/lock.warning.png b/pandora_console/images/groups_small/lock.warning.png index bfb2826d31..9cd24bc69b 100644 Binary files a/pandora_console/images/groups_small/lock.warning.png and b/pandora_console/images/groups_small/lock.warning.png differ diff --git a/pandora_console/images/groups_small/network.bad.png b/pandora_console/images/groups_small/network.bad.png index f3293d77ac..fec08fa66b 100644 Binary files a/pandora_console/images/groups_small/network.bad.png and b/pandora_console/images/groups_small/network.bad.png differ diff --git a/pandora_console/images/groups_small/network.default.png b/pandora_console/images/groups_small/network.default.png index c330e90893..6b2107017f 100644 Binary files a/pandora_console/images/groups_small/network.default.png and b/pandora_console/images/groups_small/network.default.png differ diff --git a/pandora_console/images/groups_small/network.ok.png b/pandora_console/images/groups_small/network.ok.png index edd8831666..ce767cf880 100644 Binary files a/pandora_console/images/groups_small/network.ok.png and b/pandora_console/images/groups_small/network.ok.png differ diff --git a/pandora_console/images/groups_small/network.warning.png b/pandora_console/images/groups_small/network.warning.png index 6ddd996e56..66a55e22b4 100644 Binary files a/pandora_console/images/groups_small/network.warning.png and b/pandora_console/images/groups_small/network.warning.png differ diff --git a/pandora_console/images/groups_small/old/application_osx_terminal.bad.png b/pandora_console/images/groups_small/old/application_osx_terminal.bad.png new file mode 100644 index 0000000000..ccc8f3f04d Binary files /dev/null and b/pandora_console/images/groups_small/old/application_osx_terminal.bad.png differ diff --git a/pandora_console/images/groups_small/old/application_osx_terminal.default.png b/pandora_console/images/groups_small/old/application_osx_terminal.default.png new file mode 100644 index 0000000000..85f0016ce2 Binary files /dev/null and b/pandora_console/images/groups_small/old/application_osx_terminal.default.png differ diff --git a/pandora_console/images/groups_small/old/application_osx_terminal.ok.png b/pandora_console/images/groups_small/old/application_osx_terminal.ok.png new file mode 100644 index 0000000000..0678cb09a1 Binary files /dev/null and b/pandora_console/images/groups_small/old/application_osx_terminal.ok.png differ diff --git a/pandora_console/images/groups_small/old/application_osx_terminal.warning.png b/pandora_console/images/groups_small/old/application_osx_terminal.warning.png new file mode 100644 index 0000000000..e95f210a5f Binary files /dev/null and b/pandora_console/images/groups_small/old/application_osx_terminal.warning.png differ diff --git a/pandora_console/images/groups_small/old/applications.bad_old.png b/pandora_console/images/groups_small/old/applications.bad_old.png new file mode 100644 index 0000000000..1222421693 Binary files /dev/null and b/pandora_console/images/groups_small/old/applications.bad_old.png differ diff --git a/pandora_console/images/groups_small/old/applications.default_old.png b/pandora_console/images/groups_small/old/applications.default_old.png new file mode 100644 index 0000000000..c15fff887f Binary files /dev/null and b/pandora_console/images/groups_small/old/applications.default_old.png differ diff --git a/pandora_console/images/groups_small/old/applications.ok_old.png b/pandora_console/images/groups_small/old/applications.ok_old.png new file mode 100644 index 0000000000..440fe791d3 Binary files /dev/null and b/pandora_console/images/groups_small/old/applications.ok_old.png differ diff --git a/pandora_console/images/groups_small/old/applications.warning_old.png b/pandora_console/images/groups_small/old/applications.warning_old.png new file mode 100644 index 0000000000..b708774394 Binary files /dev/null and b/pandora_console/images/groups_small/old/applications.warning_old.png differ diff --git a/pandora_console/images/groups_small/old/bricks.bad.png b/pandora_console/images/groups_small/old/bricks.bad.png new file mode 100644 index 0000000000..0a0cd5459f Binary files /dev/null and b/pandora_console/images/groups_small/old/bricks.bad.png differ diff --git a/pandora_console/images/groups_small/old/bricks.default.png b/pandora_console/images/groups_small/old/bricks.default.png new file mode 100644 index 0000000000..14d8bab5ca Binary files /dev/null and b/pandora_console/images/groups_small/old/bricks.default.png differ diff --git a/pandora_console/images/groups_small/old/bricks.ok.png b/pandora_console/images/groups_small/old/bricks.ok.png new file mode 100644 index 0000000000..931d1a389c Binary files /dev/null and b/pandora_console/images/groups_small/old/bricks.ok.png differ diff --git a/pandora_console/images/groups_small/old/bricks.warning.png b/pandora_console/images/groups_small/old/bricks.warning.png new file mode 100644 index 0000000000..bbfeb0ce3f Binary files /dev/null and b/pandora_console/images/groups_small/old/bricks.warning.png differ diff --git a/pandora_console/images/groups_small/old/chart_organisation.bad.png b/pandora_console/images/groups_small/old/chart_organisation.bad.png new file mode 100644 index 0000000000..410cd5116c Binary files /dev/null and b/pandora_console/images/groups_small/old/chart_organisation.bad.png differ diff --git a/pandora_console/images/groups_small/old/chart_organisation.default.png b/pandora_console/images/groups_small/old/chart_organisation.default.png new file mode 100644 index 0000000000..53619a608b Binary files /dev/null and b/pandora_console/images/groups_small/old/chart_organisation.default.png differ diff --git a/pandora_console/images/groups_small/old/chart_organisation.ok.png b/pandora_console/images/groups_small/old/chart_organisation.ok.png new file mode 100644 index 0000000000..ca7f04061b Binary files /dev/null and b/pandora_console/images/groups_small/old/chart_organisation.ok.png differ diff --git a/pandora_console/images/groups_small/old/chart_organisation.warning.png b/pandora_console/images/groups_small/old/chart_organisation.warning.png new file mode 100644 index 0000000000..c9ba529187 Binary files /dev/null and b/pandora_console/images/groups_small/old/chart_organisation.warning.png differ diff --git a/pandora_console/images/groups_small/old/clock.bad.png b/pandora_console/images/groups_small/old/clock.bad.png new file mode 100644 index 0000000000..f281439c87 Binary files /dev/null and b/pandora_console/images/groups_small/old/clock.bad.png differ diff --git a/pandora_console/images/groups_small/old/clock.default.png b/pandora_console/images/groups_small/old/clock.default.png new file mode 100644 index 0000000000..2b7a58aa20 Binary files /dev/null and b/pandora_console/images/groups_small/old/clock.default.png differ diff --git a/pandora_console/images/groups_small/old/clock.ok.png b/pandora_console/images/groups_small/old/clock.ok.png new file mode 100644 index 0000000000..a3cb173d9e Binary files /dev/null and b/pandora_console/images/groups_small/old/clock.ok.png differ diff --git a/pandora_console/images/groups_small/old/clock.warning.png b/pandora_console/images/groups_small/old/clock.warning.png new file mode 100644 index 0000000000..20880b31df Binary files /dev/null and b/pandora_console/images/groups_small/old/clock.warning.png differ diff --git a/pandora_console/images/groups_small/old/computer.bad_old.png b/pandora_console/images/groups_small/old/computer.bad_old.png new file mode 100644 index 0000000000..1807bd726f Binary files /dev/null and b/pandora_console/images/groups_small/old/computer.bad_old.png differ diff --git a/pandora_console/images/groups_small/old/computer.default_old.png b/pandora_console/images/groups_small/old/computer.default_old.png new file mode 100644 index 0000000000..e921e34059 Binary files /dev/null and b/pandora_console/images/groups_small/old/computer.default_old.png differ diff --git a/pandora_console/images/groups_small/old/computer.ok_old.png b/pandora_console/images/groups_small/old/computer.ok_old.png new file mode 100644 index 0000000000..c00aa7d51c Binary files /dev/null and b/pandora_console/images/groups_small/old/computer.ok_old.png differ diff --git a/pandora_console/images/groups_small/old/computer.warning_old.png b/pandora_console/images/groups_small/old/computer.warning_old.png new file mode 100644 index 0000000000..51a9acb473 Binary files /dev/null and b/pandora_console/images/groups_small/old/computer.warning_old.png differ diff --git a/pandora_console/images/groups_small/old/database_gear.bad_old.png b/pandora_console/images/groups_small/old/database_gear.bad_old.png new file mode 100644 index 0000000000..dba81d5102 Binary files /dev/null and b/pandora_console/images/groups_small/old/database_gear.bad_old.png differ diff --git a/pandora_console/images/groups_small/old/database_gear.default_old.png b/pandora_console/images/groups_small/old/database_gear.default_old.png new file mode 100644 index 0000000000..8c26e6f6b3 Binary files /dev/null and b/pandora_console/images/groups_small/old/database_gear.default_old.png differ diff --git a/pandora_console/images/groups_small/old/database_gear.ok_old.png b/pandora_console/images/groups_small/old/database_gear.ok_old.png new file mode 100644 index 0000000000..50641bb9b8 Binary files /dev/null and b/pandora_console/images/groups_small/old/database_gear.ok_old.png differ diff --git a/pandora_console/images/groups_small/old/database_gear.warning_old.png b/pandora_console/images/groups_small/old/database_gear.warning_old.png new file mode 100644 index 0000000000..cf74596aa3 Binary files /dev/null and b/pandora_console/images/groups_small/old/database_gear.warning_old.png differ diff --git a/pandora_console/images/groups_small/drive_network.bad.png b/pandora_console/images/groups_small/old/drive_network.bad.png similarity index 100% rename from pandora_console/images/groups_small/drive_network.bad.png rename to pandora_console/images/groups_small/old/drive_network.bad.png diff --git a/pandora_console/images/groups_small/old/drive_network.default.png b/pandora_console/images/groups_small/old/drive_network.default.png new file mode 100644 index 0000000000..428b2eb2a4 Binary files /dev/null and b/pandora_console/images/groups_small/old/drive_network.default.png differ diff --git a/pandora_console/images/groups_small/old/drive_network.ok.png b/pandora_console/images/groups_small/old/drive_network.ok.png new file mode 100644 index 0000000000..dbe58f007c Binary files /dev/null and b/pandora_console/images/groups_small/old/drive_network.ok.png differ diff --git a/pandora_console/images/groups_small/old/drive_network.png b/pandora_console/images/groups_small/old/drive_network.png new file mode 100644 index 0000000000..952cf5352c Binary files /dev/null and b/pandora_console/images/groups_small/old/drive_network.png differ diff --git a/pandora_console/images/groups_small/old/drive_network.warning.png b/pandora_console/images/groups_small/old/drive_network.warning.png new file mode 100644 index 0000000000..0dbdd4b2a5 Binary files /dev/null and b/pandora_console/images/groups_small/old/drive_network.warning.png differ diff --git a/pandora_console/images/groups_small/old/email.bad.png b/pandora_console/images/groups_small/old/email.bad.png new file mode 100644 index 0000000000..064222d63e Binary files /dev/null and b/pandora_console/images/groups_small/old/email.bad.png differ diff --git a/pandora_console/images/groups_small/old/email.default.png b/pandora_console/images/groups_small/old/email.default.png new file mode 100644 index 0000000000..1486cd82a0 Binary files /dev/null and b/pandora_console/images/groups_small/old/email.default.png differ diff --git a/pandora_console/images/groups_small/old/email.ok.png b/pandora_console/images/groups_small/old/email.ok.png new file mode 100644 index 0000000000..681fc2ddfa Binary files /dev/null and b/pandora_console/images/groups_small/old/email.ok.png differ diff --git a/pandora_console/images/groups_small/old/email.warning.png b/pandora_console/images/groups_small/old/email.warning.png new file mode 100644 index 0000000000..b08c99d7c1 Binary files /dev/null and b/pandora_console/images/groups_small/old/email.warning.png differ diff --git a/pandora_console/images/groups_small/old/eye.bad.png b/pandora_console/images/groups_small/old/eye.bad.png new file mode 100644 index 0000000000..f8191a1b17 Binary files /dev/null and b/pandora_console/images/groups_small/old/eye.bad.png differ diff --git a/pandora_console/images/groups_small/old/eye.default.png b/pandora_console/images/groups_small/old/eye.default.png new file mode 100644 index 0000000000..cd852b7502 Binary files /dev/null and b/pandora_console/images/groups_small/old/eye.default.png differ diff --git a/pandora_console/images/groups_small/old/eye.ok.png b/pandora_console/images/groups_small/old/eye.ok.png new file mode 100644 index 0000000000..0da4304f71 Binary files /dev/null and b/pandora_console/images/groups_small/old/eye.ok.png differ diff --git a/pandora_console/images/groups_small/old/eye.warning.png b/pandora_console/images/groups_small/old/eye.warning.png new file mode 100644 index 0000000000..65a5722201 Binary files /dev/null and b/pandora_console/images/groups_small/old/eye.warning.png differ diff --git a/pandora_console/images/groups_small/old/firewall.bad_old.png b/pandora_console/images/groups_small/old/firewall.bad_old.png new file mode 100644 index 0000000000..d138d12932 Binary files /dev/null and b/pandora_console/images/groups_small/old/firewall.bad_old.png differ diff --git a/pandora_console/images/groups_small/old/firewall.default_old.png b/pandora_console/images/groups_small/old/firewall.default_old.png new file mode 100644 index 0000000000..2c35c40139 Binary files /dev/null and b/pandora_console/images/groups_small/old/firewall.default_old.png differ diff --git a/pandora_console/images/groups_small/old/firewall.ok_old.png b/pandora_console/images/groups_small/old/firewall.ok_old.png new file mode 100644 index 0000000000..5c46d05d24 Binary files /dev/null and b/pandora_console/images/groups_small/old/firewall.ok_old.png differ diff --git a/pandora_console/images/groups_small/old/firewall.warning_old.png b/pandora_console/images/groups_small/old/firewall.warning_old.png new file mode 100644 index 0000000000..644ea4d594 Binary files /dev/null and b/pandora_console/images/groups_small/old/firewall.warning_old.png differ diff --git a/pandora_console/images/groups_small/old/heart.bad.png b/pandora_console/images/groups_small/old/heart.bad.png new file mode 100644 index 0000000000..ff3008fcc4 Binary files /dev/null and b/pandora_console/images/groups_small/old/heart.bad.png differ diff --git a/pandora_console/images/groups_small/old/heart.default.png b/pandora_console/images/groups_small/old/heart.default.png new file mode 100644 index 0000000000..a7cfff0cc3 Binary files /dev/null and b/pandora_console/images/groups_small/old/heart.default.png differ diff --git a/pandora_console/images/groups_small/old/heart.ok.png b/pandora_console/images/groups_small/old/heart.ok.png new file mode 100644 index 0000000000..0f0798523d Binary files /dev/null and b/pandora_console/images/groups_small/old/heart.ok.png differ diff --git a/pandora_console/images/groups_small/old/heart.warning.png b/pandora_console/images/groups_small/old/heart.warning.png new file mode 100644 index 0000000000..66b8583393 Binary files /dev/null and b/pandora_console/images/groups_small/old/heart.warning.png differ diff --git a/pandora_console/images/groups_small/old/house.bad.png b/pandora_console/images/groups_small/old/house.bad.png new file mode 100644 index 0000000000..815f719f7c Binary files /dev/null and b/pandora_console/images/groups_small/old/house.bad.png differ diff --git a/pandora_console/images/groups_small/old/house.default.png b/pandora_console/images/groups_small/old/house.default.png new file mode 100644 index 0000000000..fac912b267 Binary files /dev/null and b/pandora_console/images/groups_small/old/house.default.png differ diff --git a/pandora_console/images/groups_small/old/house.ok.png b/pandora_console/images/groups_small/old/house.ok.png new file mode 100644 index 0000000000..c3a2e9053e Binary files /dev/null and b/pandora_console/images/groups_small/old/house.ok.png differ diff --git a/pandora_console/images/groups_small/old/house.warning.png b/pandora_console/images/groups_small/old/house.warning.png new file mode 100644 index 0000000000..cf76552f5f Binary files /dev/null and b/pandora_console/images/groups_small/old/house.warning.png differ diff --git a/pandora_console/images/groups_small/old/images.bad.png b/pandora_console/images/groups_small/old/images.bad.png new file mode 100644 index 0000000000..454b36e1d5 Binary files /dev/null and b/pandora_console/images/groups_small/old/images.bad.png differ diff --git a/pandora_console/images/groups_small/old/images.default.png b/pandora_console/images/groups_small/old/images.default.png new file mode 100644 index 0000000000..501a97fe27 Binary files /dev/null and b/pandora_console/images/groups_small/old/images.default.png differ diff --git a/pandora_console/images/groups_small/old/images.ok.png b/pandora_console/images/groups_small/old/images.ok.png new file mode 100644 index 0000000000..530af4f4c4 Binary files /dev/null and b/pandora_console/images/groups_small/old/images.ok.png differ diff --git a/pandora_console/images/groups_small/old/images.warning.png b/pandora_console/images/groups_small/old/images.warning.png new file mode 100644 index 0000000000..46cd29d989 Binary files /dev/null and b/pandora_console/images/groups_small/old/images.warning.png differ diff --git a/pandora_console/images/groups_small/old/lightning.bad.png b/pandora_console/images/groups_small/old/lightning.bad.png new file mode 100644 index 0000000000..a6ec10a2bc Binary files /dev/null and b/pandora_console/images/groups_small/old/lightning.bad.png differ diff --git a/pandora_console/images/groups_small/old/lightning.default.png b/pandora_console/images/groups_small/old/lightning.default.png new file mode 100644 index 0000000000..47447d48be Binary files /dev/null and b/pandora_console/images/groups_small/old/lightning.default.png differ diff --git a/pandora_console/images/groups_small/old/lightning.ok.png b/pandora_console/images/groups_small/old/lightning.ok.png new file mode 100644 index 0000000000..7dee1c4a81 Binary files /dev/null and b/pandora_console/images/groups_small/old/lightning.ok.png differ diff --git a/pandora_console/images/groups_small/old/lightning.warning.png b/pandora_console/images/groups_small/old/lightning.warning.png new file mode 100644 index 0000000000..020cfe9ac7 Binary files /dev/null and b/pandora_console/images/groups_small/old/lightning.warning.png differ diff --git a/pandora_console/images/groups_small/old/lock.bad.png b/pandora_console/images/groups_small/old/lock.bad.png new file mode 100644 index 0000000000..29fecde26d Binary files /dev/null and b/pandora_console/images/groups_small/old/lock.bad.png differ diff --git a/pandora_console/images/groups_small/old/lock.default.png b/pandora_console/images/groups_small/old/lock.default.png new file mode 100644 index 0000000000..d462751473 Binary files /dev/null and b/pandora_console/images/groups_small/old/lock.default.png differ diff --git a/pandora_console/images/groups_small/old/lock.ok.png b/pandora_console/images/groups_small/old/lock.ok.png new file mode 100644 index 0000000000..fb9a8749bd Binary files /dev/null and b/pandora_console/images/groups_small/old/lock.ok.png differ diff --git a/pandora_console/images/groups_small/old/lock.warning.png b/pandora_console/images/groups_small/old/lock.warning.png new file mode 100644 index 0000000000..bfb2826d31 Binary files /dev/null and b/pandora_console/images/groups_small/old/lock.warning.png differ diff --git a/pandora_console/images/groups_small/old/network.bad.png b/pandora_console/images/groups_small/old/network.bad.png new file mode 100644 index 0000000000..f3293d77ac Binary files /dev/null and b/pandora_console/images/groups_small/old/network.bad.png differ diff --git a/pandora_console/images/groups_small/old/network.default.png b/pandora_console/images/groups_small/old/network.default.png new file mode 100644 index 0000000000..c330e90893 Binary files /dev/null and b/pandora_console/images/groups_small/old/network.default.png differ diff --git a/pandora_console/images/groups_small/old/network.ok.png b/pandora_console/images/groups_small/old/network.ok.png new file mode 100644 index 0000000000..edd8831666 Binary files /dev/null and b/pandora_console/images/groups_small/old/network.ok.png differ diff --git a/pandora_console/images/groups_small/old/network.warning.png b/pandora_console/images/groups_small/old/network.warning.png new file mode 100644 index 0000000000..6ddd996e56 Binary files /dev/null and b/pandora_console/images/groups_small/old/network.warning.png differ diff --git a/pandora_console/images/groups_small/old/plugin.bad.png b/pandora_console/images/groups_small/old/plugin.bad.png new file mode 100644 index 0000000000..6d156e363f Binary files /dev/null and b/pandora_console/images/groups_small/old/plugin.bad.png differ diff --git a/pandora_console/images/groups_small/old/plugin.default.png b/pandora_console/images/groups_small/old/plugin.default.png new file mode 100644 index 0000000000..d97051dec6 Binary files /dev/null and b/pandora_console/images/groups_small/old/plugin.default.png differ diff --git a/pandora_console/images/groups_small/old/plugin.ok.png b/pandora_console/images/groups_small/old/plugin.ok.png new file mode 100644 index 0000000000..ff830a1475 Binary files /dev/null and b/pandora_console/images/groups_small/old/plugin.ok.png differ diff --git a/pandora_console/images/groups_small/old/plugin.warning.png b/pandora_console/images/groups_small/old/plugin.warning.png new file mode 100644 index 0000000000..58104424a0 Binary files /dev/null and b/pandora_console/images/groups_small/old/plugin.warning.png differ diff --git a/pandora_console/images/groups_small/old/printer.bad.png b/pandora_console/images/groups_small/old/printer.bad.png new file mode 100644 index 0000000000..9b2d285e85 Binary files /dev/null and b/pandora_console/images/groups_small/old/printer.bad.png differ diff --git a/pandora_console/images/groups_small/old/printer.default.png b/pandora_console/images/groups_small/old/printer.default.png new file mode 100644 index 0000000000..859c2474af Binary files /dev/null and b/pandora_console/images/groups_small/old/printer.default.png differ diff --git a/pandora_console/images/groups_small/old/printer.ok.png b/pandora_console/images/groups_small/old/printer.ok.png new file mode 100644 index 0000000000..8f17c7a050 Binary files /dev/null and b/pandora_console/images/groups_small/old/printer.ok.png differ diff --git a/pandora_console/images/groups_small/old/printer.warning.png b/pandora_console/images/groups_small/old/printer.warning.png new file mode 100644 index 0000000000..7eb19cf180 Binary files /dev/null and b/pandora_console/images/groups_small/old/printer.warning.png differ diff --git a/pandora_console/images/groups_small/old/server_database.bad_old.png b/pandora_console/images/groups_small/old/server_database.bad_old.png new file mode 100644 index 0000000000..ade364eb92 Binary files /dev/null and b/pandora_console/images/groups_small/old/server_database.bad_old.png differ diff --git a/pandora_console/images/groups_small/old/server_database.default_old.png b/pandora_console/images/groups_small/old/server_database.default_old.png new file mode 100644 index 0000000000..7043931277 Binary files /dev/null and b/pandora_console/images/groups_small/old/server_database.default_old.png differ diff --git a/pandora_console/images/groups_small/old/server_database.ok_old.png b/pandora_console/images/groups_small/old/server_database.ok_old.png new file mode 100644 index 0000000000..a20fa2b821 Binary files /dev/null and b/pandora_console/images/groups_small/old/server_database.ok_old.png differ diff --git a/pandora_console/images/groups_small/old/server_database.warning_old.png b/pandora_console/images/groups_small/old/server_database.warning_old.png new file mode 100644 index 0000000000..77c0822a5e Binary files /dev/null and b/pandora_console/images/groups_small/old/server_database.warning_old.png differ diff --git a/pandora_console/images/groups_small/old/transmit.bad_old.png b/pandora_console/images/groups_small/old/transmit.bad_old.png new file mode 100644 index 0000000000..90e71b4e73 Binary files /dev/null and b/pandora_console/images/groups_small/old/transmit.bad_old.png differ diff --git a/pandora_console/images/groups_small/old/transmit.default_old.png b/pandora_console/images/groups_small/old/transmit.default_old.png new file mode 100644 index 0000000000..04e0be58ea Binary files /dev/null and b/pandora_console/images/groups_small/old/transmit.default_old.png differ diff --git a/pandora_console/images/groups_small/old/transmit.ok_old.png b/pandora_console/images/groups_small/old/transmit.ok_old.png new file mode 100644 index 0000000000..f4bbd71291 Binary files /dev/null and b/pandora_console/images/groups_small/old/transmit.ok_old.png differ diff --git a/pandora_console/images/groups_small/old/transmit.warning_old.png b/pandora_console/images/groups_small/old/transmit.warning_old.png new file mode 100644 index 0000000000..14e209e758 Binary files /dev/null and b/pandora_console/images/groups_small/old/transmit.warning_old.png differ diff --git a/pandora_console/images/groups_small/old/without_group.bad_old.png b/pandora_console/images/groups_small/old/without_group.bad_old.png new file mode 100644 index 0000000000..0fa3721da3 Binary files /dev/null and b/pandora_console/images/groups_small/old/without_group.bad_old.png differ diff --git a/pandora_console/images/groups_small/old/without_group.default_old.png b/pandora_console/images/groups_small/old/without_group.default_old.png new file mode 100644 index 0000000000..50a5e5364c Binary files /dev/null and b/pandora_console/images/groups_small/old/without_group.default_old.png differ diff --git a/pandora_console/images/groups_small/old/without_group.ok_old.png b/pandora_console/images/groups_small/old/without_group.ok_old.png new file mode 100644 index 0000000000..2e82afde5d Binary files /dev/null and b/pandora_console/images/groups_small/old/without_group.ok_old.png differ diff --git a/pandora_console/images/groups_small/old/without_group.warning_old.png b/pandora_console/images/groups_small/old/without_group.warning_old.png new file mode 100644 index 0000000000..fa7efab97d Binary files /dev/null and b/pandora_console/images/groups_small/old/without_group.warning_old.png differ diff --git a/pandora_console/images/groups_small/old/world.bad_old.png b/pandora_console/images/groups_small/old/world.bad_old.png new file mode 100644 index 0000000000..9f21eed526 Binary files /dev/null and b/pandora_console/images/groups_small/old/world.bad_old.png differ diff --git a/pandora_console/images/groups_small/old/world.default_old.png b/pandora_console/images/groups_small/old/world.default_old.png new file mode 100644 index 0000000000..8917d22cc6 Binary files /dev/null and b/pandora_console/images/groups_small/old/world.default_old.png differ diff --git a/pandora_console/images/groups_small/old/world.ok_old.png b/pandora_console/images/groups_small/old/world.ok_old.png new file mode 100644 index 0000000000..012eef9cdd Binary files /dev/null and b/pandora_console/images/groups_small/old/world.ok_old.png differ diff --git a/pandora_console/images/groups_small/old/world.warning_old.png b/pandora_console/images/groups_small/old/world.warning_old.png new file mode 100644 index 0000000000..66cf9efd03 Binary files /dev/null and b/pandora_console/images/groups_small/old/world.warning_old.png differ diff --git a/pandora_console/images/groups_small/plugin.bad.png b/pandora_console/images/groups_small/plugin.bad.png index 6d156e363f..7004df6a1e 100644 Binary files a/pandora_console/images/groups_small/plugin.bad.png and b/pandora_console/images/groups_small/plugin.bad.png differ diff --git a/pandora_console/images/groups_small/plugin.default.png b/pandora_console/images/groups_small/plugin.default.png index d97051dec6..d815c117ba 100644 Binary files a/pandora_console/images/groups_small/plugin.default.png and b/pandora_console/images/groups_small/plugin.default.png differ diff --git a/pandora_console/images/groups_small/plugin.ok.png b/pandora_console/images/groups_small/plugin.ok.png index ff830a1475..dfa215c35e 100644 Binary files a/pandora_console/images/groups_small/plugin.ok.png and b/pandora_console/images/groups_small/plugin.ok.png differ diff --git a/pandora_console/images/groups_small/plugin.warning.png b/pandora_console/images/groups_small/plugin.warning.png index 58104424a0..957bedbc15 100644 Binary files a/pandora_console/images/groups_small/plugin.warning.png and b/pandora_console/images/groups_small/plugin.warning.png differ diff --git a/pandora_console/images/groups_small/printer.bad.png b/pandora_console/images/groups_small/printer.bad.png index 9b2d285e85..79ad2126d4 100644 Binary files a/pandora_console/images/groups_small/printer.bad.png and b/pandora_console/images/groups_small/printer.bad.png differ diff --git a/pandora_console/images/groups_small/printer.default.png b/pandora_console/images/groups_small/printer.default.png index 859c2474af..c16416c149 100644 Binary files a/pandora_console/images/groups_small/printer.default.png and b/pandora_console/images/groups_small/printer.default.png differ diff --git a/pandora_console/images/groups_small/printer.ok.png b/pandora_console/images/groups_small/printer.ok.png index 8f17c7a050..4f2cd88e81 100644 Binary files a/pandora_console/images/groups_small/printer.ok.png and b/pandora_console/images/groups_small/printer.ok.png differ diff --git a/pandora_console/images/groups_small/printer.warning.png b/pandora_console/images/groups_small/printer.warning.png index 7eb19cf180..f3aaa8ef07 100644 Binary files a/pandora_console/images/groups_small/printer.warning.png and b/pandora_console/images/groups_small/printer.warning.png differ diff --git a/pandora_console/images/groups_small/server_database.bad.png b/pandora_console/images/groups_small/server_database.bad.png index ade364eb92..947084d67d 100644 Binary files a/pandora_console/images/groups_small/server_database.bad.png and b/pandora_console/images/groups_small/server_database.bad.png differ diff --git a/pandora_console/images/groups_small/server_database.default.png b/pandora_console/images/groups_small/server_database.default.png index 7043931277..825a9a2af6 100644 Binary files a/pandora_console/images/groups_small/server_database.default.png and b/pandora_console/images/groups_small/server_database.default.png differ diff --git a/pandora_console/images/groups_small/server_database.ok.png b/pandora_console/images/groups_small/server_database.ok.png index a20fa2b821..0ed068441d 100644 Binary files a/pandora_console/images/groups_small/server_database.ok.png and b/pandora_console/images/groups_small/server_database.ok.png differ diff --git a/pandora_console/images/groups_small/server_database.warning.png b/pandora_console/images/groups_small/server_database.warning.png index 77c0822a5e..adc51e3e7a 100644 Binary files a/pandora_console/images/groups_small/server_database.warning.png and b/pandora_console/images/groups_small/server_database.warning.png differ diff --git a/pandora_console/images/groups_small/transmit.bad.png b/pandora_console/images/groups_small/transmit.bad.png index 90e71b4e73..e7a7f6e7ce 100644 Binary files a/pandora_console/images/groups_small/transmit.bad.png and b/pandora_console/images/groups_small/transmit.bad.png differ diff --git a/pandora_console/images/groups_small/transmit.default.png b/pandora_console/images/groups_small/transmit.default.png index 04e0be58ea..e38d390ea0 100644 Binary files a/pandora_console/images/groups_small/transmit.default.png and b/pandora_console/images/groups_small/transmit.default.png differ diff --git a/pandora_console/images/groups_small/transmit.ok.png b/pandora_console/images/groups_small/transmit.ok.png index f4bbd71291..5e70c82058 100644 Binary files a/pandora_console/images/groups_small/transmit.ok.png and b/pandora_console/images/groups_small/transmit.ok.png differ diff --git a/pandora_console/images/groups_small/transmit.warning.png b/pandora_console/images/groups_small/transmit.warning.png index 14e209e758..3d65fc1060 100644 Binary files a/pandora_console/images/groups_small/transmit.warning.png and b/pandora_console/images/groups_small/transmit.warning.png differ diff --git a/pandora_console/images/groups_small/without_group.bad.png b/pandora_console/images/groups_small/without_group.bad.png index 0fa3721da3..c2af1c6bd9 100644 Binary files a/pandora_console/images/groups_small/without_group.bad.png and b/pandora_console/images/groups_small/without_group.bad.png differ diff --git a/pandora_console/images/groups_small/without_group.default.png b/pandora_console/images/groups_small/without_group.default.png index 50a5e5364c..b8d2946e2a 100644 Binary files a/pandora_console/images/groups_small/without_group.default.png and b/pandora_console/images/groups_small/without_group.default.png differ diff --git a/pandora_console/images/groups_small/without_group.ok.png b/pandora_console/images/groups_small/without_group.ok.png index 2e82afde5d..16dd844116 100644 Binary files a/pandora_console/images/groups_small/without_group.ok.png and b/pandora_console/images/groups_small/without_group.ok.png differ diff --git a/pandora_console/images/groups_small/without_group.warning.png b/pandora_console/images/groups_small/without_group.warning.png index fa7efab97d..7ad6053c10 100644 Binary files a/pandora_console/images/groups_small/without_group.warning.png and b/pandora_console/images/groups_small/without_group.warning.png differ diff --git a/pandora_console/images/groups_small/world.bad.png b/pandora_console/images/groups_small/world.bad.png index 9f21eed526..cf93d8108a 100644 Binary files a/pandora_console/images/groups_small/world.bad.png and b/pandora_console/images/groups_small/world.bad.png differ diff --git a/pandora_console/images/groups_small/world.default.png b/pandora_console/images/groups_small/world.default.png index 8917d22cc6..509c2d4ad7 100644 Binary files a/pandora_console/images/groups_small/world.default.png and b/pandora_console/images/groups_small/world.default.png differ diff --git a/pandora_console/images/groups_small/world.ok.png b/pandora_console/images/groups_small/world.ok.png index 012eef9cdd..fc4fac1baa 100644 Binary files a/pandora_console/images/groups_small/world.ok.png and b/pandora_console/images/groups_small/world.ok.png differ diff --git a/pandora_console/images/groups_small/world.warning.png b/pandora_console/images/groups_small/world.warning.png index 66cf9efd03..a8d44c42b4 100644 Binary files a/pandora_console/images/groups_small/world.warning.png and b/pandora_console/images/groups_small/world.warning.png differ diff --git a/pandora_console/images/icono-barras-arriba.disabled.png b/pandora_console/images/icono-barras-arriba.disabled.png new file mode 100644 index 0000000000..94fb50dc5f Binary files /dev/null and b/pandora_console/images/icono-barras-arriba.disabled.png differ diff --git a/pandora_console/images/icono-barras-arriba.png b/pandora_console/images/icono-barras-arriba.png new file mode 100644 index 0000000000..4029c48c87 Binary files /dev/null and b/pandora_console/images/icono-barras-arriba.png differ diff --git a/pandora_console/images/icono-quesito.disabled.png b/pandora_console/images/icono-quesito.disabled.png new file mode 100644 index 0000000000..8202e2040b Binary files /dev/null and b/pandora_console/images/icono-quesito.disabled.png differ diff --git a/pandora_console/images/icono-quesito.png b/pandora_console/images/icono-quesito.png new file mode 100644 index 0000000000..f1a0ed73ff Binary files /dev/null and b/pandora_console/images/icono-quesito.png differ diff --git a/pandora_console/images/image_problem_area_small.png b/pandora_console/images/image_problem_area_small.png new file mode 100644 index 0000000000..8b87788752 Binary files /dev/null and b/pandora_console/images/image_problem_area_small.png differ diff --git a/pandora_console/images/reset.png b/pandora_console/images/reset.png new file mode 100644 index 0000000000..a3304f8263 Binary files /dev/null and b/pandora_console/images/reset.png differ diff --git a/pandora_console/include/ajax/graph.ajax.php b/pandora_console/include/ajax/graph.ajax.php index 1b537f8a48..ac7decf965 100644 --- a/pandora_console/include/ajax/graph.ajax.php +++ b/pandora_console/include/ajax/graph.ajax.php @@ -64,7 +64,7 @@ if ($print_custom_graph) { $ttl = (int) get_parameter('ttl', 1); $dashboard = (bool) get_parameter('dashboard'); $vconsole = (bool) get_parameter('vconsole'); - + echo custom_graphs_print($id_graph, $height, $width, $period, $stacked, true, $date, $only_image, $background_color, $modules_param, $homeurl, $name_list, $unit_list, $show_last, $show_max, @@ -102,13 +102,14 @@ if ($print_sparse_graph) { $percentil = get_parameter('percentil', null); $dashboard = (bool) get_parameter('dashboard'); $vconsole = (bool) get_parameter('vconsole'); + $type_g = get_parameter('type_g', $config['type_module_charts']); echo grafico_modulo_sparse($agent_module_id, $period, $show_events, $width, $height , $title, $unit_name, $show_alerts, $avg_only, $pure, $date, $unit, $baseline, $return_data, $show_title, $only_image, $homeurl, $ttl, $projection, $adapt_key, $compare, $show_unknown, $menu, $backgroundColor, $percentil, - $dashboard, $vconsole, $config['type_module_charts']); + $dashboard, $vconsole, $type_g); return; } diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 32de285b11..66063ed5ab 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -123,12 +123,17 @@ if ($get_module_detail) { $time_from = (string) get_parameter ('time_from', date ('h:iA')); $date_to = (string) get_parameter ('date_to', date ('Y-m-j')); $time_to = (string) get_parameter ('time_to', date ('h:iA')); + $freesearch = (string) get_parameter ('freesearch', ''); + $free_checkbox = (bool) get_parameter ('free_checkbox', false); $formtable->width = '98%'; $formtable->class = "databox"; $formtable->data = array (); $formtable->size = array (); + $moduletype_name = modules_get_moduletype_name( + modules_get_agentmodule_type($module_id)); + $periods = array(SECONDS_5MINUTES =>__('5 minutes'), SECONDS_30MINUTES =>__('30 minutes'), SECONDS_1HOUR =>__('1 hour'), @@ -175,10 +180,19 @@ if ($get_module_detail) { $formtable->data[1][2] .= html_print_input_text('time_to', $time_to, '', 9, 7, true); - html_print_table($formtable); + $freesearch_object = ''; + if (preg_match("/_string/", $moduletype_name)) { + $formtable->data[2][0] = __('Free search') . ' '; + $formtable->data[2][1] = html_print_input_text ('freesearch', $freesearch, '', 20, null, true); + $formtable->data[2][2] = html_print_checkbox('free_checkbox', 1, $free_checkbox, true); + $formtable->data[2][2] .= ' ' . __('Exact phrase'); + $freesearch_object = json_encode( array( + 'value' => io_safe_output($freesearch), + 'exact' => (bool)$free_checkbox + )); + } - $moduletype_name = modules_get_moduletype_name( - modules_get_agentmodule_type($module_id)); + html_print_table($formtable); $offset = (int) get_parameter("offset"); $block_size = (int) $config["block_size"]; @@ -222,10 +236,10 @@ if ($get_module_detail) { } $count = modules_get_agentmodule_data ($module_id, $period, - $date, true, $conexion); + $date, true, $conexion, 'ASC', $freesearch_object); $module_data = modules_get_agentmodule_data ($module_id, $period, - $date, false, $conexion, 'DESC'); + $date, false, $conexion, 'DESC', $freesearch_object); if (empty($module_data)) { $result = array(); diff --git a/pandora_console/include/ajax/snmp.ajax.php b/pandora_console/include/ajax/snmp.ajax.php index 7b3e45c704..a372d50e11 100644 --- a/pandora_console/include/ajax/snmp.ajax.php +++ b/pandora_console/include/ajax/snmp.ajax.php @@ -20,6 +20,7 @@ require_once("include/functions_snmp.php"); $save_snmp_translation = (bool)get_parameter('save_snmp_translation', 0); $delete_snmp_translation = (bool)get_parameter('delete_snmp_translation', 0); $update_snmp_translation = (bool)get_parameter('update_snmp_translation', 0); +$delete_snmp_filter = (bool)get_parameter('delete_snmp_filter', 0); /* skins image checks */ if ($save_snmp_translation) { @@ -56,4 +57,12 @@ if ($update_snmp_translation) { return; } + +if ($delete_snmp_filter) { + $filter_id = get_parameter('filter_id'); +html_debug($filter_id, true); + db_process_sql_delete('tsnmp_filter', array('id_snmp_filter' => $filter_id)); + + return; +} ?> diff --git a/pandora_console/include/ajax/snmp_browser.ajax.php b/pandora_console/include/ajax/snmp_browser.ajax.php index 3376245093..f7414c2fe1 100644 --- a/pandora_console/include/ajax/snmp_browser.ajax.php +++ b/pandora_console/include/ajax/snmp_browser.ajax.php @@ -25,16 +25,14 @@ if(is_ajax()){ $target_ip = (string) get_parameter ("target_ip", ''); $community = (string) get_parameter ("community", ''); $snmp_version = (string) get_parameter ("snmp_browser_version", ''); - $snmp3_auth_user = get_parameter('snmp3_browser_auth_user'); + $snmp3_auth_user = io_safe_output(get_parameter('snmp3_browser_auth_user')); $snmp3_security_level = get_parameter('snmp3_browser_security_level'); $snmp3_auth_method = get_parameter('snmp3_browser_auth_method'); - $snmp3_auth_pass = get_parameter('snmp3_browser_auth_pass'); + $snmp3_auth_pass = io_safe_output(get_parameter('snmp3_browser_auth_pass')); $snmp3_privacy_method = get_parameter('snmp3_browser_privacy_method'); - $snmp3_privacy_pass = get_parameter('snmp3_browser_privacy_pass'); + $snmp3_privacy_pass = io_safe_output(get_parameter('snmp3_browser_privacy_pass')); $targets_oids = get_parameter ("oids", ""); - $targets_oids = explode(",", $targets_oids); - $custom_action = get_parameter ("custom_action", ""); if ($custom_action != "") { diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 89f2cf3bf7..6e7a612171 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -17,8 +17,25 @@ if (is_ajax ()) { global $config; - // Login check - check_login (); + enterprise_include_once("include/functions_dashboard.php"); + + $public_hash = get_parameter('hash', 0); + + // Try to authenticate by hash on public dashboards + if ($public_hash == 0) { + // Login check + check_login(); + } else { + $validate_hash = enterprise_hook( + 'dasboard_validate_public_hash', + array($public_hash, 'tree_view') + ); + if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) { + db_pandora_audit("Invalid public hash", "Trying to access report builder"); + require ("general/noaccess.php"); + exit; + } + } require_once($config['homedir'] . "/include/class/Tree.class.php"); enterprise_include_once("include/class/Tree.class.php"); @@ -36,6 +53,10 @@ if (is_ajax ()) { $rootID = get_parameter('rootID', -1); $serverID = get_parameter('serverID', false); $childrenMethod = get_parameter('childrenMethod', 'on_demand'); + $hash = get_parameter('hash', false); + if ($hash !== false) { + enterprise_hook('dasboard_validate_public_hash', array($hash, 'tree_view')); + } $default_filters = array( 'searchAgent' => '', diff --git a/pandora_console/include/ajax/visual_console.ajax.php b/pandora_console/include/ajax/visual_console.ajax.php index 789398139c..91af22ec7e 100644 --- a/pandora_console/include/ajax/visual_console.ajax.php +++ b/pandora_console/include/ajax/visual_console.ajax.php @@ -12,10 +12,30 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// Login check global $config; -check_login (); +enterprise_include_once ('include/functions_dashboard.php'); +require_once('include/functions_visual_map.php'); +enterprise_include_once('include/functions_visual_map.php'); + +$public_hash = get_parameter('hash', false); +$id_visual_console = get_parameter('id_visual_console', null); + +// Try to authenticate by hash on public dashboards +if ($public_hash === false) { + // Login check + check_login(); +} else { + $validate_hash = enterprise_hook( + 'dasboard_validate_public_hash', + array($public_hash, $id_visual_console, 'visual_console') + ); + if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) { + db_pandora_audit("Invalid public hash", "Trying to access report builder"); + require ("general/noaccess.php"); + exit; + } +} // Fix: IW was the old ACL to check for report editing, now is RW if (! check_acl ($config['id_user'], 0, "VR")) { @@ -29,12 +49,6 @@ if (! check_acl ($config['id_user'], 0, "VR")) { //Fix ajax to avoid include the file, 'functions_graph.php'. $ajax = true; - -require_once('include/functions_visual_map.php'); -enterprise_include_once('include/functions_visual_map.php'); - -$id_visual_console = get_parameter('id_visual_console', null); - $render_map = (bool)get_parameter('render_map', false); $graph_javascript = (bool)get_parameter('graph_javascript', false); diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index e854a31c49..05e6f7fc4c 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -100,10 +100,14 @@ $width = get_parameter('width', null); $height = get_parameter('height', null); $parent = get_parameter('parent', null); $map_linked = get_parameter('map_linked', null); +$map_linked_weight = get_parameter('map_linked_weight', null); +$element_group = get_parameter('element_group', null); $width_percentile = get_parameter('width_percentile', null); +$bars_graph_height = get_parameter('bars_graph_height', null); $max_percentile = get_parameter('max_percentile', null); $height_module_graph = get_parameter('height_module_graph', null); $width_module_graph = get_parameter('width_module_graph', null); +$bars_graph_type = get_parameter('bars_graph_type', null); $id_agent_module = get_parameter('id_agent_module', 0); $process_simple_value = get_parameter('process_simple_value', PROCESS_VALUE_NONE); $type_percentile = get_parameter('type_percentile', 'percentile'); @@ -112,12 +116,18 @@ $metaconsole = get_parameter('metaconsole', 0); $server_name = get_parameter('server_name', null); $server_id = (int)get_parameter('server_id', 0); $id_agent = get_parameter('id_agent', null); +$id_agent_string = get_parameter('id_agent_string', null); $id_metaconsole = get_parameter('id_metaconsole', null); $id_group = (int)get_parameter('id_group', 0); $id_custom_graph = get_parameter('id_custom_graph', null); $border_width = (int)get_parameter('border_width', 0); $border_color = get_parameter('border_color', ''); +$grid_color = get_parameter('grid_color', ''); +$resume_color = get_parameter('resume_color', ''); $fill_color = get_parameter('fill_color', ''); +$percentile_color = get_parameter('percentile_color', ''); +$percentile_label = io_safe_output(get_parameter('percentile_label', '')); +$percentile_label_color = get_parameter('percentile_label_color', ''); $width_box = (int)get_parameter('width_box', 0); $height_box = (int)get_parameter('height_box', 0); $line_start_x = (int)get_parameter('line_start_x', 0); @@ -130,6 +140,7 @@ $line_color = get_parameter('line_color', ''); $get_element_status = get_parameter('get_element_status', 0); $enable_link = get_parameter('enable_link', 1); +$show_on_top = get_parameter('show_on_top', 0); $type_graph = get_parameter('type_graph', 'area'); $label_position = get_parameter('label_position', 'down'); $show_statistics = get_parameter('show_statistics', 0); @@ -140,6 +151,57 @@ switch ($action) { $return['font'] = $config['fontpath']; echo json_encode($return); break; + + case 'get_image_from_module': + $layoutData = db_get_row_filter('tlayout_data', array('id' => $id_element)); + $sql = 'SELECT datos FROM tagente_estado WHERE id_agente_modulo = '.$layoutData['id_agente_modulo']; + ob_clean(); + $result = db_get_sql($sql); + $image = strpos($result, 'data:image'); + + if($image === false){ + $return['correct'] = false; + } + else{ + $return['correct'] = true; + } + + echo json_encode($return); + + break; + + case 'get_module_type_string': + $data = array (); + + $layoutData = db_get_row_filter('tlayout_data', array('id' => $id_element)); + + if ($layoutData['id_metaconsole'] != 0) { + $connection = db_get_row_filter ('tmetaconsole_setup', $layoutData['id_metaconsole']); + + if (metaconsole_load_external_db($connection) != NOERR) { + continue; + } + } + + $is_string = db_get_value_filter ('id_tipo_modulo', 'tagente_modulo', + array ('id_agente' => $id_agent, + 'id_agente_modulo' => $id_module)); + + if ($layoutData['id_metaconsole'] != 0) { + metaconsole_restore_db(); + } + + $return = array(); + if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) || + ($is_string == 10) || ($is_string == 33)) { + $return['no_data'] = false; + } + else { + $return['no_data'] = true; + } + + echo json_encode($return); + break; case 'get_module_events': $data = array (); @@ -321,7 +383,7 @@ switch ($action) { // Linked to other layout ?? - Only if not module defined if ($layoutData['id_layout_linked'] != 0) { - $status = visual_map_get_layout_status ($layoutData['id_layout_linked']); + $status = visual_map_get_layout_status ($layoutData['id_layout_linked'], $layoutData['id_layout_linked_weight']); // Single object } @@ -431,6 +493,7 @@ switch ($action) { $values = array(); $values['label_position'] = $label_position; + $values['show_on_top'] = $show_on_top; // In Graphs, background color is stored in column image (sorry) if ($type == 'module_graph') { @@ -452,12 +515,6 @@ switch ($action) { echo (int)$result; break; case 'simple_value': - if ($action == 'update') { - $values['type'] = visual_map_get_simple_value_type( - $process_simple_value); - $values['period'] = $period; - $values['width'] = $width; - } case 'percentile_bar': case 'percentile_item': case 'static_graph': @@ -465,6 +522,8 @@ switch ($action) { case 'label': case 'icon': case 'auto_sla_graph': + case 'bars_graph': + case 'donut_graph': default: if ($type == 'label') { $values['type'] = LABEL; @@ -474,6 +533,9 @@ switch ($action) { if ($enable_link !== null) { $values['enable_link'] = $enable_link; } + if ($show_on_top !== null) { + $values['show_on_top'] = $show_on_top; + } if ($label !== null) { $values['label'] = $label; } @@ -499,8 +561,6 @@ switch ($action) { break; } - - if (defined('METACONSOLE') && $metaconsole) { if ($server_name !== null) { $values['id_metaconsole'] = db_get_value('id', @@ -515,6 +575,9 @@ switch ($action) { $values['id_agent'] = $id_agent; } } + else if ($id_agent == 0) { + $values['id_agent'] = 0; + } else if (!empty($id_agent)) { $values['id_agent'] = $id_agent; } @@ -531,6 +594,12 @@ switch ($action) { if ($map_linked !== null) { $values['id_layout_linked'] = $map_linked; } + if ($element_group !== null) { + $values['element_group'] = $element_group; + } + if ($map_linked_weight !== null) { + $values['id_layout_linked_weight'] = $map_linked_weight; + } switch ($type) { // -- line_item ------------------------------------ case 'handler_start': @@ -551,6 +620,15 @@ switch ($action) { $values['height'] = $height; } break; + case 'donut_graph': + if ($width_percentile !== null) { + $values['width'] = $width_percentile; + $values['height'] = $width_percentile; + } + $values['border_color'] = $resume_color; + $values['type'] = DONUT_GRAPH; + $values['id_agent'] = $id_agent_string; + break; case 'box_item': $values['border_width'] = $border_width; $values['border_color'] = $border_color; @@ -588,6 +666,24 @@ switch ($action) { $values['id_custom_graph'] = $id_custom_graph; } break; + case 'bars_graph': + if ($width_percentile !== null) { + $values['width'] = $width_percentile; + } + if ($bars_graph_height !== null) { + $values['height'] = $bars_graph_height; + } + if ($bars_graph_type !== null) { + $values['type_graph'] = $bars_graph_type; + } + if ($background_color !== null) { + $values['image'] = $background_color; + } + if ($grid_color !== null) { + $values['border_color'] = $grid_color; + } + $values['id_agent'] = $id_agent_string; + break; case 'percentile_item': case 'percentile_bar': if ($action == 'update') { @@ -602,15 +698,21 @@ switch ($action) { if ($type_percentile == 'percentile') { $values['type'] = PERCENTILE_BAR; } + elseif ($type_percentile == 'circular_progress_bar') { + $values['type'] = CIRCULAR_PROGRESS_BAR; + } + elseif ($type_percentile == 'interior_circular_progress_bar') { + $values['type'] = CIRCULAR_INTERIOR_PROGRESS_BAR; + } elseif ($type_percentile == 'bubble') { $values['type'] = PERCENTILE_BUBBLE; } - //Check the field's value for back compatibility - $values['image'] = 'percent'; - if (($value_show == 'percent') || - ($value_show == 'value')) - $values['image'] = $value_show; + $values['image'] = $value_show; + + $values['border_color'] = $percentile_color; + $values['fill_color'] = $percentile_label_color; + $values['label'] = $percentile_label; } break; case 'icon': @@ -624,6 +726,15 @@ switch ($action) { if ($height !== null) { $values['height'] = $height; } + break; + case 'simple_value': + if ($action == 'update') { + $values['type'] = visual_map_get_simple_value_type( + $process_simple_value); + $values['period'] = $period; + $values['width'] = $width; + } + break; default: if (enterprise_installed()) { @@ -639,6 +750,14 @@ switch ($action) { // Don't change the label because only change the positions unset($values['label']); unset($values['label_position']); + // Don't change this values when move + unset($values['id_agent']); + unset($values['id_agente_modulo']); + unset($values['enable_link']); + unset($values['show_on_top']); + unset($values['id_layout_linked']); + unset($values['element_group']); + unset($values['id_layout_linked_weight']); // Don't change background color in graphs when move switch ($type) { @@ -650,6 +769,19 @@ switch ($action) { unset($values['image']); unset($values['type_graph']); break; + case 'bars_graph': + unset($values['image']); + unset($values['type_graph']); + unset($values['border_color']); + unset($values['width']); + unset($values['id_agent']); + unset($values['height']); + break; + case 'donut_graph': + unset($values['border_color']); + unset($values['width']); + unset($values['id_agent']); + break; case 'box_item': unset($values['border_width']); unset($values['border_color']); @@ -707,10 +839,12 @@ switch ($action) { case 'static_graph': case 'group_item': case 'module_graph': + case 'bars_graph': case 'simple_value': case 'label': case 'icon': case 'auto_sla_graph': + case 'donut_graph': $elementFields = db_get_row_filter('tlayout_data', array('id' => $id_element)); @@ -768,11 +902,8 @@ switch ($action) { case 'percentile_bar': $elementFields['width_percentile'] = $elementFields['width']; $elementFields['max_percentile'] = $elementFields['height']; - //Check the field's value for back compatibility - $elementFields['value_show'] = 'percent'; - if (($elementFields['image'] == 'percent') || - ($elementFields['image'] == 'value')) - $elementFields['value_show'] = $elementFields['image']; + + $elementFields['value_show'] = $elementFields['image']; $elementFields['type_percentile'] = 'percentile'; if ($elementFields['type'] == PERCENTILE_BAR) { @@ -781,12 +912,59 @@ switch ($action) { elseif ($elementFields['type'] == PERCENTILE_BUBBLE) { $elementFields['type_percentile'] = 'bubble'; } + elseif ($elementFields['type'] == CIRCULAR_PROGRESS_BAR) { + $elementFields['type_percentile'] = 'circular_progress_bar'; + } + elseif ($elementFields['type'] == CIRCULAR_INTERIOR_PROGRESS_BAR) { + $elementFields['type_percentile'] = 'interior_circular_progress_bar'; + } + $elementFields['percentile_color'] = $elementFields['border_color']; + $elementFields['percentile_label_color'] = $elementFields['fill_color']; + $elementFields['percentile_label'] = $elementFields['label']; + break; + case 'donut_graph': + $elementFields['width_percentile'] = $elementFields['width']; + $elementFields['resume_color'] = $elementFields['border_color']; + $elementFields['id_agent_string'] = $elementFields['id_agent']; + if (($elementFields['id_agent_string'] != 0) + && ($elementFields['id_layout_linked'] == 0)) { + $modules = agents_get_modules( + $elementFields['id_agent'], false, + array('disabled' => 0, + 'id_agente' => $elementFields['id_agent'], + 'tagente_modulo.id_tipo_modulo IN' => "(17,23,3,10,33)")); + + $elementFields['modules_html'] = ''; + foreach ($modules as $id => $name) { + $elementFields['modules_html'] .= ''; + } + } break; case 'module_graph': $elementFields['width_module_graph'] = $elementFields['width']; $elementFields['height_module_graph'] = $elementFields['height']; break; + case 'bars_graph': + $elementFields['width_percentile'] = $elementFields['width']; + $elementFields['bars_graph_height'] = $elementFields['height']; + $elementFields['bars_graph_type'] = $elementFields['type_graph']; + $elementFields['grid_color'] = $elementFields['border_color']; + $elementFields['id_agent_string'] = $elementFields['id_agent']; + if (($elementFields['id_agent_string'] != 0) + && ($elementFields['id_layout_linked'] == 0)) { + $modules = agents_get_modules( + $elementFields['id_agent'], false, + array('disabled' => 0, + 'id_agente' => $elementFields['id_agent'], + 'tagente_modulo.id_tipo_modulo IN' => "(17,23,3,10,33)")); + + $elementFields['modules_html'] = ''; + foreach ($modules as $id => $name) { + $elementFields['modules_html'] .= ''; + } + } + break; case 'box_item': $elementFields['width_box'] = $elementFields['width']; $elementFields['height_box'] = $elementFields['height']; @@ -865,8 +1043,11 @@ switch ($action) { } $values['id_agente_modulo'] = $id_module; $values['id_layout_linked'] = $map_linked; + $values['element_group'] = $element_group; + $values['id_layout_linked_weight'] = $map_linked_weight; $values['parent_item'] = $parent; $values['enable_link'] = $enable_link; + $values['show_on_top'] = $show_on_top; $values['image'] = $background_color; $values['type_graph'] = $type_graph; @@ -891,6 +1072,13 @@ switch ($action) { $values['width'] = $width_box; $values['height'] = $height_box; break; + case 'donut_graph': + $values['type'] = DONUT_GRAPH; + $values['width'] = $width_percentile; + $values['height'] = $width_percentile; + $values['border_color'] = $resume_color; + $values['id_agent'] = $id_agent_string; + break; case 'module_graph': $values['type'] = MODULE_GRAPH; @@ -923,6 +1111,15 @@ switch ($action) { } $values['period'] = $period; break; + case 'bars_graph': + $values['type'] = BARS_GRAPH; + $values['width'] = $width_percentile; + $values['height'] = $bars_graph_height; + $values['type_graph'] = $bars_graph_type; + $values['image'] = $background_color; + $values['border_color'] = $grid_color; + $values['id_agent'] = $id_agent_string; + break; case 'auto_sla_graph': $values['type'] = AUTO_SLA_GRAPH; $values['period'] = $event_max_time_row; @@ -934,12 +1131,21 @@ switch ($action) { if ($type_percentile == 'percentile') { $values['type'] = PERCENTILE_BAR; } + elseif ($type_percentile == 'circular_progress_bar') { + $values['type'] = CIRCULAR_PROGRESS_BAR; + } + elseif ($type_percentile == 'interior_circular_progress_bar') { + $values['type'] = CIRCULAR_INTERIOR_PROGRESS_BAR; + } else { $values['type'] = PERCENTILE_BUBBLE; } + $values['border_color'] = $percentile_color; $values['image'] = $value_show; //Hack to save it show percent o value. $values['width'] = $width_percentile; $values['height'] = $max_percentile; + $values['fill_color'] = $percentile_label_color; + $values['label'] = $percentile_label; break; case 'static_graph': $values['type'] = STATIC_GRAPH; @@ -977,7 +1183,7 @@ switch ($action) { } break; } - + $idData = db_process_sql_insert('tlayout_data', $values); $return = array(); @@ -1031,9 +1237,17 @@ switch ($action) { $return['values']['height_box'] = $values['height']; break; - case PERCENTILE_BUBBLE: + case CIRCULAR_PROGRESS_BAR: $return['values']['type_percentile'] = 'bubble'; break; + + case CIRCULAR_INTERIOR_PROGRESS_BAR: + $return['values']['type_percentile'] = 'circular_progress_bar'; + break; + + case PERCENTILE_BUBBLE: + $return['values']['type_percentile'] = 'interior_circular_progress_bar'; + break; case PERCENTILE_BAR: $return['values']['type_percentile'] = 'percentile'; diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 139543ee75..acd777102c 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -215,6 +215,13 @@ function process_user_login_remote ($login, $pass, $api = false) { break; } + if ($config["auth"] === 'ldap') { + $login_user_attribute = $login; + if (($config['ldap_login_user_attr'] != 'name') && ($config['ldap_login_user_attr'] != null)) { + $login = get_ldap_login_attr($login); + } + } + // Authentication ok, check if the user exists in the local database if (is_user ($login)) { if (!user_can_login($login)) { @@ -240,26 +247,19 @@ function process_user_login_remote ($login, $pass, $api = false) { } } } - elseif (($config["auth"] === 'ldap') && - (isset($config['ldap_advanced_config']) && $config['ldap_advanced_config'])) { + elseif ($config["auth"] === 'ldap') { + if ($config['ldap_save_password']) { + $update_credentials = change_local_user_pass_ldap ($login, $pass); - $return = enterprise_hook ('prepare_permissions_groups_of_user_ldap', - array ($login, $pass, false, true, defined('METACONSOLE'))); - - if ($return === "error_permissions") { - $config["auth_error"] = - __("Problems with configuration permissions. Please contact with Administrator"); - return false; - } - else { - if ($return === "permissions_changed") { + if ($update_credentials) { $config["auth_error"] = __("Your permissions have changed. Please, login again."); return false; } } - - change_local_user_pass_ldap ($login, $pass); + else { + delete_user_pass_ldap ($login); + } } return $login; @@ -310,9 +310,7 @@ function process_user_login_remote ($login, $pass, $api = false) { return false; } } - elseif ($config["auth"] === 'ldap' && - (isset($config['ldap_advanced_config']) && - $config['ldap_advanced_config'])) { + elseif ($config["auth"] === 'ldap') { if ( defined('METACONSOLE') ) { enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once ('meta/include/functions_groups_meta.php'); @@ -332,13 +330,11 @@ function process_user_login_remote ($login, $pass, $api = false) { } // Create the user - if (enterprise_hook ('prepare_permissions_groups_of_user_ldap', - array($login, - $pass, - array ('fullname' => $login, - 'comments' => 'Imported from ' . $config['auth']), - false, defined('METACONSOLE'))) === false) { - + $prepare_perms = prepare_permissions_groups_of_user_ldap($login_user_attribute, $pass, + array ('fullname' => $login_user_attribute, 'comments' => 'Imported from ' . $config['auth']), + false, defined('METACONSOLE')); + + if (!$prepare_perms) { $config["auth_error"] = __("User not found in database or incorrect password"); @@ -693,10 +689,220 @@ function ldap_process_user_login ($login, $password) { } } - $dc = $config["ldap_base_dn"]; + $correct_admin_bind = true; + if ($config['ldap_admin_login'] != "" && $config['ldap_admin_pass'] != "") { + if (!@ldap_bind($ds, io_safe_output($config['ldap_admin_login']), $config['ldap_admin_pass'])) { + $correct_admin_bind = false; + } + } + + if (!$correct_admin_bind) { + $config["auth_error"] = 'Admin ldap connection fail'; + @ldap_close ($ds); + + return false; + } + + $dc = io_safe_output($config["ldap_base_dn"]); #Search group of this user it belong. - $filter="(cn=" . io_safe_output($login) . ")"; + $filter="(" . $config['ldap_login_attr'] . "=" . io_safe_output($login) . ")"; + $justthese = array("objectclass=group"); + + $sr = ldap_search($ds, $dc, $filter, $justthese); + + $memberof = ldap_get_entries($ds, $sr); + + if ($memberof["count"] == 0 && !isset($memberof[0]["memberof"])) { + @ldap_close ($ds); + return false; + } + else { + $memberof = $memberof[0]; + } + + unset($memberof["count"]); + + $ldap_base_dn = !empty($config["ldap_base_dn"]) ? "," . io_safe_output($config["ldap_base_dn"]) : ''; + + $correct = false; + if(!empty($ldap_base_dn)) { + if (strlen($password) != 0 && @ldap_bind($ds, io_safe_output($memberof['dn']), $password) ) { + $correct = true; + } + } + else { + if (strlen($password) != 0 && @ldap_bind($ds, io_safe_output($login), $password) ) { + $correct = true; + } + } + + @ldap_close ($ds); + + if ($correct) { + return true; + } + else { + $config["auth_error"] = 'User not found in database or incorrect password'; + + return false; + } +} + +function get_ldap_login_attr ($login) { + global $config; + + if (! function_exists ("ldap_connect")) { + $config["auth_error"] = __('Your installation of PHP does not support LDAP'); + + return false; + } + + // Connect to the LDAP server + $ds = @ldap_connect ($config["ldap_server"], $config["ldap_port"]); + + if (!$ds) { + $config["auth_error"] = 'Error connecting to LDAP server'; + + return false; + } + + // Set the LDAP version + ldap_set_option ($ds, LDAP_OPT_PROTOCOL_VERSION, $config["ldap_version"]); + + if ($config["ldap_start_tls"]) { + if (!@ldap_start_tls ($ds)) { + $config["auth_error"] = 'Could not start TLS for LDAP connection'; + @ldap_close ($ds); + + return false; + } + } + + $id_user = $login; + + switch ($config['ldap_login_user_attr']) { + case 'email': + $dc = io_safe_output($config["ldap_base_dn"]); + + $correct_admin_bind = true; + if ($config['ldap_admin_login'] != "" && $config['ldap_admin_pass'] != "") { + if (!@ldap_bind($ds, io_safe_output($config['ldap_admin_login']), $config['ldap_admin_pass'])) { + $correct_admin_bind = false; + } + } + + if (!$correct_admin_bind) { + $config["auth_error"] = 'Admin ldap connection fail'; + @ldap_close ($ds); + + return false; + } + + $filter="(" . $config['ldap_login_attr'] . "=" . io_safe_output($id_user) . ")"; + $justthese = array("mail"); + + $sr = ldap_search($ds, $dc, $filter, $justthese); + + $info = ldap_get_entries($ds, $sr); + + if ($info["count"] == 0 && !isset($info[0]["mail"])) { + @ldap_close ($ds); + return $id_user; + } + else { + $info = $info[0]; + } + + $id_user = $info['mail'][0]; + + @ldap_close ($ds); + + break; + } + + return $id_user; +} + +/** + * Checks if a user is in the autocreate blacklist. + * + * @param string User + * + * @return bool True if the user is in the blacklist, false otherwise. + */ +function is_user_blacklisted ($user) { + global $config; + + $blisted_users = explode (',', $config['autocreate_blacklist']); + foreach ($blisted_users as $blisted_user) { + if ($user == $blisted_user) { + return true; + } + } + + return false; +} + +/** + * Check permissions in LDAP for prepare to create user in Pandora. + * + * @param string Login + * @param string Password + * @param string User Info + * @param string check_permissions Check if change permissions + * + * @return bool True if the login succeeds, false otherwise + */ +function prepare_permissions_groups_of_user_ldap ($id_user, $password, + $user_info, $check_permissions = false, $syncronize = false) { + + global $config; + include_once($config['homedir'] . "/include/functions_html.php"); + + if (! function_exists ("ldap_connect")) { + return false; + } + + // Do not allow blank passwords + if ($password == "") { + return false; + } + + // Connect to the LDAP server + $ds = @ldap_connect ($config["ldap_server"], $config["ldap_port"]); + if (!$ds) { + return false; + } + + // Set the LDAP version + ldap_set_option ($ds, LDAP_OPT_PROTOCOL_VERSION, $config["ldap_version"]); + + if ($config["ldap_start_tls"]) { + if (!@ldap_start_tls ($ds)) { + @ldap_close ($ds); + return false; + } + } + + $dc = io_safe_output($config["ldap_base_dn"]); + + $correct_admin_bind = true; + if ($config['ldap_admin_login'] != "" && $config['ldap_admin_pass'] != "") { + if (!@ldap_bind($ds, io_safe_output($config['ldap_admin_login']), $config['ldap_admin_pass'])) { + $correct_admin_bind = false; + } + } + + if (!$correct_admin_bind) { + $config["auth_error"] = 'Admin ldap connection fail'; + @ldap_close ($ds); + + return false; + } + + #Search group of this user it belong. + $filter="(" . $config['ldap_login_attr'] . "=" . io_safe_output($id_user) . ")"; $justthese = array("objectclass=group"); $sr = ldap_search($ds, $dc, $filter, $justthese); @@ -727,36 +933,381 @@ function ldap_process_user_login ($login, $password) { } } - @ldap_close ($ds); + if (!$correct) { + @ldap_close ($ds); - if ($correct) { - return true; - } - else { - $config["auth_error"] = 'User not found in database or incorrect password'; - return false; } + + $permissions = array(); + $i = 0; + $count_total = 0; + + $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true); + + foreach ($ldap_adv_perms as $ldap_adv_perm) { + $groups = $ldap_adv_perm['groups_ldap']; + + if ($groups[0] == '') { + $groups = array(); + } + else { + $groups = $groups[0]; + } + + $count_ad_adv_perms = count(explode(",", $groups)); + + $tags_ids = array(); + $tags = implode(",", $tags); + if ($tags == null) { + $tags = ""; + } + + foreach ($memberof as $member) { + $member_to_compare = str_replace($config['ldap_login_attr'] . "=", "", $member); + $member_to_compare = str_replace($id_user . ",", "", $member_to_compare); + $member_to_compare = str_replace("," . $dc, "", $member_to_compare); + + if (($member_to_compare == $dc) && (empty($groups))) { + $count_total++; + } + else { + $member_to_compare = explode(",", $member_to_compare); + $groups = explode(",", $groups); + foreach ($groups as $g) { + if ($member_to_compare[0] == $g) { + $count_total++; + } + } + } + } + + if ($count_total > 0) { + $profile_id = $ldap_adv_perm['profile']; + $id_grupos = $ldap_adv_perm['group']; + + if (empty($profile_id)) { + @ldap_close ($ds); + return false; + } + + $permissions[$i]["profile"] = $profile_id; + $permissions[$i]["groups"] = $id_grupos; + $permissions[$i]["tags"] = $tags; + } + $i++; + $count_total = 0; + $count_ad_adv_perms = 0; + } + + if ( $check_permissions ) { + $result = check_permission_ldap ($id_user, $password, $user_info, $permissions, $syncronize); + @ldap_close ($ds); + + return $result; + } + + if (!is_user ($id_user)) { + if (($config['ldap_login_user_attr'] != 'name') && ($config['ldap_login_user_attr'] != null)) { + switch ($config['ldap_login_user_attr']) { + case 'email': + $filter="(" . $config['ldap_login_attr'] . "=" . io_safe_output($id_user) . ")"; + $justthese = array("mail"); + + $sr = ldap_search($ds, $dc, $filter, $justthese); + + $info = ldap_get_entries($ds, $sr); + + if ($info["count"] == 0 && !isset($info[0]["mail"])) { + @ldap_close ($ds); + return false; + } + else { + $info = $info[0]; + } + + $id_user = $info['mail'][0]; + $user_info['fullname'] = $id_user; + + break; + } + } + + $create_user = create_user_and_permisions_ldap($id_user, $password, $user_info, $permissions, $syncronize); + } + + @ldap_close ($ds); + + return $create_user; } /** - * Checks if a user is in the autocreate blacklist. + * Create progile with data obtaint from AD * - * @param string User + * @param string Login + * @param string Password + * @param array user_info + * @param array permiisons * - * @return bool True if the user is in the blacklist, false otherwise. + * @return bool */ -function is_user_blacklisted ($user) { +function create_user_and_permisions_ldap ($id_user, $password, $user_info, + $permissions, $syncronize = false) { global $config; - $blisted_users = explode (',', $config['autocreate_blacklist']); - foreach ($blisted_users as $blisted_user) { - if ($user == $blisted_user) { - return true; + $values = $user_info; + $values["id_user"] = $id_user; + + if ($config['ldap_save_password']) { + $values["password"] = md5 ($password); + } + $values["last_connect"] = 0; + $values["registered"] = get_system_time (); + if ( defined("METACONSOLE") && $syncronize ) + $values['metaconsole_access_node'] = $config['ldap_adv_user_node']; + $user = (@db_process_sql_insert ("tusuario", $values)) !== false; + + if ($user) { + if (!empty($permissions)) { + foreach ($permissions as $permission) { + $id_profile = $permission["profile"]; + $id_groups = $permission["groups"]; + $tags = $permission["tags"]; + + foreach ($id_groups as $id_group) { + $profile = profile_create_user_profile( + $id_user, $id_profile, $id_group, false, $tags); + } + + if ( defined("METACONSOLE") && $syncronize ) { + enterprise_include_once('include/functions_metaconsole.php'); + + unset($values['metaconsole_access_node']); + $values['not_login'] = (int) !$config['ldap_adv_user_node']; + + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + $perfil_maestro = db_get_row('tperfil', + 'id_perfil', $permission["profile"]); + + if (metaconsole_connect($server) == NOERR ) { + + if (!profile_exist($perfil_maestro['name'])) { + unset($perfil_maestro['id_perfil']); + $id_profile = db_process_sql_insert('tperfil', $perfil_maestro); + } + else { + $id_profile = db_get_value('id_perfil', 'tperfil', 'name', $perfil_maestro['name']); + } + + db_process_sql_insert ("tusuario", $values); + foreach ($id_groups as $id_group) { + $profile = profile_create_user_profile ($id_user, + $id_profile, $id_group, false, $tags); + } + } + + metaconsole_restore_db(); + } + } + + if (!$profile) + return false; + } + } + else { + $profile = profile_create_user_profile( + $id_user, $config['default_remote_profile'], $config['default_remote_group'], false, $config['default_assign_tags']); + + if (!$profile) + return false; + } + } + return true; +} + +/** + * Check if user have right permission in pandora. This + * permission depend of ldap. + * + * @param string Login + * @param string Password + * + * @return string + */ +function check_permission_ldap ($id_user, $password, $user_info, + $permissions, $syncronize = false) { + + global $config; + include_once($config['homedir'] . "/enterprise/include/functions_metaconsole.php"); + + $result_user = users_get_user_by_id($id_user); + $filter = array("id_usuario" => $id_user); + $profiles_user = array(); + $user_profiles = + db_get_all_rows_filter ("tusuario_perfil", $filter); + + foreach ($user_profiles as $user_profile) { + $profiles_user[$user_profile["id_up"]] = + $user_profile["id_perfil"]; + } + + $profiles_user_nodes = array(); + $permissions_nodes = array(); + if ( is_metaconsole() && $syncronize ) { + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + if ( metaconsole_connect($server) == NOERR ) { + $user_profiles_nodes = + db_get_all_rows_filter ("tusuario_perfil", $filter); + foreach ($user_profiles_nodes as $user_profile_node) { + $profiles_user_nodes[$server['server_name']][$user_profile_node["id_up"]] = + $user_profile_node["id_perfil"]; + } + } + metaconsole_restore_db(); + } + + foreach ($permissions as $key => $permission) { + $perfil_maestro = db_get_row('tperfil', + 'id_perfil', $permission['profile']); + foreach ($servers as $server) { + if (metaconsole_connect($server) == NOERR ) { + if (profile_exist($perfil_maestro['name'])) { + $id_profile = db_get_value('id_perfil', 'tperfil', 'name', $perfil_maestro['name']); + $permissions_nodes[$server['server_name']][$key] = $permission; + $permissions_nodes[$server['server_name']][$key]['profile'] = $id_profile; + } + } + metaconsole_restore_db(); + } } } - return false; + $no_found = array(); + if ($result_user) { + foreach ($permissions as $permission) { + $id_profile = $permission["profile"]; + $id_groups = $permission["groups"]; + $tags = $permission["tags"]; + + foreach ($id_groups as $id_group) { + $filter = array("id_usuario" => $id_user, + "id_perfil"=>$id_profile, + "id_grupo" => $id_group); + //~ Find perfil with advance permissions in + //~ authentication menu. This data depends on + //~ groups where this user it belong. + $result_profiles = + db_get_row_filter ("tusuario_perfil", $filter); + if (!$result_profiles) { + #If not found save in array. + $no_found[] = array("id_perfil"=>$id_profile, + "id_grupo" => $id_group, "tags" =>$tags); + } + else { + #if profile is find, delete from array. + db_process_sql_update("tusuario_perfil", + array("tags" =>$tags), + array('id_usuario' => $id_user, + 'id_up' => $profiles_user[$id_profile])); + + unset($profiles_user[$result_profiles["id_up"]]); + } + } + } + + if (is_metaconsole() && $syncronize) { + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + foreach ($permissions_nodes[$server['server_name']] as $permission_node) { + + $id_profile = $permission_node["profile"]; + $id_groups = $permission_node["groups"]; + $tags = $permission_node["tags"]; + + foreach ($id_groups as $id_group) { + + $filter = array("id_usuario" => $id_user, + "id_perfil"=>$id_profile, + "id_grupo" => $id_group); + + if (metaconsole_connect($server) == NOERR ) { + $result_profiles = + db_get_row_filter ("tusuario_perfil", $filter); + + if (!$result_profiles) { + #If not found save in array. + $no_found_server[$server['server_name']][] = array("id_perfil" => $id_profile, + "id_grupo" => $id_group, "tags" => $tags); + } + else { + #if profile is find, delete from array. + db_process_sql_update("tusuario_perfil", + array("tags" =>$tags), + array('id_usuario' => $id_user, + 'id_up' => $profiles_user_nodes[$server_name][$id_profile])); + + unset($profiles_user_nodes[$server_name][$result_profiles["id_up"]]); + } + } + } + } + metaconsole_restore_db(); + } + } + + if ( empty($profiles_user) && empty($no_found) ) { + #The permmisions of user not changed + return true; + } + else { + foreach ($profiles_user as $key => $profile_user) { + #The other profiles are deleted + profile_delete_user_profile ($id_user, $key); + } + + if ( is_metaconsole() && $syncronize ) { + foreach ($profiles_user_nodes as $server_name => $profile_users) { + $server = metaconsole_get_connection($server_name); + foreach ($profile_users as $key => $profile_user) { + if ( metaconsole_connect($server) == NOERR ) { + profile_delete_user_profile ($id_user, $key); + } + } + metaconsole_restore_db(); + } + } + + foreach ($no_found as $new_profiles) { + #Add the missing permissions + profile_create_user_profile ($id_user, + $new_profiles["id_perfil"], + $new_profiles["id_grupo"], false, + $new_profiles["tags"]); + } + + if ( is_metaconsole() && $syncronize ) { + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + if ( metaconsole_connect($server) == NOERR ) { + foreach ($no_found_server[$server['server_name']] as $new_profiles) { + profile_create_user_profile ($id_user, + $new_profiles["id_perfil"], + $new_profiles["id_grupo"], false, + $new_profiles["tags"]); + } + } + metaconsole_restore_db(); + } + } + + return "permissions_changed"; + } + } + else { + return "error_permissions"; + } } /** @@ -770,13 +1321,23 @@ function is_user_blacklisted ($user) { function change_local_user_pass_ldap ($id_user, $password) { $local_user_pass = db_get_value_filter('password', 'tusuario', array('id_user' => $id_user)); + $return = false; if (md5($password) !== $local_user_pass) { $values_update = array(); $values_update['password'] = md5($password); - db_process_sql_update('tusuario', $values_update, array('id_user' => $id_user)); + $return = db_process_sql_update('tusuario', $values_update, array('id_user' => $id_user)); } + return $return; +} + +function delete_user_pass_ldap ($id_user) { + $values_update = array(); + $values_update['password'] = null; + + $return = db_process_sql_update('tusuario', $values_update, array('id_user' => $id_user)); + return; } diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index 902e964db8..52aa2dee5c 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -23,6 +23,7 @@ class Tree { protected $filter = array(); protected $childrenMethod = "on_demand"; + protected $userGroupsACL; protected $userGroups; protected $strictACL = false; @@ -36,45 +37,54 @@ class Tree { $this->id = $id; $this->rootID = !empty($rootID) ? $rootID : $id; $this->serverID = $serverID; - $this->childrenMethod = $childrenMethod; - $this->access = $access; - - $userGroups = users_get_groups(false, $this->access); + $this->childrenMethod = $childrenMethod; + $this->access = $access; - if (empty($userGroups)) - $this->userGroups = false; - else - $this->userGroups = $userGroups; + $userGroupsACL = users_get_groups(false, $this->access); + $this->userGroupsACL = empty($userGroupsACL) ? false : $userGroupsACL; + $this->userGroups = $this->userGroupsACL; global $config; include_once($config['homedir']."/include/functions_servers.php"); include_once($config['homedir']."/include/functions_modules.php"); require_once($config['homedir']."/include/functions_tags.php"); - if (is_metaconsole()) - enterprise_include_once("meta/include/functions_ui_meta.php"); + if (is_metaconsole()) enterprise_include_once("meta/include/functions_ui_meta.php"); $this->strictACL = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']); $this->acltags = tags_get_user_module_and_tags($config['id_user'], $this->access); } - public function setType($type) { - $this->type = $type; - } - public function setFilter($filter) { + // Filter the user groups + if (!empty($filter['groupID'])) { + $group_id = $filter['groupID']; + $this->userGroups = isset($this->userGroupsACL[$group_id]) + ? array($group_id => $this->userGroupsACL[$group_id]) + : array(); + } + else if (!empty($filter['searchGroup'])) { + $groups = db_get_all_rows_filter('tgrupo', array('nombre' => '%' . $filter['searchGroup'] . '%')); + + // Save the groups which intersect + $userGroupsACL = $this->userGroupsACL; + $this->userGroups = array_reduce($groups, function ($userGroups, $group) use ($userGroupsACL) { + $group_id = $group['id_grupo']; + if (isset($userGroupsACL[$group_id])) { + $userGroups[$group_id] = $userGroupsACL[$group_id]; + } + + return $userGroups; + }, array()); + } + else { + $this->userGroups = $this->userGroupsACL; + } + $this->filter = $filter; } - public function isStrict () { - return $this->strictACL; - } - - public function setStrict ($value) { - $this->strictACL = (bool) $value; - } - protected function getAgentStatusFilter ($status = -1) { if ($status == -1) $status = $this->filter['statusAgent']; @@ -323,12 +333,23 @@ class Tree { case 'group': // ACL Group $user_groups_str = "-1"; - $group_acl = ""; + $group_filter = ""; if (!$this->strictACL) { - if (!empty($this->userGroups)) { - $user_groups_str = implode(",", array_keys($this->userGroups)); + if (empty($this->userGroups)) { + return; + } + + // Asking for a specific group. + if ($item_for_count !== false) { + if (!isset($this->userGroups[$item_for_count])) { + return; + } + } + // Asking for all groups. + else { + $user_groups_str = implode(",", array_keys($this->userGroups)); + $group_filter = "AND ta.id_grupo IN ($user_groups_str)"; } - $group_acl = "AND ta.id_grupo IN ($user_groups_str)"; } else { if (!empty($this->acltags)) { @@ -345,7 +366,7 @@ class Tree { } } } - $group_acl = "AND ta.id_grupo IN ($user_groups_str)"; + $group_filter = "AND ta.id_grupo IN ($user_groups_str)"; } switch ($type) { @@ -379,7 +400,7 @@ class Tree { $module_status_join WHERE ta.disabled = 0 AND ta.id_grupo = $item_for_count - $group_acl + $group_filter $agent_search_filter $agent_status_filter"; $sql = $this->getAgentCountersSql($agent_table); @@ -400,7 +421,7 @@ class Tree { FROM tmetaconsole_agent ta WHERE ta.disabled = 0 AND ta.id_grupo = $item_for_count - $group_acl + $group_filter $agent_search_filter $agent_status_filter"; $sql = $this->getAgentCountersSql($agent_table); @@ -428,7 +449,7 @@ class Tree { $module_status_join WHERE ta.disabled = 0 AND ta.id_grupo = $rootID - $group_acl + $group_filter $agent_search_filter $agent_status_filter GROUP BY $group_by_fields @@ -445,7 +466,7 @@ class Tree { FROM tmetaconsole_agent ta WHERE ta.disabled = 0 AND ta.id_grupo = $rootID - $group_acl + $group_filter $agent_search_filter $agent_status_filter ORDER BY $order_fields"; @@ -487,7 +508,7 @@ class Tree { ON ta.disabled = 0 AND tam.id_agente = ta.id_agente AND ta.id_grupo = $rootID - $group_acl + $group_filter $agent_search_filter $agent_status_filter WHERE tam.disabled = 0 @@ -1112,7 +1133,8 @@ class Tree { if (empty($data)) return array(); - if ($this->type == 'agent') { + // [26/10/2017] It seems the module hierarchy should be only available into the tree by group + if ($this->rootType == 'group' && $this->type == 'agent') { $data = $this->getProcessedModules($data); } @@ -1142,7 +1164,7 @@ class Tree { } // If user have not permissions in parent, set parent node to 0 (all) - $user_groups_with_privileges = users_get_groups($config['id_user']); + $user_groups_with_privileges = $this->userGroups; foreach ($groups as $id => $group) { if (!in_array($groups[$id]['parent'], array_keys($user_groups_with_privileges))) { $groups[$id]['parent'] = 0; @@ -1306,7 +1328,7 @@ class Tree { // Get the counters of the group (special case) if ($processed_item['type'] == 'group') { - $counters = $this->getCounters($item['id']); + $counters = $this->getGroupCounters($item['id']); if (!empty($counters)) { foreach ($counters as $type => $value) { $item[$type] = $value; @@ -2608,6 +2630,50 @@ class Tree { return $tree_modules; } + protected function getGroupCounters($group_id) { + global $config; + static $group_stats = false; + + # Do not use the group stat cache when using tags or real time group stats. + if ($config['realtimestats'] == 1 || (isset($this->userGroups[$group_id]['tags']) && $this->userGroups[$group_id]['tags'] != "")) { + return $this->getCounters($group_id); + } + + # Update the group stat cache. + if ( $group_stats === false) { + $group_stats = array(); + $stats = db_get_all_rows_sql('SELECT * FROM tgroup_stat'); + + foreach ($stats as $group) { + if ($group['modules'] > 0) { + $group_stats[$group['id_group']]['total_count'] = $group['modules'] > 0 ? $group['agents'] : 0; + $group_stats[$group['id_group']]['total_critical_count'] = $group['critical']; + $group_stats[$group['id_group']]['total_unknown_count'] = $group['unknown']; + $group_stats[$group['id_group']]['total_warning_count'] = $group['warning']; + $group_stats[$group['id_group']]['total_not_init_count'] = $group['non-init']; + $group_stats[$group['id_group']]['total_normal_count'] = $group['normal']; + $group_stats[$group['id_group']]['total_fired_count'] = $group['alerts_fired']; + } + # Skip groups without modules. + else { + $group_stats[$group['id_group']]['total_count'] = 0; + $group_stats[$group['id_group']]['total_critical_count'] = 0; + $group_stats[$group['id_group']]['total_unknown_count'] = 0; + $group_stats[$group['id_group']]['total_warning_count'] = 0; + $group_stats[$group['id_group']]['total_not_init_count'] = 0; + $group_stats[$group['id_group']]['total_normal_count'] = 0; + $group_stats[$group['id_group']]['total_fired_count'] = 0; + } + } + } + + if ($group_stats !== false && isset($group_stats[$group_id])) { + return $group_stats[$group_id]; + } + + return $this->getCounters($group_id); + } + static function recursive_modules_tree_view (&$new_modules, &$new_modules_child, $i, $child) { foreach ($new_modules as $index => $module) { if ($module['id'] == $child['parent']) { diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 5e2483e48c..609cde2096 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,8 +22,8 @@ /** * Pandora build version and version */ -$build_version = 'PC171018'; -$pandora_version = 'v7.0NG.713'; +$build_version = 'PC171130'; +$pandora_version = 'v7.0NG.716'; // Do not overwrite default timezone set if defined. $script_tz = @date_default_timezone_get(); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index f039a90504..901cff9eeb 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -197,6 +197,10 @@ define('SERVICE', 10); //Enterprise Item. define('GROUP_ITEM', 11); define('BOX_ITEM', 12); define('LINE_ITEM', 13); +define('CIRCULAR_PROGRESS_BAR', 15); +define('CIRCULAR_INTERIOR_PROGRESS_BAR', 16); +define('DONUT_GRAPH', 17); +define('BARS_GRAPH', 18); //Some styles define('MIN_WIDTH', 300); define('MIN_HEIGHT', 120); @@ -458,7 +462,7 @@ define("STATWIN_DEFAULT_CHART_WIDTH", 555); define("STATWIN_DEFAULT_CHART_HEIGHT", 245); /* Dashboard */ -define("DASHBOARD_DEFAULT_COUNT_CELLS", 4); +define("DASHBOARD_DEFAULT_COUNT_CELLS", 1); define("OPTION_TEXT", 1); define("OPTION_SINGLE_SELECT", 2); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index f8edfd1d27..4edfe2c512 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1594,7 +1594,7 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', case '2c': case '1': default: - $command_str = $snmpwalk_bin . ' -m ALL -Oa -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg($snmp_community) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir; + $command_str = $snmpwalk_bin . ' -m ALL -Oa -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg(io_safe_output($snmp_community)) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir; break; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 838fb58d55..9c38157300 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -55,6 +55,17 @@ function agents_get_agent_id_by_module_id ($id_agente_modulo) { 'id_agente_modulo', $id_agente_modulo); } +/** + * Get agent id from an agent alias. + * + * @param string $alias Agent alias. + * + * @return int Id from the agent. + */ +function agents_get_agent_id_by_alias ($alias) { + return db_get_all_rows_sql ("SELECT id_agente FROM tagente WHERE upper(alias) LIKE upper('%$alias%')"); +} + /** * Creates an agent * @@ -314,6 +325,13 @@ function agents_get_agents ($filter = false, $fields = false, $search = ''; } + if (isset($filter['search_custom'])) { + $search_custom = $filter['search_custom']; + unset($filter['search_custom']); + } else { + $search_custom = ''; + } + if (isset($filter['offset'])) { $offset = $filter['offset']; unset($filter['offset']); @@ -450,8 +468,8 @@ function agents_get_agents ($filter = false, $fields = false, $sql_extra, $where, $where_nogroup, $status_sql, $search, $disabled); } else { - $where = sprintf('%s AND %s AND (%s) %s AND %s', - $where, $where_nogroup, $status_sql, $search, $disabled); + $where = sprintf('%s AND %s AND (%s) %s AND %s %s', + $where, $where_nogroup, $status_sql, $search, $disabled, $search_custom); } $sql = sprintf('SELECT %s FROM tagente diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 8e87eee5b3..577dfe82f1 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1039,14 +1039,16 @@ function alerts_delete_alert_agent_module ($id_alert_agent_module, $filter = fal $filter = array (); if ($id_alert_agent_module) $filter['id'] = $id_alert_agent_module; - - // Get the modules of the fired alerts that will be deleted to update counts - $filter_get = $filter; - - $filter_get['group'] = 'id_agent_module'; - $filter_get['times_fired'] = '>0'; - - $fired_alert_modules = db_get_all_rows_filter('talert_template_modules', $filter_get, array('id_agent_module', 'COUNT(*) alerts')); + + // Get the id agent to update the fired alert counts + $agent_id = false; + if (isset ($filter['id_agent_module'])){ + $agent_id = modules_get_agentmodule_agent ($filter["id_agent_module"]); + } + else if (isset ($filter['id'])){ + $alert = alerts_get_alert_agent_module($id_alert_agent_module); + $agent_id = modules_get_agentmodule_agent ($alert["id_agent_module"]); + } /* The deletion of actions from talert_template_module_actions, @@ -1054,6 +1056,11 @@ function alerts_delete_alert_agent_module ($id_alert_agent_module, $filter = fal a foreing key and delete on cascade. */ if (@db_process_sql_delete ('talert_template_modules', $filter) !== false) { + // Update fired alert count on the agent + // It will only occur if is specified the alert id or the id_agent_module + if ($agent_id !== false) { + db_process_sql(sprintf('UPDATE tagente SET update_alert_count=1 WHERE id_agente = %d', $agent_id)); + } return true; } diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 5ecac3a944..c1c7c9ca50 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -8531,7 +8531,7 @@ function api_set_enable_module ($agent_name, $module_name, $thrast3, $thrash4) { * @param string $template_name Name of the alert template (for example, "Warning event") * @param $thrash4 Don't use. -// http://localhost/pandora_console/include/api.php?op=set&op2=disable_alert&id=garfio&id2=Status&other=Warning%20condition +// http://localhost/pandora_console/include/api.php?op=set&op2=disable_alert&id=c2cea5860613e363e25f4ba185b54fe28f869ff8a5e8bb46343288337c903531&id2=Status&other=Warning%20condition */ function api_set_disable_alert ($agent_name, $module_name, $template_name, $thrash4) { @@ -8543,11 +8543,53 @@ function api_set_disable_alert ($agent_name, $module_name, $template_name, $thra $id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent, 'nombre' => $module_name)); $id_template = db_get_value_filter('id', 'talert_templates', array('name' => $template_name["data"])); - db_process_sql("UPDATE talert_template_modules + $result = db_process_sql("UPDATE talert_template_modules SET disabled = 1 WHERE id_agent_module = $id_agent_module AND id_alert_template = $id_template"); - returnData('string', array('type' => 'string', 'data' => "Correct alert disable")); + if ($result) { + returnData('string', array('type' => 'string', 'data' => "Correct alert disable")); + } else { + returnData('string', array('type' => 'string', 'data' => __('Error alert disable'))); + } +} + + +/** + * Disable an alert with alias + * + * @param string $agent_alias Alias of agent (for example "myagent") + * @param string $module_name Name of the module (for example "Host alive") + * @param string $template_name Name of the alert template (for example, "Warning event") + * @param $thrash4 Don't use. + +// http://localhost/pandora_console/include/api.php?op=set&op2=disable_alert_alias&id=garfio&id2=Status&other=Warning%20condition + */ + +function api_set_disable_alert_alias ($agent_alias, $module_name, $template_name, $thrash4) { + if (defined ('METACONSOLE')) { + return; + } + + $agent_id = agents_get_agent_id_by_alias($agent_alias); + $result = false; + foreach ($agent_id as $key => $id_agent) { + $id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent['id_agente'], 'nombre' => $module_name)); + $id_template = db_get_value_filter('id', 'talert_templates', array('name' => $template_name["data"])); + + $result = db_process_sql("UPDATE talert_template_modules + SET disabled = 1 + WHERE id_agent_module = $id_agent_module AND id_alert_template = $id_template"); + + if ($result) { + returnData('string', array('type' => 'string', 'data' => "Correct alert disable")); + return; + } + } + + if(!$result){ + returnData('string', array('type' => 'string', 'data' => __('Error alert disable'))); + } } /** diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 06f0d090b5..30078c5685 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -343,9 +343,23 @@ function config_update_config () { $error_update[] = __('Base DN'); if (!config_update_value ('ldap_login_attr', get_parameter ('ldap_login_attr'))) $error_update[] = __('Login attribute'); + if (!config_update_value ('ldap_admin_login', get_parameter ('ldap_admin_login'))) + $error_update[] = __('Admin LDAP login'); + if (!config_update_value ('ldap_admin_pass', get_parameter ('ldap_admin_pass'))) + $error_update[] = __('Admin LDAP password'); if (!config_update_value ('fallback_local_auth', get_parameter ('fallback_local_auth'))) $error_update[] = __('Fallback to local authentication'); - + if (!config_update_value ('ldap_login_user_attr', get_parameter ('ldap_login_user_attr'))) + $error_update[] = __('Login user attribute'); + + if (isset($config['fallback_local_auth']) && $config['fallback_local_auth'] == 0) { + if (!config_update_value ('ldap_save_password', get_parameter ('ldap_save_password'))) + $error_update[] = __('Save Password'); + } + else if (isset($config['fallback_local_auth']) && $config['fallback_local_auth'] == 1) { + config_update_value ('ldap_save_password', 1); + } + if (!config_update_value ('rpandora_server', get_parameter ('rpandora_server'))) $error_update[] = __('MySQL host'); if (!config_update_value ('rpandora_port', get_parameter ('rpandora_port'))) @@ -1348,6 +1362,14 @@ function config_process_config () { if (!isset ($config['ldap_login_attr'])) { config_update_value ( 'ldap_login_attr', 'uid'); } + + if (!isset ($config['ldap_admin_login'])) { + config_update_value ( 'ldap_admin_login', ''); + } + + if (!isset ($config['ldap_admin_pass'])) { + config_update_value ( 'ldap_admin_pass', ''); + } if (!isset ($config['fallback_local_auth'])) { config_update_value ( 'fallback_local_auth', '0'); diff --git a/pandora_console/include/functions_cron.php b/pandora_console/include/functions_cron.php index cf131eac8e..efa5f2f342 100644 --- a/pandora_console/include/functions_cron.php +++ b/pandora_console/include/functions_cron.php @@ -30,24 +30,30 @@ function cron_update_module_interval ($module_id, $cron) { $module_interval = db_get_value_filter('module_interval','tagente_modulo',array("id_agente_modulo" => $module_id)); return db_process_sql ('UPDATE tagente_estado SET current_interval = ' . $module_interval . ' WHERE id_agente_modulo = ' . (int) $module_id); } else { - return db_process_sql ('UPDATE tagente_estado SET current_interval = ' . cron_next_execution ($cron) . ' WHERE id_agente_modulo = ' . (int) $module_id); + return db_process_sql ( + 'UPDATE tagente_estado SET current_interval = ' . + cron_next_execution ($cron, $module_interval, $module_id) . + ' WHERE id_agente_modulo = ' . + (int) $module_id) + ; } } // Get the number of seconds left to the next execution of the given cron entry. -function cron_next_execution ($cron) { +function cron_next_execution ($cron, $module_interval, $module_id) { // Get day of the week and month from cron config list ($minute, $hour, $mday, $month, $wday) = explode (" ", $cron); - // Get current time - $cur_time = time(); + // Get last execution time + $last_execution = db_get_value('utimestamp', 'tagente_estado', 'id_agente_modulo', $module_id); + $cur_time = ($last_execution !== false) ? $last_execution : time(); // Any day of the way if ($wday == '*') { - $nex_time = cron_next_execution_date ($cron, $cur_time); + $nex_time = cron_next_execution_date ($cron, $cur_time, $module_interval); return $nex_time - $cur_time; } @@ -55,7 +61,7 @@ function cron_next_execution ($cron) { $count = 0; $nex_time = $cur_time; do { - $nex_time = cron_next_execution_date ($cron, $nex_time); + $nex_time = cron_next_execution_date ($cron, $nex_time, $module_interval); $nex_time_wd = $nex_time; list ($nex_mon, $nex_wday) = explode (" ", date ("m w", $nex_time_wd)); @@ -80,90 +86,202 @@ function cron_next_execution ($cron) { } // Get the next execution date for the given cron entry in seconds since epoch. -function cron_next_execution_date ($cron, $cur_time = false) { +function cron_next_execution_date ($cron, $cur_time = false, $module_interval = 300) { // Get cron configuration - list ($min, $hour, $mday, $mon, $wday) = explode (" ", $cron); - + $cron_array = explode (" ", $cron); // Months start from 0 - if ($mon != '*') { - $mon -= 1; + if ($cron_array[3] != '*') { + $mon_s = cron_get_interval ($cron_array[3]); + if ($mon_s['up'] !== false) { + $cron_array[3] = $mon_s['down'] - 1 . "-" . $mon_s['up'] - 1; + } else { + $cron_array[3] = $mon_s['down'] - 1; + } } // Get current time - if ($cur_time === false) { - $cur_time = time(); - } - list ($cur_min, $cur_hour, $cur_mday, $cur_mon, $cur_year) = explode (" ", date ("i H d m Y", $cur_time)); + if ($cur_time === false) $cur_time = time(); + + $nex_time = $cur_time + $module_interval; + $nex_time_array = explode (" ", date ("i H d m Y", $nex_time)); + if (cron_is_in_cron($cron_array, $nex_time_array)) return $nex_time; - // Get first next date candidate from cron configuration - $nex_min = $min; - $nex_hour = $hour; - $nex_mday = $mday; - $nex_mon = $mon; - $nex_year = $cur_year; + // Get first next date candidate from next cron configuration + // Initialize some vars + $prev_ovfl = false; + + // Update minutes + $min_s = cron_get_interval ($cron_array[0]); + $nex_time_array[0] = ($min_s['down'] == '*') ? 0 : $min_s['down']; - // Replace wildcards - if ($min == '*') { - if ($hour != '*' || $mday != '*' || $wday != '*' || $mon != '*') { - $nex_min = 0; - } - else { - $nex_min = $cur_min; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time >= $cur_time) { + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; } } - if ($hour == '*') { - if ($mday != '*' || $wday != '*' ||$mon != '*') { - $nex_hour = 0; - } - else { - $nex_hour = $cur_hour; - } - } - if ($mday == '*') { - if ($mon != '*') { - $nex_mday = 1; - } - else { - $nex_mday = $cur_mday; - } - } - if ($mon == '*') { - $nex_mon = $cur_mon; - } - - // Find the next execution date - $count = 0; - do { - $next_time = mktime($nex_hour, $nex_min, 0, $nex_mon, $nex_mday, $nex_year); - if ($next_time > $cur_time) { - return $next_time; - } - if ($min == '*' && $hour == '*' && $wday == '*' && $mday == '*' && $mon == '*') { - list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + SECONDS_1MINUTE)); - } - else if ($hour == '*' && $wday == '*' && $mday == '*' && $mon == '*') { - list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + SECONDS_1HOUR)); - } - else if ($mday == '*' && $mon == '*') { - list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + SECONDS_1DAY)); - } - else if ($mon == '*') { - $nex_mon = $nex_mon + 1; - if ($nex_mon > 11) { - $nex_mon = 0; - $nex_year++; + + // Check if next hour is in cron + $nex_time_array[1]++; + $nex_time = cron_valid_date($nex_time_array); + + if ($nex_time === false) { + // Update the month day if overflow + $prev_ovfl = true; + $nex_time_array[1] = 0; + $nex_time_array[2]++; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time === false) { + // Update the month if overflow + $nex_time_array[2] = 1; + $nex_time_array[3]++; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time === false) { + #Update the year if overflow + $nex_time_array[3] = 0; + $nex_time_array[4]++; + $nex_time = cron_valid_date($nex_time_array); } } - else { - $nex_year++; - } - $count++; } - while ($count < SECONDS_1DAY); + // Check the hour + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + + // Update the hour if fails + $hour_s = cron_get_interval ($cron_array[1]); + $nex_time_array[1] = ($hour_s['down'] == '*') ? 0 : $hour_s['down']; + + // When an overflow is passed check the hour update again + if ($prev_ovfl) { + $nex_time = cron_valid_date($nex_time_array); + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + } + $prev_ovfl = false; + + // Check if next day is in cron + $nex_time_array[2]++; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time === false) { + // Update the month if overflow + $prev_ovfl = true; + $nex_time_array[2] = 1; + $nex_time_array[3]++; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time === false) { + // Update the year if overflow + $nex_time_array[3] = 0; + $nex_time_array[4]++; + $nex_time = cron_valid_date($nex_time_array); + } + } + // Check the day + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + + // Update the day if fails + $mday_s = cron_get_interval ($cron_array[2]); + $nex_time_array[2] = ($mday_s['down'] == '*') ? 1 : $mday_s['down']; + + // When an overflow is passed check the hour update in the next execution + if ($prev_ovfl) { + $nex_time = cron_valid_date($nex_time_array); + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + } + $prev_ovfl = false; + + // Check if next month is in cron + $nex_time_array[3]++; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time === false) { + #Update the year if overflow + $prev_ovfl = true; + $nex_time_array[3]++; + $nex_time = cron_valid_date($nex_time_array); + } + + // Check the month + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + + // Update the month if fails + $mon_s = cron_get_interval ($cron_array[3]); + $nex_time_array[3] = ($mon_s['down'] == '*') ? 0 : $mon_s['down']; + + // When an overflow is passed check the hour update in the next execution + if ($prev_ovfl) { + $nex_time = cron_valid_date($nex_time_array); + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + } + + // Update the year + $nex_time_array[4]++; + $nex_time = cron_valid_date($nex_time_array); + + return ($nex_time !== false) ? $nex_time : $module_interval; +} + +// Get an array with the cron interval +function cron_get_interval ($element) { + # Not a range + if (!preg_match('/(\d+)\-(\d+)/', $element, $capture)) { + return array( + 'down' => $element, + 'up' => false + ); + } + return array( + 'down' => $capture[1], + 'up' => $capture[2] + ); +} + +// Returns if a date is in a cron. Recursive. +function cron_is_in_cron($elems_cron, $elems_curr_time) { - // Something went wrong, default to 5 minutes - return $cur_time + SECONDS_5MINUTES; + $elem_cron = array_shift($elems_cron); + $elem_curr_time = array_shift($elems_curr_time); + + // If there is no elements means that is in cron + if ($elem_cron === null || $elem_curr_time === null) return true; + + // Go to last element if current is a wild card + if ($elem_cron != '*') { + $elem_s = cron_get_interval($elem_cron); + // Check if there is no a range + if (($elem_s['up'] === false) && ($elem_s['down'] != $elem_curr_time)) { + return false; + } + // Check if there is on the range + if ($elem_s['up'] !== false) { + if ($elem_s['down'] < $elem_s['up']) { + if ($elem_curr_time < $elem_s['down'] || $elem_curr_time > $elem_s['up']){ + return false; + } + } else { + if ($elem_curr_time > $elem_s['down'] || $elem_curr_time < $elem_s['up']){ + return false; + } + } + } + } + return cron_is_in_cron($elems_cron, $elems_curr_time); +} + +function cron_valid_date ($da) { + $st = sprintf("%04d:%02d:%02d %02d:%02d:00", $da[4], $da[3], $da[2], $da[1], $da[0]); + $time = strtotime($st); + return $time; } // Check if cron is properly constructed diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 06c85ef194..70395cb205 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -81,7 +81,7 @@ function db_connect($host = null, $db = null, $user = null, $pass = null, $port $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; $config['homedir'] = $ownDir; $login_screen = 'error_authconfig'; - require($config['homedir'] . '/general/error_screen.php'); + require($config['homedir'] . '../general/error_screen.php'); exit; } else if ($error == 0) { diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 763f246bdf..58c11b1cc9 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2080,7 +2080,7 @@ function events_page_details ($event, $server = "") { } else { $module_group = db_get_value('name', 'tmodule_group', 'id_mg', $id_module_group); - $data[1] = ''; + $data[1] = ''; $data[1] .= $module_group; $data[1] .= ''; } diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index 5e0ef6c718..a27d7d2ec2 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -151,7 +151,7 @@ if ($upload_file) { check_login (); - if (! check_acl ($config['id_user'], 0, "PM")) { + if (! check_acl ($config['id_user'], 0, "AW")) { db_pandora_audit("ACL Violation", "Trying to access File manager"); require ("general/noaccess.php"); return; @@ -219,7 +219,7 @@ if ($create_text_file) { check_login (); - if (! check_acl ($config['id_user'], 0, "PM")) { + if (! check_acl ($config['id_user'], 0, "AW")) { db_pandora_audit("ACL Violation", "Trying to access File manager"); require ("general/noaccess.php"); return; @@ -279,7 +279,7 @@ if ($upload_zip) { check_login (); - if (! check_acl ($config['id_user'], 0, "PM")) { + if (! check_acl ($config['id_user'], 0, "AW")) { db_pandora_audit("ACL Violation", "Trying to access File manager"); require ("general/noaccess.php"); return; @@ -720,6 +720,17 @@ function filemanager_file_explorer($real_directory, $relative_directory, $hash = md5($relative_path . $config['dbpass']); $data[1] = ''.$fileinfo['name'].''; } + + // Notice that uploaded php files could be dangerous + if (pathinfo($fileinfo['realpath'], PATHINFO_EXTENSION) == 'php' && + (is_readable($fileinfo['realpath']) || is_executable($fileinfo['realpath']))) { + $error_message = __('This file could be executed by any user'); + $error_message .= '. ' . __('Make sure it can\'t perform dangerous tasks'); + $data[1] = '' + . $data[1] + . ''; + } + $data[2] = ui_print_timestamp ($fileinfo['last_modified'], true, array ('prominent' => true)); if ($fileinfo['is_dir']) { diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index c97867733b..3a063da403 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -232,8 +232,8 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i $projection, $avg_only = false, $uncompressed_module = false, $show_events = false, $show_alerts = false, $show_unknown = false, $baseline = false, $baseline_data = array(), $events = array(), $series_suffix = '', $start_unknown = false, - $percentil = null, $fullscale = false) { - + $percentil = null, $fullscale = false, $force_interval = false,$time_interval = 300, + $max_only = 0, $min_only = 0) { global $config; global $chart_extra_data; global $series_type; @@ -413,10 +413,17 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i } if ($count > 0) { + if ($avg_only) { $chart[$timestamp]['sum'.$series_suffix] = $total; } - else { + else if($max_only){ + $chart[$timestamp]['max'.$series_suffix] = $interval_max; + } + else if($min_only){ + $chart[$timestamp]['min'.$series_suffix] = $interval_min; + } + else{ $chart[$timestamp]['max'.$series_suffix] = $interval_max; $chart[$timestamp]['sum'.$series_suffix] = $total; $chart[$timestamp]['min'.$series_suffix] = $interval_min; @@ -428,7 +435,13 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i if ($avg_only) { $chart[$timestamp]['sum'.$series_suffix] = 0; } - else { + else if($max_only){ + $chart[$timestamp]['max'.$series_suffix] = 0; + } + else if($min_only){ + $chart[$timestamp]['min'.$series_suffix] = 0; + } + else{ $chart[$timestamp]['max'.$series_suffix] = 0; $chart[$timestamp]['sum'.$series_suffix] = 0; $chart[$timestamp]['min'.$series_suffix] = 0; @@ -438,6 +451,12 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i if ($avg_only) { $chart[$timestamp]['sum'.$series_suffix] = $last_known; } + else if ($max_only) { + $chart[$timestamp]['max'.$series_suffix] = $last_known; + } + else if ($min_only) { + $chart[$timestamp]['min'.$series_suffix] = $last_known; + } else { $chart[$timestamp]['max'.$series_suffix] = $last_known; $chart[$timestamp]['sum'.$series_suffix] = $last_known; @@ -502,8 +521,9 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $baseline = 0, $return_data = 0, $show_title = true, $projection = false, $adapt_key = '', $compare = false, $series_suffix = '', $series_suffix_str = '', $show_unknown = false, $percentil = null, $dashboard = false, $vconsole = false, - $type_graph='area', $fullscale = false, $flash_chart = false) { - + $type_graph='area', $fullscale = false, $flash_chart = false, $force_interval = false,$time_interval = 300, + $max_only = 0, $min_only = 0) { + global $config; global $chart; global $color; @@ -529,8 +549,23 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, if ($date == 0) $date = get_system_time(); $datelimit = $date - $period; $search_in_history_db = db_search_in_history_db($datelimit); - $resolution = $config['graph_res'] * 50; //Number of points of the graph - $interval = (int) ($period / $resolution); + + + + if($force_interval){ + $resolution = $period/$time_interval; + } + else{ + $resolution = $config['graph_res'] * 50; //Number of points of the graph + } + + if($force_interval){ + $interval = $time_interval; + } + else{ + $interval = (int) ($period / $resolution); + } + $agent_name = modules_get_agentmodule_agent_name ($agent_module_id); $agent_id = agents_get_agent_id ($agent_name); $module_name = modules_get_agentmodule_name ($agent_module_id); @@ -718,7 +753,8 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $projection, $avg_only, $uncompressed_module, $show_events, $show_alerts, $show_unknown, $baseline, $baseline_data, $events, $series_suffix, $start_unknown, - $percentil, $fullscale); + $percentil, $fullscale, $force_interval, $time_interval, + $max_only, $min_only); } // Return chart data and don't draw @@ -843,6 +879,19 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $legend['percentil'.$series_suffix] = __('Percentile %dº', $percentil) .$series_suffix_str . " (" . $percentil_value . " " . $unit . ") "; $chart_extra_data['legend_percentil'] = $legend['percentil'.$series_suffix_str]; } + + if($force_interval){ + $legend = array(); + if($avg_only){ + $legend['sum'.$series_suffix] = __('Avg'); + } + elseif ($max_only) { + $legend['min'.$series_suffix] = __('Max'); + } + elseif ($min_only) { + $legend['max'.$series_suffix] = __('Min'); + } + } } function grafico_modulo_sparse ($agent_module_id, $period, $show_events, @@ -853,8 +902,10 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $adapt_key = '', $compare = false, $show_unknown = false, $menu = true, $backgroundColor = 'white', $percentil = null, $dashboard = false, $vconsole = false, $type_graph = 'area', $fullscale = false, - $id_widget_dashboard = false) { - + $id_widget_dashboard = false,$force_interval = 0,$time_interval = 300, + $max_only = 0, $min_only = 0) { + + global $config; global $graphic_type; @@ -884,7 +935,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $return_data, $show_title, $projection, $adapt_key, $compare, $series_suffix, $series_suffix_str, $show_unknown, $percentil, $dashboard, $vconsole,$type_graph, - $fullscale, $flash_chart); + $fullscale, $flash_chart,$force_interval,$time_interval,$max_only,$min_only); switch ($compare) { case 'separated': @@ -917,7 +968,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $show_alerts, $avg_only, $date, $unit, $baseline, $return_data, $show_title, $projection, $adapt_key, $compare, '', '', $show_unknown, - $percentil, $dashboard, $vconsole, $type_graph, $fullscale, $flash_chart); + $percentil, $dashboard, $vconsole, $type_graph, $fullscale,$flash_chart, + $force_interval,$time_interval,$max_only,$min_only); + if ($return_data) { return $data_returned; } @@ -949,7 +1002,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, return area_graph($flash_chart, $chart, $width, $height/2, $color, $legend, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $series_type, $chart_extra_data, $warning_min, $critical_min, @@ -958,7 +1011,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, '
'. area_graph($flash_chart, $chart_prev, $width, $height/2, $color_prev, $legend_prev, $long_index_prev, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $series_type_prev, $chart_extra_data, $warning_min, $critical_min, @@ -977,7 +1030,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, return area_graph($flash_chart, $chart, $width, $height, $color, $legend, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $series_type, $chart_extra_data, $warning_min, $critical_min, @@ -990,13 +1043,13 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, return line_graph($flash_chart, $chart, $width, $height/2, $color, $legend, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor). '
'. line_graph($flash_chart, $chart_prev, $width, $height/2, $color, $legend, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); } @@ -1005,7 +1058,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, return line_graph($flash_chart, $chart, $width, $height, $color, $legend, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); } @@ -1069,6 +1122,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, if(!$fullscale){ $time_format_2 = ''; $temp_range = $period; + $unit_list_aux = array(); if ($projection != false) { if ($period < $prediction_period) @@ -1317,6 +1371,10 @@ function graphic_combined_module ($module_list, $weight_list, $period, $agent_id = agents_get_agent_id ($agent_name); + if(empty($unit_list)){ + $unit_aux = modules_get_unit($agent_module_id); + array_push($unit_list_aux,$unit_aux); + } //Get and process module name $module_name = io_safe_output( modules_get_agentmodule_name ($agent_module_id)); @@ -1500,6 +1558,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, if (!empty($unit_list) && $units_number == $module_number && isset($unit_list[$i])) { $unit = $unit_list[$i]; + }else{ + $unit = $unit_list_aux[$i]; } if ($projection == false or ($projection != false and $i == 0)) { @@ -2059,7 +2119,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, case CUSTOM_GRAPH_AREA: return area_graph($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, "", $homeurl, $water_mark, $config['fontpath'], $fixed_font_size, $unit, $ttl, array(), array(), $yellow_threshold, $red_threshold, '', false, '', true, $background_color,$dashboard, $vconsole, 0, $percentil_result, $threshold_data); @@ -2068,14 +2128,14 @@ function graphic_combined_module ($module_list, $weight_list, $period, case CUSTOM_GRAPH_STACKED_AREA: return stacked_area_graph($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, "", $water_mark, $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl, $background_color,$dashboard, $vconsole); break; case CUSTOM_GRAPH_LINE: return line_graph($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, "", $water_mark, $config['fontpath'], $fixed_font_size, $unit, $ttl, $homeurl, $background_color, $dashboard, $vconsole, $series_type, $percentil_result, $yellow_threshold, $red_threshold, $threshold_data); @@ -2083,7 +2143,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, case CUSTOM_GRAPH_STACKED_LINE: return stacked_line_graph($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", "", $water_mark, $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl, $background_color, $dashboard, $vconsole); break; @@ -2091,35 +2151,35 @@ function graphic_combined_module ($module_list, $weight_list, $period, case CUSTOM_GRAPH_BULLET_CHART: return stacked_bullet_chart($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", "", $water_mark, $config['fontpath'], ($config['font_size']+1), "", $ttl, $homeurl, $background_color); break; case CUSTOM_GRAPH_GAUGE: return stacked_gauge($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", "", $water_mark, $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl, $background_color); break; case CUSTOM_GRAPH_HBARS: return hbar_graph($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", "", $water_mark, $config['fontpath'], $fixed_font_size, - "", $ttl, $homeurl, $background_color); + "", $ttl, $homeurl, $background_color, 'black'); break; case CUSTOM_GRAPH_VBARS: return vbar_graph($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", "", $water_mark, $config['fontpath'], $fixed_font_size, - "", $ttl, $homeurl, $background_color, true); + "", $ttl, $homeurl, $background_color, true, false, "black"); break; case CUSTOM_GRAPH_PIE: return ring_graph($flash_charts, $graph_values, $width, $height, $others_str, $homeurl, $water_mark, $config['fontpath'], - ($config['font_size']+1), $ttl, false, $color, false); + ($config['font_size']+1), $ttl, false, $color, false,$background_color); break; } } @@ -2235,7 +2295,7 @@ function graphic_agentaccess ($id_agent, $width, $height, $period = 0, $return = } else { $out = area_graph($config['flash_charts'], $data, $width, $height, null, null, null, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", "", ui_get_full_url(false, false, false, false), $water_mark, $config['fontpath'], $config['font_size'], "", 1, array(), array(), 0, 0, '', false, '', false); } @@ -2457,10 +2517,10 @@ function progress_bar($progress, $width, $height, $title = '', $mode = 1, $value require_once("include_graph_dependencies.php"); include_graphs_dependencies($config['homedir'].'/'); $src = ui_get_full_url( - "/include/graphs/fgraph.php?homeurl=../../&graph_type=progressbar" . - "&width=".$width."&homedir=".$config['homedir']."&height=".$height."&progress=".$progress. + "/include/graphs/fgraph.php?graph_type=progressbar" . + "&width=".$width."&height=".$height."&progress=".$progress. "&mode=" . $mode . "&out_of_lim_str=".$out_of_lim_str . - "&title=".$title."&font=".$config['fontpath']."&value_text=". $value_text . + "&title=".$title."&value_text=". $value_text . "&colorRGB=". $colorRGB, false, false, false ); @@ -2492,10 +2552,10 @@ function progress_bubble($progress, $width, $height, $title = '', $mode = 1, $va include_graphs_dependencies($config['homedir'].'/'); return "" . $title . ""; } @@ -2704,7 +2764,7 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) { || (empty($num_1day) && empty($num_1week) && empty($num_1month) && empty($num_3months) && empty($num_all) && ($config['history_db_enabled'] == 1 && empty($num_all_w_history)))) { - return html_print_image('images/image_problem.png', true); + return html_print_image('images/image_problem_area_small.png', true); } // Data indexes @@ -2779,7 +2839,9 @@ function grafico_db_agentes_paquetes($width = 380, $height = 300) { return hbar_graph($config['flash_charts'], $data, $width, $height, array(), $legend, "", "", true, "", $water_mark, - $config['fontpath'], $config['font_size'], false); + $config['fontpath'], $config['font_size'], false, 1, $config['homeurl'], + 'white', + 'black'); } /** @@ -2846,7 +2908,9 @@ function graph_db_agentes_modulos($width, $height) { $data, $width, $height, array(), array(), "", "", true, "", $water_mark, - $config['fontpath'], $config['font_size'], false); + $config['fontpath'], $config['font_size'], false, 1, $config['homeurl'], + 'white', + 'black'); } /** @@ -3284,11 +3348,11 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = } else { if ($meta) { - $name = mb_substr (io_safe_output($row['agent_name']), 0, 14)." (".$row["count"].")"; + $name = mb_substr (io_safe_output($row['agent_name']), 0, 25)." (".$row["count"].")"; } else { $alias = agents_get_alias($row["id_agente"]); - $name = mb_substr($alias, 0, 14)." #".$row["id_agente"]." (".$row["count"].")"; + $name = mb_substr($alias, 0, 25)." #".$row["id_agente"]." (".$row["count"].")"; } $data[$name] = $row["count"]; } @@ -3621,12 +3685,14 @@ function graph_custom_sql_graph ($id, $width, $height, case 'sql_graph_vbar': // vertical bar return vbar_graph($flash_charts, $data, $width, $height, array(), array(), "", "", $homeurl, $water_mark, - $config['fontpath'], $config['font_size'], false, $ttl); + $config['fontpath'], $config['font_size'], false, $ttl, "", "white", false, false, "black"); break; case 'sql_graph_hbar': // horizontal bar return hbar_graph($flash_charts, $data, $width, $height, array(), array(), "", "", true, $homeurl, $water_mark, - $config['fontpath'], $config['font_size'], false, $ttl); + $config['fontpath'], $config['font_size'], false, $ttl,$config['homeurl'], + 'white', + 'black'); break; case 'sql_graph_pie': // Pie return pie3d_graph($flash_charts, $data, $width, $height, __("other"), $homeurl, @@ -4521,20 +4587,20 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, if ($type_graph === 'area') { if ($compare === 'separated') { return area_graph($flash_chart, $chart, $width, $height/2, $color, $legend, - $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), + $long_index, ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, 1, $series_type, $chart_extra_data, 0, 0, $adapt_key, false, $series_suffix_str, $menu). '
'. area_graph($flash_chart, $chart_prev, $width, $height/2, $color_prev, $legend_prev, - $long_index_prev, ui_get_full_url("images/image_problem.opaque.png", false, false, false), + $long_index_prev, ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, 1, $series_type_prev, $chart_extra_data_prev, 0, 0, $adapt_key, false, $series_suffix_str, $menu); } else { return area_graph($flash_chart, $chart, $width, $height, $color, $legend, - $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), + $long_index, ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, 1, $series_type, $chart_extra_data, 0, 0, $adapt_key, false, $series_suffix_str, $menu); @@ -4545,13 +4611,13 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, return line_graph($flash_chart, $chart, $width, $height/2, $color, $legend, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor). '
'. line_graph($flash_chart, $chart_prev, $width, $height/2, $color, $legend, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); } @@ -4560,7 +4626,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, return line_graph($flash_chart, $chart, $width, $height, $color, $legend, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); } @@ -4691,7 +4757,7 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $unit = return area_graph($flash_chart, $chart, $width, $height, $color, - $sources, array (), ui_get_full_url("images/image_problem.opaque.png", false, false, false), + $sources, array (), ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", $unit, $homeurl, $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], $unit, $ttl); @@ -4776,7 +4842,7 @@ function graph_netflow_total_area ($data, $period, $width, $height, $unit = '', $legend = array (__('Max.') . ' ' . format_numeric($max) . ' ' . __('Min.') . ' ' . format_numeric($min) . ' ' . __('Avg.') . ' ' . format_numeric ($avg)); return area_graph($flash_chart, $chart, $width, $height, array (), $legend, - array (), ui_get_full_url("images/image_problem.opaque.png", false, false, false), + array (), ui_get_full_url("images/image_problem_area_small.png", false, false, false), "", "", $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl); } @@ -5152,7 +5218,7 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events, return line_graph($flash_chart, $chart, $width, $height, $color, $legend, $long_index, - ui_get_full_url("images/image_problem.opaque.png", false, false, false), + ui_get_full_url("images/image_problem_area_small.png", false, false, false), $title, $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); } @@ -5663,7 +5729,7 @@ function grafico_modulo_log4x_format_y_axis ( $number , $decimals=2, $dec_point= } function graph_nodata_image($width = 300, $height = 110, $type = 'area', $text = '') { - $image = ui_get_full_url('images/image_problem_' . $type . '.png', + $image = ui_get_full_url('images/image_problem_area_small.png', false, false, false); // if ($text == '') { @@ -5743,18 +5809,41 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { $filter_module_group = (!empty($filter) && !empty($filter['module_group'])) ? $filter['module_group'] : false; - $groups = users_get_groups(false, "AR", false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null)); + if ($filter['group'] != 0) { + $groups = db_get_all_rows_sql ("SELECT * FROM tgrupo where id_grupo = " . $filter['group'] . " || parent = " . $filter['group']); + $groups_ax = array(); + foreach ($groups as $g) { + $groups_ax[$g['id_grupo']] = $g; + } + + $groups = $groups_ax; + } + else { + $groups = users_get_groups(false, "AR", false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null)); + } + $data_groups = array(); if (!empty($groups)) { $groups_aux = $groups; - $data_groups = groups_get_tree($groups); + + //$data_groups = groups_get_tree($groups); + + $childrens = array(); + $data_groups = groups_get_tree_good($groups, false, $childrens); + foreach ($childrens as $id_c) { + unset($data_groups[$id_c]); + } + $data_groups_keys = array(); + groups_get_tree_keys($data_groups, $data_groups_keys); + $groups_aux = null; } if (!empty($data_groups)) { - $filter = array('id_grupo' => array_keys($data_groups)); - $fields = array('id_agente', 'id_parent', 'id_grupo', 'nombre'); + $filter = array('id_grupo' => array_keys($data_groups_keys)); + + $fields = array('id_agente', 'id_parent', 'id_grupo', 'alias'); $agents = agents_get_agents($filter, $fields); if (!empty($agents)) { @@ -5787,7 +5876,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { if (!isset($data_agents[$agent_id])) { $data_agents[$agent_id] = array(); $data_agents[$agent_id]['id'] = $agent_id; - $data_agents[$agent_id]['name'] = io_safe_output($agents[$agent_id]['nombre']); + $data_agents[$agent_id]['name'] = io_safe_output($agents[$agent_id]['alias']); $data_agents[$agent_id]['group'] = (int) $agents[$agent_id]['id_grupo']; $data_agents[$agent_id]['type'] = 'agent'; $data_agents[$agent_id]['size'] = 30; @@ -5960,7 +6049,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { if (!isset($data_agents[$id])) { $data_agents[$id] = array(); $data_agents[$id]['id'] = (int) $id; - $data_agents[$id]['name'] = io_safe_output($agent['nombre']); + $data_agents[$id]['name'] = io_safe_output($agent['alias']); $data_agents[$id]['type'] = 'agent'; $data_agents[$id]['color'] = COL_NOTINIT; } @@ -5970,7 +6059,6 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { } function iterate_group_array ($groups, &$data_agents) { - $data = array(); foreach ($groups as $id => $group) { @@ -6007,8 +6095,8 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { $tooltip_content = html_print_image("images/groups_small/" . $group['icon'] . ".png", true) . " " . __('Group') . ": " . $group_aux['name'] . ""; $group_aux['tooltip_content'] = $tooltip_content; - if (!isset($group['children'])) - $group_aux['children'] = array(); + $group_aux['children'] = array(); + if (!empty($group['children'])) $group_aux['children'] = iterate_group_array($group['children'], $data_agents); @@ -6016,7 +6104,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { if (!empty($agents)) $group_aux['children'] = array_merge($group_aux['children'], $agents); - + $data[] = $group_aux; } @@ -6031,6 +6119,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { unset($agents[$id]); } } + if (!empty($valid_agents)) return $valid_agents; else @@ -6038,7 +6127,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { } $graph_data = array('name' => __('Main node'), 'children' => iterate_group_array($data_groups, $data_agents), 'color' => '#3F3F3F'); - + if (empty($graph_data['children'])) return fs_error_image(); diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 757e5014d5..db046c09be 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -2241,6 +2241,9 @@ function groups_get_tree(&$groups, $parent = false) { if (!empty($children)) { $return[$id]['children'] = $children; } + else { + $return[$id]['children'] = array(); + } } else if ($parent && isset($group['parent']) && $group['parent'] == $parent) { $return[$id] = $group; @@ -2250,6 +2253,9 @@ function groups_get_tree(&$groups, $parent = false) { if (!empty($children)) { $return[$id]['children'] = $children; } + else { + $return[$id]['children'] = array(); + } } else { continue; @@ -2258,6 +2264,55 @@ function groups_get_tree(&$groups, $parent = false) { return $return; } + +function groups_get_tree_good (&$groups, $parent = false, &$childs) { + $return = array(); + + foreach ($groups as $id => $group) { + if ($group['parent'] != 0) { + $childs[$id] = $id; + } + if ($parent === false && (!isset($group['parent']) || $group['parent'] == 0 || !in_array($group['parent'], $groups))) { + $return[$id] = $group; + //unset($groups[$id]); + $children = groups_get_tree_good($groups, $id); + + if (!empty($children)) { + $return[$id]['children'] = $children; + } + else { + $return[$id]['children'] = array(); + } + } + else if ($parent && isset($group['parent']) && $group['parent'] == $parent) { + $return[$id] = $group; + //unset($groups[$id]); + $children = groups_get_tree_good($groups, $id); + + if (!empty($children)) { + $return[$id]['children'] = $children; + } + else { + $return[$id]['children'] = array(); + } + } + else { + continue; + } + } + + return $return; +} + +function groups_get_tree_keys ($groups, &$group_keys) { + foreach ($groups as $id => $group) { + $group_keys[$id] = $id; + if (isset($group['children'])) { + groups_get_tree_keys($groups[$id]['children'], $group_keys); + } + } +} + function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { global $config; @@ -2289,6 +2344,8 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { return $hierarchy; } + + function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group', $agent_filter = array(), $module_filter = array()) { global $config; if ($id_user == false) { @@ -3036,4 +3093,5 @@ function groups_get_group_deep ($id_group) { return $deep; } + ?> diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index bcdeb6819c..e46334dbef 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -987,6 +987,28 @@ function modules_is_string($id_agentmodule) { return modules_is_string_type($id_type); } + +/** + * Know if a module type is a boolean or not + * + * @param int $id_type Type id + * + * @return bool true if boolean. false if not + */ +function modules_is_boolean_type ($id_type) { + $type_name = modules_get_type_name($id_type); + + return (bool)preg_match('/_proc$/', $type_name); +} + +function modules_is_boolean($id_agentmodule) { + $id_type = db_get_value('id_tipo_modulo', + 'tagente_modulo', 'id_agente_modulo', + (int) $id_agentmodule); + + return modules_is_boolean_type($id_type); +} + /** * Get the icon of a module type * @@ -1716,11 +1738,19 @@ function modules_get_next_data ($id_agent_module, $utimestamp = 0, $string = 0) * @param int Agent module id * @param int Period of time to check (in seconds) * @param int Top date to check the values. Default current time. + * @param + * @param + * @param string 'ASC' od 'DESC' + * @param string with a json with parameters to filter data + * string object: + * value: Text to search + * exact: Boolean. True if search exact phrase or false to content * * @return array The module value and the timestamp */ function modules_get_agentmodule_data ($id_agent_module, $period, - $date = 0, $trash=false, $conexion = false, $order = 'ASC') { + $date = 0, $trash=false, $conexion = false, $order = 'ASC', + $freesearch = '') { global $config; $module = db_get_row('tagente_modulo', 'id_agente_modulo', @@ -1742,12 +1772,28 @@ function modules_get_agentmodule_data ($id_agent_module, $period, case 17: //async_string case 23: - $sql = sprintf ("SELECT datos AS data, utimestamp - FROM tagente_datos_string - WHERE id_agente_modulo = %d - AND utimestamp > %d AND utimestamp <= %d - ORDER BY utimestamp %s", - $id_agent_module, $datelimit, $date, $order); + // Free search is a json with value and exact modifier + $freesearch = json_decode($freesearch, true); + $freesearch_sql = ''; + if (isset($freesearch['value']) && !empty($freesearch['value'])) { + $freesearch_sql = " AND datos "; + if ($freesearch['exact']){ + $freesearch_sql .= "='" . $freesearch['value'] . "' "; + } else { + $freesearch_sql .= " LIKE '%" . $freesearch['value'] . "%' "; + } + } + $sql = sprintf ( + "SELECT datos AS data, utimestamp FROM tagente_datos_string + WHERE id_agente_modulo = %d + %s + AND utimestamp > %d AND utimestamp <= %d + ORDER BY utimestamp %s", + $id_agent_module, + $freesearch_sql, + $datelimit, $date, + $order + ); break; //log4x case 24: diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index e1417ceec1..b88fb07510 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -254,7 +254,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true, $relative = false, $text_filter = '', $ip_mask = null, $dont_show_subgroups = false, $strict_user = false, $size_canvas = null, - $old_mode = false) { + $old_mode = false, $map_filter = array()) { global $config; $nooverlap = 1; @@ -361,7 +361,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, // Open Graph $graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, - $ranksep, $font_size, $size_canvas); + $ranksep, $font_size, $size_canvas, $map_filter); // Parse agents $nodes = array (); @@ -1111,7 +1111,7 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu } $node = "\n" . $agent['id_node'].' [ parent="' . $agent['id_parent'] . '", color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=< -
' . $img_node . '
'.io_safe_output($name).'
>, + '.io_safe_input($name).'>, shape="doublecircle", URL="'.$url.'", tooltip="' . $url_tooltip . '"];' . "\n"; } @@ -1396,7 +1396,7 @@ function networkmap_close_group () { // Opens a graph definition function networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, - $ranksep, $font_size, $size_canvas) { + $ranksep, $font_size, $size_canvas, $map_filter = array()) { global $config; @@ -1412,42 +1412,79 @@ function networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, $size = ''; } - - if ($layout == 'radial') { - $overlap = 'true'; - } - - if ($layout == 'flat' || $layout == 'radial' || $layout == 'spring1' || $layout == "spring2") { - if ($nooverlap != '') { - $overlap = 'scalexy'; - } - } - if ($zoom > 0) { $size_x *= $zoom; $size_y *= $zoom; } + $size = $size_x . ',' . $size_y; if (!is_null($size_canvas)) { $size = ($size_canvas['x'] / 100) . "," . ($size_canvas['y'] / 100); } - + + // Graphviz custom values + if (isset($map_filter['node_sep'])) { + $node_sep = $map_filter['node_sep']; + } + else { + $node_sep = 0.25; + } + if (isset($map_filter['rank_sep'])) { + $rank_sep = $map_filter['rank_sep']; + } + else { + if ($layout == "radial") { + $rank_sep = 1.0; + } + else { + $rank_sep = 0.5; + } + } + if (isset($map_filter['mindist'])) { + $mindist = $map_filter['mindist']; + } + else { + $mindist = 1.0; + } + if (isset($map_filter['kval'])) { + $kval = $map_filter['kval']; + } + else { + $kval = 0.3; + } + // BEWARE: graphwiz DONT use single ('), you need double (") $head = "graph networkmap { dpi=100; bgcolor=\"transparent\"; labeljust=l; margin=0; pad=\"0.75,0.75\";"; if ($nooverlap != '') { - $head .= "overlap=\"$overlap\";"; - $head .= "ranksep=\"$ranksep\";"; + $head .= "overlap=\"false\";"; $head .= "outputorder=edgesfirst;"; } + + if ($layout == 'flat' || $layout == 'spring1' || $layout == "spring2") { + if ($nooverlap != '') { + $head .= "overlap=\"scalexy\";"; + } + if ($layout == 'flat') { + $head .= "ranksep=\"$rank_sep\";"; + } + if ($layout == 'spring2') { + $head .= "K=\"$kval\";"; + } + } + if ($layout == 'radial') { + $head .= "ranksep=\"$rank_sep\";"; + } + if ($layout == 'circular') { + $head .= "mindist=\"$mindist\";"; + } $head .= "ratio=fill;"; $head .= "root=0;"; - $head .= "nodesep=\"0.02\";"; + $head .= "nodesep=\"$node_sep\";"; $head .= "size=\"$size\";"; $head .= "\n"; - return $head; } diff --git a/pandora_console/include/functions_pandora_networkmap.php b/pandora_console/include/functions_pandora_networkmap.php index 0bbb4dd124..4058294bbe 100644 --- a/pandora_console/include/functions_pandora_networkmap.php +++ b/pandora_console/include/functions_pandora_networkmap.php @@ -43,7 +43,7 @@ function networkmap_process_networkmap($id = 0) { $networkmap = db_get_row_filter('tmap', array('id' => $id)); - $filter = json_decode($networkmap['filter'], true); + $map_filter = json_decode($networkmap['filter'], true); $pure = (int)get_parameter('pure', 0); @@ -95,181 +95,316 @@ function networkmap_process_networkmap($id = 0) { } $nodes_and_relations = array(); - + if (enterprise_installed() && ($numNodes > 0)) { $nodes_and_relations = get_structure_nodes($id); } else { - // Generate dot file - $graph = networkmap_generate_dot (__('Pandora FMS'), - $id_group, - $simple, - $font_size, - $layout, - $nooverlap, - $zoom, - $ranksep, - $center, - $regen, - $pure, - $id, - $show_snmp_modules, - false, //cut_names - true, // relative - '', - $ip_mask, - $dont_show_subgroups, - false, - null, - $old_mode); - - switch (PHP_OS) { - case "WIN32": - case "WINNT": - case "Windows": - $filename_dot = sys_get_temp_dir() . "\\networkmap_" . $filter; - break; - default: - $filename_dot = sys_get_temp_dir() . "/networkmap_" . $filter; - break; - } - - if ($simple) { - $filename_dot .= "_simple"; - } - if ($nooverlap) { - $filename_dot .= "_nooverlap"; - } - $filename_dot .= "_" . $id . ".dot"; + if ($map_filter['empty_map']) { + // Open Graph + $graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, + $ranksep, $font_size, null); + $graph .= networkmap_create_pandora_node (__('Pandora FMS'), $font_size, $simple); + $graph .= networkmap_close_graph (); - file_put_contents($filename_dot, $graph); + switch (PHP_OS) { + case "WIN32": + case "WINNT": + case "Windows": + $filename_dot = sys_get_temp_dir() . "\\networkmap_" . $filter; + break; + default: + $filename_dot = sys_get_temp_dir() . "/networkmap_" . $filter; + break; + } + + if ($simple) { + $filename_dot .= "_simple"; + } + if ($nooverlap) { + $filename_dot .= "_nooverlap"; + } + $filename_dot .= "_" . $id . ".dot"; - switch (PHP_OS) { - case "WIN32": - case "WINNT": - case "Windows": - $filename_plain = sys_get_temp_dir() . "\\plain.txt"; - - $cmd = io_safe_output($config['graphviz_bin_dir'] . "\\$filter.exe -Tplain -o " . $filename_plain . " " . - $filename_dot); - break; - default: - $filename_plain = sys_get_temp_dir() . "/plain.txt"; + file_put_contents($filename_dot, $graph); - $cmd = "$filter -Tplain -o " . $filename_plain . " " . - $filename_dot; - break; - } + switch (PHP_OS) { + case "WIN32": + case "WINNT": + case "Windows": + $filename_plain = sys_get_temp_dir() . "\\plain.txt"; + + $cmd = io_safe_output($config['graphviz_bin_dir'] . "\\$filter.exe -Tplain -o " . $filename_plain . " " . + $filename_dot); + break; + default: + $filename_plain = sys_get_temp_dir() . "/plain.txt"; - system ($cmd); - - unlink($filename_dot); - - $nodes = networkmap_loadfile($id, $filename_plain, - $relation_nodes, $graph); - - unlink($filename_plain); + $cmd = "$filter -Tplain -o " . $filename_plain . " " . + $filename_dot; + break; + } - //Set the position of modules - foreach ($nodes as $key => $node) { - if ($node['type'] == 'module') { - //Search the agent of this module for to get the - //position - foreach ($nodes as $key2 => $node2) { - if ($node2['id_agent'] != 0 && $node2['type'] == 'agent') { - if ($node2['id_agent'] == $node['id_agent']) { - $nodes[$key]['coords'][0] = - $nodes[$key2]['coords'][0] + $node['height'] / 2; - $nodes[$key]['coords'][1] = - $nodes[$key2]['coords'][1] + $node['width'] / 2; + system ($cmd); + + unlink($filename_dot); + + $nodes = networkmap_loadfile($id, $filename_plain, + $relation_nodes, $graph); + + unlink($filename_plain); + + //Set the position of modules + foreach ($nodes as $key => $node) { + if ($node['type'] == 'module') { + //Search the agent of this module for to get the + //position + foreach ($nodes as $key2 => $node2) { + if ($node2['id_agent'] != 0 && $node2['type'] == 'agent') { + if ($node2['id_agent'] == $node['id_agent']) { + $nodes[$key]['coords'][0] = + $nodes[$key2]['coords'][0] + $node['height'] / 2; + $nodes[$key]['coords'][1] = + $nodes[$key2]['coords'][1] + $node['width'] / 2; + } } } } } + + $nodes_and_relations['nodes'] = array(); + $index = 0; + foreach ($nodes as $key => $node) { + $nodes_and_relations['nodes'][$index]['id_map'] = $id; + + $nodes_and_relations['nodes'][$index]['x'] = (int)$node['coords'][0]; + $nodes_and_relations['nodes'][$index]['y'] = (int)$node['coords'][1]; + + if (($node['type'] == 'agent') || ($node['type'] == '')) { + $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_agent']; + $nodes_and_relations['nodes'][$index]['type'] = 0; + } + else { + $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_module']; + $nodes_and_relations['nodes'][$index]['id_agent'] = $node['id_agent']; + $nodes_and_relations['nodes'][$index]['type'] = 1; + } + + $style = array(); + $style['shape'] = 'circle'; + $style['image'] = $node['image']; + $style['width'] = $node['width']; + $style['height'] = $node['height']; + $style['label'] = $node['text']; + $style['id_networkmap'] = $node['networkmap']; + $nodes_and_relations['nodes'][$index]['style'] = json_encode($style); + + $index++; + } + + $nodes_and_relations['relations'] = array(); + + if (enterprise_installed()) { + enterprise_include_once("include/functions_pandora_networkmap.php"); + save_generate_nodes($id, $nodes_and_relations); + } + } + else { + // Generate dot file + $graph = networkmap_generate_dot (__('Pandora FMS'), + $id_group, + $simple, + $font_size, + $layout, + $nooverlap, + $zoom, + $ranksep, + $center, + $regen, + $pure, + $id, + $show_snmp_modules, + false, //cut_names + true, // relative + '', + $ip_mask, + $dont_show_subgroups, + false, + null, + $old_mode, + $map_filter); + + switch (PHP_OS) { + case "WIN32": + case "WINNT": + case "Windows": + $filename_dot = sys_get_temp_dir() . "\\networkmap_" . $filter; + break; + default: + $filename_dot = sys_get_temp_dir() . "/networkmap_" . $filter; + break; + } + + if ($simple) { + $filename_dot .= "_simple"; + } + if ($nooverlap) { + $filename_dot .= "_nooverlap"; + } + $filename_dot .= "_" . $id . ".dot"; + + file_put_contents($filename_dot, $graph); + + switch (PHP_OS) { + case "WIN32": + case "WINNT": + case "Windows": + $filename_plain = sys_get_temp_dir() . "\\plain.txt"; + + $cmd = io_safe_output($config['graphviz_bin_dir'] . "\\$filter.exe -Tplain -o " . $filename_plain . " " . + $filename_dot); + break; + default: + $filename_plain = sys_get_temp_dir() . "/plain.txt"; + + $cmd = "$filter -Tplain -o " . $filename_plain . " " . + $filename_dot; + break; + } + + system ($cmd); + + unlink($filename_dot); + + $nodes = networkmap_loadfile($id, $filename_plain, + $relation_nodes, $graph); + + unlink($filename_plain); + + //Set the position of modules + foreach ($nodes as $key => $node) { + if ($node['type'] == 'module') { + //Search the agent of this module for to get the + //position + foreach ($nodes as $key2 => $node2) { + if ($node2['id_agent'] != 0 && $node2['type'] == 'agent') { + if ($node2['id_agent'] == $node['id_agent']) { + $nodes[$key]['coords'][0] = + $nodes[$key2]['coords'][0] + $node['height'] / 2; + $nodes[$key]['coords'][1] = + $nodes[$key2]['coords'][1] + $node['width'] / 2; + } + } + } + } + } + + $nodes_and_relations['nodes'] = array(); + $index = 0; + $node_center = array(); + foreach ($nodes as $key => $node) { + $nodes_and_relations['nodes'][$index]['id_map'] = $id; + + $children_count = 0; + foreach ($relation_nodes as $relation) { + if (($relation['parent_type'] == 'agent') || ($relation['parent_type'] == '')) { + if ($nodes[$relation['id_parent']]['id_agent'] == $node['id_agent']) { + $children_count++; + } + } + else if ($relation['parent_type'] == 'module') { + if ($nodes[$relation['id_parent']]['id_module'] == $node['id_module']) { + $children_count++; + } + } + + } + + if (empty($node_center) || $node_center['counter'] < $children_count) { + $node_center['x'] = (int)$node['coords'][0]; + $node_center['y'] = (int)$node['coords'][1]; + $node_center['counter'] = $children_count; + } + + $nodes_and_relations['nodes'][$index]['x'] = (int)$node['coords'][0]; + $nodes_and_relations['nodes'][$index]['y'] = (int)$node['coords'][1]; + + if (($node['type'] == 'agent') || ($node['type'] == '')) { + $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_agent']; + $nodes_and_relations['nodes'][$index]['type'] = 0; + } + else { + $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_module']; + $nodes_and_relations['nodes'][$index]['id_agent'] = $node['id_agent']; + $nodes_and_relations['nodes'][$index]['type'] = 1; + } + + $style = array(); + $style['shape'] = 'circle'; + $style['image'] = $node['image']; + $style['width'] = $node['width']; + $style['height'] = $node['height']; + $style['label'] = $node['text']; + $nodes_and_relations['nodes'][$index]['style'] = json_encode($style); + + $index++; + } + + $nodes_and_relations['relations'] = array(); + $index = 0; + foreach ($relation_nodes as $relation) { + $nodes_and_relations['relations'][$index]['id_map'] = $id; + + if (($relation['parent_type'] == 'agent') || ($relation['parent_type'] == '')) { + $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; + $nodes_and_relations['relations'][$index]['id_parent_source_data'] = $nodes[$relation['id_parent']]['id_agent']; + $nodes_and_relations['relations'][$index]['parent_type'] = 0; + } + else if ($relation['parent_type'] == 'module') { + $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; + $nodes_and_relations['relations'][$index]['id_parent_source_data'] = $nodes[$relation['id_parent']]['id_module']; + $nodes_and_relations['relations'][$index]['parent_type'] = 1; + } + else { + $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; + $nodes_and_relations['relations'][$index]['id_child_source_data'] = -2; + $nodes_and_relations['relations'][$index]['parent_type'] = 3; + } + + if (($relation['child_type'] == 'agent') || ($relation['child_type'] == '')) { + $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; + $nodes_and_relations['relations'][$index]['id_child_source_data'] = $nodes[$relation['id_child']]['id_agent']; + $nodes_and_relations['relations'][$index]['child_type'] = 0; + } + else if ($relation['child_type'] == 'module') { + $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; + $nodes_and_relations['relations'][$index]['id_child_source_data'] = $nodes[$relation['id_child']]['id_module']; + $nodes_and_relations['relations'][$index]['child_type'] = 1; + } + else { + $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; + $nodes_and_relations['relations'][$index]['id_child_source_data'] = -2; + $nodes_and_relations['relations'][$index]['child_type'] = 3; + } + + $index++; + } + + if (enterprise_installed()) { + enterprise_include_once("include/functions_pandora_networkmap.php"); + save_generate_nodes($id, $nodes_and_relations); + } + + $pandorafms_node = $nodes_and_relations['nodes'][0]; + $center = array('x' => $node_center['x'], 'y' => $node_center['y']); + + $networkmap['center_x'] = $center['x']; + $networkmap['center_y'] = $center['y']; + db_process_sql_update('tmap', + array('center_x' => $networkmap['center_x'], 'center_y' => $networkmap['center_y']), + array('id' => $id)); } - $nodes_and_relations['nodes'] = array(); - $index = 0; - foreach ($nodes as $key => $node) { - $nodes_and_relations['nodes'][$index]['id_map'] = $id; - - $nodes_and_relations['nodes'][$index]['x'] = (int)$node['coords'][0]; - $nodes_and_relations['nodes'][$index]['y'] = (int)$node['coords'][1]; - - if (($node['type'] == 'agent') || ($node['type'] == '')) { - $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_agent']; - $nodes_and_relations['nodes'][$index]['type'] = 0; - } - else { - $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_module']; - $nodes_and_relations['nodes'][$index]['id_agent'] = $node['id_agent']; - $nodes_and_relations['nodes'][$index]['type'] = 1; - } - - $style = array(); - $style['shape'] = 'circle'; - $style['image'] = $node['image']; - $style['width'] = $node['width']; - $style['height'] = $node['height']; - $style['label'] = $node['text']; - $nodes_and_relations['nodes'][$index]['style'] = json_encode($style); - - $index++; - } - - $nodes_and_relations['relations'] = array(); - $index = 0; - foreach ($relation_nodes as $relation) { - $nodes_and_relations['relations'][$index]['id_map'] = $id; - - if (($relation['parent_type'] == 'agent') || ($relation['parent_type'] == '')) { - $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; - $nodes_and_relations['relations'][$index]['id_parent_source_data'] = $nodes[$relation['id_parent']]['id_agent']; - $nodes_and_relations['relations'][$index]['parent_type'] = 0; - } - else if ($relation['parent_type'] == 'module') { - $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; - $nodes_and_relations['relations'][$index]['id_parent_source_data'] = $nodes[$relation['id_parent']]['id_module']; - $nodes_and_relations['relations'][$index]['parent_type'] = 1; - } - else { - $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; - $nodes_and_relations['relations'][$index]['id_child_source_data'] = -2; - $nodes_and_relations['relations'][$index]['parent_type'] = 3; - } - - if (($relation['child_type'] == 'agent') || ($relation['child_type'] == '')) { - $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; - $nodes_and_relations['relations'][$index]['id_child_source_data'] = $nodes[$relation['id_child']]['id_agent']; - $nodes_and_relations['relations'][$index]['child_type'] = 0; - } - else if ($relation['child_type'] == 'module') { - $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; - $nodes_and_relations['relations'][$index]['id_child_source_data'] = $nodes[$relation['id_child']]['id_module']; - $nodes_and_relations['relations'][$index]['child_type'] = 1; - } - else { - $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; - $nodes_and_relations['relations'][$index]['id_child_source_data'] = -2; - $nodes_and_relations['relations'][$index]['child_type'] = 3; - } - - $index++; - } - - if (enterprise_installed()) { - enterprise_include_once("include/functions_pandora_networkmap.php"); - save_generate_nodes($id, $nodes_and_relations); - } - - $pandorafms_node = $nodes_and_relations['nodes'][0]; - $center = array('x' => $pandorafms_node['x'], 'y' => $pandorafms_node['y']); - - $networkmap['center_x'] = $center['x']; - $networkmap['center_y'] = $center['y']; - db_process_sql_update('tmap', - array('center_x' => $networkmap['center_x'], 'center_y' => $networkmap['center_y']), - array('id' => $id)); } return $nodes_and_relations; @@ -342,6 +477,7 @@ function networkmap_db_node_to_js_node($node, &$count, &$count_item_holding_area $item['py'] = (int)$node['y']; $item['z'] = (int)$node['z']; $item['state'] = $node['state']; + $item['deleted'] = $node['deleted']; if ($item['state'] == 'holding_area') { //40 = DEFAULT NODE RADIUS //30 = for to align @@ -374,6 +510,7 @@ function networkmap_db_node_to_js_node($node, &$count, &$count_item_holding_area $item['image_width'] = (int)$image_size[0]; $item['image_height'] = (int)$image_size[1]; } + $item['raw_text'] = $node['style']['label']; $item['text'] = io_safe_output($node['style']['label']); $item['shape'] = $node['style']['shape']; switch ($node['type']) { @@ -398,6 +535,13 @@ function networkmap_db_node_to_js_node($node, &$count, &$count_item_holding_area if (isset($node['id_map'])) { $item['map_id'] = $node['id_map']; } + + if (!isset($node['style']['id_networkmap']) || $node['style']['id_networkmap'] == '' || $node['style']['id_networkmap'] == 0) { + $item['networkmap_id'] = 0; + } + else { + $item['networkmap_id'] = $node['style']['id_networkmap']; + } $count++; @@ -517,8 +661,10 @@ function networkmap_links_to_js_links($relations, $nodes_graph) { $item['id_agent_start'] = (int)$id_source_agent; $item['id_module_end'] = 0; $item['id_agent_end'] = (int)$id_target_agent; + $item['link_color'] = "#999"; $item['target'] = -1; $item['source'] = -1; + $item['deleted'] = $relation['deleted']; if (enterprise_installed()) { $target_and_source = array(); @@ -548,7 +694,7 @@ function networkmap_links_to_js_links($relations, $nodes_graph) { $item['arrow_end'] = 'module'; $item['status_end'] = modules_get_agentmodule_status((int)$id_target_module, false, false, null); $item['id_module_end'] = (int)$id_target_module; - $text_end = io_safe_output(modules_get_agentmodule_name((int)$id_target_module)); + $text_end = modules_get_agentmodule_name((int)$id_target_module); if (preg_match ("/(.+)_ifOperStatus$/" , (string)$text_end, $matches)) { if ($matches[1]) { $item['text_end'] = $matches[1]; @@ -559,7 +705,7 @@ function networkmap_links_to_js_links($relations, $nodes_graph) { $item['arrow_start'] = 'module'; $item['status_start'] = modules_get_agentmodule_status((int)$id_source_module, false, false, null); $item['id_module_start'] = (int)$id_source_module; - $text_start = io_safe_output(modules_get_agentmodule_name((int)$id_source_module)); + $text_start = modules_get_agentmodule_name((int)$id_source_module); if (preg_match ("/(.+)_ifOperStatus$/" , (string)$text_start, $matches)) { if ($matches[1]) { $item['text_start'] = $matches[1]; @@ -571,14 +717,42 @@ function networkmap_links_to_js_links($relations, $nodes_graph) { $agent2 = 0; if (($relation['parent_type'] == 1) && ($relation['child_type'] == 1)) { + $mod1_status = db_get_value_filter('estado', 'tagente_estado', array('id_agente_modulo' => $relation['id_parent_source_data'])); + $mod2_status = db_get_value_filter('estado', 'tagente_estado', array('id_agente_modulo' => $relation['id_child_source_data'])); + + if (($mod1_status == AGENT_MODULE_STATUS_CRITICAL_BAD) || ($mod2_status == AGENT_MODULE_STATUS_CRITICAL_BAD)) { + $item['link_color'] = "#FC4444"; + } + else if (($mod1_status == AGENT_MODULE_STATUS_WARNING) || ($mod2_status == AGENT_MODULE_STATUS_WARNING)) { + $item['link_color'] = "#FAD403"; + } + $agent = agents_get_agent_id_by_module_id($relation['id_parent_source_data']); $agent2 = agents_get_agent_id_by_module_id($relation['id_child_source_data']); } else if ($relation['child_type'] == 1) { + $mod1_status = db_get_value_filter('estado', 'tagente_estado', array('id_agente_modulo' => $relation['id_child_source_data'])); + + if ($mod1_status == AGENT_MODULE_STATUS_CRITICAL_BAD) { + $item['link_color'] = "#FC4444"; + } + else if ($mod1_status == AGENT_MODULE_STATUS_WARNING) { + $item['link_color'] = "#FAD403"; + } + $agent = $relation['id_parent_source_data']; $agent2 = agents_get_agent_id_by_module_id($relation['id_child_source_data']); } else if ($relation['parent_type'] == 1) { + $mod1_status = db_get_value_filter('estado', 'tagente_estado', array('id_agente_modulo' => $relation['id_parent_source_data'])); + + if ($mod1_status == AGENT_MODULE_STATUS_CRITICAL_BAD) { + $item['link_color'] = "#FC4444"; + } + else if ($mod1_status == AGENT_MODULE_STATUS_WARNING) { + $item['link_color'] = "#FAD403"; + } + $agent = agents_get_agent_id_by_module_id($relation['id_parent_source_data']); $agent2 = $relation['id_child_source_data']; } @@ -716,7 +890,9 @@ function networkmap_write_js_array($id, $nodes_and_relations = array(), $map_das $item = networkmap_db_node_to_js_node( $node, $count, $count_item_holding_area); - + if ($item['deleted']) { + continue; + } echo "networkmap.nodes.push(" . json_encode($item) . ");\n"; $nodes_graph[$item['id']] = $item; } @@ -732,6 +908,9 @@ function networkmap_write_js_array($id, $nodes_and_relations = array(), $map_das $links_js = networkmap_links_to_js_links($relations, $nodes_graph); foreach ($links_js as $link_js) { + if ($link_js['deleted']) { + continue; + } if ($link_js['target'] == -1) continue; if ($link_js['source'] == -1) @@ -789,6 +968,12 @@ function networkmap_write_js_array($id, $nodes_and_relations = array(), $map_das echo "var set_center_menu = '" . __('Set center') . "';\n"; echo "var refresh_menu = '" . __('Refresh') . "';\n"; echo "var refresh_holding_area_menu = '" . __('Refresh Holding area') . "';\n"; + echo "var ok_button = '" . __('Proceed') . "';\n"; + echo "var message_to_confirm = '" . __('Resetting the map will delete all customizations you have done, including manual relationships between elements, new items, etc.') . "';\n"; + echo "var warning_message = '" . __('WARNING') . "';\n"; + echo "var ok_button = '" . __('Proceed') . "';\n"; + echo "var cancel_button = '" . __('Cancel') . "';\n"; + echo "var restart_map_menu = '" . __('Restart map') . "';\n"; echo "var abort_relationship_interface = '" . __('Abort the interface relationship') . "';\n"; echo "var abort_relationship_menu = '" . __('Abort the action of set relationship') . "';\n"; @@ -874,7 +1059,6 @@ function networkmap_loadfile($id = 0, $file = '', modules_get_agentmodule_agent($ids[$node_id]['id_module']); $text = modules_get_agentmodule_name($data['id_module']); - $text = io_safe_output($text); $text = ui_print_truncate_text($text, 'agent_medium', false, true, false, '...', false); @@ -885,7 +1069,6 @@ function networkmap_loadfile($id = 0, $file = '', $data['id_agent'] = $ids[$node_id]['id_agent']; $text = agents_get_alias($ids[$node_id]['id_agent']); - $text = io_safe_output($text); $text = ui_print_truncate_text($text, 'agent_medium', false, true, false, '...', false); @@ -975,7 +1158,7 @@ function duplicate_networkmap($id) { $values = db_get_row('tmap', 'id', $id); unset($values['id']); $free_name = false; - $values['name'] = io_safe_input(__('Copy of ') . io_safe_output($values['name'])); + $values['name'] = io_safe_input(__('Copy of ')) . $values['name']; $count = 1; while (!$free_name) { $exist = db_get_row_filter('tmap', array('name' => $values['name'])); @@ -1336,7 +1519,6 @@ function show_networkmap($id = 0, $user_readonly = false, $nodes_and_relations = } .link { - stroke: #999; stroke-opacity: .6; } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 8a47d2c7d2..c058d94188 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -131,7 +131,9 @@ function reporting_make_reporting_data($report = null, $id_report, foreach ($contents as $content) { $server_name = $content['server_name']; - if (!empty($period)) { + // General reports with 0 period means last value + // Avoid to overwrite it by template value + if (!empty($period) && ($content['type'] !== 'general' && $content['period'] != 0)) { $content['period'] = $period; } @@ -188,6 +190,9 @@ function reporting_make_reporting_data($report = null, $id_report, $items_label['id_agent_module'] = $content['id_agent_module']; $items_label['modules'] = $modules_to_macro; $items_label['agents'] = $agents_to_macro; + $items_label['visual_format'] = $visual_format; + $metaconsole_on = is_metaconsole(); + $server_name = $content['server_name']; //Metaconsole connection if ($metaconsole_on && $server_name != '') { @@ -230,6 +235,12 @@ function reporting_make_reporting_data($report = null, $id_report, $report, $content); break; + case 'increment': + $report['contents'][] = + reporting_increment( + $report, + $content); + break; case 'general': $report['contents'][] = reporting_general( @@ -288,19 +299,19 @@ function reporting_make_reporting_data($report = null, $id_report, $report['contents'][] = reporting_value( $report, $content, - 'max'); + 'max',$pdf); break; case 'avg_value': $report['contents'][] = reporting_value( $report, $content, - 'avg'); + 'avg',$pdf); break; case 'min_value': $report['contents'][] = reporting_value( $report, $content, - 'min'); + 'min',$pdf); break; case 'sumatory': $report['contents'][] = reporting_value( @@ -774,8 +785,8 @@ function reporting_SLA($report, $content, $type = 'dinamic', } $data = array(); - $data['agent'] = modules_get_agentmodule_agent_alias($sla['id_agent_module']); - $data['module'] = modules_get_agentmodule_name($sla['id_agent_module']); + $data['agent'] = io_safe_output(modules_get_agentmodule_agent_alias($sla['id_agent_module'])); + $data['module'] = io_safe_output(modules_get_agentmodule_name($sla['id_agent_module'])); $data['max'] = $sla['sla_max']; $data['min'] = $sla['sla_min']; $data['sla_limit'] = $sla['sla_limit']; @@ -884,8 +895,8 @@ function reporting_SLA($report, $content, $type = 'dinamic', // Slice graphs calculation if ($show_graphs) { $dataslice = array(); - $dataslice['agent'] = modules_get_agentmodule_agent_alias ($sla['id_agent_module']); - $dataslice['module'] = modules_get_agentmodule_name ($sla['id_agent_module']); + $dataslice['agent'] = io_safe_output(modules_get_agentmodule_agent_alias ($sla['id_agent_module'])); + $dataslice['module'] = io_safe_output(modules_get_agentmodule_name ($sla['id_agent_module'])); $dataslice['sla_value'] = $data['sla_value']; $dataslice['order'] = $data['sla_value']; @@ -1293,7 +1304,9 @@ function reporting_event_top_n($report, $content, $type = 'dinamic', $config['font_size'], true, $ttl, - $config['homeurl']); + $config['homeurl'], + 'white', + 'black'); } $return['resume'] = null; @@ -2164,7 +2177,7 @@ function reporting_exception($report, $content, $type = 'dinamic', 'color' => array(), 'legend' => array(), 'long_index' => array(), - 'no_data_image' => ui_get_full_url("images/image_problem.opaque.png", false, false, false), + 'no_data_image' => ui_get_full_url("images/image_problem_area_small.png", false, false, false), 'xaxisname' => "", 'yaxisname' => "", 'water_mark' => ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", @@ -3750,7 +3763,7 @@ function reporting_agent_configuration($report, $content) { return reporting_check_structure_content($return); } -function reporting_value($report, $content, $type) { +function reporting_value($report, $content, $type,$pdf) { global $config; $return = array(); @@ -3835,8 +3848,14 @@ function reporting_value($report, $content, $type) { $return['agent_name'] = $agent_name; $return['module_name'] = $module_name; + if($pdf){ + $only_image = 1; + } + switch ($type) { case 'max': + if($content['lapse_calc'] == 0){ + $value = reporting_get_agentmodule_data_max( $content['id_agent_module'], $content['period'], $report["datetime"]); if (!$config['simple_module_value']) { @@ -3845,18 +3864,286 @@ function reporting_value($report, $content, $type) { else { $formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit; } - break; + + } + else{ + + $value = ' + + + + + + + + + +
'; + + if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){ + + $value .= ' + + + + + + + + + + +
+ '.__("Agent").' + + '.__("Module").' + + '.__("Maximum").' +
+ '.$agent_name.' + + '.$module_name.' + + '.format_for_graph(reporting_get_agentmodule_data_max( + $content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.' +
'; + + } + + $value .= ' +
+ '; + + if($content['visual_format'] == 2 || $content['visual_format'] == 3){ + $value .= + grafico_modulo_sparse( + $content['id_agent_module'], + $content['period'], + false, + 600, + 300, + '', + '', + false, + 0, + true, + $report["datetime"], + '', + 0, + 0, + true, + $only_image, + ui_get_full_url(false, false, false, false), + 2, + false, + '', + $time_compare_overlapped, + true, + true, + 'white', + ($content['style']['percentil'] == 1) ? $config['percentil'] : null, + false, + false, + $config['type_module_charts'], + false, + false, + $content['lapse_calc'], + $content['lapse'], + 1); + } + + $value .= ' + +
'; + + if($content['visual_format'] == 1 || $content['visual_format'] == 3){ + + $value .= ' + + + + + + '; + $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); + $date_reference = getdate(); + + for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) { + + $value .= ''; + } + else{ + $value .= 'N/A'; + } + + } + + $value .='
+ '.__("Lapse").' + + '.__("Maximum").' +
'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).''; + + if($i>$time_begin['utimestamp']){ + $value .= format_for_graph(reporting_get_agentmodule_data_max( + $content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'
'; + } + + $value .= ' + +
'; + + $formated_value = $value; + } + + break; case 'min': - $value = reporting_get_agentmodule_data_min( - $content['id_agent_module'], $content['period'], $report["datetime"]); - if (!$config['simple_module_value']) { + if($content['lapse_calc'] == 0){ + $value = reporting_get_agentmodule_data_min( + $content['id_agent_module'], $content['period'], $report["datetime"]); + + if (!$config['simple_module_value']) { + $formated_value = $value; + } + else { + $formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit; + } + + } + else{ + + $value = ' + + + + + + + + + +
'; + + if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){ + + $value .= ' + + + + + + + + + + +
+ '.__("Agent").' + + '.__("Module").' + + '.__("Minimum").' +
+ '.$agent_name.' + + '.$module_name.' + + '.format_for_graph(reporting_get_agentmodule_data_min( + $content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.' +
'; + + } + + $value .= ' +
+ '; + + if($content['visual_format'] == 2 || $content['visual_format'] == 3){ + $value .= + grafico_modulo_sparse( + $content['id_agent_module'], + $content['period'], + false, + 600, + 300, + '', + '', + false, + 0, + true, + $report["datetime"], + '', + 0, + 0, + true, + $only_image, + ui_get_full_url(false, false, false, false), + 2, + false, + '', + $time_compare_overlapped, + true, + true, + 'white', + ($content['style']['percentil'] == 1) ? $config['percentil'] : null, + false, + false, + $config['type_module_charts'], + false, + false, + $content['lapse_calc'], + $content['lapse'], + 0, + 1); + } + + $value .= ' + +
'; + + if($content['visual_format'] == 1 || $content['visual_format'] == 3){ + + $value .= ' + + + + + + '; + $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); + $date_reference = getdate(); + + for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) { + + $value .= ''; + } + else{ + $value .= 'N/A'; + } + + } + + $value .='
+ '.__("Lapse").' + + '.__("Minimum").' +
'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).''; + + if($i>$time_begin['utimestamp']){ + $value .= format_for_graph(reporting_get_agentmodule_data_min( + $content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'
'; + } + + $value .= ' + +
'; + $formated_value = $value; } - else { - $formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit; - } + break; case 'avg': + if($content['lapse_calc'] == 0){ $value = reporting_get_agentmodule_data_average( $content['id_agent_module'], $content['period'], $report["datetime"]); if (!$config['simple_module_value']) { @@ -3865,7 +4152,138 @@ function reporting_value($report, $content, $type) { else { $formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit; } - break; + } + else{ + $value = ' + + + + + + + + + +
'; + + if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){ + + $value .= ' + + + + + + + + + + +
+ '.__("Agent").' + + '.__("Module").' + + '.__("Average").' +
+ '.$agent_name.' + + '.$module_name.' + + '.format_for_graph(reporting_get_agentmodule_data_average( + $content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.' +
'; + + } + + $value .= ' +
+ '; + + if($content['visual_format'] == 2 || $content['visual_format'] == 3){ + $value .= + grafico_modulo_sparse( + $content['id_agent_module'], + $content['period'], + false, + 600, + 300, + '', + '', + false, + 1, + true, + $report["datetime"], + '', + 0, + 0, + true, + $only_image, + ui_get_full_url(false, false, false, false), + 2, + false, + '', + $time_compare_overlapped, + true, + true, + 'white', + ($content['style']['percentil'] == 1) ? $config['percentil'] : null, + false, + false, + $config['type_module_charts'], + false, + false, + $content['lapse_calc'], + $content['lapse'] + ); + } + + $value .= ' + +
'; + + if($content['visual_format'] == 1 || $content['visual_format'] == 3){ + + $value .= ' + + + + + + '; + $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); + $date_reference = getdate(); + + for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) { + + $value .= ''; + } + else{ + $value .= 'N/A'; + } + + } + + $value .='
+ '.__("Lapse").' + + '.__("Average").' +
'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).''; + + if($i>$time_begin['utimestamp']){ + $value .= format_for_graph(reporting_get_agentmodule_data_average( + $content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'
'; + } + + $value .= ' + +
'; + + $formated_value = $value; + + } + break; + case 'sum': $value = reporting_get_agentmodule_data_sum( $content['id_agent_module'], $content['period'], $report["datetime"]); @@ -5569,6 +5987,101 @@ function reporting_availability_graph($report, $content, $pdf=false) { return reporting_check_structure_content($return); } +/** + * reporting_increment + * + * Generates a structure the report. + * + */ +function reporting_increment ($report, $content) { + global $config; + + $return = array(); + $return['type'] = 'increment'; + if (empty($content['name'])) { + $content['name'] = __('Increment'); + } + + $return['title'] = $content['name']; + $return["description"] = $content["description"]; + $return["id_agent_module"] = $content["id_agent_module"]; + $return["id_agent"] = $content["id_agent"]; + + $id_agent_module = $content['id_agent_module']; + $period = (int)$content['period']; + + $return["from"] = time() - $period; + $return["to"] = time(); + + $return["data"] = array(); + + if (defined('METACONSOLE')) { + $sql1 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = ' . $id_agent_module . ' + AND utimestamp <= ' . (time() - $period) . ' ORDER BY utimestamp DESC'; + $sql2 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = ' . $id_agent_module . ' ORDER BY utimestamp DESC'; + + $servers = db_get_all_rows_sql ('SELECT * + FROM tmetaconsole_setup + WHERE disabled = 0'); + + if ($servers === false) + $servers = array(); + + $result = array(); + $count_modules = 0; + foreach ($servers as $server) { + // If connection was good then retrieve all data server + if (metaconsole_connect($server) == NOERR) + $connection = true; + else + $connection = false; + + $old_data = db_get_value_sql ($sql1); + + $last_data = db_get_value_sql ($sql2); + } + } + else { + $old_data = db_get_value_sql('SELECT datos FROM tagente_datos WHERE id_agente_modulo = ' . $id_agent_module . ' + AND utimestamp <= ' . (time() - $period) . ' ORDER BY utimestamp DESC'); + + $last_data = db_get_value_sql('SELECT datos FROM tagente_datos WHERE id_agente_modulo = ' . $id_agent_module . ' ORDER BY utimestamp DESC'); + } + + if (!defined('METACONSOLE')) { + + } + + if ($old_data === false || $last_data === false) { + $return["data"]['message'] = __('The monitor have no data in this range of dates or monitor type is not numeric'); + $return["data"]['error'] = true; + } + else if (is_numeric($old_data) && is_numeric($last_data)) { + $return["data"]['old'] = $old_data; + $return["data"]['now'] = $last_data; + $increment = $old_data - $last_data; + + if ($increment < 0) { + $return["data"]['inc'] = 'positive'; + $return["data"]["inc_data"] = $last_data - $old_data; + } + else if ($increment == 0) { + $return["data"]['inc'] = 'neutral'; + $return["data"]["inc_data"] = 0; + } + else { + $return["data"]['inc'] = 'negative'; + $return["data"]["inc_data"] = $old_data - $last_data; + } + } + else { + $return["data"]['message'] = __('The monitor type is not numeric'); + $return["data"]['error'] = true; + } + + return reporting_check_structure_content($return); +} + /** * reporting_general * @@ -5623,6 +6136,7 @@ function reporting_general($report, $content) { $i = 0; $index = 0; + $is_string = array(); foreach ($generals as $row) { //Metaconsole connection $server_name = $row ['server_name']; @@ -5648,6 +6162,7 @@ function reporting_general($report, $content) { $mod_name = modules_get_agentmodule_name ($row['id_agent_module']); $ag_name = modules_get_agentmodule_agent_alias ($row['id_agent_module']); $type_mod = modules_get_last_value($row['id_agent_module']); + $is_string[$index] = modules_is_string($row['id_agent_module']); $unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $row['id_agent_module']); @@ -5657,7 +6172,7 @@ function reporting_general($report, $content) { modules_get_last_value($row['id_agent_module']); } else { - if(is_numeric($type_mod)){ + if(is_numeric($type_mod) && !$is_string[$index]) { switch ($row['operation']) { case 'sum': $data_res[$index] = @@ -5711,7 +6226,7 @@ function reporting_general($report, $content) { } // Calculate the avg, min and max - if (is_numeric($data_res[$index])) { + if (is_numeric($data_res[$index]) && !$is_string[$index]) { $change_min = false; if (is_null($return["min"]["value"])) { $change_min = true; @@ -5837,7 +6352,7 @@ function reporting_general($report, $content) { break; } - if (!is_numeric($d)) { + if (!is_numeric($d) || $is_string[$i]) { $data['value'] = $d; // to see the chains on the table $data['formated_value'] = $d; @@ -7245,19 +7760,19 @@ function reporting_get_stats_modules_status($data, $graph_width = 250, $graph_he if ($links === false) { $urls = array(); $urls['monitor_critical'] = "index.php?" . - "sec=estado&sec2=operation/agentes/status_monitor&" . + "sec=view&sec2=operation/agentes/status_monitor&" . "refr=60&status=" . AGENT_MODULE_STATUS_CRITICAL_BAD . "&pure=" . $config['pure']; $urls['monitor_warning'] = "index.php?" . - "sec=estado&sec2=operation/agentes/status_monitor&" . + "sec=view&sec2=operation/agentes/status_monitor&" . "refr=60&status=" . AGENT_MODULE_STATUS_WARNING . "&pure=" . $config['pure']; $urls['monitor_ok'] = "index.php?" . - "sec=estado&sec2=operation/agentes/status_monitor&" . + "sec=view&sec2=operation/agentes/status_monitor&" . "refr=60&status=" . AGENT_MODULE_STATUS_NORMAL . "&pure=" . $config['pure']; $urls['monitor_unknown'] = "index.php?" . - "sec=estado&sec2=operation/agentes/status_monitor&" . + "sec=view&sec2=operation/agentes/status_monitor&" . "refr=60&status=" . AGENT_MODULE_STATUS_UNKNOWN . "&pure=" . $config['pure']; $urls['monitor_not_init'] = "index.php?" . - "sec=estado&sec2=operation/agentes/status_monitor&" . + "sec=view&sec2=operation/agentes/status_monitor&" . "refr=60&status=" . AGENT_MODULE_STATUS_NOT_INIT . "&pure=" . $config['pure']; } else { @@ -7357,7 +7872,7 @@ function reporting_get_stats_agents_monitors($data) { else { $urls = array(); $urls['total_agents'] = "index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60"; - $urls['monitor_checks'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1"; + $urls['monitor_checks'] = "index.php?sec=view&sec2=operation/agentes/status_monitor&refr=60&status=-1"; } // Agents and modules table diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 8d56a42918..eca001e288 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -208,6 +208,9 @@ function reporting_html_print_report($report, $mini = false, $report_info = 1) { case 'avg_value': reporting_html_avg_value($table, $item, $mini); break; + case 'increment': + reporting_html_increment($table, $item); + break; case 'min_value': reporting_html_min_value($table, $item, $mini); break; @@ -2213,6 +2216,69 @@ function reporting_html_value(&$table, $item, $mini, $only_value = false, $check $table->data['data']['cell'] .= '

'; } +function reporting_html_increment(&$table, $item) { + global $config; + + if (isset($item["data"]['error'])) { + $table->colspan['error']['cell'] = 3; + $table->data['error']['cell'] = $item["data"]['message']; + } + else { + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->data = array (); + + $table1->head = array (); + $table1->head[0] = __('Agent'); + $table1->head[1] = __('Module'); + $table1->head[2] = __('From'); + $table1->head[3] = __('To'); + $table1->head[4] = __('From data'); + $table1->head[5] = __('To data'); + $table1->head[6] = __('Increment'); + + $table1->headstyle = array(); + $table1->headstyle[0] = 'text-align: left'; + $table1->headstyle[1] = 'text-align: left'; + $table1->headstyle[2] = 'text-align: left'; + $table1->headstyle[3] = 'text-align: left'; + $table1->headstyle[4] = 'text-align: right'; + $table1->headstyle[5] = 'text-align: right'; + $table1->headstyle[6] = 'text-align: right'; + + $table1->style[0] = 'text-align: left'; + $table1->style[1] = 'text-align: left'; + $table1->style[2] = 'text-align: left'; + $table1->style[3] = 'text-align: left'; + $table1->style[4] = 'text-align: right'; + $table1->style[5] = 'text-align: right'; + $table1->style[6] = 'text-align: right'; + + $table1_row = array(); + $table1_row[0] = agents_get_alias($item['id_agent']); + $table1_row[1] = modules_get_agentmodule_name($item['id_agent_module']); + $table1_row[2] = date("F j, Y, G:i", $item['from']); + $table1_row[3] = date("F j, Y, G:i", $item['to']); + $table1_row[4] = $item["data"]['old']; + $table1_row[5] = $item["data"]['now']; + if ($item["data"]['inc'] == 'negative') { + $table1_row[6] = __('Negative increase: ') . $item["data"]["inc_data"]; + } + else if ($item["data"]['inc'] == 'positive') { + $table1_row[6] = __('Positive increase: ') . $item["data"]["inc_data"]; + } + else { + $table1_row[6] = __('Neutral increase: ') . $item["data"]["inc_data"]; + } + + $table1->data[] = $table1_row; + + $data = array(); + $data[0] = html_print_table($table1, true); + array_push ($table->data, $data); + } +} + function reporting_html_url(&$table, $item, $key) { $table->colspan['data']['cell'] = 3; $table->cellstyle['data']['cell'] = 'text-align: left;'; @@ -2811,13 +2877,13 @@ function reporting_get_stats_summary($data, $graph_width, $graph_height) { $tdata[0] = '
' . graph_agent_status (false, $graph_width, $graph_height, true, true) . '
'; } else { - $tdata[2] = html_print_image('images/image_problem.png', true, array('width' => $graph_width)); + $tdata[2] = html_print_image('images/image_problem_area_small.png', true, array('width' => $graph_width)); } if ($data["monitor_alerts"] > 0) { $tdata[2] = '
' . graph_alert_status ($data["monitor_alerts"], $data["monitor_alerts_fired"], $graph_width, $graph_height, true, true) . '
'; } else { - $tdata[2] = html_print_image('images/image_problem.png', true, array('width' => $graph_width)); + $tdata[2] = html_print_image('images/image_problem_area_small.png', true, array('width' => $graph_width)); } $table_sum->rowclass[] = ''; $table_sum->data[] = $tdata; diff --git a/pandora_console/include/functions_reporting_xml.php b/pandora_console/include/functions_reporting_xml.php new file mode 100644 index 0000000000..f71b465f90 --- /dev/null +++ b/pandora_console/include/functions_reporting_xml.php @@ -0,0 +1,60 @@ + 0){ + for($i = 0;$i < count($report['contents']); $i++){ + $aux = explode("-",$report['contents'][$i]['subtitle']); + $report['contents'][$i]['subtitle'] = db_get_value ("alias","tagente","nombre",$report['contents'][$i]['agent_name']) .' -'. $aux[1]; + } + } + + $xml = null; + $xml = array2XML($report, "report", $xml); + $xml = preg_replace("/(<[^>]+>)(<[^>]+>)(<[^>]+>)/", "$1\n$2\n$3", $xml); + $xml = preg_replace("/(<[^>]+>)(<[^>]+>)/", "$1\n$2", $xml); + + // Return if is marked to return + if ($return) return $xml; + + // Download if marked to download + header ('Content-Type: application/xml; charset=UTF-8'); + header ('Content-Disposition: attachment; filename="'.$filename.'.xml"'); + + // Clean the output buffer + ob_clean(); + + echo $xml; +} \ No newline at end of file diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 9282be345b..dfa3d3d490 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -574,7 +574,8 @@ function reports_get_report_types ($template = false, $not_editor = false) { 'name' => __('Summatory')); $types['historical_data'] = array('optgroup' => __('Modules'), 'name' => __('Historical Data')); - + $types['increment'] = array('optgroup' => __('Modules'), + 'name' => __('Increment')); $types['general'] = array('optgroup' => __('Grouped'), diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index b98d66789b..390d6ec151 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -196,7 +196,7 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $ve } } else { - $command = $snmpwalk_bin . " -m ALL -M +" . escapeshellarg($config['homedir'] . "/attachment/mibs") . " -Cc -c " . escapeshellarg($community) . " -v " . escapeshellarg($version) . " " . escapeshellarg($target_ip) . " " . escapeshellarg($starting_oid) . " 2> " . $error_redir_dir; + $command = $snmpwalk_bin . " -m ALL -M +" . escapeshellarg($config['homedir'] . "/attachment/mibs") . " -Cc -c " . escapeshellarg(io_safe_output($community)) . " -v " . escapeshellarg($version) . " " . escapeshellarg($target_ip) . " " . escapeshellarg($starting_oid) . " 2> " . $error_redir_dir; } exec("ssh pandora_exec_proxy@" . $server_data['ip_address'] . " \"" . $command . "\"", $output, $rc); } @@ -216,7 +216,7 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $ve } } else { - exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir, $output, $rc); + exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg(io_safe_output($community)) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir, $output, $rc); } } } @@ -236,7 +236,7 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $ve } } else { - exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir, $output, $rc); + exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg(io_safe_output($community)) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir, $output, $rc); } } @@ -348,7 +348,7 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = ' exec ($snmpget_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2> ' . $error_redir_dir, $output, $rc); } else { - exec ($snmpget_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2> ' . $error_redir_dir, $output, $rc); + exec ($snmpget_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -c ' . escapeshellarg(io_safe_output($community)) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2> ' . $error_redir_dir, $output, $rc); } if ($rc != 0) { @@ -725,35 +725,38 @@ function snmp_browser_print_container ($return = false, $width = '100%', $height }); // Prepare the AJAX call - var params = [ - "target_ip=" + target_ip, - "community=" + community, - "oids=" + oids, - "snmp_browser_version=" + snmp_version, - "snmp3_browser_auth_user=" + snmp3_auth_user, - "snmp3_browser_security_level=" + snmp3_security_level, - "snmp3_browser_auth_method=" + snmp3_auth_method, - "snmp3_browser_auth_pass=" + snmp3_auth_pass, - "snmp3_browser_privacy_method=" + snmp3_privacy_method, - "snmp3_browser_privacy_pass=" + snmp3_privacy_pass, - "action=" + "create_modules_snmp", - "custom_action=" + custom_action, - "page=include/ajax/snmp_browser.ajax" - ]; + var params = {}; + params["target_ip"] = target_ip; + params["community"] = community; + params["oids"] = oids; + params["snmp_browser_version"] = snmp_version; + params["snmp3_browser_auth_user"] = snmp3_auth_user; + params["snmp3_browser_security_level"] = snmp3_security_level; + params["snmp3_browser_auth_method"] = snmp3_auth_method; + params["snmp3_browser_auth_pass"] = snmp3_auth_pass; + params["snmp3_browser_privacy_method"] = snmp3_privacy_method; + params["snmp3_browser_privacy_pass"] = snmp3_privacy_pass; + params["action"] = "create_modules_snmp"; + params["custom_action"] = custom_action; + params["page"] = "include/ajax/snmp_browser.ajax"; $.ajax({ type: "GET", url: "ajax.php", - data: params.join ("&"), - dataType: "json", + data: params, + dataType: "html", success: function(data) { + + var dato = data.replace(/[^]+(?=\[)/,""); $('input[name*=create_network_component]').removeClass("sub spinn"); $('input[name*=create_network_component]').addClass("sub add"); - if(data.length !== 0){ + dato = JSON.parse(dato); + + if(dato.length !== 0){ $('#error_text').text(""); - data.forEach( function(valor, indice, array) { - console.log(valor); + + dato.forEach( function(valor, indice, array) { $('#error_text').append('
'+ valor ); }); $("#dialog_error") diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index de10fcaf91..e76ba9399f 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -94,22 +94,27 @@ function ui_print_truncate_text($text, $numChars = GENERIC_SIZE_TEXT, $showTextI } } - $text = io_safe_output($text); - if (mb_strlen($text, "UTF-8") > ($numChars)) { + $text_html_decoded = io_safe_output($text); + $text_has_entities = $text != $text_html_decoded; + + if (mb_strlen($text_html_decoded, "UTF-8") > ($numChars)) { // '/2' because [...] is in the middle of the word. $half_length = intval(($numChars - 3) / 2); // Depending on the strange behavior of mb_strimwidth() itself, // the 3rd parameter is not to be $numChars but the length of // original text (just means 'large enough'). - $truncateText2 = mb_strimwidth($text, - (mb_strlen($text, "UTF-8") - $half_length), - mb_strlen($text, "UTF-8"), "", "UTF-8" ); + $truncateText2 = mb_strimwidth($text_html_decoded, + (mb_strlen($text_html_decoded, "UTF-8") - $half_length), + mb_strlen($text_html_decoded, "UTF-8"), "", "UTF-8" ); - $truncateText = mb_strimwidth($text, 0, - ($numChars - $half_length), "", "UTF-8") . $suffix; + $truncateText = mb_strimwidth($text_html_decoded, 0, + ($numChars - $half_length), "", "UTF-8"); - $truncateText = $truncateText . $truncateText2; + // Recover the html entities to avoid XSS attacks + $truncateText = ($text_has_entities) + ? io_safe_input($truncateText) . $suffix . io_safe_input($truncateText2) + : $truncateText . $suffix . $truncateText2; if ($showTextInTitle) { if ($style === null) { @@ -2968,6 +2973,11 @@ function ui_print_agent_autocomplete_input($parameters) { else $metaconsole_enabled = false; } + + $get_only_string_modules = false; + if (isset($parameters['get_only_string_modules'])) { + $get_only_string_modules = true; + } $spinner_image = html_print_image('images/spinner.gif', true, false, true); if (isset($parameters['spinner_image'])) { @@ -3029,7 +3039,10 @@ function ui_print_agent_autocomplete_input($parameters) { $javascript = $parameters['javascript']; } - + $get_order_json = false; + if (isset($parameters['get_order_json'])) { + $get_order_json = true; + } $javascript_is_function_select = false; //Default value if (isset($parameters['javascript_is_function_select'])) { @@ -3116,6 +3129,14 @@ function ui_print_agent_autocomplete_input($parameters) { if (' . ((int) !$metaconsole_enabled) . ') { inputs.push ("force_local_modules=1"); } + + if (' . ((int) $get_order_json) . ') { + inputs.push ("get_order_json=1"); + } + + if (' . ((int) $get_only_string_modules) . ') { + inputs.push ("get_only_string_modules=1"); + } if (' . ((int)$metaconsole_enabled) . ') { if ((' . ((int)$use_input_server) . ') diff --git a/pandora_console/include/functions_update_manager.php b/pandora_console/include/functions_update_manager.php index 607b108e42..ba6508fa19 100755 --- a/pandora_console/include/functions_update_manager.php +++ b/pandora_console/include/functions_update_manager.php @@ -358,7 +358,14 @@ function update_manager_check_online_free_packages ($is_ajax=true) { var text1_mr_file = "\n"; var text2_mr_file = "\n"; var text3_mr_file = "\n"; - var text4_mr_file = "\n"; + var text4_mr_file = "
'.__('About minor release update').''; + } + else{ + echo __(' to this process').'

'.__('About minor release update').''; + } + ?>"; var text1_package_file = "\n"; var text2_package_file = "\n"; var applying_mr = "\n"; diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index 13116c6eb8..957c8c569e 100755 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -152,6 +152,8 @@ function users_get_groups_for_select($id_user, $privilege = "AR", $returnAllGro * @return array A list of the groups the user has certain privileges. */ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup = true, $returnAllColumns = false, $id_groups = null, $keys_field = 'id_grupo') { + static $group_cache = array(); + if (empty ($id_user)) { global $config; @@ -161,57 +163,95 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup } } - if (isset($id_groups)) { - //Get recursive id groups - $list_id_groups = array(); - foreach ((array)$id_groups as $id_group) { - $list_id_groups = array_merge($list_id_groups, groups_get_id_recursive($id_group)); + // Check the group cache first. + if (array_key_exists($id_user, $group_cache)) { + $groups = $group_cache[$id_user]; + } else { + // Admin. + if (is_user_admin($id_user)) { + $groups = db_get_all_rows_sql ("SELECT * FROM tgrupo"); + } + // Per-group permissions. + else { + $query = sprintf("SELECT tgrupo.*, tperfil.*, tusuario_perfil.tags FROM tgrupo, tusuario_perfil, tperfil + WHERE (tgrupo.id_grupo = tusuario_perfil.id_grupo OR tusuario_perfil.id_grupo = 0) + AND tusuario_perfil.id_perfil = tperfil.id_perfil + AND tusuario_perfil.id_usuario = '%s'", $id_user); + $groups = db_get_all_rows_sql ($query); + + // Get children groups. + $parent_ids = array(); + $parents = $groups; + $seen = array(); + while (!empty($parents)) { + $children = array(); + foreach ($parents as $parent) { + // Do not process the same parent twice. + if (array_key_exists($parent['id_grupo'], $seen)) { + continue; + } + $seen[$parent['id_grupo']] = 1; + + // Does this group propagate ACLs? + if ($parent['propagate'] == '0') { + continue; + } + + // Save a list of parents in the tree to search for user profiles, including the current parent! + $parent_ids[$parent['id_grupo']] = isset($parent_ids[$parent['parent']]) ? array_merge(array($parent['id_grupo']), $parent_ids[$parent['parent']]) : array($parent['id_grupo']); + + // Get children groups from the DB. + $query = sprintf("SELECT tgrupo.*, tperfil.*, tusuario_perfil.tags FROM tgrupo, tusuario_perfil, tperfil + WHERE tgrupo.parent = %d + AND tusuario_perfil.id_grupo IN (%s) + AND tusuario_perfil.id_perfil = tperfil.id_perfil + AND tusuario_perfil.id_usuario = '%s'", $parent['id_grupo'], join(',', $parent_ids[$parent['id_grupo']]), $id_user); + $local_children = db_get_all_rows_sql ($query); + if (!empty($local_children)) { + $children = array_merge($children, $local_children); + } + } + + if (!empty($children)) { + $groups = array_merge($groups, $children); + } + + // Move down in the hierarchy. + $parents = $children; + } } - - $list_id_groups = array_unique($list_id_groups); - - $groups = db_get_all_rows_filter('tgrupo', array('id_grupo' => $list_id_groups, 'order' => 'parent, nombre')); - } - else { - $groups = db_get_all_rows_in_table ('tgrupo', 'parent, nombre'); + + // Update the group cache. + $group_cache[$id_user] = $groups; } $user_groups = array (); - if (!$groups) { return $user_groups; } if ($returnAllGroup) { //All group - if ($returnAllColumns) { - $groupall = array('id_grupo' => 0, 'nombre' => __('All'), - 'icon' => 'world', 'parent' => 0, 'disabled' => 0, - 'custom_id' => null, 'description' => '', 'propagate' => 0); - } - else { - $groupall = array('id_grupo' => 0, 'nombre' => __("All")); - } + $groupall = array('id_grupo' => 0, 'nombre' => __('All'), + 'icon' => 'world', 'parent' => 0, 'disabled' => 0, + 'custom_id' => null, 'description' => '', 'propagate' => 0); // Add the All group to the beginning to be always the first array_unshift($groups, $groupall); } + $acl_column = get_acl_column($privilege); foreach ($groups as $group) { - if ($privilege === false) { - if ($returnAllColumns) { - $user_groups[$group[$keys_field]] = $group; - } - else { - $user_groups[$group[$keys_field]] = $group['nombre']; - } + + # Check the specific permission column. acl_column is undefined for admins. + if (defined($group[$acl_column]) && $group[$acl_column] != '1') { + continue; } - else if (check_acl($id_user, $group["id_grupo"], $privilege)) { - if ($returnAllColumns) { - $user_groups[$group[$keys_field]] = $group; - } - else { - $user_groups[$group[$keys_field]] = $group['nombre']; - } + + if ($returnAllColumns) { + $user_groups[$group[$keys_field]] = $group; + } + else { + $user_groups[$group[$keys_field]] = $group['nombre']; } } diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index b06a0c6d5c..2085e9d56d 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -31,6 +31,7 @@ require_once ($config['homedir'].'/include/functions_agents.php'); require_once ($config['homedir'].'/include/functions_modules.php'); require_once ($config['homedir'].'/include/functions_users.php'); require_once ($config['homedir'].'/include/functions.php'); +require_once ($config['homedir'].'/include/graphs/functions_d3.php'); function visual_map_print_item_toolbox($idDiv, $text, $float) { if ($float == 'left') { @@ -110,6 +111,14 @@ function visual_map_print_item($mode = "read", $layoutData, $border_color = $layoutData['border_color']; $fill_color = $layoutData['fill_color']; $label_position = $layoutData['label_position']; + $show_on_top = $layoutData['show_on_top']; + + if($show_on_top){ + $show_on_top_index = 10; + } + else{ + $show_on_top_index = ''; + } $sizeStyle = ''; $borderStyle = ''; @@ -303,6 +312,8 @@ function visual_map_print_item($mode = "read", $layoutData, break; case PERCENTILE_BAR: case PERCENTILE_BUBBLE: + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: if (!empty($layoutData['id_agent']) && empty($layoutData['id_layout_linked'])) { @@ -375,10 +386,16 @@ function visual_map_print_item($mode = "read", $layoutData, $link = true; } + break; + case BARS_GRAPH: + $link = true; break; case AUTO_SLA_GRAPH: $link = true; break; + case DONUT_GRAPH: + $link = true; + break; default: if (!empty($element_enterprise)) { $link = $element_enterprise['link']; @@ -433,7 +450,7 @@ function visual_map_print_item($mode = "read", $layoutData, // Link to an module if (empty($layoutData['id_metaconsole'])) { $url = $config['homeurl'] . - 'index.php?sec=estado&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; + 'index.php?sec=view&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; } else { $url = ui_meta_get_url_console_child( @@ -487,6 +504,29 @@ function visual_map_print_item($mode = "read", $layoutData, "&date_to=" . $date_to . "&time_to=" . $time_to . "&status=-1"; } break; + + case DONUT_GRAPH: + if (empty($layout_data['id_metaconsole'])) { + $url = $config['homeurl'] . "index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=" . $layoutData['id_agent'] . + "&tab=module&edit_module=1&id_agent_module=" . $layoutData['id_agente_modulo']; + } + else { + $url = "index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=" . $layoutData['id_agent'] . + "&tab=module&edit_module=1&id_agent_module=" . $layoutData['id_agente_modulo']; + } + break; + + case BARS_GRAPH: + if (empty($layout_data['id_metaconsole'])) { + $url = $config['homeurl'] . "index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=" . $layoutData['id_agent'] . + "&tab=module&edit_module=1&id_agent_module=" . $layoutData['id_agente_modulo']; + } + else { + $url = "index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=" . $layoutData['id_agent'] . + "&tab=module&edit_module=1&id_agent_module=" . $layoutData['id_agente_modulo']; + } + break; + case GROUP_ITEM: $is_a_link_to_other_visualconsole = false; if ($layoutData['id_layout_linked'] != 0) { @@ -581,7 +621,7 @@ function visual_map_print_item($mode = "read", $layoutData, // Link to an module if (empty($layoutData['id_metaconsole'])) { $url = $config['homeurl'] . - 'index.php?sec=estado&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; + 'index.php?sec=view&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; } else { $url = ui_meta_get_url_console_child( @@ -592,6 +632,8 @@ function visual_map_print_item($mode = "read", $layoutData, break; case PERCENTILE_BAR: case PERCENTILE_BUBBLE: + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: if (!empty($layoutData['id_agent'])) { //Extract id service if it is a prediction module. @@ -628,11 +670,11 @@ function visual_map_print_item($mode = "read", $layoutData, $url = $server["server_url"] . - '/index.php?sec=estado&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; + '/index.php?sec=view&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; } else { $url = - $config['homeurl'].'/index.php?sec=estado&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; + $config['homeurl'].'/index.php?sec=view&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; } } else { @@ -696,7 +738,7 @@ function visual_map_print_item($mode = "read", $layoutData, else { if (empty($layoutData['id_metaconsole'])) { $url = $config['homeurl'] . - '/index.php?sec=estado&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; + '/index.php?sec=view&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; } else { $url = ui_meta_get_url_console_child( @@ -811,6 +853,8 @@ function visual_map_print_item($mode = "read", $layoutData, break; case PERCENTILE_BAR: case PERCENTILE_BUBBLE: + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: //Metaconsole db connection if ($layoutData['id_metaconsole'] != 0) { $connection = db_get_row_filter ('tmetaconsole_setup', @@ -925,14 +969,14 @@ function visual_map_print_item($mode = "read", $layoutData, else { if ($width == 0 || $height == 0) { if ($layoutData['label_position']=='left') { - $img = '
'.custom_graphs_print( + $img = '
'.custom_graphs_print( $layoutData['id_custom_graph'], 180, 480, $period, null, true, 0, $only_image, $layoutData['image'], array(), '', array(), array(), true, false, false, true, 1, false, true).'
'; } elseif ($layoutData['label_position']=='right') { - $img = '
'.custom_graphs_print( + $img = '
'.custom_graphs_print( $layoutData['id_custom_graph'], 180, 480, $period, null, true, 0, $only_image, $layoutData['image'], array(), '', array(), array(), true, @@ -952,14 +996,14 @@ function visual_map_print_item($mode = "read", $layoutData, } else { if ($layoutData['label_position']=='left') { - $img = '
'.custom_graphs_print( + $img = '
'.custom_graphs_print( $layoutData['id_custom_graph'], $height, $width, $period, null, true, 0, $only_image, $layoutData['image'], array(), '', array(), array(), true, false, false, true, 1, false, true).'
'; } elseif($layoutData['label_position']=='right') { - $img = '
'.custom_graphs_print( + $img = '
'.custom_graphs_print( $layoutData['id_custom_graph'], $height, $width, $period, null, true, 0, $only_image, $layoutData['image'], array(), '', array(), array(), true, @@ -1005,7 +1049,7 @@ function visual_map_print_item($mode = "read", $layoutData, if ($width == 0 || $height == 0) { if ($layoutData['label_position']=='left') { - $img = '
'. + $img = '
'. grafico_modulo_sparse($id_module, $period, 0, 300, 180, modules_get_agentmodule_name($id_module),null, false, 1, false, 0, modules_get_unit($id_module), 0, 0, true, $only_image, '', 1, false, '', @@ -1013,7 +1057,7 @@ function visual_map_print_item($mode = "read", $layoutData, null, true, false, $type_graph) . '
'; } elseif($layoutData['label_position']=='right') { - $img = '
' . + $img = '
' . grafico_modulo_sparse($id_module, $period, 0, 300, 180, modules_get_agentmodule_name($id_module),null, false, 1, false, 0, modules_get_unit($id_module), 0, 0, true, $only_image, '', @@ -1031,7 +1075,7 @@ function visual_map_print_item($mode = "read", $layoutData, } else{ if ($layoutData['label_position']=='left') { - $img = '
' . + $img = '
' . grafico_modulo_sparse($id_module, $period, 0, $width, $height, modules_get_agentmodule_name($id_module), null, false, 1, false, 0, modules_get_unit($id_module), 0, 0, true, $only_image, '', @@ -1040,7 +1084,7 @@ function visual_map_print_item($mode = "read", $layoutData, false, $type_graph) . '
'; } elseif ($layoutData['label_position']=='right') { - $img = '
' . + $img = '
' . grafico_modulo_sparse($id_module, $period, 0, $width, $height, modules_get_agentmodule_name($id_module), null, false, 1, false, 0, modules_get_unit($id_module), 0, 0, true, $only_image, @@ -1066,6 +1110,312 @@ function visual_map_print_item($mode = "read", $layoutData, } break; + + case BARS_GRAPH: + + $imgpos = ''; + + if($layoutData['label_position']=='left'){ + $imgpos = 'float:right'; + } + else if($layoutData['label_position']=='right'){ + $imgpos = 'float:left'; + } + + if (!empty($proportion)) { + $width = + ((integer)($proportion['proportion_width'] * $width)); + $height = + ((integer)($proportion['proportion_height'] * $height)); + } + //Metaconsole db connection + if ($layoutData['id_metaconsole'] != 0) { + $connection = db_get_row_filter ('tmetaconsole_setup', + array('id' => $layoutData['id_metaconsole'])); + if (metaconsole_load_external_db($connection) != NOERR) { + continue; + } + } + + if ($isExternalLink) + $homeurl = $config['homeurl']; + else + $homeurl = ''; + + $is_string = db_get_value_filter ('id_tipo_modulo', 'tagente_modulo', + array ('id_agente' => $layoutData['id_agent'], + 'id_agente_modulo' => $id_module)); + + if ( (get_parameter('action') == 'edit') || (get_parameter('operation') == 'edit_visualmap') ) { + if($width == 0){ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + else{ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + } + else { + $color = array(); + + $color[0] = array('border' => '#000000', + 'color' => $config['graph_color1'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[1] = array('border' => '#000000', + 'color' => $config['graph_color2'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[2] = array('border' => '#000000', + 'color' => $config['graph_color3'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[3] = array('border' => '#000000', + 'color' => $config['graph_color4'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[4] = array('border' => '#000000', + 'color' => $config['graph_color5'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[5] = array('border' => '#000000', + 'color' => $config['graph_color6'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[6] = array('border' => '#000000', + 'color' => $config['graph_color7'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[7] = array('border' => '#000000', + 'color' => $config['graph_color8'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[8] = array('border' => '#000000', + 'color' => $config['graph_color9'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[9] = array('border' => '#000000', + 'color' => $config['graph_color10'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[11] = array('border' => '#000000', + 'color' => COL_GRAPH9, + 'alpha' => CHART_DEFAULT_ALPHA); + $color[12] = array('border' => '#000000', + 'color' => COL_GRAPH10, + 'alpha' => CHART_DEFAULT_ALPHA); + $color[13] = array('border' => '#000000', + 'color' => COL_GRAPH11, + 'alpha' => CHART_DEFAULT_ALPHA); + $color[14] = array('border' => '#000000', + 'color' => COL_GRAPH12, + 'alpha' => CHART_DEFAULT_ALPHA); + $color[15] = array('border' => '#000000', + 'color' => COL_GRAPH13, + 'alpha' => CHART_DEFAULT_ALPHA); + + $module_data = get_bars_module_data($id_module); + $water_mark = array('file' => '/var/www/html/pandora_console/images/logo_vertical_water.png', + 'url' => 'http://localhost/pandora_console/images/logo_vertical_water.png'); + + if ($width == 0 && $height == 0) { + if ($layoutData['label_position']=='left') { + if ($layoutData['type_graph'] == 'horizontal') { + $img = '
'. + hbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; + } + else { + $img = '
'. + vbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; + } + } + elseif($layoutData['label_position']=='right') { + if ($layoutData['type_graph'] == 'horizontal') { + $img = '
'. + hbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; + } + else { + $img = '
'. + vbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; + } + } + else { + if ($layoutData['type_graph'] == 'horizontal') { + $img = hbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']); + } + else { + $img = vbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']); + } + } + } + else{ + if ($layoutData['label_position']=='left') { + if ($layoutData['type_graph'] == 'horizontal') { + $img = '
'. + hbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; + } + else { + $img = '
'. + vbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; + } + } + elseif($layoutData['label_position']=='right') { + if ($layoutData['type_graph'] == 'horizontal') { + $img = '
'. + hbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; + } + else { + $img = '
'. + vbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; + } + } + else { + if ($layoutData['type_graph'] == 'horizontal') { + $img = hbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']); + } + else { + $img = vbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']); + } + } + } + } + + //Restore db connection + if ($layoutData['id_metaconsole'] != 0) { + metaconsole_restore_db(); + } + + break; + + case DONUT_GRAPH: + if (!empty($id_metaconsole)) { + $connection = db_get_row_filter ('tmetaconsole_setup', $id_metaconsole); + if (metaconsole_load_external_db($connection) != NOERR) { + continue; + } + } + + + $is_string = db_get_value_filter ('id_tipo_modulo', 'tagente_modulo', + array ('id_agente' => $layoutData['id_agent'], + 'id_agente_modulo' => $id_module)); + + if (!empty($id_metaconsole)) { + metaconsole_restore_db(); + } + + if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) || + ($is_string == 10) || ($is_string == 33)) { + $no_data = false; + } + else { + $no_data = true; + } + + if ($no_data) { + if($width == 0){ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + else{ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + } + else { + $donut_data = get_donut_module_data($layoutData['id_agente_modulo']); + + if ((get_parameter('action') == 'edit') || (get_parameter('operation') == 'edit_visualmap')) { + if($width == 0){ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + else{ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + } + else { + if ($width == 0) { + $img = d3_donut_graph ($layoutData['id'], 300, 300, $donut_data, $layoutData['border_color']); + } + else{ + $img = d3_donut_graph ($layoutData['id'], $width, $width, $donut_data, $layoutData['border_color']); + } + } + } + + //Restore db connection + if ($layoutData['id_metaconsole'] != 0) { + metaconsole_restore_db(); + } + + $z_index = 2 + 1; + break; + case LABEL: $z_index = 4 + 1; break; @@ -1094,10 +1444,10 @@ function visual_map_print_item($mode = "read", $layoutData, else { if ($width == 0 || $height == 0) { if ($layoutData['label_position']=='left') { - $img = '
' .graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true).'
'; + $img = '
' .graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true).'
'; } elseif ($layoutData['label_position']=='right') { - $img = '
' . graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true).'
'; + $img = '
' . graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true).'
'; } else { $img = graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true); @@ -1105,10 +1455,10 @@ function visual_map_print_item($mode = "read", $layoutData, } else{ if ($layoutData['label_position']=='left') { - $img = '
' . graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true).'
'; + $img = '
' . graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true).'
'; } elseif ($layoutData['label_position']=='right') { - $img = '
' .graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true).'
'; + $img = '
' .graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true).'
'; } else { $img = graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true); @@ -1136,13 +1486,21 @@ function visual_map_print_item($mode = "read", $layoutData, case GROUP_ITEM: $class .= "group_item"; break; + case DONUT_GRAPH: + $class .= "donut_graph"; + break; case PERCENTILE_BAR: case PERCENTILE_BUBBLE: + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: $class .= "percentile_item"; break; case MODULE_GRAPH: $class .= "module_graph"; break; + case BARS_GRAPH: + $class .= "bars_graph"; + break; case SIMPLE_VALUE: case SIMPLE_VALUE_MAX: case SIMPLE_VALUE_MIN: @@ -1165,6 +1523,10 @@ function visual_map_print_item($mode = "read", $layoutData, break; } + if($show_on_top){ + $z_index = 10; + } + echo '
"; } - + + //for clean link text from bbdd only edit_visualmap + if (get_parameter('action') == 'edit' || get_parameter('operation') == 'edit_visualmap') { + $text = preg_replace("/<\/*a.*?>/", '', $text); + } + switch ($type) { case BOX_ITEM: if ($width == 0 || $width == 0) { @@ -1186,7 +1553,7 @@ function visual_map_print_item($mode = "read", $layoutData, $style .= "border-width: " . $border_width . "px; "; $style .= "border-color: " . $border_color . "; "; $style .= "background-color: " . $fill_color . "; "; - echo "
"; + echo "
"; } else { if (!empty($proportion)) { @@ -1197,7 +1564,7 @@ function visual_map_print_item($mode = "read", $layoutData, $style .= "border-width: " . $border_width . "px; "; $style .= "border-color: " . $border_color . "; "; $style .= "background-color: " . $fill_color . "; "; - echo "
"; + echo "
"; } else { $style = ""; @@ -1207,13 +1574,14 @@ function visual_map_print_item($mode = "read", $layoutData, $style .= "border-width: " . $border_width . "px; "; $style .= "border-color: " . $border_color . "; "; $style .= "background-color: " . $fill_color . "; "; - echo "
"; + echo "
"; } } break; case STATIC_GRAPH: case GROUP_ITEM: - if ($layoutData['image'] != null || $layoutData['show_statistics'] == 1) { + + if (($layoutData['image'] != null && $layoutData['image'] != 'none') || $layoutData['show_statistics'] == 1) { $img_style_title = strip_tags($label); @@ -1232,8 +1600,12 @@ function visual_map_print_item($mode = "read", $layoutData, if (!empty($unit_text)) $value .= " " . $unit_text; - $img_style_title .= "
" . __("Last value: ") . - $value; + // Hide value on boolean modules + if (!modules_is_boolean($layoutData['id_agente_modulo'])) { + $img_style_title .= + "
" . __("Last value: ") + . $value; + } } if(get_parameter('action') == 'edit'){ @@ -1408,145 +1780,173 @@ function visual_map_print_item($mode = "read", $layoutData, break; case PERCENTILE_BAR: - $imgpos = ''; - - if($layoutData['label_position']=='left'){ - $imgpos = 'float:right;'; - } - else if($layoutData['label_position']=='right'){ - $imgpos = 'float:left;'; - } - - $progress_bar_heigh = 15; - if (!empty($proportion)) { - if ($width != 0) { - $width = (integer)($proportion['proportion_width'] * $width); - } - else { - $width = (integer)($proportion['proportion_width'] * $infoImage[0]); - } + if (($layoutData['image'] == 'value') && ($value_text !== false)) { + $unit_text = db_get_sql ('SELECT unit + FROM tagente_modulo + WHERE id_agente_modulo = ' . $id_module); + $unit_text = trim(io_safe_output($unit_text)); - if ($height != 0) { - $height = (integer)($proportion['proportion_height'] * $height); - $progress_bar_heigh = $progress_bar_heigh * $proportion['proportion_height']; - } - else { - $height = (integer)($proportion['proportion_height'] * $infoImage[1]); - } - } - - if($layoutData['label_position']=='up'){ - echo io_safe_output($text); - } - - ob_start(); - if ($type == PERCENTILE_BUBBLE) { - echo progress_bubble($percentile, $width, $width, '', 1, $value_text, $colorStatus,$imgpos); + $percentile = $value_text; } else { - echo progress_bar($percentile, $width, $progress_bar_heigh, '', 1, $value_text, $colorStatus,$imgpos); + $unit_text = "%"; } - $img = ob_get_clean(); - if (get_parameter('action') == 'edit') { - if ($width == 0) { - $img = ''; + if (get_parameter('action') == 'edit' || (get_parameter('operation') == 'edit_visualmap')) { + if($width == 0){ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } } - else { - $img = ''; + else{ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } } } else{ - $img = str_replace('>', 'class="image" style="height:'.$himg.'px;width:'.$wimg.'px;'.$imgpos.'" id="image_' . $id . '" />', $img); + $img = d3_progress_bar($id, $percentile, $width, 50, $border_color, $unit_text, io_safe_output($label), $fill_color); } - echo $img; + echo $img; - if($layoutData['label_position']=='down'){ - echo io_safe_output($text); - } - else if($layoutData['label_position']=='left' || $layoutData['label_position']=='right'){ - echo io_safe_output($text); - } - break; - case PERCENTILE_BUBBLE: - - $imgpos = ''; - - if($layoutData['label_position']=='left'){ - $imgpos = 'float:right;'; + if (($layoutData['image'] == 'value') && ($value_text !== false)) { + $unit_text = db_get_sql ('SELECT unit + FROM tagente_modulo + WHERE id_agente_modulo = ' . $id_module); + $unit_text = trim(io_safe_output($unit_text)); + + $percentile = $value_text; } - else if($layoutData['label_position']=='right'){ - $imgpos = 'float:left;'; + else { + $unit_text = "%"; } - - $progress_bar_heigh = 15; - if (!empty($proportion)) { - if ($width != 0) { - $width = (integer)($proportion['proportion_width'] * $width); + + if(get_parameter('action') == 'edit' || (get_parameter('operation') == 'edit_visualmap')){ + if($width == 0){ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + else{ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + } + else{ + if($width == 0){ + $img = d3_progress_bubble($id, $percentile, 200,200, $border_color, $unit_text, io_safe_output($label), $fill_color); + } + else{ + $img = d3_progress_bubble($id, $percentile, $width, $width, $border_color, $unit_text, io_safe_output($label), $fill_color); + } + } + + echo $img; + + break; + case CIRCULAR_PROGRESS_BAR: + if(get_parameter('action') == 'edit' || (get_parameter('operation') == 'edit_visualmap')){ + if($width == 0){ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + else{ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + } + else { + if (($layoutData['image'] == 'value') && ($value_text !== false)) { + $unit_text = db_get_sql ('SELECT unit + FROM tagente_modulo + WHERE id_agente_modulo = ' . $id_module); + $unit_text = trim(io_safe_output($unit_text)); + + $percentile = $value_text; } else { - $width = (integer)($proportion['proportion_width'] * $infoImage[0]); + $unit_text = "%"; } - if ($height != 0) { - $height = (integer)($proportion['proportion_height'] * $height); - $progress_bar_heigh = $progress_bar_heigh * $proportion['proportion_height']; + if($width == 0){ + $img = progress_circular_bar($id, $percentile, 200,200, $border_color, $unit_text, io_safe_output($label), $fill_color); } - else { - $height = (integer)($proportion['proportion_height'] * $infoImage[1]); + else{ + $img = progress_circular_bar($id, $percentile, $width, $width, $border_color, $unit_text, io_safe_output($label), $fill_color); } } + + echo $img; - if($layoutData['label_position']=='up'){ - echo io_safe_output($text); - } - - ob_start(); - if ($type == PERCENTILE_BUBBLE) { + break; + case CIRCULAR_INTERIOR_PROGRESS_BAR: + if(get_parameter('action') == 'edit' || (get_parameter('operation') == 'edit_visualmap')){ if($width == 0){ - echo progress_bubble($percentile, 100,100, '', 1, $value_text, $colorStatus,$s); + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + else{ + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; + } + else{ + $img = ''; + } + } + } + else { + if (($layoutData['image'] == 'value') && ($value_text !== false)) { + $unit_text = db_get_sql ('SELECT unit + FROM tagente_modulo + WHERE id_agente_modulo = ' . $id_module); + $unit_text = trim(io_safe_output($unit_text)); + + $percentile = $value_text; + } + else { + $unit_text = "%"; + } + + if($width == 0){ + $img = progress_circular_bar_interior($id, $percentile, 200,200, $border_color, $unit_text, io_safe_output($label), $fill_color); } else{ - echo progress_bubble($percentile, $width,$width, '', 1, $value_text, $colorStatus); + $img = progress_circular_bar_interior($id, $percentile, $width, $width, $border_color, $unit_text, io_safe_output($label), $fill_color); } } - else { - echo progress_bar($percentile, $width, $progress_bar_heigh, '', 1, $value_text, $colorStatus); - } - $img = ob_get_clean(); - - if(get_parameter('action') == 'edit'){ - - if($width == 0){ - $img = ''; - } - else{ - $img = ''; - } - - } - else{ - - $img = str_replace('>', 'class="image" style="width:'.$wimg.'px;height:'.$himg.'px;'.$imgpos.'" id="image_' . $id . '" />', $img); - - } - - echo $img; - - if($layoutData['label_position']=='down'){ - echo io_safe_output($text); - } - else if($layoutData['label_position']=='left' || $layoutData['label_position']=='right'){ - echo io_safe_output($text); - } + echo $img; break; - case MODULE_GRAPH: if ($layoutData['label_position']=='up') { echo io_safe_output($text); @@ -1554,6 +1954,20 @@ function visual_map_print_item($mode = "read", $layoutData, echo $img; + if ($layoutData['label_position']=='down') { + echo io_safe_output($text); + } + elseif($layoutData['label_position']=='left' || $layoutData['label_position']=='right') { + echo io_safe_output($text); + } + break; + case BARS_GRAPH: + if ($layoutData['label_position']=='up') { + echo io_safe_output($text); + } + + echo $img; + if ($layoutData['label_position']=='down') { echo io_safe_output($text); } @@ -1575,6 +1989,10 @@ function visual_map_print_item($mode = "read", $layoutData, echo io_safe_output($text); } break; + case DONUT_GRAPH: + echo $img; + break; + case SIMPLE_VALUE: case SIMPLE_VALUE_MAX: case SIMPLE_VALUE_MIN: @@ -1604,39 +2022,25 @@ function visual_map_print_item($mode = "read", $layoutData, global $config; - if ($type == SIMPLE_VALUE) { - //~ $returnValue_value = explode(' ', $value); - - //~ if ($returnValue_value[1] != "") { - //~ $value = remove_right_zeros(number_format($returnValue_value[0], $config['graph_precision'])) . " " . $returnValue_value[1]; - //~ } - //~ else { - //~ $value = remove_right_zeros(number_format($returnValue_value[0], $config['graph_precision'])); - //~ } - - } - else { - // If the value is a string, dont format it - if (!is_string($value)) { - //~ $value = remove_right_zeros(format_for_graph($value, $config['graph_precision'])); - } - } - - if(get_parameter('action') == 'edit'){ - if( (strip_tags($io_safe_output_text) != '_VALUE_') || (strip_tags($io_safe_output_text) != '(_VALUE_)') ) { + $is_image = get_if_module_is_image($layoutData['id_agente_modulo']); + if(get_parameter('action') == 'edit') { + if(!$is_image) { echo $io_safe_output_text; } else { echo ""; } - } else { - if(strrpos(strip_tags($io_safe_output_text),'(_VALUE_)') !== false || (strip_tags($io_safe_output_text) == '(_VALUE_)')) { - echo str_replace(array("(_VALUE_)","(_value_)"), $value, $io_safe_output_text); + } + else { + if(!$is_image) { + $new_text = str_replace(array("(_VALUE_)","(_value_)"), $value, $io_safe_output_text); + $new_text = str_replace(array('_VALUE_','_value_'), $value, $new_text); + + echo $new_text; } - elseif(strrpos(strip_tags($io_safe_output_text),'_VALUE_') !== false || (strip_tags($io_safe_output_text) == '_VALUE_')) { - echo str_replace(array('_VALUE_','_value_'), $value, $io_safe_output_text); - } else { - echo str_replace('>', ' style="width:'.$layoutData['width'].'px">',$value); + else { + $simple_value_img = str_replace('>', ' style="width:'.$layoutData['width'].'px">', $value); + echo $simple_value_img; } } @@ -1726,6 +2130,43 @@ function visual_map_print_item($mode = "read", $layoutData, } } +function get_if_module_is_image ($id_module) { + $sql = 'SELECT datos FROM tagente_estado WHERE id_agente_modulo = ' . $id_module; + + $result = db_get_sql($sql); + $image = strpos($result, 'data:image'); + + if($image === false){ + return false; + } + else{ + return true; + } +} + +function get_bars_module_data ($id_module) { + $mod_values = db_get_value_filter('datos', 'tagente_estado', array('id_agente_modulo' => $id_module)); + + if (preg_match("/\r\n/", $mod_values)) { + $values = explode("\r\n", $mod_values); + } + elseif (preg_match("/\n/", $mod_values)) { + $values = explode("\n", $mod_values); + } + + $values_to_return = array(); + $index = 0; + $color_index = 0; + $total = 0; + foreach ($values as $val) { + $data = explode(",", $val); + $values_to_return[$data[0]] = array('g' =>$data[1]); + } + + return $values_to_return; +} + + /** * The function to get simple value type from the value of process type in the form * @@ -1889,11 +2330,19 @@ function visual_map_process_wizard_add ($id_agents, $image, $id_layout, $range, switch ($type) { case PERCENTILE_BAR: case PERCENTILE_BUBBLE: + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: $value_height = $max_value; $value_image = $value_show; if ($type_percentile == 'percentile') { $value_type = PERCENTILE_BAR; } + elseif ($type_percentile == 'interior_circular_progress_bar') { + $value_type = CIRCULAR_INTERIOR_PROGRESS_BAR; + } + elseif ($type_percentile == 'circular_progress_bar') { + $value_type = CIRCULAR_PROGRESS_BAR; + } else { $value_type = PERCENTILE_BUBBLE; } @@ -2015,12 +2464,20 @@ function visual_map_process_wizard_add_modules ($id_modules, $image, switch ($type) { case PERCENTILE_BAR: case PERCENTILE_BUBBLE: + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: $value_height = $max_value; $value_width = $percentileitem_width; $value_image = $value_show; if ($type_percentile == 'percentile') { $value_type = PERCENTILE_BAR; } + elseif ($type_percentile == 'interior_circular_progress_bar') { + $value_type = CIRCULAR_INTERIOR_PROGRESS_BAR; + } + elseif ($type_percentile == 'circular_progress_bar') { + $value_type = CIRCULAR_PROGRESS_BAR; + } else { $value_type = PERCENTILE_BUBBLE; } @@ -2078,6 +2535,88 @@ function visual_map_process_wizard_add_modules ($id_modules, $image, return $return; } +function get_donut_module_data ($id_module) { + $mod_values = db_get_value_filter('datos', 'tagente_estado', array('id_agente_modulo' => $id_module)); + + if (preg_match("/\r\n/", $mod_values)) { + $values = explode("\r\n", $mod_values); + } + elseif (preg_match("/\n/", $mod_values)) { + $values = explode("\n", $mod_values); + } + + $colors = array(); + $colors[] = "#aa3333"; + $colors[] = "#045FB4"; + $colors[] = "#8181F7"; + $colors[] = "#F78181"; + $colors[] = "#D0A9F5"; + $colors[] = "#BDBDBD"; + $colors[] = "#6AB277"; + + $max_elements = 6; + $values_to_return = array(); + $index = 0; + $total = 0; + foreach ($values as $val) { + if ($index < $max_elements) { + $data = explode(",", $val); + if ($data[1] == 0) { + $data[1] = __('No data'); + } + $values_to_return[$index]['tag_name'] = $data[0] . ": " . $data[1]; + $values_to_return[$index]['color'] = $colors[$index]; + $values_to_return[$index]['value'] = (int)$data[1]; + $total += (int)$data[1]; + $index++; + } + else { + if ($data[1] == 0) { + $data[1] = __('No data'); + } + $data = explode(",", $val); + $values_to_return[$index]['tag_name'] = __('Others') . ": " . $data[1]; + $values_to_return[$index]['color'] = $colors[$index]; + $values_to_return[$index]['value'] += (int)$data[1]; + $total += (int)$data[1]; + } + } + + foreach ($values_to_return as $ind => $donut_data) { + $values_to_return[$ind]['percent'] = ($donut_data['value'] * 100) / $total; + } + + $new_values_to_return = array(); + while (!empty($values_to_return)) { + $first = true; + $max_elem = 0; + $max_elem_array = array(); + $index_to_del = 0; + foreach ($values_to_return as $i => $val) { + if ($first) { + $max_elem = $val['value']; + $max_elem_array = $val; + $index_to_del = $i; + $first = false; + } + else { + if ($val['value'] > $max_elem) { + $max_elem = $val['value']; + $max_elem_array = $val; + $index_to_del = $i; + } + } + } + + $new_values_to_return[] = $max_elem_array; + unset($values_to_return[$index_to_del]); + } + $values_to_return = $new_values_to_return; + + return $values_to_return; +} + + /** * The function to save the new elements of agents make as wizard. * @@ -2143,12 +2682,20 @@ function visual_map_process_wizard_add_agents ($id_agents, $image, switch ($type) { case PERCENTILE_BAR: case PERCENTILE_BUBBLE: + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: $value_height = $max_value; $value_width = $percentileitem_width; $value_image = $value_show; if ($type_percentile == 'percentile') { $value_type = PERCENTILE_BAR; } + elseif ($type_percentile == 'interior_circular_progress_bar') { + $value_type = CIRCULAR_INTERIOR_PROGRESS_BAR; + } + elseif ($type_percentile == 'circular_progress_bar') { + $value_type = CIRCULAR_PROGRESS_BAR; + } else { $value_type = PERCENTILE_BUBBLE; } @@ -2369,6 +2916,8 @@ function visual_map_get_image_status_element($layoutData, $status = false) { * @return integer */ function visual_map_get_status_element($layoutData) { + global $config; + enterprise_include_once('include/functions_visual_map.php'); if (enterprise_installed()) { $status = enterprise_visual_map_get_status_element($layoutData); @@ -2386,7 +2935,34 @@ function visual_map_get_status_element($layoutData) { //Linked to other layout ?? - Only if not module defined if ($layoutData['id_layout_linked'] != 0) { - $status = visual_map_get_layout_status ($layoutData['id_layout_linked']); + if ($layoutData['id_layout_linked_weight'] != 0) { + $calculate_weight = true; + } + else { + $calculate_weight = false; + } + $status = visual_map_get_layout_status ($layoutData['id_layout_linked'], 0, 0, $calculate_weight); + + if ($layoutData['id_layout_linked_weight'] > 0) { + $elements_to_compare = db_get_all_rows_sql("SELECT id, element_group FROM tlayout_data WHERE type = 0 AND id_layout = " . $layoutData['id_layout_linked']); + + $childs_group_acl = array(); + foreach ($elements_to_compare as $c) { + if (check_acl ($config['id_user'], $c['element_group'], "VR")) { + $childs_group_acl[] = $c['id']; + } + } + $elements_to_compare = $childs_group_acl; + + $aux_weight = ($status['elements_in_critical'] / count($elements_to_compare)) * 100; + + if ($aux_weight >= $layoutData['id_layout_linked_weight']) { + $status = $status['temp_total']; + } + else { + $status = VISUAL_MAP_STATUS_NORMAL; + } + } } else { switch ($layoutData["type"]) { @@ -2455,6 +3031,8 @@ function visual_map_get_status_element($layoutData) { case PERCENTILE_BAR: case PERCENTILE_BUBBLE: + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: if (empty($module_value) || $module_value == '') { return VISUAL_MAP_STATUS_UNKNOWN; @@ -2709,6 +3287,11 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, foreach ($layout_datas as $layout_data) { + $layout_group = $layout_data['element_group']; + if (!check_acl ($config['id_user'], $layout_group, "VR")) { + continue; + } + //Check the items are from disabled or pending delete modules if ($layout_data['id_agente_modulo'] != 0 && (($layout_data['type'] != LABEL) @@ -2736,7 +3319,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, 'proportion_width' => $proportion_width); } - $layout_data['label'] = visual_map_macro($layout_data['label']); + $layout_data['label'] = visual_map_macro($layout_data['label'],$layout_data["id_agente_modulo"]); switch ($layout_data['type']) { case LINE_ITEM: @@ -2775,13 +3358,32 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, * @return array A list of layouts the user can see. */ function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter = false, $returnAllGroup = true) { - if (! is_array ($filter)) + if (! is_array ($filter)){ $filter = array (); - - if ($returnAllGroup) + } else { + if(!empty($filter['name'])){ + $where .= "name LIKE '%".io_safe_output($filter['name'])."%'"; + unset($filter['name']); + } + } + + if ($returnAllGroup) { $groups = users_get_groups ($id_user, 'VR'); - else - $groups = users_get_groups ($id_user, 'VR', false); + } else { + if(!empty($filter['group'])) { + $permissions_group = users_get_groups ($id_user, 'VR', false); + if(empty($permissions_group)){ + $permissions_group = users_get_groups ($id_user, 'VM', false); + } + $groups = array_intersect_key($filter['group'], $permissions_group); + } else { + $groups = users_get_groups ($id_user, 'VR', false); + if(empty($groups)) { + $groups = users_get_groups ($id_user, 'VM', false); + } + } + unset($filter['group']); + } if (!empty($groups)) { if (empty($where)) @@ -2828,7 +3430,9 @@ function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter * * @return bool The status of the given layout. True if it's OK, false if not. */ -function visual_map_get_layout_status ($id_layout = 0, $depth = 0) { +function visual_map_get_layout_status ($id_layout = 0, $depth = 0, $elements_in_critical = 0, $calculate_weight = false) { + global $config; + $temp_status = VISUAL_MAP_STATUS_NORMAL; $temp_total = VISUAL_MAP_STATUS_NORMAL; $depth++; // For recursion depth checking @@ -2848,11 +3452,20 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) { 'parent_item', 'id_layout_linked', 'id_agent', - 'type')); + 'type', + 'id_layout_linked_weight', + 'id', + 'id_layout', + 'element_group')); if ($result === false) return VISUAL_MAP_STATUS_NORMAL; foreach ($result as $data) { + $layout_group = $data['element_group']; + if (!check_acl ($config['id_user'], $layout_group, "VR")) { + continue; + } + switch ($data['type']) { case GROUP_ITEM: if ($data["id_layout_linked"] == 0) { @@ -2890,12 +3503,39 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) { // Other Layout (Recursive!) if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) { - $status = visual_map_get_layout_status($data["id_layout_linked"], $depth); + if ($data['id_layout_linked_weight'] > 0) { + $calculate_weight_c = true; + } + else { + $calculate_weight_c = false; + } + $status = visual_map_get_layout_status($data["id_layout_linked"], $depth, 0, $calculate_weight_c); + + $elements_in_child = db_get_all_rows_sql("SELECT id, element_group FROM tlayout_data WHERE type = 0 AND id_layout = " . $data['id_layout_linked']); + $layout_group = $data['element_group']; + + $childs_group_acl = array(); + foreach ($elements_in_child as $c) { + if (check_acl ($config['id_user'], $c['element_group'], "VR")) { + $childs_group_acl[] = $c['id']; + } + } + $elements_in_child = $childs_group_acl; + + if ($calculate_weight_c) { + $aux_weight = ($status['elements_in_critical'] / count($elements_in_child)) * 100; + + if ($aux_weight >= $data['id_layout_linked_weight']) { + $status = $status['temp_total']; + } + else { + $status = VISUAL_MAP_STATUS_NORMAL; + } + } } // Module elseif ($data["id_agente_modulo"] != 0) { $status = modules_get_agentmodule_status($data["id_agente_modulo"]); - } // Agent else { @@ -2909,11 +3549,31 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) { break; } - if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD) - return VISUAL_MAP_STATUS_CRITICAL_BAD; + if ($calculate_weight) { + if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD || $status == VISUAL_MAP_STATUS_WARNING) { + $elements_in_critical++; + } + } + else { + if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD) { + return VISUAL_MAP_STATUS_CRITICAL_BAD; + } - if ($status > $temp_total) + } + if ($calculate_weight) { + if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD) { + $temp_total = VISUAL_MAP_STATUS_CRITICAL_BAD; + } + else if ($status == VISUAL_MAP_STATUS_WARNING && $temp_total != VISUAL_MAP_STATUS_CRITICAL_BAD) { + $temp_total = VISUAL_MAP_STATUS_WARNING; + } + } + else if ($status > $temp_total) { $temp_total = $status; + } + } + if ($calculate_weight) { + return array('elements_in_critical' => $elements_in_critical, 'temp_total' => $temp_total); } return $temp_total; @@ -2947,6 +3607,10 @@ function visual_map_create_internal_name_item($label = null, $type, $image, $age case MODULE_GRAPH: $text = __('Module graph'); break; + case 'bars_graph': + case BARS_GRAPH: + $text = __('Bars graph'); + break; case 'auto_sla_graph': case AUTO_SLA_GRAPH: $text = __('Auto SLA Graph'); @@ -2955,6 +3619,14 @@ function visual_map_create_internal_name_item($label = null, $type, $image, $age case PERCENTILE_BAR: $text = __('Percentile bar'); break; + case 'circular_progress_bar': + case CIRCULAR_PROGRESS_BAR: + $text = __('Circular progress bar'); + break; + case 'interior_circular_progress_bar': + case CIRCULAR_INTERIOR_PROGRESS_BAR: + $text = __('Circular progress bar (interior)'); + break; case 'static_graph': case STATIC_GRAPH: $text = __('Static graph') . " - " . @@ -3059,9 +3731,18 @@ function visual_map_type_in_js($type) { case PERCENTILE_BAR: return 'percentile_item'; break; + case CIRCULAR_PROGRESS_BAR: + return 'percentile_item'; + break; + case CIRCULAR_INTERIOR_PROGRESS_BAR: + return 'percentile_item'; + break; case MODULE_GRAPH: return 'module_graph'; break; + case BARS_GRAPH: + return 'bars_graph'; + break; case AUTO_SLA_GRAPH: return 'auto_sla_graph'; break; @@ -3101,9 +3782,14 @@ function visual_map_type_in_js($type) { } } -function visual_map_macro($label){ +function visual_map_macro($label,$module){ $label = str_replace('_date_',strftime("%x"),$label); $label = str_replace('_time_',strftime("%T"),$label); + $label = str_replace('_agent_',agents_get_alias(modules_get_agentmodule_agent($module)),$label); + $label = str_replace('_module_',modules_get_agentmodule_name($module),$label); + $label = str_replace('_agentdescription_',agents_get_description(modules_get_agentmodule_agent($module)),$label); + $label = str_replace('_address_',agents_get_address(modules_get_agentmodule_agent($module)),$label); + $label = str_replace('_moduledescription_',modules_get_agentmodule_descripcion($module),$label); return $label; } diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index 54db2d8008..682b78d3e5 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -157,13 +157,12 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['label_row'] = array(); $form_items['label_row']['items'] = array('label', 'static_graph', - 'percentile_bar', - 'percentile_item', 'module_graph', 'simple_value', 'datos', 'group_item', - 'auto_sla_graph'); + 'auto_sla_graph', + 'bars_graph'); $form_items['label_row']['html'] = '' . __('Label') . ' @@ -189,7 +188,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { ' . html_print_input_text('label', '', '', 20, 200, true) . ' - '.__("Click right mouse button to change the background color of the label editor").' + '.__("Scroll the mouse wheel over the label editor to change the background color").' '; @@ -202,7 +201,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['image_row']['html'] = '' . __('Image') . ' ' . - html_print_select ($images_list, 'image', '', 'showPreview(this.value);', 'None', '', true) . + html_print_select ($images_list, 'image', '', 'showPreview(this.value);', 'None', 'none', true) . ''; @@ -214,7 +213,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { 'module_graph', 'simple_value', 'datos', - 'icon'); + 'icon', + 'bars_graph'); if (!is_metaconsole()) $form_items['enable_link_row']['items'][] = 'group_item'; @@ -237,7 +237,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['background_color'] = array(); $form_items['background_color']['items'] = array( 'module_graph', - 'datos'); + 'datos', + 'bars_graph'); $form_items['background_color']['html'] = '' . __('Background color') . ' '. html_print_select ( @@ -245,6 +246,18 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { 'black' => __('Black'), 'transparent' => __('Transparent')), 'background_color', '', '', 0, 'white', true, false, false) . ''; + + $form_items['grid_color_row'] = array(); + $form_items['grid_color_row']['items'] = array('bars_graph'); + $form_items['grid_color_row']['html'] = + '' . + __('Grid color') . + '' . + '' . + html_print_input_text_extended ('grid_color', + '#000000', 'text-grid_color', '', 7, 7, false, + '', 'class="grid_color"', true) . + ''; $form_items['radio_choice_graph'] = array(); $form_items['radio_choice_graph']['items'] = array( @@ -290,6 +303,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $params['use_hidden_input_idagent'] = true; $params['print_hidden_input_idagent'] = true; $params['hidden_input_idagent_name'] = 'id_agent'; + $params['get_order_json'] = true; if (defined('METACONSOLE')) { $params['javascript_ajax_page'] = '../../ajax.php'; $params['disabled_javascript_on_blur_function'] = true; @@ -306,17 +320,62 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['agent_row']['html'] .= '' . ui_print_agent_autocomplete_input($params) . ''; + + $form_items['agent_row_string'] = array(); + $form_items['agent_row_string']['items'] = array('donut_graph', 'bars_graph'); + $form_items['agent_row_string']['html'] = '' . + __('Agent') . ''; + $params = array(); + $params['return'] = true; + $params['show_helptip'] = true; + $params['input_name'] = 'agent_string'; + $params['size'] = 30; + $params['selectbox_id'] = 'module'; + $params['javascript_is_function_select'] = true; + $params['use_hidden_input_idagent'] = true; + $params['print_hidden_input_idagent'] = true; + $params['hidden_input_idagent_name'] = 'id_agent_string'; + $params['get_order_json'] = true; + $params['get_only_string_modules'] = true; + if (defined('METACONSOLE')) { + $params['javascript_ajax_page'] = '../../ajax.php'; + $params['disabled_javascript_on_blur_function'] = true; + + $params['print_input_server'] = true; + $params['print_input_id_server'] = true; + $params['input_server_id'] = 'id_server_name'; + $params['input_id_server_name'] = 'id_server_metaconsole'; + $params['input_server_value'] = ''; + $params['use_input_id_server'] = true; + $params['metaconsole_enabled'] = true; + $params['print_hidden_input_idagent'] = true; + } + $form_items['agent_row_string']['html'] .= '' . + ui_print_agent_autocomplete_input($params) . + ''; $form_items['module_row'] = array(); $form_items['module_row']['items'] = array('static_graph', 'percentile_bar', 'percentile_item', 'module_graph', - 'simple_value', 'datos', 'auto_sla_graph'); + 'simple_value', 'datos', 'auto_sla_graph', 'donut_graph', 'bars_graph'); $form_items['module_row']['html'] = '' . __('Module') . ' ' . html_print_select(array(), 'module', '', '', __('Any'), 0, true) . ' '; + $form_items['resume_color_row'] = array(); + $form_items['resume_color_row']['items'] = array('donut_graph'); + $form_items['resume_color_row']['html'] = + '' . + __('Resume data color') . + '' . + '' . + html_print_input_text_extended ('resume_color', + '#000000', 'text-resume_color', '', 7, 7, false, + '', 'class="resume_color"', true) . + ''; + $event_times = array(86400 => __('24h'), 28800 => __('8h'), 7200 => __('2h'), @@ -396,11 +455,16 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['percentile_bar_row_1'] = array(); - $form_items['percentile_bar_row_1']['items'] = array('percentile_bar', 'percentile_item', 'datos'); + $form_items['percentile_bar_row_1']['items'] = array('percentile_bar', 'percentile_item', 'datos', 'donut_graph', 'bars_graph'); $form_items['percentile_bar_row_1']['html'] = '' . __('Width') . ' ' . html_print_input_text('width_percentile', 0, '', 3, 5, true) . ''; - + + $form_items['height_bars_graph_row'] = array(); + $form_items['height_bars_graph_row']['items'] = array('bars_graph'); + $form_items['height_bars_graph_row']['html'] = '' . + __('Height') . ' + ' . html_print_input_text('bars_graph_height', 0, '', 3, 5, true) . ''; $form_items['percentile_bar_row_2'] = array(); $form_items['percentile_bar_row_2']['items'] = array('percentile_bar', 'percentile_item', 'datos'); @@ -408,23 +472,22 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { __('Max value') . ' ' . html_print_input_text('max_percentile', 0, '', 3, 5, true) . ''; + $percentile_type = array('percentile' => __('Percentile'), 'bubble' => __('Bubble'), 'circular_progress_bar' => __('Circular porgress bar'), 'interior_circular_progress_bar' => __('Circular progress bar (interior)')); + $percentile_value = array('percent' => __('Percent'), 'value' => __('Value')); if (is_metaconsole()){ $form_items['percentile_item_row_3'] = array(); $form_items['percentile_item_row_3']['items'] = array('percentile_bar', 'percentile_item', 'datos'); $form_items['percentile_item_row_3']['html'] = '' . __('Type') . ' ' . - html_print_radio_button_extended('type_percentile', 'percentile', ('Percentile'), 'percentile', false, '', 'style="float: left;"', true) . - html_print_radio_button_extended('type_percentile', 'bubble', ('Bubble'), 'percentile', false, '', 'style="float: left;"', true) . + html_print_select($percentile_type, 'type_percentile', 'percentile', '', '', '', true, false, false, '', false, 'style="float: left;"') . ''; - $form_items['percentile_item_row_4'] = array(); $form_items['percentile_item_row_4']['items'] = array('percentile_bar', 'percentile_item', 'datos'); $form_items['percentile_item_row_4']['html'] = '' . __('Value to show') . ' ' . - html_print_radio_button_extended('value_show', 'percent', ('Percent'), 'value', false, '', 'style="float: left;"', true) . - html_print_radio_button_extended('value_show', 'value', ('Value'), 'value', false, '', 'style="float: left;"', true) . + html_print_select($percentile_value, 'value_show', 'percent', '', '', '', true, false, false, '', false, 'style="float: left;"') . ''; } else{ @@ -433,20 +496,40 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['percentile_item_row_3']['html'] = '' . __('Type') . ' ' . - html_print_radio_button_extended('type_percentile', 'percentile', ('Percentile'), 'percentile', false, '', '', true) . - html_print_radio_button_extended('type_percentile', 'bubble', ('Bubble'), 'percentile', false, '', '', true) . + html_print_select($percentile_type, 'type_percentile', 'percentile', '', '', '', true) . ''; - $form_items['percentile_item_row_4'] = array(); $form_items['percentile_item_row_4']['items'] = array('percentile_bar', 'percentile_item', 'datos'); $form_items['percentile_item_row_4']['html'] = '' . __('Value to show') . ' ' . - html_print_radio_button_extended('value_show', 'percent', ('Percent'), 'value', false, '', '', true) . - html_print_radio_button_extended('value_show', 'value', ('Value'), 'value', false, '', '', true) . + html_print_select($percentile_value, 'value_show', 'percent', '', '', '', true) . ''; } + $form_items['percentile_item_row_5'] = array(); + $form_items['percentile_item_row_5']['items'] = array('percentile_bar', 'percentile_item', 'datos'); + $form_items['percentile_item_row_5']['html'] = '' . __('Element color') . ' + ' . + html_print_input_text_extended ('percentile_color', '#ffffff', + 'text-percentile_color', '', 7, 7, false, '', + 'class="percentile_color"', true) . + ''; + + $form_items['percentile_item_row_6'] = array(); + $form_items['percentile_item_row_6']['items'] = array('percentile_bar', 'percentile_item', 'datos'); + $form_items['percentile_item_row_6']['html'] = '' . __('Label color') . ' + ' . + html_print_input_text_extended ('percentile_label_color', '#ffffff', + 'text-percentile_label_color', '', 7, 7, false, '', + 'class="percentile_label_color"', true) . + ''; + + $form_items['percentile_bar_row_7'] = array(); + $form_items['percentile_bar_row_7']['items'] = array('percentile_bar', 'percentile_item', 'datos'); + $form_items['percentile_bar_row_7']['html'] = '' . + __('Label') . ' + ' . html_print_input_text('percentile_label', '', '', 30, 100, true) . ''; $form_items['period_row'] = array(); $form_items['period_row']['items'] = array('module_graph', 'simple_value', 'datos'); @@ -459,7 +542,13 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { '' . __('Show statistics') . ' ' . html_print_checkbox('show_statistics', 1, '', true) . ''; - + + $form_items['show_on_top_row'] = array(); + $form_items['show_on_top_row']['items'] = array('group_item'); + $form_items['show_on_top_row']['html'] = + '' . __('Always show on top') . ' + ' . + html_print_checkbox('show_on_top', 1, '', true) . ''; $form_items['module_graph_size_row'] = array(); $form_items['module_graph_size_row']['items'] = array('module_graph', 'datos'); @@ -472,6 +561,13 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { '1 '. ' item/s '; + + $bars_graph_types = array('vertical' => __('Vertical'), 'horizontal' => __('Horizontal')); + $form_items['bars_graph_type'] = array(); + $form_items['bars_graph_type']['items'] = array('bars_graph'); + $form_items['bars_graph_type']['html'] = '' . + __('Type') . ' + ' . html_print_select($bars_graph_types, 'bars_graph_type', 'vertical', '', '', '', true) . ''; //Insert and modify before the buttons to create or update. @@ -518,7 +614,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items_advance['position_row']['items'] = array('static_graph', 'percentile_bar', 'percentile_item', 'module_graph', 'simple_value', 'label', 'icon', 'datos', 'box_item', - 'auto_sla_graph'); + 'auto_sla_graph', 'bars_graph'); $form_items_advance['position_row']['html'] = ' ' . __('Position') . ' (' . html_print_input_text('left', '0', '', 3, 5, true) . @@ -547,7 +643,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items_advance['parent_row']['items'] = array( 'group_item', 'static_graph', 'percentile_bar', 'percentile_item', 'module_graph', - 'simple_value', 'label', 'icon', 'datos', 'auto_sla_graph'); + 'simple_value', 'label', 'icon', 'datos', 'auto_sla_graph', + 'bars_graph'); $form_items_advance['parent_row']['html'] = '' . __('Parent') . ' ' . @@ -568,10 +665,40 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { WHERE id != ' . $visualConsole_id, 'map_linked', '', '', 'None', '0', true) . ''; + $form_items_advance['map_linked_weight'] = array(); + $form_items_advance['map_linked_weight']['items'] = array('static_graph'); + $form_items_advance['map_linked_weight']['html'] = ''. + __('Map linked weight') . '' . + '' . html_print_select(array('10' => '10%', + '20' => '20%', + '30' => '30%', + '40' => '40%', + '50' => '50%', + '60' => '60%', + '70' => '70%', + '80' => '80%', + '90' => '90%', + '100' => '100%'), + 'map_linked_weight', '', '', __('By default'), 0, true) . + ui_print_help_icon ("linked_map_weight", true) . + ''; + $form_items_advance['line_case']['items'] = array('line_item'); $form_items_advance['line_case']['html'] = ' ' . __('Lines haven\'t advanced options') . ''; + $user_groups = users_get_groups($config['id_user']); + $form_items_advance['element_group_row'] = array(); + $form_items_advance['element_group_row']['items'] = array( + 'group_item', 'static_graph', 'percentile_bar', + 'percentile_item', 'module_graph', 'simple_value', + 'icon', 'label', 'datos'); + $form_items_advance['element_group_row']['html'] = ''. + __('Restrict access to group') . '' . + '' . html_print_select($user_groups, 'element_group', '', '', '', 0, true) . + ui_print_help_tip ( + __("If selected, restrict visualization of this item in the visual console to users who have access to selected group. This is also used on calculating child visual consoles."), true) . + ''; //Insert and modify before the buttons to create or update. if (enterprise_installed()) { @@ -614,6 +741,10 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $(".border_color").attachColorPicker(); $(".fill_color").attachColorPicker(); $(".line_color").attachColorPicker(); + $(".percentile_color").attachColorPicker(); + $(".percentile_label_color").attachColorPicker(); + $(".resume_color").attachColorPicker(); + $(".grid_color").attachColorPicker(); $("input[name=radio_choice]").change(function(){ $('#count_items').html(1); @@ -674,6 +805,8 @@ function visual_map_editor_print_toolbox() { visual_map_print_button_editor('static_graph', __('Static Graph'), 'left', false, 'camera_min', true); visual_map_print_button_editor('percentile_item', __('Percentile Item'), 'left', false, 'percentile_item_min', true); visual_map_print_button_editor('module_graph', __('Module Graph'), 'left', false, 'graph_min', true); + visual_map_print_button_editor('donut_graph', __('Serialized pie graph'), 'left', false, 'donut_graph_min', true); + visual_map_print_button_editor('bars_graph', __('Bars Graph'), 'left', false, 'bars_graph_min', true); visual_map_print_button_editor('auto_sla_graph', __('Auto SLA Graph'), 'left', false, 'auto_sla_graph_min', true); visual_map_print_button_editor('simple_value', __('Simple Value'), 'left', false, 'binary_min', true); visual_map_print_button_editor('label', __('Label'), 'left', false, 'label_min', true); @@ -735,6 +868,8 @@ function visual_map_editor_print_hack_translate_strings() { __('No Max value defined.') .''; echo ''; + echo ''; echo ''; echo '
"; show_alerts: showAlerts, avg_only: avgOnly, date: date, - unit: unit + unit: unit, + type_g: type_g }); } @@ -380,15 +418,23 @@ echo "
"; var $container = $(element); var $errorMessage = $('div#graph-error-message'); var period = $container.data('period'); - var conf_stacked = ''; + var conf_stacked = parseInt($("#option_type").val()); + switch (conf_stacked) { - case 'area': + case 0: var stacked = 0; break; - case 'line': + case 1: + var stacked = 1; + break; + case 2: var stacked = 2; break; + case 3: + var stacked = 3; + break; } + var date = $container.data('date'); var height = $container.data('height'); @@ -426,6 +472,16 @@ echo "
"; var unit = $container.data('unit'); var date = $container.data('date'); var height = $container.data('height'); + var conf_stacked = parseInt($("#option_type").val()); + + switch (conf_stacked) { + case 0: + var type_g = 'area'; + break; + case 2: + var type_g = 'line'; + break; + } var width = $container.width() - 20; @@ -435,8 +491,8 @@ echo "
"; var handleError = function (xhr, textStatus, errorThrown) { $container.html($errorMessage.html()); } - - requestSparseGraph(moduleId, period, showEvents, width, height, title, showAlerts, avgOnly, date, unit) + + requestSparseGraph(moduleId, period, showEvents, width, height, title, showAlerts, avgOnly, date, unit, type_g) .done(handleSuccess) .fail(handleError); } diff --git a/pandora_console/operation/agentes/networkmap.dinamic.php b/pandora_console/operation/agentes/networkmap.dinamic.php index 89db930aed..11e4874b3a 100644 --- a/pandora_console/operation/agentes/networkmap.dinamic.php +++ b/pandora_console/operation/agentes/networkmap.dinamic.php @@ -18,7 +18,13 @@ global $config; check_login (); -$id = get_parameter('id_networkmap', true); +if (_id_ != "_id_") { + $id = _id_; +} +else { + $id = get_parameter('id_networkmap', true); +} + $activeTab = get_parameter('activeTab', true); if (enterprise_installed()) { @@ -31,6 +37,11 @@ if (enterprise_installed()) { } } +if (_activeTab_ != "_activeTab_") { + $activeTab = _activeTab_; + $tab = $activeTab; +} + // Networkmap id required if (!isset($id)) { db_pandora_audit("ACL Violation", @@ -69,9 +80,49 @@ require_once ('include/functions_networkmap.php'); $strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); +$networkmap = db_get_row('tmap', 'id', $id); +$pure = (int) get_parameter ('pure', 0); + +/* Main code */ +if ($pure == 1) { + $buttons['screen'] = array('active' => false, + 'text' => '' . + html_print_image("images/normal_screen.png", true, + array ('title' => __('Normal screen'))) . + ''); +} +else { + if (!$dash_mode) { + $buttons['screen'] = array('active' => false, + 'text' => '' . + html_print_image("images/full_screen.png", true, + array ('title' => __('Full screen'))) . + ''); + $buttons['list'] = array('active' => false, + 'text' => '' . + html_print_image("images/list.png", true, + array ('title' => __('List of networkmap'))) . + ''); + } +} + +ui_print_page_header(io_safe_output($networkmap['name']), + "images/bricks.png", false, "network_map_enterprise", + false, $buttons, false, '', $config['item_title_size_text']); + global $width; global $height; +if (_id_ != "_id_") { + $width = array(); + $height = array(); +} + if (empty($width)) { $width = 600; } @@ -85,8 +136,9 @@ if ($activeTab == "radial_dynamic") { echo "
"; $filter = array(); - if (!empty($group)) - $filter['group'] = $group; + if ($networkmap['source'] == 0) { + $filter['group'] = $networkmap['source_data']; + } if (!empty($module_group)) $filter['module_group'] = $module_group; diff --git a/pandora_console/operation/agentes/pandora_networkmap.editor.php b/pandora_console/operation/agentes/pandora_networkmap.editor.php index eea978db77..6549c63cb3 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.editor.php +++ b/pandora_console/operation/agentes/pandora_networkmap.editor.php @@ -38,6 +38,13 @@ if ($new_networkmap) { $source = 'group'; $ip_mask = ''; $dont_show_subgroups = false; + $offset_x = ""; + $offset_y = ""; + $scale_z = 0.5; + $node_sep = 0.25; + $rank_sep = 1.0; + $mindist = 1.0; + $kval = 0.3; } $disabled_generation_method_select = false; @@ -75,6 +82,40 @@ if ($edit_networkmap) { $description = $values['description']; $filter = json_decode($values['filter'], true); + + $offset_x = $filter['x_offs']; + $offset_y = $filter['y_offs']; + $scale_z = $filter['z_dash']; + + if (isset($filter['node_sep'])) { + $node_sep = $filter['node_sep']; + } + else { + $node_sep = 0.25; + } + if (isset($filter['rank_sep'])) { + $rank_sep = $filter['rank_sep']; + } + else { + if ($values['generation_method'] == "twopi") { + $rank_sep = 1.0; + } + else { + $rank_sep = 0.5; + } + } + if (isset($filter['mindist'])) { + $mindist = $filter['mindist']; + } + else { + $mindist = 1.0; + } + if (isset($filter['kval'])) { + $kval = $filter['kval']; + } + else { + $kval = 0.3; + } $node_radius = $filter['node_radius']; @@ -190,6 +231,17 @@ else { $table->data[3][0] = __('Description'); $table->data[3][1] = html_print_textarea ('description', 7, 25, $description, '', true); + + $table->data[4][0] = __('Position X'); + $table->data[4][1] = html_print_input_text ('pos_x', $offset_x, '', 2, 10,true); + $table->data[5][0] = __('Position Y'); + $table->data[5][1] = html_print_input_text ('pos_y', $offset_y, '', 2, 10,true); + + $table->data[6][0] = __('Zoom scale'); + if ($scale_z == "") { + $scale_z = 0.5; + } + $table->data[6][1] = html_print_input_text ('scale_z', $scale_z, '', 2, 10,true) . ui_print_help_tip (__('Introduce zoom level. 1 = Highest resolution. Figures may include decimals'), true); $table->data['source'][0] = __('Source'); $table->data['source'][1] = @@ -222,11 +274,23 @@ else { 'radial_dinamic' => 'radial dinamic' ); - $table->data[4][0] = __('Method generation networkmap'); - $table->data[4][1] = html_print_select($methods, 'method', $method, + $table->data[7][0] = __('Method generation networkmap'); + $table->data[7][1] = html_print_select($methods, 'method', $method, '', '', 'twopi', true, false, true, '', $disabled_generation_method_select); + + $table->data['nodesep'][0] = __('Node separation'); + $table->data['nodesep'][1] = html_print_input_text ('node_sep', $node_sep, '', 5, 10,true, $disabled_source) . ui_print_help_tip (__('Separation between nodes. By default 0.25'), true); + $table->data['ranksep'][0] = __('Rank separation'); + $table->data['ranksep'][1] = html_print_input_text ('rank_sep', $rank_sep, '', 5, 10,true, $disabled_source) . ui_print_help_tip (__('Only flat and radial. Separation between arrows. By default 0.5 in flat and 1.0 in radial'), true); + + $table->data['mindist'][0] = __('Min nodes dist'); + $table->data['mindist'][1] = html_print_input_text ('mindist', $mindist, '', 5, 10,true, $disabled_source) . ui_print_help_tip (__('Only circular. Minimum separation between all nodes. By default 1.0'), true); + + $table->data['kval'][0] = __('Default ideal node separation'); + $table->data['kval'][1] = html_print_input_text ('kval', $kval, '', 5, 10,true, $disabled_source) . ui_print_help_tip (__('Only fdp. Default ideal node separation in the layout. By default 0.3'), true); + echo ''; html_print_table($table); @@ -278,7 +342,73 @@ $(document).ready(function() { .css('display', ''); } }); + + $("#method").on('change', function () { + var method = $("#method").val(); + + if (method == 'circo') { + $("#form_editor-ranksep") + .css('display', 'none'); + $("#form_editor-mindist") + .css('display', ''); + $("#form_editor-kval") + .css('display', 'none'); + $("#form_editor-nodesep") + .css('display', ''); + } + else if (method == 'dot') { + $("#form_editor-ranksep") + .css('display', ''); + $("#form_editor-mindist") + .css('display', 'none'); + $("#form_editor-kval") + .css('display', 'none'); + $("#form_editor-nodesep") + .css('display', ''); + } + else if (method == 'twopi') { + $("#form_editor-ranksep") + .css('display', ''); + $("#form_editor-mindist") + .css('display', 'none'); + $("#form_editor-kval") + .css('display', 'none'); + $("#form_editor-nodesep") + .css('display', ''); + } + else if (method == 'neato') { + $("#form_editor-ranksep") + .css('display', 'none'); + $("#form_editor-mindist") + .css('display', 'none'); + $("#form_editor-kval") + .css('display', 'none'); + $("#form_editor-nodesep") + .css('display', ''); + } + else if (method == 'radial_dinamic') { + $("#form_editor-ranksep") + .css('display', 'none'); + $("#form_editor-mindist") + .css('display', 'none'); + $("#form_editor-kval") + .css('display', 'none'); + $("#form_editor-nodesep") + .css('display', 'none'); + } + else if (method == 'fdp') { + $("#form_editor-ranksep") + .css('display', 'none'); + $("#form_editor-mindist") + .css('display', 'none'); + $("#form_editor-kval") + .css('display', ''); + $("#form_editor-nodesep") + .css('display', ''); + } + }); $("input[name='source']").trigger("change"); + $("#method").trigger("change"); }); diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index 9e44b92338..a944803d3f 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -33,10 +33,140 @@ include_once("include/functions_pandora_networkmap.php"); $new_networkmap = (bool) get_parameter('new_networkmap', false); $save_networkmap = (bool) get_parameter('save_networkmap', false); +$save_empty_networkmap = (bool) get_parameter('save_empty_networkmap', false); +$update_empty_networkmap = (bool) get_parameter('save_empty_networkmap', false); $update_networkmap = (bool) get_parameter('update_networkmap', false); $copy_networkmap = (bool) get_parameter('copy_networkmap', false); $delete = (bool) get_parameter('delete', false); $tab = (string) get_parameter('tab', 'list'); +$new_empty_networkmap = get_parameter('new_empty_networkmap', false); + +if (enterprise_installed()) { + if ($new_empty_networkmap) { + if ($networkmaps_write || $networkmaps_manage) { + require ($config["homedir"]."/enterprise/godmode/agentes/pandora_networkmap_empty.editor.php"); + require('pandora_networkmap_empty.editor.php'); + return; + } + } + + if ($save_empty_networkmap) { + $id_group = (int) get_parameter('id_group', 0); + + // ACL for the network map + // $networkmap_read = check_acl ($config['id_user'], $id_group, "MR"); + $networkmap_write = check_acl ($config['id_user'], $id_group, "MW"); + $networkmap_manage = check_acl ($config['id_user'], $id_group, "MM"); + + if (!$networkmap_write && !$networkmap_manage) { + db_pandora_audit("ACL Violation", + "Trying to access networkmap"); + require ("general/noaccess.php"); + return; + } + + $name = (string) get_parameter('name', ''); + + // Default size values + $width = 4000; + $height = 4000; + + $method = (string) get_parameter('method', 'fdp'); + + $dont_show_subgroups = 0; + $node_radius = (int)get_parameter('node_radius', 40); + $description = get_parameter('description', ''); + + $values = array(); + $values['name'] = $name; + $values['id_group'] = $id_group; + $values['source_period'] = 60; + $values['width'] = $width; + $values['height'] = $height; + $values['id_user'] = $config['id_user']; + $values['description'] = $description; + $values['source'] = 0; + $values['source_data'] = $id_group; + + + if (!$networkmap_write && !$networkmap_manage) { + db_pandora_audit("ACL Violation", + "Trying to access networkmap"); + require ("general/noaccess.php"); + return; + } + + $filter = array(); + $filter['dont_show_subgroups'] = $dont_show_subgroups; + $filter['node_radius'] = $node_radius; + $filter['empty_map'] = 1; + $values['filter'] = json_encode($filter); + + $result = false; + if (!empty($name)) { + $result = db_process_sql_insert('tmap', + $values); + } + + $result_txt = ui_print_result_message($result, + __('Succesfully created'), __('Could not be created'), '', + true); + + $id = $result; + define("_id_", $id); + + $tab = "view"; + } + else if ($update_empty_networkmap) { + $id_group = (int) get_parameter('id_group', 0); + + // ACL for the new network map + $networkmap_write_new = check_acl ($config['id_user'], $id_group, "MW"); + $networkmap_manage_new = check_acl ($config['id_user'], $id_group, "MM"); + + if (!$networkmap_write && !$networkmap_manage) { + db_pandora_audit("ACL Violation", + "Trying to access networkmap"); + require ("general/noaccess.php"); + return; + } + + $name = (string) get_parameter('name', ''); + + $recon_task_id = (int) get_parameter( + 'recon_task_id', 0); + + $source = (string)get_parameter('source', 'group'); + + $values = array(); + $values['name'] = $name; + $values['id_group'] = $id_group; + + $values['generation_method'] = 4; + + $description = get_parameter('description', ''); + $values['description'] = $description; + + $dont_show_subgroups = 0; + $node_radius = (int)get_parameter('node_radius', 40); + $row = db_get_row('tmap', 'id', $id); + $filter = json_decode($row['filter'], true); + $filter['dont_show_subgroups'] = $dont_show_subgroups; + $filter['node_radius'] = $node_radius; + + $values['filter'] = json_encode($filter); + + $result = false; + if (!empty($name)) { + $result = db_process_sql_update('tmap', + $values, array('id' => $id)); + } + + $result_txt = ui_print_result_message($result, + __('Succesfully updated'), __('Could not be updated'), '', + true); + } +} $result_txt = ''; // The networkmap doesn't exist yet @@ -84,6 +214,20 @@ if ($new_networkmap || $save_networkmap) { $dont_show_subgroups = (int)get_parameter('dont_show_subgroups', 0); $node_radius = (int)get_parameter('node_radius', 40); $description = get_parameter('description', ''); + + $offset_x = get_parameter('pos_x'); + $offset_y = get_parameter('pos_y'); + $scale_z = get_parameter('scale_z', 0.5); + + $node_sep = get_parameter('node_sep', "0.25"); + if ($method == "twopi") { + $rank_sep = get_parameter('rank_sep', "1.0"); + } + else { + $rank_sep = get_parameter('rank_sep', "0.5"); + } + $mindist = get_parameter('mindist', "1.0"); + $kval = get_parameter('kval', "0.3"); $values = array(); $values['name'] = $name; @@ -141,6 +285,14 @@ if ($new_networkmap || $save_networkmap) { $filter = array(); $filter['dont_show_subgroups'] = $dont_show_subgroups; $filter['node_radius'] = $node_radius; + $filter['x_offs'] = $offset_x; + $filter['y_offs'] = $offset_y; + $filter['z_dash'] = $scale_z; + $filter['node_sep'] = $node_sep; + $filter['rank_sep'] = $rank_sep; + $filter['mindist'] = $mindist; + $filter['kval'] = $kval; + $values['filter'] = json_encode($filter); $result = false; @@ -153,8 +305,15 @@ if ($new_networkmap || $save_networkmap) { __('Succesfully created'), __('Could not be created'), '', true); - // Force the tab = 'list' - $tab = "list"; + $id = $result; + define("_id_", $id); + + $tab = "view"; + + if ($values['generation_method'] == 6) { + $tab = "r_dinamic"; + define("_activeTab_", 'radial_dynamic'); + } } } // The networkmap exists @@ -209,26 +368,15 @@ else if ($update_networkmap || $copy_networkmap || $delete) { 'recon_task_id', 0); $source = (string)get_parameter('source', 'group'); + + $offset_x = get_parameter('pos_x'); + $offset_y = get_parameter('pos_y'); + $scale_z = get_parameter('scale_z', 0.5); $values = array(); $values['name'] = $name; $values['id_group'] = $id_group; - /* - if ($source == 'group') { - $values['source'] = 0; - $values['source_data'] = $id_group; - } - else if ($source == 'recon_task') { - $values['source'] = 1; - $values['source_data'] = $recon_task_id; - } - else if ($source == 'ip_mask') { - $values['source'] = 2; - $values['source_data'] = $ip_mask; - } - */ - switch ($method) { case 'twopi': $values['generation_method'] = 2; @@ -262,6 +410,9 @@ else if ($update_networkmap || $copy_networkmap || $delete) { $filter = json_decode($row['filter'], true); $filter['dont_show_subgroups'] = $dont_show_subgroups; $filter['node_radius'] = $node_radius; + $filter['x_offs'] = $offset_x; + $filter['y_offs'] = $offset_y; + $filter['z_dash'] = $scale_z; $values['filter'] = json_encode($filter); @@ -304,6 +455,9 @@ else if ($update_networkmap || $copy_networkmap || $delete) { } switch ($tab) { + case 'r_dinamic': + require('networkmap.dinamic.php'); + break; case 'edit': require('pandora_networkmap.editor.php'); break; @@ -546,6 +700,15 @@ switch ($tab) { html_print_submit_button (__('Create networkmap'), 'crt', false, 'class="sub next" style="float: right;"'); echo ""; echo "
"; + + if (enterprise_installed()) { + echo "
"; + echo '
'; + html_print_input_hidden ('new_empty_networkmap', 1); + html_print_submit_button (__('Create empty networkmap'), 'crt', false, 'class="sub next" style="float: right; margin-right:20px;"'); + echo "
"; + echo "
"; + } } break; diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index 5c5d2969c4..d2a7830f83 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -13,13 +13,29 @@ // Load global variables global $config; -// Check user credentials -check_login(); - require_once ('include/functions_pandora_networkmap.php'); enterprise_include_once('include/functions_policies.php'); +enterprise_include_once('include/functions_dashboard.php'); require_once ('include/functions_modules.php'); +$public_hash = get_parameter('hash', false); + +// Try to authenticate by hash on public dashboards +if ($public_hash === false) { + // Login check + check_login(); +} else { + $validate_hash = enterprise_hook( + 'dasboard_validate_public_hash', + array($public_hash, get_parameter('networkmap_id'), 'network_map') + ); + if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) { + db_pandora_audit("Invalid public hash", "Trying to access report builder"); + require ("general/noaccess.php"); + exit; + } +} + //--------------INIT AJAX----------------------------------------------- if (is_ajax ()) { $update_refresh_state = (bool)get_parameter('update_refresh_state',false); @@ -72,7 +88,7 @@ if (is_ajax ()) { if ($update_fictional_point) { $id_node = (int)get_parameter('id_node', 0); - $name = io_safe_output(get_parameter('name', '')); + $name = get_parameter('name', ''); $shape = get_parameter('shape', 0); $radious = (int)get_parameter('radious', 20); $color = get_parameter('color', 0); @@ -123,7 +139,7 @@ if (is_ajax ()) { $id = (int)get_parameter('id', 0); $x = (int)get_parameter('x', 0); $y = (int)get_parameter('y', 0); - $id_agents = io_safe_output(get_parameter('id_agents', '')); + $id_agents = get_parameter('id_agents', ''); $id_agents = json_decode($id_agents, true); if ($id_agents === null) @@ -426,7 +442,7 @@ if (is_ajax ()) { if ($get_agent_pos_search) { $id = (int)get_parameter('id', 0); - $name = io_safe_output((string)get_parameter('name', 0)); + $name = (string)get_parameter('name'); $return = array(); $return['correct'] = true; @@ -447,7 +463,7 @@ if (is_ajax ()) { $id = (int)get_parameter('id', 0); /* q is what autocomplete plugin gives */ - $string = io_safe_output((string) get_parameter ('q')); + $string = (string) get_parameter('q'); $agents = db_get_all_rows_filter('titem', array('id_map' => $id, @@ -459,7 +475,7 @@ if (is_ajax ()) { $data = array(); foreach ($agents as $agent) { $style = json_decode($agent['style'], true); - $data[] = array('name' => io_safe_output($style['label'])); + $data[] = array('name' => $style['label']); } echo json_encode($data); @@ -677,10 +693,16 @@ if (is_ajax ()) { } } //--------------END AJAX------------------------------------------------ -$id = (int) get_parameter('id_networkmap', 0); +if (_id_ != "_id_") { + $id = _id_; +} +else { + $id = (int) get_parameter('id_networkmap', 0); +} + $dash_mode = 0; $map_dash_details = array(); - +$networkmap = db_get_row('tmap', 'id', $id); if (enterprise_installed()) { include_once("enterprise/dashboard/widgets/network_map.php"); if ($id_networkmap) { @@ -692,11 +714,32 @@ if (enterprise_installed()) { $map_dash_details['x_offs'] = $x_offs; $map_dash_details['y_offs'] = $y_offs; $map_dash_details['z_dash'] = $z_dash; + + $networkmap = db_get_row('tmap', 'id', $id); + } + else { + $networkmap_filter = json_decode($networkmap['filter'], true); + if ($networkmap_filter['x_offs'] != null) { + $map_dash_details['x_offs'] = $networkmap_filter['x_offs']; + } + else { + $map_dash_details['x_offs'] = 0; + } + if ($networkmap_filter['y_offs'] != null) { + $map_dash_details['y_offs'] = $networkmap_filter['y_offs']; + } + else { + $map_dash_details['y_offs'] = 0; + } + if ($networkmap_filter['z_dash'] != null) { + $map_dash_details['z_dash'] = $networkmap_filter['z_dash']; + } + else { + $map_dash_details['z_dash'] = 0; + } } } -$networkmap = db_get_row('tmap', 'id', $id); - if ($networkmap === false) { ui_print_page_header(__('Networkmap'), "images/bricks.png", false, "network_map_enterprise", false); @@ -750,7 +793,7 @@ else { } if (!$dash_mode) { - ui_print_page_header(io_safe_output($networkmap['name']), + ui_print_page_header($networkmap['name'], "images/bricks.png", false, "network_map_enterprise", false, $buttons, false, '', $config['item_title_size_text']); } diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 27baeced96..480dc6b354 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -365,6 +365,9 @@ else { $prediction_available = db_get_sql ("SELECT count(*) FROM tserver WHERE server_type = 5"); //POSTGRESQL AND ORACLE COMPATIBLE + $wux_available = db_get_sql ("SELECT count(*) + FROM tserver + WHERE server_type = 17"); //POSTGRESQL AND ORACLE COMPATIBLE // Development mode to use all servers if ($develop_bypass) { @@ -386,6 +389,9 @@ else { $typemodules[5] = __('Prediction server module'); if (enterprise_installed()) { $typemodules[7] = __('Web server module'); + if ($wux_available) { + $typemodules[8] = __('Wux server module'); + } } @@ -443,6 +449,11 @@ else { FROM ttipo_modulo WHERE categoria = 0'); break; + case 8: + $sql = sprintf ('SELECT id_tipo, descripcion + FROM ttipo_modulo + WHERE nombre = \'web_analysis\''); + break; case '': $sql = sprintf ('SELECT id_tipo, descripcion FROM ttipo_modulo'); @@ -516,7 +527,7 @@ foreach ($custom_fields as $custom_field) { } -$filters = '
'; if (is_metaconsole()) { @@ -943,31 +954,31 @@ if (!empty($result)) { $table->head[0] = '' . __('P.') . ''; $table->head[1] = __('Agent'); - $table->head[1] .=' ' . html_print_image('images/sort_up.png', true, array('style' => $selectAgentNameUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectAgentNameDown, 'alt' => 'down')) . ''; + $table->head[1] .=' ' . html_print_image('images/sort_up.png', true, array('style' => $selectAgentNameUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectAgentNameDown, 'alt' => 'down')) . ''; $table->head[2] = __('Data Type'); - $table->head[2] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTypeUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectTypeDown, 'alt' => 'down')) . ''; + $table->head[2] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTypeUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectTypeDown, 'alt' => 'down')) . ''; $table->align[2] = 'left'; $table->head[3] = __('Module name'); - $table->head[3] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; + $table->head[3] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; $table->head[4] = __('Server type'); - $table->head[4] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; + $table->head[4] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; $table->head[5] = __('Interval'); - $table->head[5] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectIntervalUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectIntervalDown, 'alt' => 'down')) . ''; + $table->head[5] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectIntervalUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectIntervalDown, 'alt' => 'down')) . ''; $table->align[5] = 'left'; $table->head[6] = __('Status'); - $table->head[6] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; + $table->head[6] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; $table->align[6] = 'left'; @@ -980,13 +991,13 @@ if (!empty($result)) { $table->head[9] = __('Data'); $table->align[9] = 'left'; if ( is_metaconsole() ) { - $table->head[9] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; + $table->head[9] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; } $table->head[10] = __('Timestamp'); - $table->head[10] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTimestampUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectTimestampDown, 'alt' => 'down')) . ''; + $table->head[10] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTimestampUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectTimestampDown, 'alt' => 'down')) . ''; $table->align[10] = 'left'; $id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 7f8ef41777..b2479fec88 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -47,7 +47,7 @@ if (is_ajax ()) { $id_group = (int) get_parameter('id_group'); if ($get_agents_group_json) { $id_group = (int) get_parameter('id_group'); - $recursion = (int) get_parameter ('recursion', 0); + $recursion = get_parameter ('recursion'); $id_os = get_parameter('id_os', ''); $agent_name = get_parameter('name', ''); $privilege = (string) get_parameter ('privilege', "AR"); @@ -58,7 +58,7 @@ if (is_ajax ()) { if ($id_group > 0) { $groups = array($id_group); - if ($recursion) { + if ($recursion === 'true') { $groups = array_merge($groups, groups_get_id_recursive($id_group, true)); } @@ -97,7 +97,7 @@ if (is_ajax ()) { $filter[] = "(notinit_count = total_count)"; break; } - $filter['order'] = "nombre ASC"; + $filter['order'] = "alias ASC"; // Build fields $fields = array('id_agente', 'alias'); @@ -589,6 +589,11 @@ if (is_ajax ()) { if (empty($filter)) $filter = false; + $get_only_string_modules = get_parameter('get_only_string_modules', false); + if ($get_only_string_modules) { + $filter['tagente_modulo.id_tipo_modulo IN'] = "(17,23,3,10,33)"; + } + // Status selector if ($status_modulo == AGENT_MODULE_STATUS_NORMAL) { //Normal $sql_conditions .= ' estado = 0 AND utimestamp > 0 ) @@ -702,6 +707,18 @@ if (is_ajax ()) { foreach ($agent_modules as $key => $module) { $agent_modules[$key]['nombre'] = io_safe_output($module['nombre']); } + + $get_order_json = (bool)get_parameter('get_order_json', false); + if ($get_order_json) { + $new_elements = array(); + $index = 0; + foreach ($agent_modules as $key => $module) { + $new_elements[$index]['id_agente_modulo'] = $module['id_agente_modulo']; + $new_elements[$index]['nombre'] = io_safe_output($module['nombre']); + $index++; + } + $agent_modules = $new_elements; + } echo json_encode ($agent_modules); @@ -1044,7 +1061,7 @@ if ($policyTab == -1) /* UX Console */ enterprise_include_once('/include/functions_ux_console.php'); -$active_ux = get_ux_transactions($id_agente); +$active_ux = enterprise_hook('get_ux_transactions', array($id_agente)); if(!empty($active_ux)){ $ux_console_tab = enterprise_hook('ux_console_tab'); if ($ux_console_tab == -1) diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index 303fdcc435..8a506c979e 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -36,7 +36,7 @@ if ($group_rep == 2) { $table->head[1] = __('Agent'); $table->head[5] = __('More detail'); - $params = "search=" . rawurlencode(io_safe_input($search)) . + $params = "search=" . io_safe_input($search) . "&severity=" . $severity . "&status=" . $status . "&id_group=" . $id_group . diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 15da1cf221..1fbcde3ad4 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -165,7 +165,7 @@ if (is_ajax ()) { $module_name = modules_get_agentmodule_name($event['id_agentmodule']); $agent_name = agents_get_alias($event['id_agente']); - $return['message'] = $agent_name . " - " . __('Alert fired in module ') . io_safe_output($module_name) . + $return['message'] = io_safe_output($agent_name) . " - " . __('Alert fired in module ') . io_safe_output($module_name) . " - " . $event['timestamp']; } else if ($resultCritical) { @@ -176,7 +176,7 @@ if (is_ajax ()) { $module_name = modules_get_agentmodule_name($event['id_agentmodule']); $agent_name = agents_get_alias($event['id_agente']); - $return['message'] = $agent_name . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to critical') . + $return['message'] = io_safe_output($agent_name) . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to critical') . " - " . $event['timestamp']; } else if ($resultWarning) { @@ -187,7 +187,7 @@ if (is_ajax ()) { $module_name = modules_get_agentmodule_name($event['id_agentmodule']); $agent_name = agents_get_alias($event['id_agente']); - $return['message'] = $agent_name . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to warning') . + $return['message'] = io_safe_output($agent_name) . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to warning') . " - " . $event['timestamp']; } else if ($resultUnknown) { @@ -198,7 +198,7 @@ if (is_ajax ()) { $module_name = modules_get_agentmodule_name($event['id_agentmodule']); $agent_name = agents_get_alias($event['id_agente']); - $return['message'] = $agent_name . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to unknown') . + $return['message'] = io_safe_output($agent_name) . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to unknown') . " - " . $event['timestamp']; } else { @@ -307,9 +307,7 @@ users_get_groups ($config["id_user"], "ER"); $ids = (array) get_parameter ("eventid", -1); - - -$params = "search=" . rawurlencode(io_safe_input($search)) . +$params = "search=" . io_safe_input($search) . "&event_type=" . $event_type . "&severity=" . $severity . "&status=" . $status . diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index a9574b21bf..a4d773fde7 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -13,7 +13,6 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - // Load global vars global $config; @@ -671,8 +670,6 @@ if ($event_w || $event_m) { $data[0] .= '' . html_print_image("images/load.png", true, array("border" => '0', "title" => __('Load filter'), "alt" => __('Load filter'))) . '  '; -$data[0] .= '' . - html_print_image('images/chart_curve.png', true, array('title' => __('Show events graph'))) . '
'; $data[0] .= '
'; @@ -787,8 +784,6 @@ elseif ($group_rep == 2) { $history); } - - // Active filter tag view call (only enterprise version) // It is required to pass some references to enterprise function // to translate the active filters @@ -803,87 +798,6 @@ enterprise_hook('print_event_tags_active_filters', ) ); -if (!empty($result)) { - if ($group_rep == 0) { - $sql = "SELECT COUNT(id_evento) - FROM $event_table - WHERE 1=1 " . $sql_post; - } - elseif ($group_rep == 1) { - switch ($config["dbtype"]) { - case "mysql": - case "postgresql": - $sql = "SELECT COUNT(1) - FROM (SELECT 1 - FROM $event_table - WHERE 1=1 " . $sql_post . " - GROUP BY evento, id_agentmodule) t"; - break; - case "oracle": - $sql = "SELECT COUNT(1) - FROM (SELECT 1 - FROM $event_table - WHERE 1=1 " . $sql_post . " - GROUP BY to_char(evento), id_agentmodule) t"; - break; - } - } - elseif ($group_rep == 2) { - - } - $limit = (int) db_get_sql ($sql); - - if ($group_rep == 0) { - switch ($config["dbtype"]) { - case "mysql": - $sql = "SELECT *, 1 event_rep - FROM $event_table - WHERE 1=1 " . $sql_post . " - ORDER BY utimestamp DESC LIMIT 0,".$limit; - break; - case "postgresql": - $sql = "SELECT *, 1 event_rep - FROM $event_table - WHERE 1=1 " . $sql_post . " - ORDER BY utimestamp DESC LIMIT ".$limit." OFFSET 0"; - break; - case "oracle": - $set = array(); - $set['limit'] = $pagination; - $set['offset'] = $offset; - $sql = "SELECT $event_table.*, 1 event_rep - FROM $event_table - WHERE 1=1 " . $sql_post . " - ORDER BY utimestamp DESC"; - $sql = oracle_recode_query ($sql, $set); - break; - } - - //Extract the events by filter (or not) from db - $results_graph = db_get_all_rows_sql ($sql); - } - elseif ($group_rep == 1) { - $results_graph = events_get_events_grouped($sql_post, - 0, - $limit, - $meta, - $history); - } - elseif ($group_rep == 2) { - - } - - if (($group_rep == 1) OR ($group_rep == 0)) { - $graph = '
' . - grafico_eventos_agente(350, 185, - $results_graph, $meta, $history, $tags_acls_condition,$limit) . - '
'; - html_print_div(array('id' => 'events_graph', - 'hidden' => true, 'content' => $graph)); - } -} - - if (!empty($result)) { //~ Checking the event tags exactly. The event query filters approximated tags to keep events //~ with several tags @@ -986,11 +900,6 @@ $(document).ready( function() { $("#text-date_from, #text-date_to").datepicker({dateFormat: ""}); - // If the events are not charged, dont show graphs link - if ($('#events_graph').val() == undefined) { - $('#events_graph_link').hide(); - } - // Don't collapse filter if update button has been pushed if ($("#hidden-open_filter").val() == 'true') { $("#event_control").toggle(); @@ -1658,23 +1567,6 @@ function reorder_tags_inputs() { } } -// Show the modal window of an module -function show_events_graph_dialog() { - $("#events_graph").hide () - .dialog ({ - resizable: true, - draggable: true, - title: '', - modal: true, - overlay: { - opacity: 0.5, - background: "black" - }, - width: 450, - height: 380 - }) - .show (); -} /* ]]> */ //function datetime diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 6c27ce428d..b7c57882a8 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -59,6 +59,8 @@ if (check_acl ($config['id_user'], 0, "AR")) { $sub2["operation/agentes/status_monitor"]["text"] = __('Monitor detail'); $sub2["operation/agentes/status_monitor"]["refr"] = 0; + enterprise_hook ('tag_view_submenu'); + $sub2["operation/agentes/alerts_status"]["text"] = __('Alert detail'); $sub2["operation/agentes/alerts_status"]["refr"] = 0; diff --git a/pandora_console/operation/reporting/reporting_xml.php b/pandora_console/operation/reporting/reporting_xml.php index 42de928c06..aaffa4f18a 100755 --- a/pandora_console/operation/reporting/reporting_xml.php +++ b/pandora_console/operation/reporting/reporting_xml.php @@ -17,6 +17,7 @@ include_once("include/functions_modules.php"); include_once("include/functions_events.php"); include_once ('include/functions_groups.php'); include_once ('include/functions_netflow.php'); +include_once ('include/functions_reporting_xml.php'); enterprise_include_once ('include/functions_metaconsole.php'); @@ -127,38 +128,7 @@ switch ($date_mode) { $report = reporting_make_reporting_data(null, $id_report, $date, $time, $period, 'static'); -//------- Removed the unused fields ------------------------------------ -unset($report['header']); -unset($report['first_page']); -unset($report['footer']); -unset($report['custom_font']); -unset($report['id_template']); -unset($report['id_group_edit']); -unset($report['metaconsole']); -unset($report['private']); -unset($report['custom_logo']); -//---------------------------------------------------------------------- - -//change agent name -if(count($report['contents']) > 0){ - for($i = 0;$i < count($report['contents']); $i++){ - $aux = explode("-",$report['contents'][$i]['subtitle']); - $report['contents'][$i]['subtitle'] = db_get_value ("alias","tagente","nombre",$report['contents'][$i]['agent_name']) .' -'. $aux[1]; - } -} - -$xml = null; -$xml = array2XML($report, "report", $xml); -$xml = preg_replace("/(<[^>]+>)(<[^>]+>)(<[^>]+>)/", "$1\n$2\n$3", $xml); -$xml = preg_replace("/(<[^>]+>)(<[^>]+>)/", "$1\n$2", $xml); - -header ('Content-Type: application/xml; charset=UTF-8'); -header ('Content-Disposition: attachment; filename="'.$filename.'.xml"'); - -// Clean the output buffer -ob_clean(); - -echo $xml; +reporting_xml_get_report($report, $filename); exit; ?> diff --git a/pandora_console/operation/search_agents.getdata.php b/pandora_console/operation/search_agents.getdata.php index d605cbaad8..60c7f87ad4 100644 --- a/pandora_console/operation/search_agents.getdata.php +++ b/pandora_console/operation/search_agents.getdata.php @@ -168,7 +168,7 @@ if ($searchAgents) { ) "; - $select = "SELECT t1.id_agente, t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias"; + $select = "SELECT t1.id_agente, t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias, t1.quiet"; if ($only_count) { $limit = " ORDER BY " . $order['field'] . " " . $order['order'] . " LIMIT " . $config["block_size"] . " OFFSET 0"; diff --git a/pandora_console/operation/search_agents.php b/pandora_console/operation/search_agents.php index 5720730787..3282deaa70 100755 --- a/pandora_console/operation/search_agents.php +++ b/pandora_console/operation/search_agents.php @@ -70,13 +70,13 @@ else { $table->align = array (); $table->align[0] = "left"; - $table->align[1] = "center"; - $table->align[2] = "center"; - $table->align[3] = "center"; - $table->align[4] = "center"; - $table->align[5] = "center"; - $table->align[6] = "center"; - $table->align[7] = "right"; + $table->align[1] = "left"; + $table->align[2] = "left"; + $table->align[3] = "left"; + $table->align[4] = "left"; + $table->align[5] = "left"; + $table->align[6] = "left"; + $table->align[7] = "left"; $table->align[8] = "center"; $table->data = array (); @@ -95,6 +95,22 @@ else { ''.$agent["alias"].''; } + if ($agent['quiet']) { + $cellName .= " "; + $cellName .= html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")); + } + + $in_planned_downtime = db_get_sql('SELECT executed FROM tplanned_downtime + INNER JOIN tplanned_downtime_agents + ON tplanned_downtime.id = tplanned_downtime_agents.id_downtime + WHERE tplanned_downtime_agents.id_agent = '. $agent["id_agente"] . + ' AND tplanned_downtime.executed = 1'); + + if ($in_planned_downtime) { + $cellName .= "".ui_print_help_tip (__('Agent in planned downtime'), true, 'images/minireloj-16.png'); + $cellName .= ""; + } + $last_time = strtotime ($agent["ultimo_contacto"]); $now = time (); $diferencia = $now - $last_time; diff --git a/pandora_console/operation/snmpconsole/snmp_browser.php b/pandora_console/operation/snmpconsole/snmp_browser.php index 0a8204208e..3f005cf063 100644 --- a/pandora_console/operation/snmpconsole/snmp_browser.php +++ b/pandora_console/operation/snmpconsole/snmp_browser.php @@ -28,12 +28,12 @@ if (is_ajax()) { $community = (string) get_parameter ("community", ''); $snmp_version = (string) get_parameter ("snmp_browser_version", ''); $server_to_exec = (int) get_parameter ("server_to_exec", 0); - $snmp3_auth_user = get_parameter('snmp3_browser_auth_user'); + $snmp3_auth_user = io_safe_output(get_parameter('snmp3_browser_auth_user')); $snmp3_security_level = get_parameter('snmp3_browser_security_level'); $snmp3_auth_method = get_parameter('snmp3_browser_auth_method'); - $snmp3_auth_pass = get_parameter('snmp3_browser_auth_pass'); + $snmp3_auth_pass = io_safe_output(get_parameter('snmp3_browser_auth_pass')); $snmp3_privacy_method = get_parameter('snmp3_browser_privacy_method'); - $snmp3_privacy_pass = get_parameter('snmp3_browser_privacy_pass'); + $snmp3_privacy_pass = io_safe_output(get_parameter('snmp3_browser_privacy_pass')); // SNMP browser if ($action == "snmptree") { diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index c7a23fb0fd..993f95c4fe 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -18,6 +18,7 @@ global $config; $pure = get_parameter('pure', 0); $tab = get_parameter('tab', 'group'); +$search_group = get_parameter('searchGroup', ''); $search_agent = get_parameter('searchAgent', ''); $status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL); $search_module = get_parameter('searchModule', ''); @@ -135,13 +136,16 @@ $agent_status_arr[AGENT_STATUS_UNKNOWN] = __('Unknown'); $agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init'); $row = array(); +$row[] = __('Search group'); +$row[] = html_print_input_text("search_group", $search_group, '', is_metaconsole() ? 70 : 40, 30, true); + +$table->data[] = $row; + +$row = array(); +$row[] = __('Search agent'); +$row[] = html_print_input_text("search_agent", $search_agent, '', is_metaconsole() ? 70 : 40, 30, true); $row[] = __('Agent status'); $row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true); -$row[] = __('Search agent'); -if (is_metaconsole()) - $row[] = html_print_input_text("search_agent", $search_agent, '', 70, 30, true); -else - $row[] = html_print_input_text("search_agent", $search_agent, '', 40, 30, true); // Button $row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true); @@ -160,10 +164,10 @@ if (!is_metaconsole()) { $module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init'); $row = array(); - $row[] = __('Module status'); - $row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true); $row[] = __('Search module'); $row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true); + $row[] = __('Module status'); + $row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true); $table->data[] = $row; } @@ -240,8 +244,9 @@ enterprise_hook('close_meta_frame'); var parameters = {}; parameters['page'] = "include/ajax/tree.ajax"; parameters['getChildren'] = 1; - parameters['filter'] = {}; parameters['type'] = ""; + parameters['filter'] = {}; + parameters['filter']['searchGroup'] = $("input#text-search_group").val(); parameters['filter']['searchAgent'] = $("input#text-search_agent").val(); parameters['filter']['statusAgent'] = $("select#status_agent").val(); parameters['filter']['searchModule'] = $("input#text-search_module").val(); diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 4e76d32899..47f52d0cd8 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -99,6 +99,8 @@ if (isset ($_GET["modified"]) && !$view_mode) { else{ $upd_info['autorefresh_white_list'] = json_encode($autorefresh_list); } + + $upd_info['time_autorefresh'] = (int) get_parameter ("time_autorefresh", 0); $is_admin = db_get_value('is_admin', 'tusuario', 'id_user', $id); @@ -439,10 +441,13 @@ $table_ichanges = '
'; $data[0] .= $table_ichanges; +//time autorefresh +$times = get_refresh_time_array(); +$data[1] = ''.__('Time autorefresh').''; +$data[1] .= $jump . ''. html_print_select ($times, 'time_autorefresh', $user_info["time_autorefresh"], '', '', '', true,false,false).''; $table->rowclass[] = ''; -$table->colspan[count($table->data)][0] = 3; -$table->rowstyle[] = 'font-weight: bold;'; +$table->rowstyle[] = 'font-weight: bold;vertical-align: top'; $table->data[] = $data; $data = array(); diff --git a/pandora_console/operation/visual_console/public_console.php b/pandora_console/operation/visual_console/public_console.php index 6b77dd4798..21bf94fe65 100755 --- a/pandora_console/operation/visual_console/public_console.php +++ b/pandora_console/operation/visual_console/public_console.php @@ -208,51 +208,57 @@ $ignored_params['refr'] = ''; $(".overlay").removeClass("overlay").addClass("overlaydisabled"); - $('.item:not(.icon) img').each(function(){ - - - if($(this).css('float')=='left' || $(this).css('float')=='right'){ - - - $(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px'); - $(this).css('margin-left',''); - + // Start the map fetch + //~ fetchMap(); + }); + + $(window).load (function () { + $('.item:not(.icon) img:not(.b64img)').each( function() { + if ($(this).css('float')=='left' || $(this).css('float')=='right') { + if( $(this).parent()[0].tagName == 'DIV'){ + $(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px'); + } + else if ( $(this).parent()[0].tagName == 'A') { + $(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px'); + } + $(this).css('margin-left',''); } - else{ - $(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); - $(this).css('margin-top',''); + else { + if(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2 < 0){ + $(this).css('margin-left',''); + $(this).css('margin-top',''); + } else { + if( $(this).parent()[0].tagName == 'DIV'){ + $(this).css('margin-left',(parseInt($(this).parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); + } + else if ( $(this).parent()[0].tagName == 'A') { + $(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); + } + $(this).css('margin-top',''); + } } - }); - $('.item > div').each(function(){ - if($(this).css('float')=='left' || $(this).css('float')=='right'){ - - - $(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2-15)+'px'); - $(this).css('margin-left',''); - + $('.item > div').each( function() { + if ($(this).css('float')=='left' || $(this).css('float')=='right') { + $(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2-15)+'px'); + $(this).css('margin-left',''); } - else{ + else { $(this).css('margin-left',(parseInt($(this).parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); $(this).css('margin-top',''); } - }); - $('.item > a > div').each(function(){ - if($(this).css('float')=='left' || $(this).css('float')=='right'){ - - - $(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2-5)+'px'); - $(this).css('margin-left',''); - + $('.item > a > div').each( function() { + if ($(this).css('float')=='left' || $(this).css('float')=='right') { + $(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2-5)+'px'); + $(this).css('margin-left',''); } - else{ + else { $(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); $(this).css('margin-top',''); } - }); $(".graph:not([class~='noresizevc'])").each(function(){ diff --git a/pandora_console/operation/visual_console/pure_ajax.php b/pandora_console/operation/visual_console/pure_ajax.php index 08b5460067..58e920550f 100644 --- a/pandora_console/operation/visual_console/pure_ajax.php +++ b/pandora_console/operation/visual_console/pure_ajax.php @@ -183,7 +183,10 @@ $ignored_params['refr'] = ''; }); $(".overlay").removeClass("overlay").addClass("overlaydisabled"); - + + }); + + $(window).load (function () { $('.item:not(.icon) img').each(function(){ diff --git a/pandora_console/operation/visual_console/render_view.php b/pandora_console/operation/visual_console/render_view.php index 261205818b..0f2a2b9750 100755 --- a/pandora_console/operation/visual_console/render_view.php +++ b/pandora_console/operation/visual_console/render_view.php @@ -244,10 +244,11 @@ $ignored_params['refr'] = ''; $('div.vc-countdown').countdown('destroy'); //cb(); url = js_html_entity_decode( href ) + duration; - //$(document).attr ("location", url); - $.post(window.location.href.replace("refr=300","refr="+new_count), function(respuestaSolicitud){ + $(document).attr ("location", url); + /*$.post(window.location.href.replace("refr=300","refr="+new_count), function(respuestaSolicitud){ $('#background_').html(respuestaSolicitud); }); + */ $("#main_pure").css('background-color',''); } @@ -279,7 +280,10 @@ $ignored_params['refr'] = ''; }); $(".overlay").removeClass("overlay").addClass("overlaydisabled"); - + + }); + + $(window).load (function () { $('.item:not(.icon) img:not(.b64img)').each( function() { if ($(this).css('float')=='left' || $(this).css('float')=='right') { if( $(this).parent()[0].tagName == 'DIV'){ @@ -332,6 +336,6 @@ $ignored_params['refr'] = ''; height = parseInt($(this).css("height")) - 30; $(this).css('height', height); }); - + }); \ No newline at end of file diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 571f010512..89d14e6341 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -2,8 +2,8 @@ # Pandora FMS Console # %define name pandorafms_console -%define version 7.0NG.713 -%define release 171018 +%define version 7.0NG.716 +%define release 171130 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index a5145c3811..02cfb81e0f 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -2,8 +2,8 @@ # Pandora FMS Console # %define name pandorafms_console -%define version 7.0NG.713 -%define release 171018 +%define version 7.0NG.716 +%define release 171130 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandora_console_install b/pandora_console/pandora_console_install index e5c3de540a..2ffb7db4e2 100644 --- a/pandora_console/pandora_console_install +++ b/pandora_console/pandora_console_install @@ -9,7 +9,7 @@ # This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.713" +PI_VERSION="7.0NG.716" FORCE=0 DESTDIR="" LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"` diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 801fcfe4f3..e6511623b8 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -85,6 +85,7 @@ CREATE TABLE IF NOT EXISTS `tagente` ( `alias` varchar(600) BINARY NOT NULL default '', `transactional_agent` tinyint(1) NOT NULL default '0', `alias_as_name` tinyint(2) NOT NULL default '0', + `safe_mode_module` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`(255)), KEY `direccion` (`direccion`), @@ -99,7 +100,7 @@ CREATE TABLE IF NOT EXISTS `tagente_datos` ( `id_agente_modulo` int(10) unsigned NOT NULL default '0', `datos` double(22,5) default NULL, `utimestamp` bigint(20) default '0', - KEY `data_index1` (`id_agente_modulo`), + KEY `data_index1` (`id_agente_modulo`, `utimestamp`), KEY `idx_utimestamp` USING BTREE (`utimestamp`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; @@ -120,7 +121,7 @@ CREATE TABLE IF NOT EXISTS `tagente_datos_string` ( `id_agente_modulo` int(10) unsigned NOT NULL default '0', `datos` mediumtext NOT NULL, `utimestamp` int(20) unsigned NOT NULL default 0, - KEY `data_string_index_1` (`id_agente_modulo`), + KEY `data_string_index_1` (`id_agente_modulo`, `utimestamp`), KEY `idx_utimestamp` USING BTREE (`utimestamp`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -1114,6 +1115,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` ( `session_time` int(10) signed NOT NULL default 0, `default_event_filter` int(10) unsigned NOT NULL default 0, `autorefresh_white_list` text not null default '', + `time_autorefresh` int(5) unsigned NOT NULL default '30', CONSTRAINT `fk_filter_id` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter (`id_filter`) ON DELETE SET NULL, UNIQUE KEY `id_user` (`id_user`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -1188,6 +1190,8 @@ CREATE TABLE IF NOT EXISTS `tgraph` ( `id_group` mediumint(8) unsigned NULL default 0, `id_graph_template` int(11) NOT NULL default 0, `percentil` tinyint(1) UNSIGNED NOT NULL default 0, + `summatory_series` tinyint(1) UNSIGNED NOT NULL default 0, + `average_series` tinyint(1) UNSIGNED NOT NULL default 0, PRIMARY KEY(`id_graph`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -1269,6 +1273,9 @@ CREATE TABLE IF NOT EXISTS `treport_content` ( `id_module_group` INT (10) unsigned NOT NULL DEFAULT 0, `server_name` text, `historical_db` tinyint(1) UNSIGNED NOT NULL default 0, + `lapse_calc` tinyint(1) UNSIGNED NOT NULL default '0', + `lapse` int(11) UNSIGNED NOT NULL default '300', + `visual_format` tinyint(1) UNSIGNED NOT NULL default '0', PRIMARY KEY(`id_rc`), FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) ON UPDATE CASCADE ON DELETE CASCADE @@ -1356,6 +1363,9 @@ CREATE TABLE IF NOT EXISTS `tlayout_data` ( `border_color` varchar(200) DEFAULT "", `fill_color` varchar(200) DEFAULT "", `show_statistics` tinyint(2) NOT NULL default '0', + `id_layout_linked_weight` int(10) NOT NULL default '0', + `element_group` int(10) NOT NULL default '0', + `show_on_top` tinyint(1) NOT NULL default '0', PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -1707,6 +1717,7 @@ CREATE TABLE IF NOT EXISTS `tsnmp_filter` ( `id_snmp_filter` int(10) unsigned NOT NULL auto_increment, `description` varchar(255) default '', `filter` varchar(255) default '', + `unified_filters_id` int(10) not null default 0, PRIMARY KEY (`id_snmp_filter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -2206,6 +2217,7 @@ CREATE TABLE IF NOT EXISTS `tdashboard` ( `id_group` int(10) NOT NULL default 0, `active` tinyint(1) NOT NULL default 0, `cells` int(10) unsigned default 0, + `cells_slideshow` TINYINT(1) NOT NULL default 0, PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -2727,6 +2739,9 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` ( `each_agent` tinyint(1) default 1, `historical_db` tinyint(1) UNSIGNED NOT NULL default 0, `hide_no_data` tinyint(1) default 0, + `lapse_calc` tinyint(1) UNSIGNED NOT NULL default '0', + `lapse` int(11) UNSIGNED NOT NULL default '300', + `visual_format` tinyint(1) UNSIGNED NOT NULL default '0', PRIMARY KEY(`id_rc`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -2958,6 +2973,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` ( `transactional_agent` tinyint(1) NOT NULL default '0', `alias` varchar(600) BINARY NOT NULL default '', `alias_as_name` tinyint(2) NOT NULL default '0', + `safe_mode_module` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`(255)), KEY `direccion` (`direccion`), diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index dfe916aa13..476750758f 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -12,7 +12,7 @@ -- Dumping data for table `talert_commands` -- -INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (1,'eMail','Internal type','This alert send an email using internal Pandora FMS Server SMTP capabilities (defined in each server, using: _field1_ as destination email address, and _field2_ as subject for message. _field3_ as text of message.',1,'[\"Destination address\",\"Subject\",\"Text\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"_html_editor_\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); +INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (1,'eMail','Internal type','This alert send an email using internal Pandora FMS Server SMTP capabilities (defined in each server, using: _field1_ as destination email address, and _field2_ as subject for message. _field3_ as text of message. _field4_ as content type (plain/text or html/text).',1,'[\"Destination address\",\"Subject\",\"Text\",\"Content Type\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"_html_editor_\",\"_content_type_\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (2,'Internal Audit','Internal type','This alert save alert in Pandora internal audit system. Fields are static and only _field1_ is used.',1,'[\"Description\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (3,'Pandora FMS Event','Internal type','This alert create an special event into Pandora FMS event manager.',1,'[\"Event text\",\"Event type\",\"Source\",\"Agent name or _agent_\",\"Event criticity\",\"ID extra\",\"Tags separated by commas\",\"Comments\",\"\",\"\"]','[\"\",\"alert_ceased,Alert ceased;alert_fired,Alert fired;alert_manual_validation,Alert manual validation;alert_recovered,Alert recovered;configuration_change,Configuration change ;error,Error;critical,Monitor Critical;normal,Monitor Normal;going_unknown,Monitor\",\"\",\"\",\"4,Critical;1,Informational;0,Maintenance;6,Major;5,Minor;2,Normal;3,Warning\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (4,'Pandora FMS Alertlog','echo _timestamp_ pandora _agent_ _data_ _field1_ _field2_ >> /var/log/pandora/pandora_alert.log','This is a default alert to write alerts in a standard ASCII plaintext log file in /var/log/pandora/pandora_alert.log ',0,'[\"Log Info 1\",\"Log Info 2\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); @@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), -('MR', 7), +('MR', 9), ('identification_reminder', 1), ('identification_reminder_timestamp', 0), -('current_package_enterprise', '713'), +('current_package_enterprise', '716'), ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'); UNLOCK TABLES; @@ -1105,7 +1105,7 @@ INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal -- alert actions (default) INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES -(1,'Mail to Admin',1,'yourmail@domain.es','[PANDORA] Alert from agent _agent_ on module _module_','<style type="text/css"> /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } </style> <style type="text/css" media="screen"> @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } </style> <style type="text/css" media="only screen and (max-width: 600px)"> /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } </style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>bad news</strong> for you. Something is on <strong>CRITICAL</strong> status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_roja.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://wiki.pandorafms.com">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','',0,0,'','','<style type="text/css"><!-- /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } --></style> <style type="text/css" media="screen"><!-- @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } --></style> <style type="text/css" media="only screen and (max-width: 600px)"><!-- /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } --></style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>good news</strong> for you. Alert has been <strong>RECOVERED</strong>&nbsp;status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_verde.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://wiki.pandorafms.com">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','',''); +(1,'Mail to Admin',1,'yourmail@domain.es','[PANDORA] Alert from agent _agent_ on module _module_','<style type="text/css"> /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } </style> <style type="text/css" media="screen"> @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } </style> <style type="text/css" media="only screen and (max-width: 600px)"> /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } </style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>bad news</strong> for you. Something is on <strong>CRITICAL</strong> status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_roja.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://wiki.pandorafms.com">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','',0,0,'','','<style type="text/css"><!-- /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } --></style> <style type="text/css" media="screen"><!-- @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } --></style> <style type="text/css" media="only screen and (max-width: 600px)"><!-- /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } --></style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>good news</strong> for you. Alert has been <strong>RECOVERED</strong>&nbsp;status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_verde.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://wiki.pandorafms.com">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','text/html','','','','','',''); INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (2,'Restart agent',12,'REFRESH AGENT *','','','','','','','','','',0,0,'','','','','','','','','',''); INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index a1740629f6..737178fb8a 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.713-171018 +Version: 7.0NG.716-171130 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 391df2685c..11a1afba0e 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.713-171018" +pandora_version="7.0NG.716-171130" package_cpan=0 package_pandora=1 diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index ef617343aa..1f13627cb3 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -314,9 +314,6 @@ sub pandora_server_tasks ($) { # Check if an autodisabled agent needs to be autodisable pandora_disable_autodisable_agents ($pa_config, $dbh); - - # Set event storm protection - pandora_set_event_storm_protection (pandora_get_tconfig_token ($dbh, 'event_storm_protection', 0)); } # TASKS EXECUTED EVERY 60 SECONDS (High latency tasks) @@ -355,6 +352,9 @@ sub pandora_server_tasks ($) { # Rotate Log File if (($counter % 30) == 0) { pandora_rotate_logfile($pa_config); + + # Set event storm protection + pandora_set_event_storm_protection (pandora_get_tconfig_token ($dbh, 'event_storm_protection', 0)); } # Pandora self monitoring if (defined($pa_config->{"self_monitoring"}) diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 8d5e5270ef..28b8e8aead 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -1,7 +1,7 @@ ############################################################################# # Pandora FMS Server Parameters # Pandora FMS, the Flexible Monitoring System. -# Version 7.0NG.713 +# Version 7.0NG.716 # Licensed under GPL license v2, # (c) 2003-2017 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -161,10 +161,10 @@ network_threads 4 # that ping should be 1 to report 1. Setting this to 1 will make all icmp montioring faster but # with more probability of failure. -icmp_checks 3 +icmp_checks 1 # Number of ICMP packets to send per request. -icmp_packets 1 +icmp_packets 2 # tcp specific options : # tcp_checks: number of tcp retries if first attempt fails. diff --git a/pandora_server/conf/pandora_server.conf.windows b/pandora_server/conf/pandora_server.conf.windows index 94b764de40..a1429970b1 100644 --- a/pandora_server/conf/pandora_server.conf.windows +++ b/pandora_server/conf/pandora_server.conf.windows @@ -164,10 +164,10 @@ network_threads 5 # that ping should be 1 to report 1. Lower value have better performance, but more probability # of false positives -icmp_checks 3 +icmp_checks 1 # Number of ICMP packets to send per request. -icmp_packets 1 +icmp_packets 2 # tcp specific options : # tcp_checks: number of tcp retries if first attempt fails. diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 869296bef6..51d9f463c7 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -42,8 +42,8 @@ our @EXPORT = qw( ); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.713"; -my $pandora_build = "171018"; +my $pandora_version = "7.0NG.716"; +my $pandora_build = "171130"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 88edb0a11a..bcb8534fc8 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -525,7 +525,7 @@ Process an alert given the status returned by pandora_evaluate_alert. ########################################################################## sub pandora_process_alert ($$$$$$$$;$) { my ($pa_config, $data, $agent, $module, $alert, $rc, $dbh, $timestamp, $extra_macros) = @_; - + if (defined ($agent)) { logger ($pa_config, "Processing alert '" . safe_output($alert->{'name'}) . "' for agent '" . safe_output($agent->{'nombre'}) . "': " . (defined ($AlertStatus[$rc]) ? $AlertStatus[$rc] : 'Unknown status') . ".", 10); } @@ -565,12 +565,12 @@ sub pandora_process_alert ($$$$$$$$;$) { # Generate an event if ($table eq 'tevent_alert') { pandora_event ($pa_config, "Alert ceased (" . - $alert->{'name'} . ")", 0, 0, $alert->{'priority'}, $id, + safe_output($alert->{'name'}) . ")", 0, 0, $alert->{'priority'}, $id, (defined ($alert->{'id_agent_module'}) ? $alert->{'id_agent_module'} : 0), "alert_ceased", 0, $dbh, 'Pandora', '', '', '', '', $critical_instructions, $warning_instructions, $unknown_instructions); } else { pandora_event ($pa_config, "Alert ceased (" . - $alert->{'name'} . ")", $agent->{'id_grupo'}, + safe_output($alert->{'name'}) . ")", $agent->{'id_grupo'}, $agent->{'id_agente'}, $alert->{'priority'}, $id, (defined ($alert->{'id_agent_module'}) ? $alert->{'id_agent_module'} : 0), "alert_ceased", 0, $dbh, 'Pandora', '', '', '', '', $critical_instructions, $warning_instructions, $unknown_instructions); @@ -1014,6 +1014,8 @@ sub pandora_execute_action ($$$$$$$$$;$) { _id_group_ => (defined ($group)) ? $group->{'id_grupo'} : '', _id_alert_ => (defined ($alert->{'id_template_module'})) ? $alert->{'id_template_module'} : '', _interval_ => (defined ($module) && $module->{'module_interval'} != 0) ? $module->{'module_interval'} : (defined ($agent)) ? $agent->{'intervalo'} : '', + _server_ip_ => (defined ($agent)) ? get_db_value($dbh, "SELECT ip_address FROM tserver WHERE name = ?", $agent->{'server_name'}) : '', + _server_name_ => (defined ($agent)) ? $agent->{'server_name'} : '', _target_ip_ => (defined ($module)) ? $module->{'ip_target'} : '', _target_port_ => (defined ($module)) ? $module->{'tcp_port'} : '', _policy_ => undef, @@ -1108,6 +1110,12 @@ sub pandora_execute_action ($$$$$$$$$;$) { $field2 = subst_alert_macros ($field2, \%macros, $pa_config, $dbh, $agent, $module); # Message $field3 = subst_alert_macros ($field3, \%macros, $pa_config, $dbh, $agent, $module); + # Content + $field4 = subst_alert_macros ($field4, \%macros, $pa_config, $dbh, $agent, $module); + + if($field4 eq ""){ + $field4 = "text/html"; + } # Check for _module_graph_Xh_ macros # Check for _module_graph_Xh_ macros and _module_graphth_Xh_ @@ -1165,13 +1173,13 @@ sub pandora_execute_action ($$$$$$$$$;$) { }; # Default content type - my $content_type = 'text/html; charset="iso-8859-1"'; + my $content_type = $field4 . '; charset="iso-8859-1"'; # Check if message has non-ascii chars. # non-ascii chars should be encoded in UTF-8. if ($field3 =~ /[^[:ascii:]]/o) { $field3 = encode("UTF-8", $field3); - $content_type = 'text/html; charset="UTF-8"'; + $content_type = $field4 . '; charset="UTF-8"'; } @@ -1472,7 +1480,10 @@ sub pandora_process_module ($$$$$$$$$;$) { # Calculate the current interval my $current_interval; if (defined ($module->{'cron_interval'}) && $module->{'cron_interval'} ne '' && $module->{'cron_interval'} ne '* * * * *') { - $current_interval = cron_next_execution ($module->{'cron_interval'}); + $current_interval = cron_next_execution ( + $module->{'cron_interval'}, + $module->{'module_interval'} == 0 ? $agent->{'intervalo'} : $module->{'module_interval'} + ); } elsif ($module->{'module_interval'} == 0) { $current_interval = $agent->{'intervalo'}; @@ -1519,6 +1530,11 @@ sub pandora_process_module ($$$$$$$$$;$) { # Update module status count. $mark_for_update = 1; + + # Safe mode execution. + if ($agent->{'safe_mode_module'} == $module->{'id_agente_modulo'}) { + safe_mode($pa_config, $agent, $module, $new_status, $known_status, $dbh); + } } # Set not-init modules to normal status even if min_ff_event is not matched the first time they receive data. # if critical or warning status, just pass through here and wait the time min_ff_event will be matched. @@ -1611,9 +1627,8 @@ sub pandora_planned_downtime_disabled_once_stop($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 0 WHERE id = ?', $downtime->{'id'}); - pandora_event ($pa_config, - '(Created by ' . $downtime->{'id_user'} . ') Server ' . $pa_config->{'servername'} . ' stopped planned downtime: ' . $downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + '(Created by ' . $downtime->{'id_user'} . ') Server ' . $pa_config->{'servername'} . ' stopped planned downtime: ' . safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); pandora_planned_downtime_unset_disabled_elements($pa_config, $dbh, $downtime); @@ -1658,8 +1673,9 @@ sub pandora_planned_downtime_disabled_once_start($$) { SET executed = 1 WHERE id = ?', $downtime->{'id'}); + print"pandora_planned_downtime_disabled_once_start\n"; pandora_event ($pa_config, - "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); pandora_planned_downtime_set_disabled_elements($pa_config, $dbh, $downtime); @@ -1849,7 +1865,7 @@ sub pandora_planned_downtime_quiet_once_stop($$) { SET executed = 0 WHERE id = ?', $downtime->{'id'}); pandora_event ($pa_config, - "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." stopped planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." stopped planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); pandora_planned_downtime_unset_quiet_elements($pa_config, $dbh, $downtime->{'id'}); @@ -1890,8 +1906,9 @@ sub pandora_planned_downtime_quiet_once_start($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 1 WHERE id = ?', $downtime->{'id'}); + print"pandora_planned_downtime_quiet_once_start\n"; pandora_event ($pa_config, - "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); pandora_planned_downtime_set_quiet_elements($pa_config, $dbh, $downtime->{'id'}); @@ -1944,8 +1961,9 @@ sub pandora_planned_downtime_monthly_start($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 1 WHERE id = ?', $downtime->{'id'}); + print"pandora_planned_downtime_monthly_start\n"; pandora_event ($pa_config, - "Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); if ($downtime->{'type_downtime'} eq "quiet") { @@ -2020,8 +2038,9 @@ sub pandora_planned_downtime_monthly_stop($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 0 WHERE id = ?', $downtime->{'id'}); + print"pandora_planned_downtime_monthly_stop\n"; pandora_event ($pa_config, - "Server ".$pa_config->{'servername'}." stopped planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "Server ".$pa_config->{'servername'}." stopped planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); if ($downtime->{'type_downtime'} eq "quiet") { pandora_planned_downtime_unset_quiet_elements($pa_config, @@ -2129,8 +2148,9 @@ sub pandora_planned_downtime_weekly_start($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 1 WHERE id = ?', $downtime->{'id'}); + print"pandora_planned_downtime_weekly_start\n"; pandora_event ($pa_config, - "Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); if ($downtime->{'type_downtime'} eq "quiet") { pandora_planned_downtime_set_quiet_elements($pa_config, @@ -2243,8 +2263,10 @@ sub pandora_planned_downtime_weekly_stop($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 0 WHERE id = ?', $downtime->{'id'}); + + print"pandora_planned_downtime_weekly_stop\n"; pandora_event ($pa_config, - "Server ".$pa_config->{'servername'}." stopped planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "Server ".$pa_config->{'servername'}." stopped planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); if ($downtime->{'type_downtime'} eq "quiet") { pandora_planned_downtime_unset_quiet_elements($pa_config, @@ -2974,7 +2996,7 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$) { } logger ($pa_config, "Server '$server_name' CREATED agent '$agent_name' address '$address'.", 10); - pandora_event ($pa_config, "Agent [$alias] created by $server_name", $group_id, $agent_id, 2, 0, 0, 'new_agent', 0, $dbh); + pandora_event ($pa_config, "Agent [" . safe_output($alias) . "] created by $server_name", $group_id, $agent_id, 2, 0, 0, 'new_agent', 0, $dbh); return $agent_id; } @@ -3168,7 +3190,10 @@ sub pandora_update_module_on_error ($$$) { # Set tagente_estado.current_interval to make sure it is not 0 my $current_interval; if (defined($module->{'cron_interval'}) && $module->{'cron_interval'} ne '' && $module->{'cron_interval'} ne '* * * * *') { - $current_interval = cron_next_execution ($module->{'cron_interval'}); + $current_interval = cron_next_execution ( + $module->{'cron_interval'}, + $module->{'module_interval'} == 0 ? 300 : $module->{'module_interval'} + ); } elsif ($module->{'module_interval'} == 0) { $current_interval = 300; @@ -3495,7 +3520,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { # Generate an event, ONLY if our alert action is different from generate an event. if ($action->{'id_alert_command'} != 3){ - pandora_event ($pa_config, "SNMP alert fired (" . $alert->{'description'} . ")", + pandora_event ($pa_config, "SNMP alert fired (" . safe_output($alert->{'description'}) . ")", 0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh); } @@ -3549,7 +3574,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { # Generate an event, ONLY if our alert action is different from generate an event. if ($other_action->{'id_alert_command'} != 3){ - pandora_event ($pa_config, "SNMP alert fired (" . $alert->{'description'} . ")", + pandora_event ($pa_config, "SNMP alert fired (" . safe_output($alert->{'description'}) . ")", 0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh); } @@ -4553,6 +4578,7 @@ sub pandora_group_statistics ($$) { # Get all groups my @groups = get_db_rows ($dbh, 'SELECT id_grupo FROM tgrupo'); + my $table = is_metaconsole($pa_config) ? 'tmetaconsole_agent' : 'tagente'; # For each valid group get the stats: Simple uh? foreach my $group_row (@groups) { @@ -4561,50 +4587,46 @@ sub pandora_group_statistics ($$) { # NOTICE - Calculations done here MUST BE the same than used in PHP code to have # the same criteria. PLEASE, double check any changes here and in functions_groups.php - $agents_unknown = get_db_value ($dbh, "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo=?", $group); + $agents_unknown = get_db_value ($dbh, "SELECT COUNT(*) FROM $table WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo=?", $group); $agents_unknown = 0 unless defined ($agents_unknown); - $agents = get_db_value ($dbh, "SELECT COUNT(*) FROM tagente WHERE id_grupo = $group AND disabled = 0"); + $agents = get_db_value ($dbh, "SELECT COUNT(*) FROM $table WHERE id_grupo = $group AND disabled=0"); $agents = 0 unless defined ($agents); - $modules = get_db_value ($dbh, "SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = $group AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0"); + $modules = get_db_value ($dbh, "SELECT SUM(total_count) FROM $table WHERE disabled=0 AND id_grupo=?", $group); $modules = 0 unless defined ($modules); - $normal = get_db_value ($dbh, "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND normal_count=total_count AND id_grupo=?", $group); + $normal = get_db_value ($dbh, "SELECT COUNT(*) FROM $table WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count=0 AND normal_count>0 AND id_grupo=?", $group); $normal = 0 unless defined ($normal); - $critical = get_db_value ($dbh, "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo=?", $group); + $critical = get_db_value ($dbh, "SELECT COUNT(*) FROM $table WHERE disabled=0 AND critical_count>0 AND id_grupo=?", $group); $critical = 0 unless defined ($critical); - $warning = get_db_value ($dbh, "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo=?", $group); + $warning = get_db_value ($dbh, "SELECT COUNT(*) FROM $table WHERE disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo=?", $group); $warning = 0 unless defined ($warning); - $unknown = get_db_value ($dbh, "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo=?", $group); + $unknown = get_db_value ($dbh, "SELECT COUNT(*) FROM $table WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo=?", $group); $unknown = 0 unless defined ($unknown); - $non_init = get_db_value ($dbh, "SELECT COUNT(*) FROM tagente WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count=0 AND notinit_count>0 AND id_grupo=?", $group); + $non_init = get_db_value ($dbh, "SELECT COUNT(*) FROM $table WHERE disabled=0 AND total_count=notinit_count AND id_grupo=?", $group); $non_init = 0 unless defined ($non_init); - $alerts = get_db_value ($dbh, "SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente - WHERE tagente.id_grupo = $group AND tagente_modulo.id_agente = tagente.id_agente - AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 - AND talert_template_modules.disabled = 0 - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"); + # Total alert count not available on the meta console. + if ($table eq 'tagente') { + $alerts = get_db_value ($dbh, "SELECT COUNT(talert_template_modules.id) + FROM talert_template_modules, tagente_modulo, tagente + WHERE tagente.id_grupo = $group AND tagente_modulo.id_agente = tagente.id_agente + AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 + AND talert_template_modules.disabled = 0 + AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"); + } $alerts = 0 unless defined ($alerts); - $alerts_fired = get_db_value ($dbh, "SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente - WHERE tagente.id_grupo = $group AND tagente_modulo.id_agente = tagente.id_agente - AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 - AND talert_template_modules.disabled = 0 - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo - AND times_fired > 0"); + $alerts_fired = get_db_value ($dbh, "SELECT SUM(fired_count) FROM $table WHERE disabled=0 AND id_grupo=?", $group); $alerts_fired = 0 unless defined ($alerts_fired); # Update the record. - db_do ($dbh, "DELETE FROM tgroup_stat WHERE id_group = $group"); - db_do ($dbh, "INSERT INTO tgroup_stat (id_group, modules, normal, critical, warning, unknown, " . $PandoraFMS::DB::RDBMS_QUOTE . 'non-init' . $PandoraFMS::DB::RDBMS_QUOTE . ", alerts, alerts_fired, agents, agents_unknown, utimestamp) VALUES ($group, $modules, $normal, $critical, $warning, $unknown, $non_init, $alerts, $alerts_fired, $agents, $agents_unknown, UNIX_TIMESTAMP())"); + db_do ($dbh, "REPLACE INTO tgroup_stat (id_group, modules, normal, critical, warning, unknown, " . $PandoraFMS::DB::RDBMS_QUOTE . 'non-init' . $PandoraFMS::DB::RDBMS_QUOTE . ", alerts, alerts_fired, agents, agents_unknown, utimestamp) VALUES ($group, $modules, $normal, $critical, $warning, $unknown, $non_init, $alerts, $alerts_fired, $agents, $agents_unknown, UNIX_TIMESTAMP())"); } @@ -4702,23 +4724,29 @@ sub pandora_self_monitoring ($$) { $xml_output .=" $agents_unknown"; $xml_output .=" "; - $xml_output .=" "; - $xml_output .=" System_Load_AVG"; - $xml_output .=" generic_data"; - $xml_output .=" $load_average"; - $xml_output .=" "; + if (defined($load_average)) { + $xml_output .=" "; + $xml_output .=" System_Load_AVG"; + $xml_output .=" generic_data"; + $xml_output .=" $load_average"; + $xml_output .=" "; + } - $xml_output .=" "; - $xml_output .=" Free_RAM"; - $xml_output .=" generic_data"; - $xml_output .=" $free_mem"; - $xml_output .=" "; + if (defined($free_mem)) { + $xml_output .=" "; + $xml_output .=" Free_RAM"; + $xml_output .=" generic_data"; + $xml_output .=" $free_mem"; + $xml_output .=" "; + } - $xml_output .=" "; - $xml_output .=" FreeDisk_SpoolDir"; - $xml_output .=" generic_data"; - $xml_output .=" $free_disk_spool"; - $xml_output .=" "; + if (defined($free_disk_spool)) { + $xml_output .=" "; + $xml_output .=" FreeDisk_SpoolDir"; + $xml_output .=" generic_data"; + $xml_output .=" $free_disk_spool"; + $xml_output .=" "; + } $xml_output .= ""; @@ -5456,6 +5484,30 @@ sub pandora_output_password($$) { return $decrypted_password; } +########################################################################## +=head2 C<< safe_mode (I<$pa_config>, I<$agent>, I<$module>, I<$new_status>, I<$known_status>, I<$dbh>) >> + +Execute safe mode for the given agent based on the status of the given module. + +=cut +########################################################################## +sub safe_mode($$$$$$) { + my ($pa_config, $agent, $module, $new_status, $known_status, $dbh) = @_; + + return unless $agent->{'safe_mode_module'} > 0; + + # Going to critical. Disable the rest of the modules. + if ($new_status == MODULE_CRITICAL) { + logger($pa_config, "Enabling safe mode for agent " . $agent->{'nombre'}, 10); + db_do($dbh, 'UPDATE tagente_modulo SET disabled=1 WHERE id_agente=? AND id_agente_modulo!=?', $agent->{'id_agente'}, $module->{'id_agente_modulo'}); + } + # Coming back from critical. Enable the rest of the modules. + elsif ($known_status == MODULE_CRITICAL) { + logger($pa_config, "Disabling safe mode for agent " . $agent->{'nombre'}, 10); + db_do($dbh, 'UPDATE tagente_modulo SET disabled=0 WHERE id_agente=? AND id_agente_modulo!=?', $agent->{'id_agente'}, $module->{'id_agente_modulo'}); + } +} + # End of function declaration # End of defined Code diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index ebd8f860ee..dab25b57e6 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -186,6 +186,7 @@ sub data_consumer ($$) { for (0..1) { eval { threads->yield; + $xml_data = XMLin ($file_name, forcearray => 'module'); }; @@ -333,19 +334,22 @@ sub process_xml_data ($$$$$) { if (defined ($data->{'group_id'}) && $data->{'group_id'} ne '') { $group_id = $data->{'group_id'}; if (! defined (get_group_name ($dbh, $group_id))) { - pandora_event ($pa_config, "Unable to create agent '$agent_name': group ID '" . $group_id . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh); + print "UNABLE GROUP ID\n"; + pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': group ID '" . $group_id . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh); logger($pa_config, "Group ID " . $group_id . " does not exist.", 3); return; } } elsif (defined ($data->{'group'}) && $data->{'group'} ne '') { $group_id = get_group_id ($dbh, $data->{'group'}); if (! defined (get_group_name ($dbh, $group_id))) { - pandora_event ($pa_config, "Unable to create agent '$agent_name': group '" . $data->{'group'} . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh); + print "UNABLE GROUP\n"; + pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': group '" . safe_output($data->{'group'}) . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh); logger($pa_config, "Group " . $data->{'group'} . " does not exist.", 3); return; } } else { - pandora_event ($pa_config, "Unable to create agent '$agent_name': autocreate_group $group_id does not exist. Edit the pandora_server.conf file and change it.", 0, 0, 0, 0, 0, 'error', 0, $dbh); + print "UNABLE AUTOCREATE\n"; + pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': autocreate_group $group_id does not exist. Edit the pandora_server.conf file and change it.", 0, 0, 0, 0, 0, 'error', 0, $dbh); logger($pa_config, "Group id $group_id does not exist (check autocreate_group config token).", 3); return; } @@ -527,7 +531,7 @@ sub process_xml_data ($$$$$) { # Single data if (! defined ($module_data->{'datalist'})) { my $data_timestamp = get_tag_value ($module_data, 'timestamp', $timestamp); - process_module_data ($pa_config, $module_data, $server_id, $agent_name, $module_name, $module_type, $interval, $data_timestamp, $dbh, $new_agent); + process_module_data ($pa_config, $module_data, $server_id, $agent, $module_name, $module_type, $interval, $data_timestamp, $dbh, $new_agent); next; } @@ -544,7 +548,7 @@ sub process_xml_data ($$$$$) { $module_data->{'data'} = $data->{'value'}; my $data_timestamp = get_tag_value ($data, 'timestamp', $timestamp); - process_module_data ($pa_config, $module_data, $server_id, $agent_name, $module_name, + process_module_data ($pa_config, $module_data, $server_id, $agent, $module_name, $module_type, $interval, $data_timestamp, $dbh, $new_agent); } } @@ -584,16 +588,16 @@ sub process_xml_data ($$$$$) { # Process module data, creating module if necessary. ########################################################################## sub process_module_data ($$$$$$$$$$) { - my ($pa_config, $data, $server_id, $agent_name, + my ($pa_config, $data, $server_id, $agent, $module_name, $module_type, $interval, $timestamp, $dbh, $force_processing) = @_; # Get agent data - my $agent = get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE nombre = ?', safe_input($agent_name)); if (! defined ($agent)) { - logger($pa_config, "Invalid agent '$agent_name' for module '$module_name'.", 3); + logger($pa_config, "Invalid agent for module '$module_name'.", 3); return; } + my $agent_name = $agent->{'nombre'}; # Get module parameters, matching column names in tagente_modulo my $module_conf; diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index ea433ad9ec..f52b6e8a72 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -344,10 +344,10 @@ sub pandora_query_snmp ($$$$) { my $snmp_version = $module->{"tcp_send"}; # (1, 2, 2c or 3) my $snmp3_privacy_method = $module->{"custom_string_1"}; # DES/AES - my $snmp3_privacy_pass = pandora_output_password($pa_config, $module->{"custom_string_2"}); + my $snmp3_privacy_pass = safe_output(pandora_output_password($pa_config, $module->{"custom_string_2"})); my $snmp3_security_level = $module->{"custom_string_3"}; # noAuthNoPriv|authNoPriv|authPriv - my $snmp3_auth_user = $module->{"plugin_user"}; - my $snmp3_auth_pass = pandora_output_password($pa_config, $module->{"plugin_pass"}); + my $snmp3_auth_user = safe_output($module->{"plugin_user"}); + my $snmp3_auth_pass = safe_output(pandora_output_password($pa_config, $module->{"plugin_pass"})); my $snmp3_auth_method = $module->{"plugin_parameter"}; #MD5/SHA1 my $snmp_community = $module->{"snmp_community"}; my $snmp_target = $ip_target; @@ -400,19 +400,19 @@ sub pandora_query_snmp ($$$$) { # SNMP v3 no authentication and no privacy if ($snmp3_security_level eq "noAuthNoPriv"){ - $snmp3_extra = " -u $snmp3_auth_user "; + $snmp3_extra = " -u '$snmp3_auth_user' "; } # SNMP v3 authentication only if ($snmp3_security_level eq "authNoPriv"){ - $snmp3_extra = " -a $snmp3_auth_method -u $snmp3_auth_user -A $snmp3_auth_pass "; + $snmp3_extra = " -a $snmp3_auth_method -u '$snmp3_auth_user' -A '$snmp3_auth_pass' "; } # SNMP v3 privacy AND authentication if ($snmp3_security_level eq "authPriv"){ - $snmp3_extra = " -a $snmp3_auth_method -u $snmp3_auth_user -A $snmp3_auth_pass -x $snmp3_privacy_method -X $snmp3_privacy_pass "; + $snmp3_extra = " -a $snmp3_auth_method -u '$snmp3_auth_user' -A '$snmp3_auth_pass' -x $snmp3_privacy_method -X '$snmp3_privacy_pass' "; } - + $output = pandora_snmp_get_command ($snmpget_cmd, $snmp_version, $snmp_retries, $snmp_timeout, $snmp_community, $snmp_target, $snmp_oid, $snmp3_security_level, $snmp3_extra, $snmp_port, $pa_config); if (defined ($output) && $output ne ""){ $module_result = 0; diff --git a/pandora_server/lib/PandoraFMS/ReconServer.pm b/pandora_server/lib/PandoraFMS/ReconServer.pm index b25c222bf7..3261729569 100644 --- a/pandora_server/lib/PandoraFMS/ReconServer.pm +++ b/pandora_server/lib/PandoraFMS/ReconServer.pm @@ -421,7 +421,7 @@ sub PandoraFMS::Recon::Base::create_agent($$) { $agent_id = pandora_create_agent($self->{'pa_config'}, $self->{'pa_config'}->{'servername'}, $host_name, $device, $self->{'group_id'}, 0, $id_os, '', 300, $self->{'dbh'}); return undef unless defined ($agent_id) and ($agent_id > 0); - pandora_event($self->{'pa_config'}, "[RECON] New " . $self->get_device_type($device) . " found (" . join(',', $self->get_addresses($device)) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'}); + pandora_event($self->{'pa_config'}, "[RECON] New " . safe_output($self->get_device_type($device)) . " found (" . join(',', safe_output($self->get_addresses($device))) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'}); $agent_learning = 1; # Create network profile modules for the agent diff --git a/pandora_server/lib/PandoraFMS/SNMPServer.pm b/pandora_server/lib/PandoraFMS/SNMPServer.pm index bc7b3a708a..9328f56c68 100644 --- a/pandora_server/lib/PandoraFMS/SNMPServer.pm +++ b/pandora_server/lib/PandoraFMS/SNMPServer.pm @@ -196,10 +196,10 @@ sub pandora_snmptrapd { my ($pa_config, $line, $server_id, $dbh) = @_; (my $trap_ver, $line) = split(/\[\*\*\]/, $line, 2); - +print STDERR "ANTES"; # Process SNMP filter next if (matches_filter ($dbh, $pa_config, $line) == 1); - +print STDERR "DESPUES"; logger($pa_config, "Reading trap '$line'", 10); my ($date, $time, $source, $oid, $type, $type_desc, $value, $data) = ('', '', '', '', '', '', '', ''); @@ -345,22 +345,34 @@ sub pandora_snmptrapd { sub matches_filter ($$$) { my ($dbh, $pa_config, $string) = @_; - # Get filters - my @filters = get_db_rows ($dbh, 'SELECT filter FROM tsnmp_filter'); - foreach my $filter (@filters) { - my $regexp = safe_output($filter->{'filter'}) ; - my $eval_result; + my @filter_unique_functions = get_db_rows ($dbh, 'SELECT DISTINCT(unified_filters_id) FROM tsnmp_filter ORDER BY unified_filters_id'); + + foreach my $filter_unique_func (@filter_unique_functions) { + # Get filters + my @filters = get_db_rows ($dbh, 'SELECT filter FROM tsnmp_filter WHERE unified_filters_id = ' . $filter_unique_func->{'unified_filters_id'}); + + my $eval_acum = 1; + foreach my $filter (@filters) { + my $regexp = safe_output($filter->{'filter'}) ; + my $eval_result; - # eval protects against server down (by invalid regular expressions) - $eval_result = eval { - $string =~ m/$regexp/i ; - }; - - if ($eval_result) { - logger($pa_config, "Trap '$string' matches filter '$regexp'. Discarding...", 10); - return 1; - } + # eval protects against server down (by invalid regular expressions) + $eval_result = eval { + $string =~ m/$regexp/i ; + }; + if ($eval_result && $eval_acum) { + $eval_acum = 1; + } + else { + $eval_acum = 0; + last; + } + } + + if ($eval_acum) { + return 1; + } } return 0; diff --git a/pandora_server/lib/PandoraFMS/Server.pm b/pandora_server/lib/PandoraFMS/Server.pm index 9ec0ae01bd..f5c91869fb 100644 --- a/pandora_server/lib/PandoraFMS/Server.pm +++ b/pandora_server/lib/PandoraFMS/Server.pm @@ -254,7 +254,7 @@ sub restartEvent ($$) { return unless defined ($self->{'_dbh'}); eval { - pandora_event ($self->{'_pa_config'}, $self->{'_pa_config'}->{'servername'} . + pandora_event ($self->{'_pa_config'}, $self->{'_pa_config'}->{'servername'} . ' ' . $ServerTypes[$self->{'_server_type'}] . " RESTARTING" . ($msg ne '' ? " ($msg)" : ''), 0, 0, 4, 0, 0, 'system', 0, $self->{'_dbh'}); }; diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index e0dda9af4f..2a3af2783e 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -68,6 +68,11 @@ our @EXPORT = qw( $OS_VERSION RECOVERED_ALERT FIRED_ALERT + MODULE_NORMAL + MODULE_CRITICAL + MODULE_WARNING + MODULE_UNKNOWN + MODULE_NOTINIT cron_get_closest_in_range cron_next_execution cron_next_execution_date @@ -127,6 +132,13 @@ use constant MFSERVER => 15; use constant SYNCSERVER => 16; use constant WUXSERVER => 17; +# Module status +use constant MODULE_NORMAL => 0; +use constant MODULE_CRITICAL => 1; +use constant MODULE_WARNING => 2; +use constant MODULE_UNKNOWN => 3; +use constant MODULE_NOTINIT => 4; + # Value for a metaconsole license type use constant METACONSOLE_LICENSE => 0x01; @@ -151,6 +163,141 @@ if ($OS eq 'linux') { } chomp($OS_VERSION); +# Entity to character mapping. Contains a few tweaks to make it backward compatible with the previous safe_input implementation. +my %ENT2CHR = ( + '#x00' => chr(0), + '#x01' => chr(1), + '#x02' => chr(2), + '#x03' => chr(3), + '#x04' => chr(4), + '#x05' => chr(5), + '#x06' => chr(6), + '#x07' => chr(7), + '#x08' => chr(8), + '#x09' => chr(9), + '#x0a' => chr(10), + '#x0b' => chr(11), + '#x0c' => chr(12), + '#x0d' => chr(13), + '#x0e' => chr(14), + '#x0f' => chr(15), + '#x10' => chr(16), + '#x11' => chr(17), + '#x12' => chr(18), + '#x13' => chr(19), + '#x14' => chr(20), + '#x15' => chr(21), + '#x16' => chr(22), + '#x17' => chr(23), + '#x18' => chr(24), + '#x19' => chr(25), + '#x1a' => chr(26), + '#x1b' => chr(27), + '#x1c' => chr(28), + '#x1d' => chr(29), + '#x1e' => chr(30), + '#x1f' => chr(31), + '#x20' => chr(32), + 'quot' => chr(34), + 'amp' => chr(38), + '#039' => chr(39), + '#40' => chr(40), + '#41' => chr(41), + 'lt' => chr(60), + 'gt' => chr(62), + '#92' => chr(92), + '#x80' => chr(128), + '#x81' => chr(129), + '#x82' => chr(130), + '#x83' => chr(131), + '#x84' => chr(132), + '#x85' => chr(133), + '#x86' => chr(134), + '#x87' => chr(135), + '#x88' => chr(136), + '#x89' => chr(137), + '#x8a' => chr(138), + '#x8b' => chr(139), + '#x8c' => chr(140), + '#x8d' => chr(141), + '#x8e' => chr(142), + '#x8f' => chr(143), + '#x90' => chr(144), + '#x91' => chr(145), + '#x92' => chr(146), + '#x93' => chr(147), + '#x94' => chr(148), + '#x95' => chr(149), + '#x96' => chr(150), + '#x97' => chr(151), + '#x98' => chr(152), + '#x99' => chr(153), + '#x9a' => chr(154), + '#x9b' => chr(155), + '#x9c' => chr(156), + '#x9d' => chr(157), + '#x9e' => chr(158), + '#x9f' => chr(159), + '#xa0' => chr(160), + '#xa1' => chr(161), + '#xa2' => chr(162), + '#xa3' => chr(163), + '#xa4' => chr(164), + '#xa5' => chr(165), + '#xa6' => chr(166), + '#xa7' => chr(167), + '#xa8' => chr(168), + '#xa9' => chr(169), + '#xaa' => chr(170), + '#xab' => chr(171), + '#xac' => chr(172), + '#xad' => chr(173), + '#xae' => chr(174), + '#xaf' => chr(175), + '#xb0' => chr(176), + '#xb1' => chr(177), + '#xb2' => chr(178), + '#xb3' => chr(179), + '#xb4' => chr(180), + '#xb5' => chr(181), + '#xb6' => chr(182), + '#xb7' => chr(183), + '#xb8' => chr(184), + '#xb9' => chr(185), + '#xba' => chr(186), + '#xbb' => chr(187), + '#xbc' => chr(188), + '#xbd' => chr(189), + '#xbe' => chr(190), + 'Aacute' => chr(193), + 'Auml' => chr(196), + 'Eacute' => chr(201), + 'Euml' => chr(203), + 'Iacute' => chr(205), + 'Iuml' => chr(207), + 'Ntilde' => chr(209), + 'Oacute' => chr(211), + 'Ouml' => chr(214), + 'Uacute' => chr(218), + 'Uuml' => chr(220), + 'aacute' => chr(225), + 'auml' => chr(228), + 'eacute' => chr(233), + 'euml' => chr(235), + 'iacute' => chr(237), + 'iuml' => chr(239), + 'ntilde' => chr(241), + 'oacute' => chr(243), + 'ouml' => chr(246), + 'uacute' => chr(250), + 'uuml' => chr(252), +); + +# Construct the character to entity mapping. +my %CHR2ENT; +while (my ($ent, $chr) = each(%ENT2CHR)) { + $CHR2ENT{$chr} = "&" . $ent . ";"; +} ############################################################################### # Sets user:group owner for the given file @@ -201,49 +348,7 @@ sub pandora_trash_ascii { sub safe_input($) { my $value = shift; - $value = encode_entities ($value, "<>&"); - - #//Replace the character '\' for the equivalent html entitie - $value =~ s/\\/\/gi; - - #// First attempt to avoid SQL Injection based on SQL comments - #// Specific for MySQL. - $value =~ s/\/\*//*/gi; - $value =~ s/\*\//*//gi; - - #//Replace ' for the html entitie - $value =~ s/\"/"/gi; - - #//Replace ' for the html entitie - $value =~ s/\'/'/gi; - - #//Replace ( for the html entitie - $value =~ s/\(/(/gi; - - #//Replace ( for the html entitie - $value =~ s/\)/)/gi; - - #//Replace some characteres for html entities - for (my $i=0;$i<33;$i++) { - my $pattern = chr($i); - my $hex = ascii_to_html($i); - $value =~ s/$pattern/$hex/gi; - } - - for (my $i=128;$i<191;$i++) { - my $pattern = chr($i); - my $hex = ascii_to_html($i); - $value =~ s/$pattern/$hex/gi; - } - - #//Replace characteres for tildes and others - my $trans = get_html_entities(); - - foreach(keys(%$trans)) - { - my $pattern = chr($_); - $value =~ s/$pattern/$trans->{$_}/g; - } + $value =~ s/([\x00-\xFF])/$CHR2ENT{$1}||$1/ge; return $value; } @@ -254,99 +359,11 @@ sub safe_input($) { sub safe_output($) { my $value = shift; - $value = decode_entities ($value); - - #//Replace the character '\' for the equivalent html entitie - $value =~ s/\/\\/gi; - - #// First attempt to avoid SQL Injection based on SQL comments - #// Specific for MySQL. - $value =~ s//*/\/\*/gi; - $value =~ s/*//\*\//gi; - - #//Replace ( for the html entitie - $value =~ s/(/\(/gi; - - #//Replace ( for the html entitie - $value =~ s/)/\)/gi; - - #//Replace ' for the html entitie - $value =~ s/'/')/gi; - - #//Replace " for the html entitie - $value =~ s/"/")/gi; - - #//Replace some characteres for html entities - for (my $i=0;$i<33;$i++) { - my $pattern = chr($i); - my $hex = ascii_to_html($i); - $value =~ s/$hex/$pattern/gi; - } - - for (my $i=128;$i<191;$i++) { - my $pattern = chr($i); - my $hex = ascii_to_html($i); - $value =~ s/$hex/$pattern/gi; - } - - #//Replace characteres for tildes and others - my $trans = get_html_entities(); - - foreach(keys(%$trans)) - { - my $pattern = chr($_); - $value =~ s/$trans->{$_}/$pattern/g; - } - + _decode_entities ($value, \%ENT2CHR); + return $value; } -########################################################################## -# SUB get_html_entities -# Returns a hash table with the acute and special html entities -# Usefull for future chars addition: -# http://cpansearch.perl.org/src/GAAS/HTML-Parser-3.68/lib/HTML/Entities.pm -########################################################################## - -sub get_html_entities { - my %trans = ( - 225 => 'á', - 233 => 'é', - 237 => 'í', - 243 => 'ó', - 250 => 'ú', - 193 => 'Á', - 201 => 'É', - 205 => 'Í', - 211 => 'Ó', - 218 => 'Ú', - 228 => 'ä', - 235 => 'ë', - 239 => 'ï', - 246 => 'ö', - 252 => 'ü', - 196 => 'Ä', - 203 => 'Ë', - 207 => 'Ï', - 214 => 'Ö', - 220 => 'Ü', - 241 => 'ñ', - 209 => 'Ñ' - ); - - return \%trans; -} -######################################################################## -# SUB ascii_to_html (string) -# Convert an ascii string to hexadecimal -######################################################################## - -sub ascii_to_html($) { - my $ascii = shift; - - return "&#x".substr(unpack("H*", pack("N", $ascii)),6,3).";"; -} - ######################################################################## # Sub daemonize () # Put program in background (for daemon mode) @@ -861,6 +878,24 @@ sub dateTimeToTimestamp { sub disk_free ($) { my $target = $_[0]; + my $OSNAME = $^O; + + # Get the free disk on data_in folder unit + if ($OSNAME eq "MSWin32") { + # Check relative path + my $unit; + if ($target =~ m/^([a-zA-Z]):/gi) { + $unit = $1/(1024*1024); + } else { + return; + } + # Get the free space of unit found + my $all_disk_info = `wmic logicaldisk get caption, freespace`; + if ($all_disk_info =~ m/$unit:\D*(\d+)/gmi){ + return $1; + } + return; + } # Try to use df command with Posix parameters... my $command = "df -k -P ".$target." | tail -1 | awk '{ print \$4/1024}'"; my $output = `$command`; @@ -874,6 +909,9 @@ sub load_average { if ($OSNAME eq "freebsd"){ $load_average = ((split(/\s+/, `/sbin/sysctl -n vm.loadavg`))[1]); + } elsif ($OSNAME eq "MSWin32") { + # Windows hasn't got load average. + $load_average = undef; } # by default LINUX calls else { @@ -896,6 +934,14 @@ sub free_mem { elsif ($OSNAME eq "netbsd"){ $free_mem = `cat /proc/meminfo | grep MemFree | awk '{ print \$2 }'`; } + elsif ($OSNAME eq "MSWin32"){ + $free_mem = `wmic OS get FreePhysicalMemory /Value`; + if ($free_mem =~ m/=(.*)$/gm) { + $free_mem = $1; + } else { + $free_mem = undef; + } + } # by default LINUX calls else { $free_mem = `free | grep Mem | awk '{ print \$4 }'`; @@ -1254,12 +1300,12 @@ sub translate_obj ($$$) { ############################################################################### # Get the number of seconds left to the next execution of the given cron entry. ############################################################################### -sub cron_next_execution ($) { - my ($cron) = @_; +sub cron_next_execution { + my ($cron, $interval) = @_; # Check cron conf format if ($cron !~ /^((\*|(\d+(-\d+){0,1}))\s*){5}$/) { - return 300; + return $interval; } # Get day of the week and month from cron config @@ -1271,7 +1317,7 @@ sub cron_next_execution ($) { # Any day of the week if ($wday eq '*') { - my $nex_time = cron_next_execution_date ($cron, $cur_time); + my $nex_time = cron_next_execution_date ($cron, $cur_time, $interval); return $nex_time - time(); } # A range? @@ -1283,7 +1329,7 @@ sub cron_next_execution ($) { my $count = 0; my $nex_time = $cur_time; do { - $nex_time = cron_next_execution_date ($cron, $nex_time); + $nex_time = cron_next_execution_date ($cron, $nex_time, $interval); my $nex_time_wd = $nex_time; my ($nex_mon, $nex_wday) = (localtime ($nex_time_wd))[4, 6]; my $nex_mon_wd; @@ -1301,7 +1347,7 @@ sub cron_next_execution ($) { } while ($count < 60); # Something went wrong, default to 5 minutes - return 300; + return $interval; } ############################################################################### # Get the number of seconds left to the next execution of the given cron entry. @@ -1315,94 +1361,191 @@ sub cron_check_syntax ($) { ############################################################################### # Get the next execution date for the given cron entry in seconds since epoch. ############################################################################### -sub cron_next_execution_date ($$) { - my ($cron, $cur_time) = @_; +sub cron_next_execution_date { + my ($cron, $cur_time, $interval) = @_; # Get cron configuration my ($min, $hour, $mday, $mon, $wday) = split (/\s/, $cron); # Months start from 0 if($mon ne '*') { - $mon -= 1; + my ($mon_down, $mon_up) = cron_get_interval ($mon); + if (defined($mon_up)) { + $mon = $mon_down - 1 . "-" . $mon_up - 1; + } else { + $mon = $mon_down - 1; + } } # Get current time if (! defined ($cur_time)) { $cur_time = time(); } - my ($cur_min, $cur_hour, $cur_mday, $cur_mon, $cur_year) = (localtime ($cur_time))[1, 2, 3, 4, 5]; + # Check if current time + interval is on cron too + my $nex_time = $cur_time + $interval; + my ($cur_min, $cur_hour, $cur_mday, $cur_mon, $cur_year) + = (localtime ($nex_time))[1, 2, 3, 4, 5]; - # Parse intervals - $min = cron_get_closest_in_range ($cur_min, $min); - $hour = cron_get_closest_in_range ($cur_hour, $hour); - $mday = cron_get_closest_in_range ($cur_mday, $mday); - $mon = cron_get_closest_in_range ($cur_mon, $mon); + my @cron_array = ($min, $hour, $mday, $mon); + my @curr_time_array = ($cur_min, $cur_hour, $cur_mday, $cur_mon); + return ($nex_time) if cron_is_in_cron(\@cron_array, \@curr_time_array) == 1; - # Get first next date candidate from cron configuration - my ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = ($min, $hour, $mday, $mon, $cur_year); + # Get first next date candidate from next cron configuration + # Initialize some vars + my @nex_time_array = @curr_time_array; + my $prev_ovfl = 0; - # Replace wildcards - if ($min eq '*') { - if ($hour ne '*' || $mday ne '*' || $wday ne '*' || $mon ne '*') { - $nex_min = 0; - } - else { - $nex_min = $cur_min; - } - } - if ($hour eq '*') { - if ($mday ne '*' || $wday ne '*' ||$mon ne '*') { - $nex_hour = 0; - } - else { - $nex_hour = $cur_hour; - } - } - if ($mday eq '*') { - if ($mon ne '*') { - $nex_mday = 1; - } - else { - $nex_mday = $cur_mday; - } - } - if ($mon eq '*') { - $nex_mon = $cur_mon; + # Update minutes + my ($min_down, undef) = cron_get_interval ($min); + $nex_time_array[0] = ($min_down eq '*') ? 0 : $min_down; + + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time >= $cur_time) { + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); } - # Find the next execution date - my $count = 0; - do { - my $next_time = timelocal(0, $nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year); - if ($next_time > $cur_time) { - return $next_time; - } - if ($min eq '*' && $hour eq '*' && $wday eq '*' && $mday eq '*' && $mon eq '*') { - ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = (localtime ($next_time + 60))[1, 2, 3, 4, 5]; - } - elsif ($hour eq '*' && $wday eq '*' && $mday eq '*' && $mon eq '*') { - ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = (localtime ($next_time + 3600))[1, 2, 3, 4, 5]; - } - elsif ($mday eq '*' && $mon eq '*') { - ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = (localtime ($next_time + 86400))[1, 2, 3, 4, 5]; - } - elsif ($mon eq '*') { - $nex_mon = $nex_mon + 1; - if ($nex_mon > 11) { - $nex_mon = 0; - $nex_year++; + # Check if next hour is in cron + $nex_time_array[1]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + + if ($nex_time == 0) { + #Update the month day if overflow + $prev_ovfl = 1; + $nex_time_array[1] = 0; + $nex_time_array[2]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time == 0) { + #Update the month if overflow + $nex_time_array[2] = 1; + $nex_time_array[3]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time == 0) { + #Update the year if overflow + $cur_year++; + $nex_time_array[3] = 0; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); } } - else { - $nex_year++; - } - $count++; - } while ($count < 60); - - # Something went wrong, default to 5 minutes - return $cur_time + 300; -} + } + #Check the hour + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); + #Update the hour if fails + my ($hour_down, undef) = cron_get_interval ($hour); + $nex_time_array[1] = ($hour_down eq '*') ? 0 : $hour_down; + + # When an overflow is passed check the hour update again + if ($prev_ovfl) { + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); + } + $prev_ovfl = 0; + + # Check if next day is in cron + $nex_time_array[2]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time == 0) { + #Update the month if overflow + $prev_ovfl = 1; + $nex_time_array[2] = 1; + $nex_time_array[3]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time == 0) { + #Update the year if overflow + $nex_time_array[3] = 0; + $cur_year++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + } + } + #Check the day + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); + + #Update the day if fails + my ($mday_down, undef) = cron_get_interval ($mday); + $nex_time_array[2] = ($mday_down eq '*') ? 1 : $mday_down; + + # When an overflow is passed check the hour update in the next execution + if ($prev_ovfl) { + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); + } + $prev_ovfl = 0; + + # Check if next month is in cron + $nex_time_array[3]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time == 0) { + #Update the year if overflow + $prev_ovfl = 1; + $cur_year++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + } + + #Check the month + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); + + #Update the month if fails + my ($mon_down, undef) = cron_get_interval ($mon); + $nex_time_array[3] = ($mday_down eq '*') ? 0 : $mday_down; + + # When an overflow is passed check the hour update in the next execution + if ($prev_ovfl) { + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); + } + + $nex_time = cron_valid_date(@nex_time_array, $cur_year + 1); + + return $nex_time; +} +############################################################################### +# Returns if a date is in a cron. Recursive. +# Needs the cron like an array reference and +# current time in cron format to works properly +############################################################################### +sub cron_is_in_cron { + my ($elems_cron, $elems_curr_time) = @_; + + my @deref_elems_cron = @$elems_cron; + my @deref_elems_curr_time = @$elems_curr_time; + + my $elem_cron = shift(@deref_elems_cron); + my $elem_curr_time = shift (@deref_elems_curr_time); + + #If there is no elements means that is in cron + return 1 unless (defined($elem_cron) || defined($elem_curr_time)); + + # Go to last element if current is a wild card + if ($elem_cron ne '*') { + my ($down, $up) = cron_get_interval($elem_cron); + # Check if there is no a range + return 0 if (!defined($up) && ($down != $elem_curr_time)); + # Check if there is on the range + if (defined($up)) { + if ($down < $up) { + return 0 if ($elem_curr_time < $down || $elem_curr_time > $up); + } else { + return 0 if ($elem_curr_time > $down || $elem_curr_time < $up); + } + } + } + return cron_is_in_cron(\@deref_elems_cron, \@deref_elems_curr_time); +} +############################################################################### +# Returns the interval of a cron element. If there is not a range, +# returns an array with the first element in the first place of array +# and the second place undefined. +############################################################################### +sub cron_get_interval { + my ($element) = @_; + + # Not a range + if ($element !~ /(\d+)\-(\d+)/) { + return ($element, undef); + } + + return ($1, $2); +} ############################################################################### # Returns the closest number to the target inside the given range (including # the target itself). @@ -1428,6 +1571,22 @@ sub cron_get_closest_in_range ($$) { return $target; } +############################################################################### +# Check if a date is valid to get timelocal +############################################################################### +sub cron_valid_date { + my ($min, $hour, $mday, $month, $year) = @_; + my $utime; + eval { + local $SIG{__DIE__} = sub {}; + $utime = timelocal(0, $min, $hour, $mday, $month, $year); + }; + if ($@) { + return 0; + } + return $utime; +} + ############################################################################### # Attempt to resolve the given hostname. ############################################################################### diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 1d0f34221b..937f088aa0 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -2,8 +2,8 @@ # Pandora FMS Server # %define name pandorafms_server -%define version 7.0NG.713 -%define release 171018 +%define version 7.0NG.716 +%define release 171130 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index b7d07bd4d0..d2ecac53a2 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -2,8 +2,8 @@ # Pandora FMS Server # %define name pandorafms_server -%define version 7.0NG.713 -%define release 171018 +%define version 7.0NG.716 +%define release 171130 Summary: Pandora FMS Server Name: %{name} @@ -99,6 +99,11 @@ exit 0 chkconfig pandora_server on chkconfig tentacle_serverd on +# Enable the services on SystemD +systemctl enable tentacle_serverd.service +systemctl enable pandora_server.service + + echo "/usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf" > /etc/cron.hourly/pandora_db chmod 750 /etc/cron.hourly/pandora_db cp -aRf /usr/share/pandora_server/util/pandora_server_logrotate /etc/logrotate.d/pandora_server diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index fc5c70ac92..1b2e016056 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -8,8 +8,8 @@ # This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.713" -PI_BUILD="171018" +PI_VERSION="7.0NG.716" +PI_BUILD="171130" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 93883c075a..ce7d59b791 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -33,7 +33,7 @@ use PandoraFMS::Tools; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.713 PS171018"; +my $version = "7.0NG.716 PS171130"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index d3b19db48c..e8a2b003a1 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.713 PS171018"; +my $version = "7.0NG.716 PS171130"; # save program name for logging my $progname = basename($0); @@ -4535,13 +4535,6 @@ sub cli_module_get_data () { AND utimestamp > (UNIX_TIMESTAMP(NOW()) - $interval) ORDER BY utimestamp DESC"); } - elsif ($module_type =~ m/_inc$/) { - @data = get_db_rows ($dbh, "SELECT utimestamp, datos - FROM tagente_datos_inc - WHERE id_agente_modulo = $id_agent_module - AND utimestamp > (UNIX_TIMESTAMP(NOW()) - $interval) - ORDER BY utimestamp DESC"); - } else { @data = get_db_rows ($dbh, "SELECT utimestamp, datos FROM tagente_datos @@ -4831,9 +4824,13 @@ sub cli_create_visual_console() { my $label_position = $elem->{'label_position'}; my $border_color = $elem->{'border_color'}; my $fill_color = $elem->{'fill_color'}; + my $show_statistics = $elem->{'fill_color'}; + my $id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $element_group = $elem->{'element_group'}; + my $show_on_top = $elem->{'show_on_top'}; - my $elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $vc_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0); + my $elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics, id_layout_linked_weight, element_group, show_on_top) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $vc_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0, $id_layout_linked_weight, $element_group, $show_on_top); print_log "[INFO] The element id in position $elem_count is '$elem_id' \n\n"; @@ -4900,9 +4897,13 @@ sub cli_create_visual_console() { my $label_position = $elem->{'label_position'}; my $border_color = $elem->{'border_color'}; my $fill_color = $elem->{'fill_color'}; + my $id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $element_group = $elem->{'element_group'}; + my $show_on_top = $elem->{'show_on_top'}; + - my $elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $vc_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0); + my $elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics, id_layout_linked_weight, element_group, show_on_top) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $vc_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0, $id_layout_linked_weight, $element_group, $show_on_top); print_log "[INFO] The element id in position $elem_count is '$elem_id' \n\n"; @@ -5008,6 +5009,9 @@ sub cli_edit_visual_console() { my $new_label_position = $element_in_db->{'label_position'}; my $new_border_color = $element_in_db->{'border_color'}; my $new_fill_color = $element_in_db->{'fill_color'}; + my $new_id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $new_element_group = $elem->{'element_group'}; + my $new_show_on_top = $elem->{'show_on_top'}; if(defined($elem->{'pos_x'})) { $new_pos_x = $elem->{'pos_x'}; @@ -5072,6 +5076,15 @@ sub cli_edit_visual_console() { if(defined($elem->{'fill_color'})) { $new_fill_color = $elem->{'fill_color'}; } + if(defined($elem->{'id_layout_linked_weight'})) { + $new_id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + } + if(defined($elem->{'element_group'})) { + $new_element_group = $elem->{'element_group'}; + } + if(defined($elem->{'show_on_top'})) { + $new_show_on_top = $elem->{'show_on_top'}; + } db_update ($dbh, "UPDATE tlayout_data SET pos_x = " . $new_pos_x . ", pos_y = " . $new_pos_y . ", width = " . $new_width . ", height = " . $new_height . ", label = '" . $new_label . "', image = '" . $new_image . @@ -5080,6 +5093,7 @@ sub cli_edit_visual_console() { ", enable_link = " . $new_enable_link . ", id_metaconsole = " . $new_id_metaconsole . ", id_group = " . $new_id_group . ", id_custom_graph = " . $new_id_custom_graph . ", border_width = " . $new_border_width . ", type_graph = '" . $new_type_graph . "', label_position = '" . $new_label_position . "', border_color = '" . $new_border_color . "', fill_color = '" . $new_fill_color . + "', id_layout_linked_weight = '" . $new_id_layout_linked_weight . "', element_group = '" . $new_element_group . "', show_on_top = '" . $new_show_on_top . "' WHERE id = " . $elem->{'id'}); print_log "[INFO] Element with id " . $elem->{'id'} . " has been updated \n\n"; @@ -5106,9 +5120,12 @@ sub cli_edit_visual_console() { my $label_position = $elem->{'label_position'}; my $border_color = $elem->{'border_color'}; my $fill_color = $elem->{'fill_color'}; + my $id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $element_group = $elem->{'element_group'}; + my $show_on_top = $elem->{'show_on_top'}; - my $new_elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0); + my $new_elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics, id_layout_linked_weight, element_group, show_on_top) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0, $id_layout_linked_weight, $element_group, $show_on_top); print_log "[INFO] New element with id $new_elem_id has been created \n\n"; } @@ -5149,6 +5166,9 @@ sub cli_edit_visual_console() { my $new_label_position = $element_in_db->{'label_position'}; my $new_border_color = $element_in_db->{'border_color'}; my $new_fill_color = $element_in_db->{'fill_color'}; + my $new_id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $new_element_group = $elem->{'element_group'}; + my $new_show_on_top = $elem->{'show_on_top'}; if(defined($elem->{'width'})) { $new_width = $elem->{'width'}; @@ -5207,6 +5227,15 @@ sub cli_edit_visual_console() { if(defined($elem->{'fill_color'})) { $new_fill_color = $elem->{'fill_color'}; } + if(defined($elem->{'id_layout_linked_weight'})) { + $new_id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + } + if(defined($elem->{'element_group'})) { + $new_element_group = $elem->{'element_group'}; + } + if(defined($elem->{'show_on_top'})) { + $new_show_on_top = $elem->{'show_on_top'}; + } db_update ($dbh, "UPDATE tlayout_data SET pos_x = " . $new_pos_x . ", pos_y = " . $new_pos_y . ", width = " . $new_width . ", height = " . $new_height . ", label = '" . $new_label . "', image = '" . $new_image . @@ -5215,6 +5244,7 @@ sub cli_edit_visual_console() { ", enable_link = " . $new_enable_link . ", id_metaconsole = " . $new_id_metaconsole . ", id_group = " . $new_id_group . ", id_custom_graph = " . $new_id_custom_graph . ", border_width = " . $new_border_width . ", type_graph = '" . $new_type_graph . "', label_position = '" . $new_label_position . "', border_color = '" . $new_border_color . "', fill_color = '" . $new_fill_color . + "', id_layout_linked_weight = '" . $new_id_layout_linked_weight . "', element_group = '" . $new_element_group . "', show_on_top = '" . $new_show_on_top . "' WHERE id = " . $elem->{'id'}); print_log "[INFO] Element with id " . $elem->{'id'} . " has been updated \n\n"; @@ -5241,9 +5271,12 @@ sub cli_edit_visual_console() { my $label_position = $elem->{'label_position'}; my $border_color = $elem->{'border_color'}; my $fill_color = $elem->{'fill_color'}; + my $id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $element_group = $elem->{'element_group'}; + my $show_on_top = $elem->{'show_on_top'}; - my $new_elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0); + my $new_elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics, id_layout_linked_weight, element_group, show_on_top) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0, $id_layout_linked_weight, $element_group, $show_on_top); print_log "[INFO] New element with id $new_elem_id has been created \n\n"; } @@ -5448,9 +5481,12 @@ sub cli_duplicate_visual_console () { my $label_position = $element->{'label_position'}; my $border_color = $element->{'border_color'}; my $fill_color = $element->{'fill_color'}; + my $id_layout_linked_weight = $element->{'id_layout_linked_weight'}; + my $element_group = $element->{'element_group'}; + my $show_on_top = $element->{'show_on_top'}; - my $element_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $new_console_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0); + my $element_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics, id_layout_linked_weight, element_group, show_on_top) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $new_console_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0, $id_layout_linked_weight, $element_group, $show_on_top); print_log "[INFO] Element with ID " . $element->{"id"} . " has been duplicated to the new console \n\n"; } @@ -5516,6 +5552,9 @@ sub cli_export_visual_console() { my $label_position = $element->{'label_position'}; my $border_color = $element->{'border_color'}; my $fill_color = $element->{'fill_color'}; + my $id_layout_linked_weight = $element->{'id_layout_linked_weight'}; + my $element_group = $element->{'element_group'}; + my $show_on_top = $element->{'show_on_top'}; if ($first == 0) { $data_to_json .= ',' @@ -5553,6 +5592,9 @@ sub cli_export_visual_console() { $data_to_json .= ',"label_position":"' . $label_position . '"'; $data_to_json .= ',"border_color":"' . $border_color . '"'; $data_to_json .= ',"fill_color":"' . $fill_color . '"'; + $data_to_json .= ',"id_layout_linked_weight":' . $id_layout_linked_weight; + $data_to_json .= ',"element_group":' . $element_group; + $data_to_json .= ',"show_on_top":' . $show_on_top; $data_to_json .= '}'; } diff --git a/pandora_server/util/pwrd/install_pwrd.sh b/pandora_server/util/pwrd/install_pwrd.sh index 66cb0a9795..2de6b11e3d 100644 --- a/pandora_server/util/pwrd/install_pwrd.sh +++ b/pandora_server/util/pwrd/install_pwrd.sh @@ -45,7 +45,7 @@ ln -s $PWR_FIREFOX_INSTALLDIR/firefox/firefox /usr/bin/firefox # Generate logrotate configuration -echo < /etc/logrotate.d/pwrd +cat > /etc/logrotate.d/pwrd <