From 1dedb96314cf2ac4819f3b4f16d7482cdde5afcd Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 6 Jul 2023 16:39:21 +0200 Subject: [PATCH 1/5] #11682 fixed special days alert --- pandora_console/godmode/alerts/alert_view.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 3a71292aed..0076859649 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -262,7 +262,7 @@ $data[1] = ''; $table_conditions->data[] = $data; $data[0] = __('Use special days list'); -$data[1] = (isset($alert['special_day']) && $alert['special_day'] == 1) ? __('Yes') : __('No'); +$data[1] = (isset($template['special_day']) && (int) $template['special_day'] !== 0) ? __('Yes') : __('No'); $table_conditions->data[] = $data; $data[0] = __('Time threshold'); From 043e92afe20262aafb678f4099e36d80b256a5f0 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 7 Aug 2023 09:06:50 +0200 Subject: [PATCH 2/5] #11682 fixed error sql in special day when group is empty --- pandora_console/views/calendar/special_days_edit.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/views/calendar/special_days_edit.php b/pandora_console/views/calendar/special_days_edit.php index 5bfaa540b4..7ea8c17462 100644 --- a/pandora_console/views/calendar/special_days_edit.php +++ b/pandora_console/views/calendar/special_days_edit.php @@ -108,6 +108,7 @@ $inputs[] = [ 'returnAllGroup' => $display_all_group, 'name' => 'id_group', 'selected' => $specialDay->id_group(), + 'required' => true, ], ]; From e88a990164b3cd95107ffacd3919c12880d60940 Mon Sep 17 00:00:00 2001 From: rafael Date: Tue, 8 Aug 2023 14:51:32 +0200 Subject: [PATCH 3/5] 11850 adding auto delete deprecated files to rpms --- pandora_console/pandora_console.redhat.spec | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 5ab2dd936a..fb23513b27 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -86,6 +86,14 @@ else echo "Please, now, point your browser to http://your_IP_address/pandora_console/install.php and follow all the steps described on it." fi +# Delete old dprecated files +if [ -f %{prefix}/pandora_console/extras/delete_files/delete_files.txt ] ; then + echo "Deleting old deprecated files" + cd %{prefix}/pandora_console/ + rm -rf `cat extras/delete_files/delete_files.txt` + cd - +fi + %preun # Upgrading From 9d08261a2cd5025eff479d7695bf1212804cb828 Mon Sep 17 00:00:00 2001 From: rafael Date: Tue, 8 Aug 2023 15:17:13 +0200 Subject: [PATCH 4/5] 11850 adding files to delete to delete_file.txt --- pandora_console/extras/delete_files/delete_files.txt | 7 ++++++- pandora_console/pandora_console.redhat.spec | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index 5d603ac1f9..26eaa93392 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -1702,4 +1702,9 @@ enterprise/meta/monitoring/wizard/wizard.module.network.php enterprise/meta/monitoring/wizard/wizard.module.web.php enterprise/meta/monitoring/wizard/wizard.php enterprise/meta/monitoring/wizard/wizard.update_agent.php -enterprise/meta/monitoring/wizard/wizard.update_module.php \ No newline at end of file +enterprise/meta/monitoring/wizard/wizard.update_module.php +enterprise/godmode/wizards/Applications.class.php +enterprise/godmode/wizards/Cloud.class.php +enterprise/images/wizard/applications.png +enterprise/images/wizard/cloud.png +enterprise/images/wizard/consoletasks.png \ No newline at end of file diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index fb23513b27..a45c742dd7 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -91,7 +91,9 @@ if [ -f %{prefix}/pandora_console/extras/delete_files/delete_files.txt ] ; then echo "Deleting old deprecated files" cd %{prefix}/pandora_console/ rm -rf `cat extras/delete_files/delete_files.txt` - cd - + cd - > /dev/null + echo "Done deleting deprecated files" + fi %preun From 131f78e21e104218de9789f9313f838bcbc287bc Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 8 Aug 2023 18:04:30 +0200 Subject: [PATCH 5/5] #11682 fixed special days calendar --- pandora_console/include/lib/SpecialDay.php | 22 +++++++++++++++++++ .../views/calendar/special_days.php | 4 ++-- pandora_server/lib/PandoraFMS/Core.pm | 20 +++++++++++++---- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/lib/SpecialDay.php b/pandora_console/include/lib/SpecialDay.php index 0cd42abdb5..92ab6f04f0 100644 --- a/pandora_console/include/lib/SpecialDay.php +++ b/pandora_console/include/lib/SpecialDay.php @@ -78,6 +78,17 @@ class SpecialDay extends Entity // Update. $updates = $this->fields; + $exist_special_days = $this->specialDays( + [ '`talert_special_days`.*' ], + ['date_match' => $updates['date']] + ); + + if (count($exist_special_days) > 0) { + throw new \Exception( + __('Already exist special day in this day.'), + ); + } + $rs = \db_process_sql_update( $this->table, $updates, @@ -94,6 +105,17 @@ class SpecialDay extends Entity // Creation. $inserts = $this->fields; + $exist_special_days = $this->specialDays( + [ '`talert_special_days`.*' ], + ['date_match' => $inserts['date']] + ); + + if (count($exist_special_days) > 0) { + throw new \Exception( + __('Already exist special day in this day.'), + ); + } + // Clean null fields. foreach ($inserts as $k => $v) { if ($v === null) { diff --git a/pandora_console/views/calendar/special_days.php b/pandora_console/views/calendar/special_days.php index 26573aa06a..aa0954e51a 100644 --- a/pandora_console/views/calendar/special_days.php +++ b/pandora_console/views/calendar/special_days.php @@ -331,7 +331,7 @@ for ($month = 1; $month <= 12; $month++) { } } - if ($week == 0 || $week == 6) { + if ($week == 0 || $week == 6 || isset($specialDays[$display_year][$display_month][$day]) === true) { $cal_table->cellstyle[$cal_line][$week] = 'color: red;'; } @@ -341,7 +341,7 @@ for ($month = 1; $month <= 12; $month++) { $cal_table->cellstyle[$cal_line][$week] .= 'font-size: 18px;'; $cal_table->data[$cal_line][$week] = $day.' '; - if ($is_management_allowed === true) { + if ($is_management_allowed === true && isset($specialDays[$display_year][$display_month][$day]) === false) { $cal_table->data[$cal_line][$week] .= 'data[$cal_line][$week] .= '>'.html_print_image( diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 31774f61c5..460d9dc260 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -535,20 +535,22 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) { # Get current time my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time()); - + + my @weeks = ( 'none', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'holiday'); + my $special_day; + # Check weekday if ($alert->{'special_day'}) { logger ($pa_config, "Checking special days '" . $alert->{'name'} . "'.", 10); my $date = sprintf("%4d%02d%02d", $year + 1900, $mon + 1, $mday); # '0001' means every year. my $date_every_year = sprintf("0001%02d%02d", $mon + 1, $mday); - my $special_day = get_db_value ($dbh, 'SELECT day_code FROM talert_special_days WHERE (date = ? OR date = ?) AND (id_group = 0 OR id_group = ?) AND (id_calendar = ?) ORDER BY date DESC', $date, $date_every_year, $alert->{'id_group'}, $alert->{'special_day'}); + $special_day = get_db_value ($dbh, 'SELECT day_code FROM talert_special_days WHERE (date = ? OR date = ?) AND (id_group = 0 OR id_group = ?) AND (id_calendar = ?) ORDER BY date DESC', $date, $date_every_year, $alert->{'id_group'}, $alert->{'special_day'}); if (!defined($special_day)) { $special_day = 0; } - my @weeks = ( 'none', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'holiday'); if ($special_day != 0) { logger ($pa_config, $date . " is a special day for " . $alert->{'name'} . ". (as a " . $weeks[$special_day] . ")", 10); return $status if (!defined($alert->{$weeks[$special_day]}) || $alert->{$weeks[$special_day]} == 0); @@ -565,6 +567,9 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) { my $schedule; if (defined($alert->{'schedule'}) && $alert->{'schedule'} ne '') { $schedule = PandoraFMS::Tools::p_decode_json($pa_config, $alert->{'schedule'}); + if ($special_day != 0) { + return $status if (!defined($schedule->{$weeks[$special_day]})); + } } if (defined($schedule)) { @@ -577,11 +582,18 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) { my $time = sprintf ("%.2d:%.2d:%.2d", $hour, $min, $sec); + my $schedule_day; + if ($special_day != 0 && defined($schedule->{$weeks[$special_day]})) { + $schedule_day = $weeks[$special_day]; + } else { + $schedule_day = $DayNames[$wday]; + } + # # Check time slots # my $inSlot = 0; - foreach my $timeBlock (@{$schedule->{$DayNames[$wday]}}) { + foreach my $timeBlock (@{$schedule->{$schedule_day}}) { if ($timeBlock->{'start'} eq $timeBlock->{'end'}) { # All day. $inSlot = 1;