コード例 #1
0
 public function filterAction()
 {
     $flat = array();
     $filter = Filter::fromQueryString('vars.bpconfig=*');
     Benchmark::measure('ready');
     $objs = IcingaHost::loadAll($this->db());
     Benchmark::measure('db done');
     foreach ($objs as $host) {
         $flat[$host->id] = (object) array();
         foreach ($host->getProperties() as $k => $v) {
             $flat[$host->id]->{$k} = $v;
         }
     }
     Benchmark::measure('objects ready');
     $vars = IcingaHostVar::loadAll($this->db());
     Benchmark::measure('vars loaded');
     foreach ($vars as $var) {
         if (!array_key_exists($var->host_id, $flat)) {
             continue;
         }
         // Templates?
         $flat[$var->host_id]->{'vars.' . $var->varname} = $var->varvalue;
     }
     Benchmark::measure('vars done');
     foreach ($flat as $host) {
         if ($filter->matches($host)) {
             echo $host->object_name . "\n";
         }
     }
     return;
     Benchmark::measure('all done');
 }
コード例 #2
0
 public function getActionsForService(Service $service)
 {
     $db = $this->db();
     if (!$db) {
         return array();
     }
     if (IcingaHost::exists($service->host_name, $db)) {
         return array('Inspect' => Url::fromPath('director/inspect/object', array('type' => 'service', 'plural' => 'services', 'name' => sprintf('%s!%s', $service->host_name, $service->service_description))));
     } else {
         return array();
     }
 }
コード例 #3
0
 public function getActionsForHost(Host $host)
 {
     $db = $this->db();
     if (!$db) {
         return array();
     }
     if (IcingaHost::exists($host->host_name, $db)) {
         return array('Modify' => Url::fromPath('director/host/edit', array('name' => $host->host_name)), 'Inspect' => Url::fromPath('director/inspect/object', array('type' => 'host', 'plural' => 'hosts', 'name' => $host->host_name)));
     } else {
         return array();
     }
 }
コード例 #4
0
 protected function loadObject()
 {
     if ($this->object === null && ($name = $this->params->get('name'))) {
         $params = array('object_name' => $name);
         $db = $this->db();
         if ($hostname = $this->params->get('host')) {
             $this->view->host = IcingaHost::load($hostname, $db);
             $params['host_id'] = $this->view->host->id;
         }
         $this->object = IcingaService::load($params, $db);
     }
     return $this->object;
 }
コード例 #5
0
 protected function addHostPropertyElements()
 {
     $this->addElement('select', 'host_property', array('label' => 'Host property', 'required' => true, 'multiOptions' => $this->optionalEnum(IcingaHost::enumProperties($this->db))));
     $this->addElement('text', 'filter_expression', array('label' => 'Filter expression', 'required' => true));
 }
コード例 #6
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;
 }