2013-02-12 Miguel de Dios <miguel.dedios@artica.es>
* lib/PandoraFMS/Core.pm: fixed the planned downtime. Fixes: #3602365 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7637 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ff11353b5b
commit
83c40c5a7d
|
@ -1,3 +1,9 @@
|
|||
2013-02-12 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* lib/PandoraFMS/Core.pm: fixed the planned downtime.
|
||||
|
||||
Fixes: #3602365
|
||||
|
||||
2013-02-12 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* conf/pandora_server.conf: review of all file and removed
|
||||
|
|
|
@ -408,7 +408,9 @@ sub pandora_evaluate_alert ($$$$$$$;$$$) {
|
|||
$data =~ m/$alert->{'value'}/i;
|
||||
};
|
||||
if ($@) {
|
||||
logger ($pa_config, "Error evaluating alert '" . safe_output($alert->{'name'}) . "' for agent '" . safe_output($agent->{'nombre'}) . "': '" . $alert->{'value'} . "' is not a valid regular expression.", 10);
|
||||
logger ($pa_config, "Error evaluating alert '" .
|
||||
safe_output($alert->{'name'}) . "' for agent '" .
|
||||
safe_output($agent->{'nombre'}) . "': '" . $alert->{'value'} . "' is not a valid regular expression.", 10);
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
@ -449,7 +451,8 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
|||
|
||||
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);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
logger ($pa_config, "Processing alert '" . safe_output($alert->{'name'}) . "': " . (defined ($AlertStatus[$rc]) ? $AlertStatus[$rc] : 'Unknown status') . ".", 10);
|
||||
}
|
||||
|
||||
|
@ -471,7 +474,7 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
|||
|
||||
# Update alert status
|
||||
db_do($dbh, 'UPDATE ' . $table . ' SET times_fired = 0,
|
||||
internal_counter = 0 WHERE id = ?', $id);
|
||||
internal_counter = 0 WHERE id = ?', $id);
|
||||
|
||||
# Update fired alert count
|
||||
if (defined ($agent)) {
|
||||
|
@ -531,7 +534,7 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
|||
|
||||
# Do we have to start a new interval?
|
||||
my $new_interval = ($alert->{'internal_counter'} == 0) ?
|
||||
', last_reference = ' . $utimestamp : '';
|
||||
', last_reference = ' . $utimestamp : '';
|
||||
|
||||
# Increment internal counter
|
||||
if ($rc == 2) {
|
||||
|
@ -591,7 +594,8 @@ sub pandora_execute_alert ($$$$$$$$;$) {
|
|||
|
||||
if (defined ($module)) {
|
||||
logger ($pa_config, "Executing alert '" . safe_output($alert->{'name'}) . "' for module '" . safe_output($module->{'nombre'}) . "'.", 10);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
logger ($pa_config, "Executing alert '" . safe_output($alert->{'name'}) . "'.", 10);
|
||||
}
|
||||
|
||||
|
@ -1072,11 +1076,12 @@ sub pandora_planned_downtime_disabled_once_stop($$) {
|
|||
my ($pa_config, $dbh) = @_;
|
||||
my $utimestamp = time();
|
||||
|
||||
# Stop executed downtimes (enable agents)
|
||||
# Stop executed downtimes (enable agents and disable_agents_alerts)
|
||||
my @downtimes = get_db_rows($dbh, 'SELECT *
|
||||
FROM tplanned_downtime
|
||||
WHERE type_downtime != "quiet" AND type_execution="once"
|
||||
AND executed = 1 AND date_to <= ?', $utimestamp);
|
||||
|
||||
foreach my $downtime (@downtimes) {
|
||||
|
||||
logger($pa_config, "Ending planned downtime '" . $downtime->{'name'} . "'.", 10);
|
||||
|
@ -1103,10 +1108,10 @@ sub pandora_planned_downtime_disabled_once_start($$) {
|
|||
my ($pa_config, $dbh) = @_;
|
||||
my $utimestamp = time();
|
||||
|
||||
# Start pending downtimes (disable agents)
|
||||
# Start pending downtimes (disable agents and disable_agents_alerts)
|
||||
my @downtimes = get_db_rows($dbh, 'SELECT *
|
||||
FROM tplanned_downtime
|
||||
WHERE type_downtime = "quiet" AND type_execution="once"
|
||||
WHERE type_downtime != "quiet" AND type_execution="once"
|
||||
AND executed = 0 AND date_from <= ?
|
||||
AND date_to >= ?', $utimestamp, $utimestamp);
|
||||
|
||||
|
@ -1119,7 +1124,11 @@ sub pandora_planned_downtime_disabled_once_start($$) {
|
|||
$downtime->{'name'} = "N/A";
|
||||
}
|
||||
|
||||
logger($pa_config, "Starting planned downtime '" . $downtime->{'name'} . "'.", 1);
|
||||
logger($pa_config, "[PLANNED_DOWNTIME] " .
|
||||
"Starting planned downtime '" . $downtime->{'name'} . "'.", 10);
|
||||
|
||||
logger($pa_config, "[PLANNED_DOWNTIME] " .
|
||||
"Starting planned downtime ID " . $downtime->{'id'} . ".", 10);
|
||||
|
||||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 1
|
||||
|
@ -1133,7 +1142,7 @@ sub pandora_planned_downtime_disabled_once_start($$) {
|
|||
}
|
||||
|
||||
########################################################################
|
||||
=head2 C<< pandora_planned_downtime_set_quiet_elements (I<$pa_config>, I<$dbh>, <$id_downtime>) >>
|
||||
=head2 C<< pandora_planned_downtime_set_disabled_elements (I<$pa_config>, I<$dbh>, <$id_downtime>) >>
|
||||
|
||||
Start the planned downtime, the once type.
|
||||
|
||||
|
@ -1150,13 +1159,13 @@ sub pandora_planned_downtime_set_disabled_elements($$$) {
|
|||
my $only_alerts = 0;
|
||||
|
||||
if ($downtime->{'only_alerts'} == 0) {
|
||||
if ($downtime->{'type_downtime'} == 'disable_agents_alerts') {
|
||||
if ($downtime->{'type_downtime'} eq 'disable_agents_alerts') {
|
||||
$only_alerts = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$only_alerts = 1;
|
||||
}
|
||||
|
||||
logger($pa_config, "[PLANNED_DOWNTIME] " .
|
||||
"Only Alerts " . $only_alerts . ".", 10);
|
||||
|
||||
if ($only_alerts == 0) {
|
||||
db_do ($dbh, 'UPDATE tagente
|
||||
|
@ -1164,6 +1173,9 @@ sub pandora_planned_downtime_set_disabled_elements($$$) {
|
|||
WHERE id_agente = ?', $downtime_agent->{'id_agent'});
|
||||
}
|
||||
else {
|
||||
logger($pa_config, "[PLANNED_DOWNTIME] " .
|
||||
"Disabled Agent " . $downtime_agent->{'id_agent'} . ".", 10);
|
||||
|
||||
db_do ($dbh, 'UPDATE talert_template_modules
|
||||
SET disabled = 1
|
||||
WHERE id_agent_module IN (
|
||||
|
@ -1193,13 +1205,10 @@ sub pandora_planned_downtime_unset_disabled_elements($$$) {
|
|||
my $only_alerts = 0;
|
||||
|
||||
if ($downtime->{'only_alerts'} == 0) {
|
||||
if ($downtime->{'type_downtime'} == 'disable_agents_alerts') {
|
||||
if ($downtime->{'type_downtime'} eq 'disable_agents_alerts') {
|
||||
$only_alerts = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$only_alerts = 1;
|
||||
}
|
||||
|
||||
if ($only_alerts == 0) {
|
||||
db_do ($dbh, 'UPDATE tagente
|
||||
|
@ -1247,7 +1256,8 @@ sub pandora_planned_downtime_set_quiet_elements($$$) {
|
|||
foreach my $downtime_module (@downtime_modules) {
|
||||
db_do ($dbh, 'UPDATE tagente_modulo
|
||||
SET quiet = 1
|
||||
WHERE id_agente_modulo = ?', $downtime_agent->{'id_agent_module'});
|
||||
WHERE id_agente_modulo = ?',
|
||||
$downtime_module->{'id_agent_module'});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1282,7 +1292,8 @@ sub pandora_planned_downtime_unset_quiet_elements($$$) {
|
|||
foreach my $downtime_module (@downtime_modules) {
|
||||
db_do ($dbh, 'UPDATE tagente_modulo
|
||||
SET quiet = 0
|
||||
WHERE id_agente_modulo = ?', $downtime_agent->{'id_agent_module'});
|
||||
WHERE id_agente_modulo = ?',
|
||||
$downtime_module->{'id_agent_module'});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1299,12 +1310,11 @@ sub pandora_planned_downtime_quiet_once_stop($$) {
|
|||
my ($pa_config, $dbh) = @_;
|
||||
my $utimestamp = time();
|
||||
|
||||
# Start pending downtimes
|
||||
# Stop pending downtimes
|
||||
my @downtimes = get_db_rows($dbh, 'SELECT *
|
||||
FROM tplanned_downtime
|
||||
WHERE type_downtime = "quiet" AND type_execution="once"
|
||||
AND executed = 1 AND date_from <= ?
|
||||
AND date_to >= ?', $utimestamp, $utimestamp);
|
||||
AND executed = 1 AND date_to <= ?', $utimestamp);
|
||||
|
||||
foreach my $downtime (@downtimes) {
|
||||
if (!defined($downtime->{'description'})) {
|
||||
|
@ -1315,7 +1325,8 @@ sub pandora_planned_downtime_quiet_once_stop($$) {
|
|||
$downtime->{'name'} = "N/A";
|
||||
}
|
||||
|
||||
logger($pa_config, "Starting planned downtime '" . $downtime->{'name'} . "'.", 1);
|
||||
logger($pa_config, "[PLANNED_DOWNTIME] " .
|
||||
"Starting planned downtime '" . $downtime->{'name'} . "'.", 10);
|
||||
|
||||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 0
|
||||
|
@ -1339,6 +1350,9 @@ sub pandora_planned_downtime_quiet_once_start($$) {
|
|||
my ($pa_config, $dbh) = @_;
|
||||
my $utimestamp = time();
|
||||
|
||||
logger($pa_config, "[PLANNED_DOWNTIME] " .
|
||||
"Enter pandora_planned_downtime_quiet_once_start().", 10);
|
||||
|
||||
# Start pending downtimes
|
||||
my @downtimes = get_db_rows($dbh, 'SELECT *
|
||||
FROM tplanned_downtime
|
||||
|
@ -1355,7 +1369,8 @@ sub pandora_planned_downtime_quiet_once_start($$) {
|
|||
$downtime->{'name'} = "N/A";
|
||||
}
|
||||
|
||||
logger($pa_config, "Starting planned downtime '" . $downtime->{'name'} . "'.", 1);
|
||||
logger($pa_config, "[PLANNED_DOWNTIME] " .
|
||||
"Starting planned downtime '" . $downtime->{'name'} . "'.", 10);
|
||||
|
||||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 1
|
||||
|
@ -1377,6 +1392,10 @@ Start the planned downtime, the monthly type.
|
|||
########################################################################
|
||||
sub pandora_planned_downtime_monthly_start($$) {
|
||||
my ($pa_config, $dbh) = @_;
|
||||
|
||||
logger($pa_config, "[PLANNED_DOWNTIME] " .
|
||||
"Enter pandora_planned_downtime_monthly_start().", 10);
|
||||
|
||||
#my $local_time = localtime();
|
||||
my @var_localtime = localtime(time);
|
||||
my $year = $var_localtime[5] + 1900;
|
||||
|
@ -1411,8 +1430,15 @@ sub pandora_planned_downtime_monthly_start($$) {
|
|||
# "%H:%M:%S");
|
||||
#
|
||||
#if ($date_now_time >= $date_downtime) {
|
||||
if (($time gt $downtime->{'periodically_time_from'})
|
||||
|| ($time eq $downtime->{'periodically_time_from'})) {
|
||||
|
||||
|
||||
if (
|
||||
(($time gt $downtime->{'periodically_time_from'})
|
||||
|| ($time eq $downtime->{'periodically_time_from'}))
|
||||
&&
|
||||
(($time lt $downtime->{'periodically_time_to'})
|
||||
|| ($time eq $downtime->{'periodically_time_to'}))
|
||||
) {
|
||||
|
||||
if (!defined($downtime->{'description'})) {
|
||||
$downtime->{'description'} = "N/A";
|
||||
|
@ -1422,7 +1448,7 @@ sub pandora_planned_downtime_monthly_start($$) {
|
|||
$downtime->{'name'} = "N/A";
|
||||
}
|
||||
|
||||
logger($pa_config, "Starting planned monthly downtime '" . $downtime->{'name'} . "'.", 1);
|
||||
logger($pa_config, "Starting planned monthly downtime '" . $downtime->{'name'} . "'.", 10);
|
||||
|
||||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 1
|
||||
|
@ -1430,15 +1456,22 @@ sub pandora_planned_downtime_monthly_start($$) {
|
|||
pandora_event ($pa_config,
|
||||
"Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
if ($downtime->{'type_downtime'} == "quiet") {
|
||||
|
||||
logger($pa_config, $downtime->{'type_downtime'}, 10);
|
||||
if ($downtime->{'type_downtime'} eq "quiet") {
|
||||
pandora_planned_downtime_set_quiet_elements($pa_config,
|
||||
$dbh, $downtime->{'id'});
|
||||
}
|
||||
elsif (($downtime->{'type_downtime'} == "disable_agents")
|
||||
|| ($downtime->{'type_downtime'} == "disabled_agents_alerts")) {
|
||||
elsif (($downtime->{'type_downtime'} eq "disable_agents")
|
||||
|| ($downtime->{'type_downtime'} eq "disable_agents_alerts")) {
|
||||
|
||||
logger($pa_config, "ON DISABLE AGENTS/ALERTS", 10);
|
||||
|
||||
pandora_planned_downtime_set_disabled_elements($pa_config,
|
||||
$dbh, $downtime);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1453,6 +1486,10 @@ Start the planned downtime, the montly type.
|
|||
########################################################################
|
||||
sub pandora_planned_downtime_monthly_stop($$) {
|
||||
my ($pa_config, $dbh) = @_;
|
||||
|
||||
logger($pa_config, "[PLANNED_DOWNTIME] " .
|
||||
"Enter pandora_planned_downtime_monthly_stop().", 10);
|
||||
|
||||
#my $local_time = localtime();
|
||||
my @var_localtime = localtime(time);
|
||||
my $year = $var_localtime[5] + 1900;
|
||||
|
@ -1480,16 +1517,21 @@ sub pandora_planned_downtime_monthly_stop($$) {
|
|||
($number_day_month >= 30)) {
|
||||
$number_day_month = 31;
|
||||
}
|
||||
|
||||
logger($pa_config, $number_day_month, 10);
|
||||
|
||||
# Start pending downtimes
|
||||
my @downtimes = get_db_rows($dbh, 'SELECT *
|
||||
FROM tplanned_downtime
|
||||
WHERE type_periodicity="monthly"
|
||||
WHERE type_periodicity = "monthly"
|
||||
AND executed = 1
|
||||
AND periodically_day_to <= ?', $number_day_month);
|
||||
AND type_execution <> "once"');
|
||||
|
||||
foreach my $downtime (@downtimes) {
|
||||
|
||||
logger($pa_config, "Stop Time: " . $time, 10);
|
||||
logger($pa_config, "Stop periodically_time_from: " .
|
||||
$downtime->{'periodically_time_from'}, 10);
|
||||
|
||||
#Convert to identical type.
|
||||
#my $date_downtime = Time::Piece->strptime(
|
||||
# $downtime->{'periodically_time_to'},
|
||||
|
@ -1500,7 +1542,13 @@ sub pandora_planned_downtime_monthly_stop($$) {
|
|||
#
|
||||
#if ($date_now_time <= $date_downtime) {
|
||||
if (($time gt $downtime->{'periodically_time_to'})
|
||||
|| ($time eq $downtime->{'periodically_time_to'})) {
|
||||
||
|
||||
($time lt $downtime->{'periodically_time_from'})
|
||||
||
|
||||
($downtime->{'periodically_day_from'} > $number_day_month)
|
||||
||
|
||||
($downtime->{'periodically_day_to'} < $number_day_month)
|
||||
) {
|
||||
|
||||
if (!defined($downtime->{'description'})) {
|
||||
$downtime->{'description'} = "N/A";
|
||||
|
@ -1510,7 +1558,7 @@ sub pandora_planned_downtime_monthly_stop($$) {
|
|||
$downtime->{'name'} = "N/A";
|
||||
}
|
||||
|
||||
logger($pa_config, "Stopping planned monthly downtime '" . $downtime->{'name'} . "'.", 1);
|
||||
logger($pa_config, "Stopping planned monthly downtime '" . $downtime->{'name'} . "'.", 10);
|
||||
|
||||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 0
|
||||
|
@ -1518,13 +1566,16 @@ sub pandora_planned_downtime_monthly_stop($$) {
|
|||
pandora_event ($pa_config,
|
||||
"Server ".$pa_config->{'servername'}." stopped planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
if ($downtime->{'type_downtime'} == "quiet") {
|
||||
if ($downtime->{'type_downtime'} eq "quiet") {
|
||||
pandora_planned_downtime_unset_quiet_elements($pa_config,
|
||||
$dbh, $downtime->{'id'});
|
||||
}
|
||||
elsif (($downtime->{'type_downtime'} == "disable_agents")
|
||||
|| ($downtime->{'type_downtime'} == "disabled_agents_alerts")) {
|
||||
pandora_planned_downtime_set_disabled_elements($pa_config,
|
||||
elsif (($downtime->{'type_downtime'} eq "disable_agents")
|
||||
|| ($downtime->{'type_downtime'} eq "disable_agents_alerts")) {
|
||||
|
||||
logger($pa_config, "OFF DISABLE AGENTS/ALERTS", 10);
|
||||
|
||||
pandora_planned_downtime_unset_disabled_elements($pa_config,
|
||||
$dbh, $downtime);
|
||||
}
|
||||
}
|
||||
|
@ -1588,9 +1639,9 @@ sub pandora_planned_downtime_weekly_start($$) {
|
|||
$found = 1;
|
||||
}
|
||||
|
||||
logger($pa_config, "Debug time = " . $time, 5);
|
||||
logger($pa_config, "Debug time = " . $time, 10);
|
||||
logger($pa_config, "Debug periodically_time_to = " .
|
||||
$downtime->{'periodically_time_to'}, 5);
|
||||
$downtime->{'periodically_time_to'}, 10);
|
||||
|
||||
if ($found) {
|
||||
#Convert to identical type.
|
||||
|
@ -1605,7 +1656,7 @@ sub pandora_planned_downtime_weekly_start($$) {
|
|||
if ((($time gt $downtime->{'periodically_time_from'})
|
||||
|| ($time eq $downtime->{'periodically_time_from'}))
|
||||
&& (($time lt $downtime->{'periodically_time_to'})
|
||||
|| ($time eq $downtime->{'periodically_time_to'}))) {
|
||||
|| ($time eq $downtime->{'periodically_time_to'}))) {
|
||||
if (!defined($downtime->{'description'})) {
|
||||
$downtime->{'description'} = "N/A";
|
||||
}
|
||||
|
@ -1614,7 +1665,7 @@ sub pandora_planned_downtime_weekly_start($$) {
|
|||
$downtime->{'name'} = "N/A";
|
||||
}
|
||||
|
||||
logger($pa_config, "Starting planned weekly downtime '" . $downtime->{'name'} . "'.", 1);
|
||||
logger($pa_config, "Starting planned weekly downtime '" . $downtime->{'name'} . "'.", 10);
|
||||
|
||||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 1
|
||||
|
@ -1622,12 +1673,12 @@ sub pandora_planned_downtime_weekly_start($$) {
|
|||
pandora_event ($pa_config,
|
||||
"Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
if ($downtime->{'type_downtime'} == "quiet") {
|
||||
if ($downtime->{'type_downtime'} eq "quiet") {
|
||||
pandora_planned_downtime_set_quiet_elements($pa_config,
|
||||
$dbh, $downtime->{'id'});
|
||||
}
|
||||
elsif (($downtime->{'type_downtime'} == "disable_agents")
|
||||
|| ($downtime->{'type_downtime'} == "disabled_agents_alerts")) {
|
||||
elsif (($downtime->{'type_downtime'} eq "disable_agents")
|
||||
|| ($downtime->{'type_downtime'} eq "disable_agents_alerts")) {
|
||||
pandora_planned_downtime_set_disabled_elements($pa_config,
|
||||
$dbh, $downtime);
|
||||
}
|
||||
|
@ -1659,7 +1710,8 @@ sub pandora_planned_downtime_weekly_stop($$) {
|
|||
# Start pending downtimes
|
||||
my @downtimes = get_db_rows($dbh, 'SELECT *
|
||||
FROM tplanned_downtime
|
||||
WHERE type_periodicity="weekly"
|
||||
WHERE type_periodicity = "weekly"
|
||||
AND type_execution <> "once"
|
||||
AND executed = 1');
|
||||
|
||||
foreach my $downtime (@downtimes) {
|
||||
|
@ -1673,12 +1725,43 @@ sub pandora_planned_downtime_weekly_stop($$) {
|
|||
#
|
||||
#if ($date_now_time <= $date_downtime) {
|
||||
|
||||
logger($pa_config, "Debug time = " . $time, 5);
|
||||
logger($pa_config, "Debug time = " . $time, 10);
|
||||
logger($pa_config, "Debug periodically_time_to = " .
|
||||
$downtime->{'periodically_time_to'}, 5);
|
||||
$downtime->{'periodically_time_to'}, 10);
|
||||
|
||||
if (($number_day_week == 1) &&
|
||||
($downtime->{'monday'})) {
|
||||
$found = 1;
|
||||
}
|
||||
if (($number_day_week == 2) &&
|
||||
($downtime->{'tuesday'})) {
|
||||
$found = 1;
|
||||
}
|
||||
if (($number_day_week == 3) &&
|
||||
($downtime->{'wednesday'})) {
|
||||
$found = 1;
|
||||
}
|
||||
if (($number_day_week == 4) &&
|
||||
($downtime->{'thursday'})) {
|
||||
$found = 1;
|
||||
}
|
||||
if (($number_day_week == 5) &&
|
||||
($downtime->{'friday'})) {
|
||||
$found = 1;
|
||||
}
|
||||
if (($number_day_week == 6) &&
|
||||
($downtime->{'saturday'})) {
|
||||
$found = 1;
|
||||
}
|
||||
if (($number_day_week == 0) &&
|
||||
($downtime->{'sunday'})) {
|
||||
$found = 1;
|
||||
}
|
||||
|
||||
if (($time gt $downtime->{'periodically_time_to'})
|
||||
|| ($time eq $downtime->{'periodically_time_to'})) {
|
||||
||
|
||||
($time lt $downtime->{'periodically_time_from'})
|
||||
|| ($found == 0)) {
|
||||
|
||||
if (!defined($downtime->{'description'})) {
|
||||
$downtime->{'description'} = "N/A";
|
||||
|
@ -1688,7 +1771,7 @@ sub pandora_planned_downtime_weekly_stop($$) {
|
|||
$downtime->{'name'} = "N/A";
|
||||
}
|
||||
|
||||
logger($pa_config, "Stopping planned weekly downtime '" . $downtime->{'name'} . "'.", 1);
|
||||
logger($pa_config, "Stopping planned weekly downtime '" . $downtime->{'name'} . "'.", 10);
|
||||
|
||||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 0
|
||||
|
@ -1696,12 +1779,12 @@ sub pandora_planned_downtime_weekly_stop($$) {
|
|||
pandora_event ($pa_config,
|
||||
"Server ".$pa_config->{'servername'}." stopped planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
if ($downtime->{'type_downtime'} == "quiet") {
|
||||
if ($downtime->{'type_downtime'} eq "quiet") {
|
||||
pandora_planned_downtime_unset_quiet_elements($pa_config,
|
||||
$dbh, $downtime->{'id'});
|
||||
}
|
||||
elsif (($downtime->{'type_downtime'} == "disable_agents")
|
||||
|| ($downtime->{'type_downtime'} == "disabled_agents_alerts")) {
|
||||
elsif (($downtime->{'type_downtime'} eq "disable_agents")
|
||||
|| ($downtime->{'type_downtime'} eq "disable_agents_alerts")) {
|
||||
pandora_planned_downtime_unset_disabled_elements($pa_config,
|
||||
$dbh, $downtime);
|
||||
}
|
||||
|
@ -1709,16 +1792,19 @@ sub pandora_planned_downtime_weekly_stop($$) {
|
|||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
########################################################################
|
||||
=head2 C<< pandora_planned_downtime (I<$pa_config>, I<$dbh>) >>
|
||||
|
||||
Update planned downtimes.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
########################################################################
|
||||
sub pandora_planned_downtime ($$) {
|
||||
my ($pa_config, $dbh) = @_;
|
||||
|
||||
logger($pa_config, "[PLANNED_DOWNTIME] " .
|
||||
"Enter pandora_planned_downtime()\n", 10);
|
||||
|
||||
pandora_planned_downtime_disabled_once_start($pa_config, $dbh);
|
||||
pandora_planned_downtime_disabled_once_stop($pa_config, $dbh);
|
||||
|
||||
|
@ -1732,17 +1818,19 @@ sub pandora_planned_downtime ($$) {
|
|||
pandora_planned_downtime_weekly_stop($pa_config, $dbh);
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
########################################################################
|
||||
=head2 C<< pandora_reset_server (I<$pa_config>, I<$dbh>) >>
|
||||
|
||||
Reset the status of all server types for the current server.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
########################################################################
|
||||
sub pandora_reset_server ($$) {
|
||||
my ($pa_config, $dbh) = @_;
|
||||
|
||||
db_do ($dbh, 'UPDATE tserver SET status = 0, threads = 0, queued_modules = 0 WHERE name = ?', $pa_config->{'servername'});
|
||||
db_do ($dbh, 'UPDATE tserver
|
||||
SET status = 0, threads = 0, queued_modules = 0
|
||||
WHERE name = ?', $pa_config->{'servername'});
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
@ -1824,7 +1912,8 @@ sub pandora_update_agent ($$$$$$$;$$$$$$) {
|
|||
if ($agent_interval == -1){
|
||||
db_do($dbh, 'UPDATE tagente SET agent_version = ?, ultimo_contacto_remoto = ?, ultimo_contacto = ?, os_version = ? WHERE id_agente = ?',
|
||||
$agent_version, $agent_timestamp, $timestamp, $os_version, $agent_id);
|
||||
return;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( defined ($timezone_offset)) {
|
||||
|
@ -1885,7 +1974,7 @@ sub pandora_update_agent ($$$$$$$;$$$$$$) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
logger($pa_config, "Agent id $agent_id positional data ignored (update_gis_data (agent) = $update_gis_data ; activate_gis (server) = " . $pa_config->{'activate_gis'} . ")",10);
|
||||
logger($pa_config, "Agent id $agent_id positional data ignored (update_gis_data = $update_gis_data)",10);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1936,7 +2025,7 @@ Create a template action.
|
|||
sub pandora_create_template_module_action ($$$) {
|
||||
my ($pa_config, $parameters, $dbh) = @_;
|
||||
|
||||
logger($pa_config, "Creating module alert action to alert '$parameters->{'id_alert_template_module'}'.", 10);
|
||||
logger($pa_config, "Creating module alert action to alert '$parameters->{'id_alert_template_module'}'.", 10);
|
||||
|
||||
my $action_id = db_process_insert($dbh, 'id', 'talert_template_module_actions', $parameters);
|
||||
|
||||
|
@ -2044,7 +2133,7 @@ sub pandora_create_module ($$$$$$$$$$) {
|
|||
my ($pa_config, $agent_id, $module_type_id, $module_name, $max,
|
||||
$min, $post_process, $description, $interval, $dbh) = @_;
|
||||
|
||||
logger($pa_config, "Creating module '$module_name' for agent ID $agent_id.", 10);
|
||||
logger($pa_config, "Creating module '$module_name' for agent ID $agent_id.", 10);
|
||||
|
||||
# Provide some default values
|
||||
$max = 0 if ($max eq '');
|
||||
|
@ -2058,13 +2147,14 @@ sub pandora_create_module ($$$$$$$$$$) {
|
|||
}
|
||||
|
||||
my $module_id = db_insert($dbh, 'id_agente_modulo', 'INSERT INTO tagente_modulo (id_agente, id_tipo_modulo, nombre, max, min, post_process, descripcion, module_interval, id_modulo)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1)', $agent_id, $module_type_id, safe_input($module_name), $max, $min, $post_process, $description, $interval);
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1)', $agent_id, $module_type_id, safe_input($module_name), $max, $min, $post_process, $description, $interval);
|
||||
db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado, last_status, last_known_status, last_try) VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\')', $module_id, $agent_id, $status, $status, $status);
|
||||
|
||||
# Update the module status count
|
||||
if ($status == 4) {
|
||||
db_do ($dbh, 'UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente=?', $agent_id);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
db_do ($dbh, 'UPDATE tagente SET total_count=total_count+1, normal_count=normal_count+1 WHERE id_agente=?', $agent_id);
|
||||
}
|
||||
|
||||
|
@ -2110,13 +2200,17 @@ sub pandora_delete_module ($$;$) {
|
|||
# Update module status count
|
||||
if ($module->{'utimestamp'} == 0) {
|
||||
db_do ($dbh, 'UPDATE tagente SET notinit_count=notinit_count-1 WHERE id_agente=' . $module->{'id_agente'});
|
||||
} elsif ($module->{'estado'} == 0) {
|
||||
}
|
||||
elsif ($module->{'estado'} == 0) {
|
||||
db_do ($dbh, 'UPDATE tagente SET normal_count=normal_count-1 WHERE id_agente=' . $module->{'id_agente'});
|
||||
} elsif ($module->{'estado'} == 1) {
|
||||
}
|
||||
elsif ($module->{'estado'} == 1) {
|
||||
db_do ($dbh, 'UPDATE tagente SET critical_count=critical_count-1 WHERE id_agente=' . $module->{'id_agente'});
|
||||
} elsif ($module->{'estado'} == 2) {
|
||||
}
|
||||
elsif ($module->{'estado'} == 2) {
|
||||
db_do ($dbh, 'UPDATE tagente SET warning_count=warning_count-1 WHERE id_agente=' . $module->{'id_agente'});
|
||||
} elsif ($module->{'estado'} == 3) {
|
||||
}
|
||||
elsif ($module->{'estado'} == 3) {
|
||||
db_do ($dbh, 'UPDATE tagente SET unknown_count=unknown_count-1 WHERE id_agente=' . $module->{'id_agente'});
|
||||
}
|
||||
db_do ($dbh, 'UPDATE tagente SET total_count=total_count-1 WHERE id_agente=' . $module->{'id_agente'});
|
||||
|
@ -2128,7 +2222,7 @@ sub pandora_delete_module ($$;$) {
|
|||
sub pandora_create_module_from_hash ($$$) {
|
||||
my ($pa_config, $parameters, $dbh) = @_;
|
||||
|
||||
logger($pa_config, "Creating module '$parameters->{'nombre'}' for agent ID $parameters->{'id_agente'}.", 10);
|
||||
logger($pa_config, "Creating module '$parameters->{'nombre'}' for agent ID $parameters->{'id_agente'}.", 10);
|
||||
|
||||
my $module_id = db_process_insert($dbh, 'id_agente_modulo', 'tagente_modulo', $parameters);
|
||||
|
||||
|
@ -2142,7 +2236,8 @@ sub pandora_create_module_from_hash ($$$) {
|
|||
# Update the module status count
|
||||
if ($status == 4) {
|
||||
db_do ($dbh, 'UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente=?', $parameters->{'id_agente'});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
db_do ($dbh, 'UPDATE tagente SET total_count=total_count+1, normal_count=normal_count+1 WHERE id_agente=?', $parameters->{'id_agente'});
|
||||
}
|
||||
|
||||
|
@ -2176,7 +2271,7 @@ sub pandora_create_group ($$$$$$$$$) {
|
|||
my ($name, $icon, $parent, $propagate, $disabled, $custom_id, $id_skin, $description, $dbh) = @_;
|
||||
|
||||
my $group_id = db_insert ($dbh, 'id_grupo', 'INSERT INTO tgrupo (nombre, icon, parent, propagate, disabled, custom_id, id_skin, description) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', safe_input($name), $icon,
|
||||
$parent, $propagate, $disabled, $custom_id, $id_skin, $description);
|
||||
$parent, $propagate, $disabled, $custom_id, $id_skin, $description);
|
||||
|
||||
return $group_id;
|
||||
}
|
||||
|
@ -2247,9 +2342,9 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$) {
|
|||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)', safe_input($agent_name), $address, $description, $group_id, $os_id, $server_name, $interval, $parent_id, $custom_id, $url_address);
|
||||
}
|
||||
else {
|
||||
$agent_id = db_insert ($dbh, 'id_agente', 'INSERT INTO tagente (nombre, direccion, comentarios, id_grupo, id_os, server_name, intervalo, id_parent,
|
||||
timezone_offset, modo, custom_id, url_address) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)', safe_input($agent_name), $address,
|
||||
$description, $group_id, $os_id, $server_name, $interval, $parent_id, $timezone_offset, $custom_id, $url_address);
|
||||
$agent_id = db_insert ($dbh, 'id_agente', 'INSERT INTO tagente (nombre, direccion, comentarios, id_grupo, id_os, server_name, intervalo, id_parent,
|
||||
timezone_offset, modo, custom_id, url_address) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)', safe_input($agent_name), $address,
|
||||
$description, $group_id, $os_id, $server_name, $interval, $parent_id, $timezone_offset, $custom_id, $url_address);
|
||||
}
|
||||
if (defined ($longitude) && defined ($latitude ) && $pa_config->{'activate_gis'} == 1 ) {
|
||||
if (!defined($altitude)) {
|
||||
|
@ -2257,7 +2352,7 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$) {
|
|||
}
|
||||
# Save the first position
|
||||
my $utimestamp = time ();
|
||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
|
||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
|
||||
|
||||
save_agent_position($pa_config, $longitude, $latitude, $altitude, $agent_id, $dbh, $timestamp, $position_description) ;
|
||||
}
|
||||
|
@ -2315,7 +2410,7 @@ sub pandora_delete_agent ($$;$) {
|
|||
|
||||
my @modules = get_db_rows ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente = ?', $agent_id);
|
||||
|
||||
if(defined $conf) {
|
||||
if (defined $conf) {
|
||||
# Delete the conf files
|
||||
if (-e $conf->{incomingdir}.'/conf/'.md5($agent_name).'.conf') {
|
||||
unlink($conf->{incomingdir}.'/conf/'.md5($agent_name).'.conf');
|
||||
|
|
Loading…
Reference in New Issue