コード例 #1
0
 protected function api()
 {
     $this->view->endpoint = $this->params->get('endpoint');
     $endpoint = IcingaEndpoint::load($this->view->endpoint, $this->db());
     $apiconfig = $this->Config()->getSection('api');
     $client = new RestApiClient($endpoint->host, $endpoint->port);
     $client->setCredentials($apiconfig->get('username'), $apiconfig->get('password'));
     $api = new CoreApi($client);
     return $api;
 }
コード例 #2
0
 protected function generateFromDb()
 {
     $start = microtime(true);
     $this->configFile('conf.d/001-director-basics')->prepend("\nconst DirectorStageDir = dirname(dirname(current_filename))\n" . "\nobject Zone \"director-global\" {\n    global = true\n}\n");
     // TODO: combine this with real fetches, this is a test right now
     IcingaEndpoint::prefetchAll($this->connection);
     $this->createFileFromDb('zone')->createFileFromDb('endpoint')->createFileFromDb('command')->createFileFromDb('hostGroup')->createFileFromDb('host')->createFileFromDb('serviceGroup')->createFileFromDb('service')->createFileFromDb('userGroup')->createFileFromDb('user');
     $this->generationTime = (int) ((microtime(true) - $start) * 1000);
     return $this;
 }
コード例 #3
0
 protected function autogenerateAgents()
 {
     $zones = array();
     $endpoints = array();
     foreach (IcingaHost::prefetchAll($this->connection) as $host) {
         if ($host->object_type !== 'object') {
             continue;
         }
         if ($host->getResolvedProperty('has_agent') !== 'y') {
             continue;
         }
         $name = $host->object_name;
         if (IcingaEndpoint::exists($name, $this->connection)) {
             continue;
         }
         $props = array('object_name' => $name, 'object_type' => 'object', 'log_duration' => 0);
         if ($host->getResolvedProperty('master_should_connect') === 'y') {
             $props['host'] = $host->getResolvedProperty('address');
             $props['zone_id'] = $host->getResolvedProperty('zone_id');
         }
         $endpoints[] = IcingaEndpoint::create($props);
         $zones[] = IcingaZone::create(array('object_name' => $name, 'parent' => $this->getMasterZoneName()), $this->connection)->setEndpointList(array($name));
     }
     $this->createFileForObjects('endpoint', $endpoints);
     $this->createFileForObjects('zone', $zones);
     return $this;
 }