Private GIT

Skip to content
Snippets Groups Projects
Commit 8b541533 authored by Kev's avatar Kev Committed by Matthieu Kermagoret
Browse files

fix(downtime): improve dst management with downtimes

parent ad375c08
Branches
Tags
No related merge requests found
...@@ -101,6 +101,10 @@ default: ...@@ -101,6 +101,10 @@ default:
paths: [ %paths.base%/features/DowntimeStartAndStop.feature ] paths: [ %paths.base%/features/DowntimeStartAndStop.feature ]
contexts: [ DowntimeStartAndStopContext ] contexts: [ DowntimeStartAndStopContext ]
downtime_dst:
paths: [ %paths.base%/features/DowntimeDST.feature ]
contexts: [ DowntimeDSTContext ]
command_arguments: command_arguments:
paths: [ %paths.base%/features/CommandArguments.feature ] paths: [ %paths.base%/features/CommandArguments.feature ]
contexts: [ CommandArgumentsContext ] contexts: [ CommandArgumentsContext ]
......
Feature: Downtime DST
As a Centreon user
I want to be certain that the downtimes work correctly with DST
To release quality products
Background:
Given I am logged in a Centreon server located at "Europe/Paris"
And a passive service is monitored
# summer changing time
@critical
Scenario: realtime downtime starting on summer changing time
Given a downtime starting on summer changing time
When realtime downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: recurrent downtime starting on summer changing time
Given a downtime starting on summer changing time
When recurrent downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: recurrent downtime ending on summer changing time
Given a downtime ending on summer changing time
When recurrent downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: realtime downtime ending on summer changing time
Given a downtime ending on summer changing time
When realtime downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: recurrent downtime starting and ending on summer changing time
Given a downtime starting and ending on summer changing time
When recurrent downtime is applied
Then the downtime is not scheduled
@critical
Scenario: realtime downtime starting and ending on summer changing time
Given a downtime starting and ending on summer changing time
When realtime downtime is applied
Then the downtime is not scheduled
@critical
Scenario: recurrent downtime during all day on summer changing date
Given a downtime during all day on summer changing date
When recurrent downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: realtime downtime during all day on summer changing date
Given a downtime during all day on summer changing date
When realtime downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: recurrent downtime of next day of summer changing date
Given a downtime during all day on summer changing date is scheduled
And a downtime of next day of summer changing date
When recurrent downtime is applied
Then the downtime is properly scheduled
# winter changing time
@critical
Scenario: recurrent downtime starting on winter changing time
Given a downtime starting on winter changing time
When recurrent downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: realtime downtime starting on winter changing time
Given a downtime starting on winter changing time
When realtime downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: recurrent downtime ending on winter changing time
Given a downtime ending on winter changing time
When recurrent downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: realtime downtime ending on winter changing time
Given a downtime ending on winter changing time
When realtime downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: recurrent downtime starting and ending on winter changing time
Given a downtime starting and ending on winter changing time
When recurrent downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: realtime downtime starting and ending on winter changing time
Given a downtime starting and ending on winter changing time
When realtime downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: recurrent downtime during all day on winter changing date
Given a downtime during all day on winter changing date
When recurrent downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: realtime downtime during all day on winter changing date
Given a downtime during all day on winter changing date
When realtime downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: recurrent downtime of next day of winter changing date
Given a downtime during all day on winter changing date is scheduled
And a downtime of next day of winter changing date
When recurrent downtime is applied
Then the downtime is properly scheduled
@critical
Scenario: realtime downtime of next day of winter changing date
Given a downtime during all day on winter changing date is scheduled
And a downtime of next day of winter changing date
When realtime downtime is applied
Then the downtime is properly scheduled
\ No newline at end of file
<?php
use Centreon\Test\Behat\CentreonContext;
use Centreon\Test\Behat\Configuration\DowntimeConfigurationPage;
use Centreon\Test\Behat\Configuration\ServiceConfigurationPage;
use Centreon\Test\Behat\Configuration\RecurrentDowntimeConfigurationPage;
/**
* Defines application features from the specific context.
*/
class DowntimeDSTContext extends CentreonContext
{
protected $page;
protected $host = 'Centreon-Server';
protected $service = 'downtimeService';
protected $downtimeProperties;
private function setRecurrentDowntime()
{
$this->page = new RecurrentDowntimeConfigurationPage($this);
$this->page->setProperties(array(
'name' => 'test',
'alias' => $this->service,
'days' => array(7, 1, 2, 3, 4, 5, 6),
'start' => $this->downtimeProperties['start_time'],
'end' => $this->downtimeProperties['end_time'],
'svc_relation' => $this->host . ' - ' . $this->service
));
$this->page->save();
}
private function setRealtimeDowntime()
{
$this->page = new DowntimeConfigurationPage($this);
$this->page->setProperties(array(
'type' => DowntimeConfigurationPage::TYPE_SERVICE,
'service' => $this->host . ' - ' . $this->service,
'comment' => 'Acceptance test',
'start_day' => $this->downtimeProperties['start_day'],
'start_time' => $this->downtimeProperties['start_time'],
'end_day' => $this->downtimeProperties['end_day'],
'end_time' => $this->downtimeProperties['end_time'],
));
$this->page->save();
}
/**
* @Given a passive service is monitored
*/
public function aPassiveServiceIsMonitored()
{
$page = new ServiceConfigurationPage($this);
$page->setProperties(array(
'hosts' => $this->host,
'description' => $this->service,
'templates' => 'generic-service',
'check_command' => 'check_centreon_dummy',
'check_period' => '24x7',
'max_check_attempts' => 1,
'normal_check_interval' => 1,
'retry_check_interval' => 1,
'active_checks_enabled' => 0,
'passive_checks_enabled' => 1,
'notifications_enabled' => 1,
'notify_on_recovery' => 1,
'notify_on_critical' => 1,
'recovery_notification_delay' => 1,
'cs' => 'admin_admin'
));
$page->save();
$this->reloadAllPollers();
$this->submitServiceResult($this->host, $this->service, 0, __FUNCTION__);
$this->waitServiceInMonitoring();
}
private function waitServiceInMonitoring()
{
$this->spin(
function ($context) {
$monitored = false;
$storageDb = $context->getStorageDatabase();
$res = $storageDb->query(
'SELECT s.service_id ' .
'FROM hosts h, services s ' .
'WHERE s.host_id = h.host_id ' .
'AND h.name = "' . $context->host . '" ' .
'AND s.description = "' . $context->service . '" '
);
if ($res->fetch()) {
$monitored = true;
}
return $monitored;
},
'Service ' . $this->host . ' / ' . $this->service . ' is not monitored.',
30
);
}
/**
* @Given a downtime starting on summer changing time
*/
public function aDowntimeStartingOnSummerChangingTime()
{
// on Europe/Paris at 2AM, we jump to 3AM
$this->downtimeProperties = array(
'start_day' => '03/28/2021',
'start_time' => '02:30',
'end_day' => '03/28/2021',
'end_time' => '03:30',
'expected_start' => '2021-03-28 03:00',
'expected_end' => '2021-03-28 03:30',
'expected_duration' => '1800', // 30m
'faketime' => '2021-03-28 01:56:00'
);
}
/**
* @Given a downtime ending on summer changing time
*/
public function aDowntimeEndingOnSummerChangingTime()
{
// on Europe/Paris at 2AM, we jump to 3AM
$this->downtimeProperties = array(
'start_day' => '03/28/2021',
'start_time' => '01:30',
'end_day' => '03/28/2021',
'end_time' => '02:30',
'expected_start' => '2021-03-28 01:30',
'expected_end' => '2021-03-28 03:00',
'expected_duration' => '1800', // 30m
'faketime' => '2021-03-28 01:26:00'
);
}
/**
* @Given a downtime starting and ending on summer changing time
*/
public function aDowntimeStartingAndEndingOnSummerChangingTime()
{
// on Europe/Paris at 2AM, we jump to 3AM
$this->downtimeProperties = array(
'start_day' => '03/28/2021',
'start_time' => '02:03',
'end_day' => '03/28/2021',
'end_time' => '02:33',
'expected_start' => '',
'expected_end' => '',
'expected_duration' => '0',
'faketime' => '2021-03-28 01:58:00'
);
}
/**
* @Given a downtime during all day on summer changing date
*/
public function aDowntimeDuringAllDayOnSummerChangingDate()
{
// on Europe/Paris at 2AM, we jump to 3AM
$this->downtimeProperties = array(
'start_day' => '03/28/2021',
'start_time' => '00:00',
'end_day' => '03/28/2021',
'end_time' => '24:00',
'expected_start' => '2021-03-28 00:00',
'expected_end' => '2021-03-29 00:00',
'expected_duration' => '82800', // 23h
'faketime' => '2021-03-27 23:56:00'
);
}
/**
* @Given a downtime during all day on summer changing date is scheduled
*/
public function aDowntimeDuringAllDayOnSummerChangingDateIsScheduled()
{
$this->aDowntimeDuringAllDayOnSummerChangingDate();
$this->downtimeIsApplied('recurrent');
$this->theDowntimeIsProperlyScheduled();
}
/**
* @Given a downtime of next day of summer changing date
*/
public function aDowntimeOfNextDayOfSummerChangingDate()
{
$this->downtimeProperties = array(
'start_day' => '03/29/2021',
'start_time' => '00:00',
'end_day' => '03/29/2021',
'end_time' => '24:00',
'expected_start' => '2021-03-29 00:00',
'expected_end' => '2021-03-30 00:00',
'expected_duration' => '86400', // 24h
'faketime' => '2021-03-28 23:58:00'
);
}
/**
* @Given a downtime starting on winter changing time
*/
public function aDowntimeStartingOnWinterChangingDate()
{
// on Europe/Paris at 3AM, backward to 2AM
$this->downtimeProperties = array(
'start_day' => '10/31/2021',
'start_time' => '02:03',
'end_day' => '10/31/2021',
'end_time' => '03:33',
'expected_start' => '2021-10-31 02:03',
'expected_end' => '2021-10-31 03:33',
'expected_duration' => '9000', // 2h30
'faketime' => '2021-10-31 01:58:00'
);
}
/**
* @Given a downtime ending on winter changing time
*/
public function aDowntimeEndingOnWinterChangingDate()
{
// on Europe/Paris at 3AM, backward to 2AM
$this->downtimeProperties = array(
'start_day' => '10/31/2021',
'start_time' => '01:00',
'end_day' => '10/31/2021',
'end_time' => '02:30',
'expected_start' => '2021-10-31 01:00',
'expected_end' => '2021-10-31 02:30',
'expected_duration' => '9000', // 2h30
'faketime' => '2021-10-31 00:58:00'
);
}
/**
* @Given a downtime starting and ending on winter changing time
*/
public function aDowntimeStartingAndEndingOnWinterChangingDate()
{
// on Europe/Paris at 3AM, backward to 2AM
$this->downtimeProperties = array(
'start_day' => '10/31/2021',
'start_time' => '02:03',
'end_day' => '10/31/2021',
'end_time' => '02:33',
'expected_start' => '2021-10-31 02:03',
'expected_end' => '2021-10-31 02:33',
'expected_duration' => '5400', // 1h30
'faketime' => '2021-10-31 01:58:00'
);
}
/**
* @Given a downtime during all day on winter changing date
*/
public function aDowntimeDuringAllDayOnWinterChangingDate()
{
// on Europe/Paris at 3AM, backward to 2AM
$this->downtimeProperties = array(
'start_day' => '10/31/2021',
'start_time' => '00:00',
'end_day' => '10/31/2021',
'end_time' => '24:00',
'expected_start' => '2021-10-31 00:00',
'expected_end' => '2021-11-01 00:00',
'expected_duration' => '90000', // 25h
'faketime' => '2021-10-30 23:58:00'
);
}
/**
* @Given a downtime during all day on winter changing date is scheduled
*/
public function aDowntimeDuringAllDayOnWinterChangingDateIsScheduled()
{
$this->aDowntimeDuringAllDayOnWinterChangingDate();
$this->downtimeIsApplied('recurrent');
$this->theDowntimeIsProperlyScheduled();
}
/**
* @Given a downtime of next day of winter changing date
*/
public function aDowntimeOfNextDayOfWinterChangingDate()
{
$this->downtimeProperties = array(
'start_day' => '11/01/2021',
'start_time' => '00:00',
'end_day' => '11/01/2021',
'end_time' => '24:00',
'expected_start' => '2021-11-01 00:00',
'expected_end' => '2021-11-02 00:00',
'expected_duration' => '86400', // 24h
'faketime' => '2021-10-31 23:58:00'
);
}
/**
* @When :downtimeType downtime is applied
*/
public function downtimeIsApplied($downtimeType)
{
if ($downtimeType == 'realtime') {
$this->setRealtimeDowntime();
} else {
$this->setRecurrentDowntime();
$this->container->execute(
"faketime '" . $this->downtimeProperties['faketime'] . "'" .
" php /usr/share/centreon/cron/downtimeManager.php",
'web'
);
}
}
/**
* @Then the downtime is properly scheduled
*/
public function theDowntimeIsProperlyScheduled()
{
$this->spin(
function ($context) {
$scheduled = false;
$return = $context->container->execute(
"cat /var/log/centreon-engine/centengine.log",
'web'
);
$output = $return['output'];
if (preg_match_all(
'/SCHEDULE_SVC_DOWNTIME;' . $context->host . ';' . $context->service . ';(\d+);(\d+);.+/',
$output,
$matches
)) {
$startTimestamp = end($matches[1]);
$endTimestamp = end($matches[2]);
$dateStart = new DateTime('now', new \DateTimeZone('Europe/Paris'));
$dateStart->setTimestamp($startTimestamp);
$dateEnd = new DateTime('now', new \DateTimeZone('Europe/Paris'));
$dateEnd->setTimestamp($endTimestamp);
if ($dateStart->format('Y-m-d H:i') == $context->downtimeProperties['expected_start'] &&
$dateEnd->format('Y-m-d H:i') == $context->downtimeProperties['expected_end'] &&
($endTimestamp - $startTimestamp) == $context->downtimeProperties['expected_duration']) {
$scheduled = true;
}
$storageDb = $context->getStorageDatabase();
$res = $storageDb->query(
"SELECT downtime_id FROM downtimes " .
"WHERE start_time = " . $startTimestamp . " " .
"AND end_time = " . $endTimestamp
);
if (!$res->fetch()) {
$scheduled = false;
}
}
return $scheduled;
},
'Downtime is not scheduled',
10
);
}
/**
* @Then the downtime is not scheduled
*/
public function theDowntimeIsNotScheduled()
{
$this->spin(
function ($context) {
$scheduled = true;
$return = $context->container->execute(
"cat /var/log/centreon-engine/centengine.log",
'web'
);
$output = $return['output'];
if (preg_match(
'/SCHEDULE_SVC_DOWNTIME;' . $this->host . ';' . $this->service . ';(\d+);(\d+);.+/',
$output
)) {
$scheduled = false;
}
return $scheduled;
},
'Downtime is scheduled',
10
);
}
}
...@@ -292,6 +292,20 @@ class CentreonDowntimeBroker extends CentreonDowntime ...@@ -292,6 +292,20 @@ class CentreonDowntimeBroker extends CentreonDowntime
return $timestamp; return $timestamp;
} }
private function manageSummerToWinterTimestamp($timestamp, $timezone)
{
$dstDate = new DateTime('now', $timezone);
$dstDate->setTimestamp($timestamp);
$dateTime2 = clone $dstDate;
$dateTime2->setTimestamp($timestamp - 3600);
if ($dateTime2->getTimestamp() == $dstDate->getTimestamp()) {
$timestamp = $timestamp - 3600;
}
return $timestamp;
}
public function getApproachingDowntimes($delay) public function getApproachingDowntimes($delay)
{ {
$approachingDowntimes = array(); $approachingDowntimes = array();
...@@ -323,11 +337,6 @@ class CentreonDowntimeBroker extends CentreonDowntime ...@@ -323,11 +337,6 @@ class CentreonDowntimeBroker extends CentreonDowntime
$endTime = $this->setTime($downtime['dtp_end_time'], $timezone, $tomorrow); $endTime = $this->setTime($downtime['dtp_end_time'], $timezone, $tomorrow);
$endTimestamp = $endTime->getTimestamp(); $endTimestamp = $endTime->getTimestamp();
# Check if HH:mm time is approaching
if (!$this->isApproachingTime($startTimestamp, $startDelay->getTimestamp(), $endDelay->getTimestamp())) {
continue;
}
# Check if we jump an hour # Check if we jump an hour
$startTimestamp = $this->manageWinterToSummerTimestamp($startTime, $startTimestamp, $timezone); $startTimestamp = $this->manageWinterToSummerTimestamp($startTime, $startTimestamp, $timezone);
$endTimestamp = $this->manageWinterToSummerTimestamp($endTime, $endTimestamp, $timezone); $endTimestamp = $this->manageWinterToSummerTimestamp($endTime, $endTimestamp, $timezone);
...@@ -335,6 +344,14 @@ class CentreonDowntimeBroker extends CentreonDowntime ...@@ -335,6 +344,14 @@ class CentreonDowntimeBroker extends CentreonDowntime
continue; continue;
} }
# Check if HH:mm time is approaching
if (!$this->isApproachingTime($startTimestamp, $startDelay->getTimestamp(), $endDelay->getTimestamp())) {
continue;
}
# check backward of one hour
$startTimestamp = $this->manageSummerToWinterTimestamp($startTimestamp, $timezone);
$approaching = false; $approaching = false;
if (preg_match('/^\d(,\d)*$/', $downtime['dtp_day_of_week']) && preg_match('/^(none)|(all)$/', $downtime['dtp_month_cycle'])) { if (preg_match('/^\d(,\d)*$/', $downtime['dtp_day_of_week']) && preg_match('/^(none)|(all)$/', $downtime['dtp_month_cycle'])) {
$approaching = $this->isWeeklyApproachingDowntime( $approaching = $this->isWeeklyApproachingDowntime(
......
...@@ -400,6 +400,43 @@ class CentreonExternalCommand ...@@ -400,6 +400,43 @@ class CentreonExternalCommand
* Downtime * Downtime
***********/ ***********/
private function getDowntimeTimestampFromDate($date = 'now', $timezone = '', $start = true)
{
$dateTime = new \DateTime($date, new \DateTimeZone($timezone));
// Winter to summer dst
$dateTime2 = clone $dateTime;
$dateTime2->setTimestamp($dateTime2->getTimestamp());
if ($dateTime2->format("H") != $dateTime->format("H")) {
$hour = $dateTime->format('H');
$dateTime->setTime($hour, '00');
return $dateTime->getTimestamp();
}
// Summer to winter dst
$dateTime3 = clone $dateTime;
$dateTime3 = $dateTime3->setTimestamp($dateTime3->getTimestamp() - 3600);
if ($dateTime3->getTimestamp() == $dateTime->getTimestamp()) {
if ($start) {
return $dateTime3->getTimestamp() - 3600;
} else {
return $dateTime3->getTimestamp();
}
}
$dateTime4 = clone $dateTime;
$dateTime4 = $dateTime3->setTimestamp($dateTime4->getTimestamp() + 3600);
if ($dateTime4->getTimestamp() == $dateTime->getTimestamp()) {
if ($start) {
return $dateTime->getTimestamp();
} else {
return $dateTime4->getTimestamp() + 3600;
}
}
return $dateTime->getTimestamp();
}
/** /**
* *
* Delete downtimes. * Delete downtimes.
...@@ -447,17 +484,16 @@ class CentreonExternalCommand ...@@ -447,17 +484,16 @@ class CentreonExternalCommand
} }
if ($hostOrCentreonTime == "0") { if ($hostOrCentreonTime == "0") {
$start_time = $this->GMT->getUTCDateFromString( $timezoneId = $this->GMT->getMyGTMFromUser($this->userId);
$start,
$this->GMT->getMyGTMFromUser($this->userId)
);
$end_time = $this->GMT->getUTCDateFromString(
$end,
$this->GMT->getMyGTMFromUser($this->userId)
);
} else { } else {
$start_time = $this->GMT->getUTCDateFromString($start, $this->GMT->getUTCLocationHost($host)); $timezoneId = $this->GMT->getUTCLocationHost($host);
$end_time = $this->GMT->getUTCDateFromString($end, $this->GMT->getUTCLocationHost($host)); }
$timezone = $this->GMT->getActiveTimezone($timezoneId);
$start_time = $this->getDowntimeTimestampFromDate($start, $timezone, true);
$end_time = $this->getDowntimeTimestampFromDate($end, $timezone, false);
if ($end_time == $start_time) {
return;
} }
/* /*
...@@ -469,7 +505,7 @@ class CentreonExternalCommand ...@@ -469,7 +505,7 @@ class CentreonExternalCommand
* Send command * Send command
*/ */
if (!isset($duration)) { if (!isset($duration)) {
$duration = $start_time - $end_time; $duration = $end_time - $start_time;
} }
$finalHostName = ''; $finalHostName = '';
if (!is_numeric($host)) { if (!is_numeric($host)) {
...@@ -524,17 +560,17 @@ class CentreonExternalCommand ...@@ -524,17 +560,17 @@ class CentreonExternalCommand
} }
if ($hostOrCentreonTime == "0") { if ($hostOrCentreonTime == "0") {
$start_time = $this->GMT->getUTCDateFromString( $timezoneId = $this->GMT->getMyGTMFromUser($this->userId);
$start,
$this->GMT->getMyGTMFromUser($centreon->userId)
);
$end_time = $this->GMT->getUTCDateFromString(
$end,
$this->GMT->getMyGTMFromUser($centreon->userId)
);
} else { } else {
$start_time = $this->GMT->getUTCDateFromString($start, $this->GMT->getUTCLocationHost($host)); $timezoneId = $this->GMT->getUTCLocationHost($host);
$end_time = $this->GMT->getUTCDateFromString($end, $this->GMT->getUTCLocationHost($host)); }
$timezone = $this->GMT->getActiveTimezone($timezoneId);
$start_time = $this->getDowntimeTimestampFromDate($start, $timezone, true);
$end_time = $this->getDowntimeTimestampFromDate($end, $timezone, false);
if ($end_time == $start_time) {
return;
} }
/* /*
...@@ -546,7 +582,7 @@ class CentreonExternalCommand ...@@ -546,7 +582,7 @@ class CentreonExternalCommand
* Send command * Send command
*/ */
if (!isset($duration)) { if (!isset($duration)) {
$duration = $start_time - $end_time; $duration = $end_time - $start_time;
} }
$finalHostName = ''; $finalHostName = '';
if (!is_numeric($host)) { if (!is_numeric($host)) {
......
...@@ -71,6 +71,12 @@ class CentreonGMT ...@@ -71,6 +71,12 @@ class CentreonGMT
*/ */
protected $hostLocations = array(); protected $hostLocations = array();
/**
*
* @param array $pollerLocations
*/
protected $pollerLocations = array();
/** /**
* Default timezone setted in adminstration/options * Default timezone setted in adminstration/options
* @var string $sDefaultTimezone * @var string $sDefaultTimezone
...@@ -495,18 +501,47 @@ class CentreonGMT ...@@ -495,18 +501,47 @@ class CentreonGMT
return $this->hostLocations; return $this->hostLocations;
} }
$this->getPollerLocations();
$this->hostLocations = array(); $this->hostLocations = array();
$query = 'SELECT host_id, timezone FROM hosts WHERE enabled = 1 '; $query = 'SELECT host_id, instance_id, timezone FROM hosts WHERE enabled = 1 ';
$res = $this->dbc->query($query); $res = $this->dbc->query($query);
if (!PEAR::isError($res)) { if (!PEAR::isError($res)) {
while ($row = $res->fetchRow()) { while ($row = $res->fetchRow()) {
if ($row['timezone'] == "" && isset($this->pollerLocations[$row['instance_id']])) {
$this->hostLocations[$row['host_id']] = $this->pollerLocations[$row['instance_id']];
} else {
$this->hostLocations[$row['host_id']] = str_replace(':', '', $row['timezone']); $this->hostLocations[$row['host_id']] = str_replace(':', '', $row['timezone']);
} }
} }
}
return $this->hostLocations; return $this->hostLocations;
} }
/**
* Get list of timezone of pollers
* @return array
*/
public function getPollerLocations()
{
if (count($this->pollerLocations)) {
return $this->pollerLocations;
}
$query = 'SELECT ns.id, t.timezone_name ' .
'FROM cfg_nagios cfgn, nagios_server ns, timezone t ' .
'WHERE cfgn.nagios_activate = "1" ' .
'AND cfgn.nagios_server_id = ns.id ' .
'AND cfgn.use_timezone = t.timezone_id ';
$res = $this->db->query($query);
while ($row = $res->fetchRow()) {
$this->pollerLocations[$row['id']] = $row['timezone_name'];
}
return $this->pollerLocations;
}
/** /**
* Get default timezone setted in admintration/options * Get default timezone setted in admintration/options
* *
...@@ -535,7 +570,7 @@ class CentreonGMT ...@@ -535,7 +570,7 @@ class CentreonGMT
* @param string $gmt * @param string $gmt
* @return string timezone * @return string timezone
*/ */
private function getActiveTimezone($gmt) public function getActiveTimezone($gmt)
{ {
$sTimezone = ""; $sTimezone = "";
if (count($this->timezones) == 0) { if (count($this->timezones) == 0) {
......
...@@ -249,8 +249,8 @@ if (!$centreon->user->access->checkAction("host_schedule_downtime") ...@@ -249,8 +249,8 @@ if (!$centreon->user->access->checkAction("host_schedule_downtime")
$form->addRule('comment', _("Required Field"), 'required'); $form->addRule('comment', _("Required Field"), 'required');
$data = array(); $data = array();
$data["start"] = $centreonGMT->getDate("Y/m/d", time()); $data["start"] = $centreonGMT->getDate("m/d/Y", time());
$data["end"] = $centreonGMT->getDate("Y/m/d", time() + 7200); $data["end"] = $centreonGMT->getDate("m/d/Y", time() + 7200);
$data["start_time"] = $centreonGMT->getDate("G:i", time()); $data["start_time"] = $centreonGMT->getDate("G:i", time());
$data["end_time"] = $centreonGMT->getDate("G:i", time() + 7200); $data["end_time"] = $centreonGMT->getDate("G:i", time() + 7200);
$data["host_or_hg"] = 1; $data["host_or_hg"] = 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment