diff --git a/library/Director/Db.php b/library/Director/Db.php index d1cdbe93..d95c6478 100644 --- a/library/Director/Db.php +++ b/library/Director/Db.php @@ -47,7 +47,22 @@ class Db extends DbConnection public function getMasterZoneName() { - return $this->getSetting('master_zone', 'master'); + if ($zone = $this->getSetting('master_zone')) { + return $zone; + } + + $db = $this->db(); + $query = $db->select() + ->from('icinga_zone', 'object_name') + ->where('is_global = ?', 'n'); + + $zones = $db->fetchCol($query); + + if (count($zones) === 1) { + return $zones[0]; + } + + return 'master'; } public function getDefaultGlobalZoneName()