Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(gmt): get host locations from poller too
Browse files Browse the repository at this point in the history
  • Loading branch information
kduret committed Oct 13, 2017
1 parent d5e3fef commit 6ddb787
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions www/class/centreonGMT.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class CentreonGMT
*/
protected $hostLocations = array();

/**
*
* @param array $pollerLocations
*/
protected $pollerLocations = array();

/**
* Default timezone setted in adminstration/options
* @var string $sDefaultTimezone
Expand Down Expand Up @@ -495,17 +501,46 @@ public function getHostLocations()
return $this->hostLocations;
}

$this->getPollerLocations();

$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);
if (!PEAR::isError($res)) {
while ($row = $res->fetchRow()) {
$this->hostLocations[$row['host_id']] = str_replace(':', '', $row['timezone']);
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']);
}
}
}
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
Expand Down

0 comments on commit 6ddb787

Please sign in to comment.