Esempio n. 1
0
 protected function init()
 {
     $cfg = Config::module('pnp4nagios')->getSection('pnp4nagios');
     $this->configDir = rtrim($cfg->get('config_dir', $this->configDir), '/');
     $this->baseUrl = rtrim($cfg->get('base_url', $this->baseUrl), '/');
     $this->readPnpConfig();
 }
 /**
  * (non-PHPDoc)
  * @see \Icinga\Web\Form::createElements() For the method documentation.
  */
 public function createElements(array $formData = array())
 {
     $config = Config::module('monitoring');
     parent::createElements($formData);
     $this->addElements(array(array('checkbox', 'all_services', array('label' => $this->translate('All Services'), 'value' => (bool) $config->get('settings', 'hostcheck_all_services', false), 'description' => $this->translate('Schedule check for all services on the hosts and the hosts themselves.')))));
     return $this;
 }
Esempio n. 3
0
 /**
  * Create menu from the application's menu config file plus the config files from all enabled modules
  *
  * @return  self
  */
 public static function fromConfig()
 {
     $menu = new static('menu');
     $manager = Icinga::app()->getModuleManager();
     try {
         $menuConfigs = array(Config::app('menu'));
     } catch (NotReadableError $e) {
         Logger::error($e);
         $menuConfigs = array();
     }
     try {
         $modules = $manager->listEnabledModules();
     } catch (NotReadableError $e) {
         Logger::error($e);
         $modules = array();
     }
     foreach ($modules as $moduleName) {
         try {
             $moduleMenuConfig = Config::module($moduleName, 'menu');
         } catch (NotReadableError $e) {
             Logger::error($e);
             $moduleMenuConfig = array();
         }
         if (!empty($moduleMenuConfig)) {
             $menuConfigs[] = $moduleMenuConfig;
         }
     }
     return $menu->loadMenuItems($menu->flattenConfigs($menuConfigs));
 }
 protected function db()
 {
     $resourceName = Config::module('director')->get('db', 'resource');
     if (!$resourceName) {
         return false;
     }
     return Db::fromResourceName($resourceName);
 }
 /**
  * (non-PHPDoc)
  * @see \Icinga\Web\Form::createElements() For the method documentation.
  */
 public function createElements(array $formData = array())
 {
     $this->addElement('textarea', 'comment', array('required' => true, 'label' => $this->translate('Comment'), 'description' => $this->translate('If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.')));
     if (!$this->getBackend()->isIcinga2()) {
         $this->addElement('checkbox', 'persistent', array('label' => $this->translate('Persistent'), 'value' => (bool) Config::module('monitoring')->get('settings', 'comment_persistent', true), 'description' => $this->translate('If you uncheck this option, the comment will automatically be deleted the next time Icinga is' . ' restarted.')));
     }
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public static function fromConfig()
 {
     $backend = parent::fromConfig();
     // TODO: move this to log types #11636
     $resourceConfig = Config::module('elasticsearch')->getSection('elasticsearch');
     $backend->setIndex($resourceConfig->get('logstash_pattern', 'logstash-*'));
     return $backend;
 }
 /**
  * {@inheritdoc}
  */
 public function createElements(array $formData = array())
 {
     $config = Config::module('monitoring');
     $this->addElements(array(array('textarea', 'comment', array('required' => true, 'label' => $this->translate('Comment'), 'description' => $this->translate('If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.'))), array('checkbox', 'forced', array('label' => $this->translate('Forced'), 'value' => (bool) $config->get('settings', 'custom_notification_forced', false), 'description' => $this->translate('If you check this option, the notification is sent out regardless of time restrictions and' . ' whether or not notifications are enabled.')))));
     if (!$this->getBackend()->isIcinga2()) {
         $this->addElement('checkbox', 'broadcast', array('label' => $this->translate('Broadcast'), 'value' => (bool) $config->get('settings', 'custom_notification_broadcast', false), 'description' => $this->translate('If you check this option, the notification is sent out to all normal and escalated contacts.')));
     }
     return $this;
 }
 public function fetchFiles()
 {
     $files = array();
     $storage = new LegacyStorage(Config::module('businessprocess')->getSection('global'));
     foreach ($storage->listProcesses() as $name => $title) {
         $files['processes/' . $name . '.bp'] = $storage->getSource($name);
     }
     return $files;
 }
 protected function init()
 {
     $cfg = Config::module('graphite')->getSection('graphite');
     $this->baseUrl = rtrim($cfg->get('base_url', $this->baseUrl), '/');
     $this->metricPrefix = $cfg->get('metric_prefix', $this->metricPrefix);
     $this->serviceMacro = $cfg->get('service_name_template', $this->serviceMacro);
     $this->hostMacro = $cfg->get('host_name_template', $this->hostMacro);
     $this->imageUrlMacro = $cfg->get('graphite_args_template', $this->imageUrlMacro);
     $this->largeImageUrlMacro = $cfg->get('graphite_large_args_template', $this->largeImageUrlMacro);
 }
Esempio n. 10
0
 /**
  * Get transport configuration
  *
  * @return Config
  * @throws ConfigurationError
  */
 public static function getConfig()
 {
     if (!isset(self::$config)) {
         self::$config = Config::module('monitoring', 'instances');
         if (self::$config->isEmpty()) {
             throw new ConfigurationError('No instances have been configured in \'%s\'.', self::$config->getConfigFile());
         }
     }
     return self::$config;
 }
Esempio n. 11
0
 protected function init()
 {
     $cfg = Config::module('graphite')->getSection('graphite');
     $this->baseUrl = rtrim($cfg->get('base_url', $this->baseUrl), '/');
     $this->legacyMode = filter_var($cfg->get('legacy_mode', $this->legacyMode), FILTER_VALIDATE_BOOLEAN);
     $this->serviceMacro = $cfg->get('service_name_template', $this->serviceMacro);
     $this->hostMacro = $cfg->get('host_name_template', $this->hostMacro);
     $this->imageUrlMacro = $cfg->get('graphite_args_template', $this->imageUrlMacro);
     $this->largeImageUrlMacro = $cfg->get('graphite_large_args_template', $this->largeImageUrlMacro);
 }
 protected function db()
 {
     if ($this->db === null) {
         $resourceName = Config::module('director')->get('db', 'resource');
         if ($resourceName) {
             $this->db = Db::fromResourceName($resourceName);
         }
     }
     return $this->db;
 }
 protected function getDirectories()
 {
     return Config::module('fileshipper', 'directories');
     $config = Config::module('fileshipper', 'directories');
     $dirs = array();
     foreach ($config as $key => $c) {
         $dirs[$key] = (object) $c->toArray();
     }
     return $dirs;
 }
 /**
  * Get transport configuration
  *
  * @return  Config
  *
  * @throws  ConfigurationError
  */
 public static function getConfig()
 {
     if (static::$config === null) {
         $config = Config::module('monitoring', 'commandtransports');
         if ($config->isEmpty()) {
             throw new ConfigurationError(mt('monitoring', 'No command transports have been configured in "%s".'), $config->getConfigFile());
         }
         static::$config = $config;
     }
     return static::$config;
 }
 public function ssldir($subdir = null)
 {
     if ($this->ssldir === null) {
         $this->ssldir = dirname(Config::module('puppetdb')->getConfigFile()) . '/ssl';
     }
     if ($subdir === null) {
         return $this->ssldir;
     } else {
         return $this->ssldir . '/' . $subdir;
     }
 }
Esempio n. 16
0
 protected function joinBaseTables()
 {
     if (version_compare($this->getIdoVersion(), '1.12.0', '<')) {
         $this->columnMap['customvariablestatus']['is_json'] = '(0)';
     }
     if (!(bool) Config::module('monitoring')->get('ido', 'use_customvar_status_table', true)) {
         $table = 'customvariables';
     } else {
         $table = 'customvariablestatus';
     }
     $this->select->from(array('cvs' => $this->prefix . $table), array())->join(array('cvo' => $this->prefix . 'objects'), 'cvs.object_id = cvo.object_id AND cvo.is_active = 1', array());
     $this->joinedVirtualTables = array('customvariablestatus' => true, 'objects' => true);
 }
 /**
  * (non-PHPDoc)
  * @see \Icinga\Web\Form::createElements() For the method documentation.
  */
 public function createElements(array $formData = array())
 {
     $config = Config::module('monitoring');
     $this->addElements(array(array('textarea', 'comment', array('required' => true, 'label' => $this->translate('Comment'), 'description' => $this->translate('If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.'))), array('checkbox', 'persistent', array('label' => $this->translate('Persistent Comment'), 'value' => (bool) $config->get('settings', 'acknowledge_persistent', false), 'description' => $this->translate('If you would like the comment to remain even when the acknowledgement is removed, check this' . ' option.'))), array('checkbox', 'expire', array('label' => $this->translate('Use Expire Time'), 'value' => (bool) $config->get('settings', 'acknowledge_expire', false), 'description' => $this->translate('If the acknowledgement should expire, check this option.'), 'autosubmit' => true))));
     if (isset($formData['expire']) && (bool) $formData['expire'] === true) {
         $expireTime = new DateTime();
         $expireTime->add(new DateInterval('PT1H'));
         $this->addElement('dateTimePicker', 'expire_time', array('label' => $this->translate('Expire Time'), 'value' => $expireTime, 'description' => $this->translate('Enter the expire date and time for this acknowledgement here. Icinga will delete the' . ' acknowledgement after this time expired.')));
         $this->addDisplayGroup(array('expire', 'expire_time'), 'expire-expire_time', array('decorators' => array('FormElements', array('HtmlTag', array('tag' => 'div')))));
     }
     $this->addElements(array(array('checkbox', 'sticky', array('label' => $this->translate('Sticky Acknowledgement'), 'value' => (bool) $config->get('settings', 'acknowledge_sticky', false), 'description' => $this->translate('If you want the acknowledgement to remain until the host or service recovers even if the host' . ' or service changes state, check this option.'))), array('checkbox', 'notify', array('label' => $this->translate('Send Notification'), 'value' => (bool) $config->get('settings', 'acknowledge_notify', true), 'description' => $this->translate('If you do not want an acknowledgement notification to be sent out to the appropriate contacts,' . ' uncheck this option.')))));
     return $this;
 }
Esempio n. 18
0
 public function Config($file = null)
 {
     if ($file === null) {
         if ($this->config === null) {
             $this->config = Config::module($this->getModuleName());
         }
         return $this->config;
     } else {
         if (!array_key_exists($file, $this->configs)) {
             $this->configs[$file] = Config::module($this->getModuleName(), $file);
         }
         return $this->configs[$file];
     }
 }
Esempio n. 19
0
 private function getMainConfig($file = null)
 {
     if ($file === null) {
         if ($this->config === null) {
             $this->config = Config::app();
         }
         return $this->config;
     } else {
         if (!array_key_exists($file, $this->configs)) {
             $this->configs[$file] = Config::module($module, $file);
         }
         return $this->configs[$file];
     }
     return $this->config;
 }
 protected function init()
 {
     $cfg = Config::module('graphite')->getSection('graphite');
     $this->baseUrl = rtrim($cfg->get('base_url', $this->baseUrl), '/');
     $this->legacyMode = filter_var($cfg->get('legacy_mode', $this->legacyMode), FILTER_VALIDATE_BOOLEAN);
     $this->serviceMacro = $cfg->get('service_name_template', $this->serviceMacro);
     $this->hostMacro = $cfg->get('host_name_template', $this->hostMacro);
     $this->imageUrlMacro = $cfg->get('graphite_args_template', $this->imageUrlMacro);
     $this->largeImageUrlMacro = $cfg->get('graphite_large_args_template', $this->largeImageUrlMacro);
     $this->iframeWidth = $cfg->get('graphite_iframe_w', $this->iframeWidth);
     $this->iframeHeight = $cfg->get('graphite_iframe_h', $this->iframeHeight);
     $this->areaMode = $cfg->get('graphite_area_mode', $this->areaMode);
     $this->areaAlpha = $cfg->get('graphite_area_alpha', $this->areaAlpha);
     $this->summarizeInterval = $cfg->get('graphite_summarize_interval', $this->summarizeInterval);
     $this->colorList = $cfg->get('graphite_color_list', $this->colorList);
 }
 protected function importedNode()
 {
     if ($this->importedNode === null) {
         $storage = new LegacyStorage(Config::module('businessprocess')->getSection('global'));
         try {
             $this->importedBp = $storage->loadProcess($this->configName);
             if ($this->bp->usesSoftStates()) {
                 $this->importedBp->useSoftStates();
             } else {
                 $this->importedBp->useHardStates();
             }
             $this->importedBp->retrieveStatesFromBackend();
             $this->importedNode = $this->importedBp->getNode($this->name);
         } catch (Exception $e) {
             $node = new BpNode($this->bp, (object) array('name' => $this->name, 'operator' => '&', 'child_names' => array()));
             $node->setState(2);
             $node->setMissing(false)->setDowntime(false)->setAck(false)->setAlias($e->getMessage());
             $this->importedNode = $node;
         }
     }
     return $this->importedNode;
 }
Esempio n. 22
0
 /**
  * Fetch this object's obfuscated custom variables
  *
  * @return  $this
  */
 public function fetchCustomvars()
 {
     if ($this->backend->is('livestatus')) {
         $this->customvars = array();
         return $this;
     }
     $blacklist = array();
     $blacklistPattern = '';
     if (($blacklistConfig = Config::module('monitoring')->get('security', 'protected_customvars', '')) !== '') {
         foreach (explode(',', $blacklistConfig) as $customvar) {
             $nonWildcards = array();
             foreach (explode('*', $customvar) as $nonWildcard) {
                 $nonWildcards[] = preg_quote($nonWildcard, '/');
             }
             $blacklist[] = implode('.*', $nonWildcards);
         }
         $blacklistPattern = '/^(' . implode('|', $blacklist) . ')$/i';
     }
     if ($this->type === self::TYPE_SERVICE) {
         $this->fetchServiceVariables();
         $customvars = $this->serviceVariables;
     } else {
         $this->fetchHostVariables();
         $customvars = $this->hostVariables;
     }
     $this->customvars = $customvars;
     $this->hideBlacklistedProperties();
     if ($blacklistPattern) {
         $this->customvars = $this->obfuscateCustomVars($this->customvars, $blacklistPattern);
     }
     return $this;
 }
Esempio n. 23
0
 /**
  * Create menu from the application's menu config file plus the config files from all enabled modules
  *
  * @return      static
  *
  * @deprecated  THIS IS OBSOLETE. LEFT HERE FOR FUTURE USE WITH USER-SPECIFIC MODULES
  */
 public static function fromConfig()
 {
     $menu = new static('menu');
     $manager = Icinga::app()->getModuleManager();
     $modules = $manager->listEnabledModules();
     $menuConfigs = array(Config::app('menu'));
     foreach ($modules as $moduleName) {
         $moduleMenuConfig = Config::module($moduleName, 'menu');
         if (!$moduleMenuConfig->isEmpty()) {
             $menuConfigs[] = $moduleMenuConfig;
         }
     }
     return $menu->loadSubMenus($menu->flattenConfigs($menuConfigs));
 }
 /**
  * Return the configuration for the first enabled or the given backend
  */
 protected static function loadConfig($name = null)
 {
     $backends = Config::module('monitoring', 'backends');
     if ($name === null) {
         $count = 0;
         foreach ($backends as $name => $config) {
             $count++;
             if ((bool) $config->get('disabled', false) === false) {
                 return array($name, $config);
             }
         }
         if ($count === 0) {
             $message = mt('monitoring', 'No backend has been configured');
         } else {
             $message = mt('monitoring', 'All backends are disabled');
         }
         throw new ConfigurationError($message);
     } else {
         $config = $backends->getSection($name);
         if ($config->isEmpty()) {
             throw new ConfigurationError(mt('monitoring', 'No configuration for backend %s'), $name);
         }
         if ((bool) $config->get('disabled', false) === true) {
             throw new ConfigurationError(mt('monitoring', 'Configuration for backend %s is disabled'), $name);
         }
         return array($name, $config);
     }
 }
Esempio n. 25
0
 /**
  * Return the setup for this wizard
  *
  * @return  Setup
  */
 public function getSetup()
 {
     $pageData = $this->getPageData();
     $setup = new Setup();
     if (isset($pageData['setup_auth_db_resource']) && !$pageData['setup_auth_db_resource']['skip_validation'] && (!isset($pageData['setup_auth_db_creation']) || !$pageData['setup_auth_db_creation']['skip_validation'])) {
         $setup->addStep(new DatabaseStep(array('tables' => $this->databaseTables, 'privileges' => $this->databaseUsagePrivileges, 'resourceConfig' => $pageData['setup_auth_db_resource'], 'adminName' => isset($pageData['setup_auth_db_creation']['username']) ? $pageData['setup_auth_db_creation']['username'] : null, 'adminPassword' => isset($pageData['setup_auth_db_creation']['password']) ? $pageData['setup_auth_db_creation']['password'] : null, 'schemaPath' => Config::module('setup')->get('schema', 'path', Icinga::app()->getBaseDir('etc' . DIRECTORY_SEPARATOR . 'schema')))));
     } elseif (isset($pageData['setup_config_db_resource']) && !$pageData['setup_config_db_resource']['skip_validation'] && (!isset($pageData['setup_config_db_creation']) || !$pageData['setup_config_db_creation']['skip_validation'])) {
         $setup->addStep(new DatabaseStep(array('tables' => $this->databaseTables, 'privileges' => $this->databaseUsagePrivileges, 'resourceConfig' => $pageData['setup_config_db_resource'], 'adminName' => isset($pageData['setup_config_db_creation']['username']) ? $pageData['setup_config_db_creation']['username'] : null, 'adminPassword' => isset($pageData['setup_config_db_creation']['password']) ? $pageData['setup_config_db_creation']['password'] : null, 'schemaPath' => Config::module('setup')->get('schema', 'path', Icinga::app()->getBaseDir('etc' . DIRECTORY_SEPARATOR . 'schema')))));
     }
     $setup->addStep(new GeneralConfigStep(array('generalConfig' => $pageData['setup_general_config'], 'resourceName' => isset($pageData['setup_auth_db_resource']['name']) ? $pageData['setup_auth_db_resource']['name'] : (isset($pageData['setup_config_db_resource']['name']) ? $pageData['setup_config_db_resource']['name'] : null))));
     $adminAccountType = $pageData['setup_admin_account']['user_type'];
     $adminAccountData = array('username' => $pageData['setup_admin_account'][$adminAccountType]);
     if ($adminAccountType === 'new_user' && !$pageData['setup_auth_db_resource']['skip_validation'] && (!isset($pageData['setup_auth_db_creation']) || !$pageData['setup_auth_db_creation']['skip_validation'])) {
         $adminAccountData['resourceConfig'] = $pageData['setup_auth_db_resource'];
         $adminAccountData['password'] = $pageData['setup_admin_account']['new_user_password'];
     }
     $authType = $pageData['setup_authentication_type']['type'];
     $setup->addStep(new AuthenticationStep(array('adminAccountData' => $adminAccountData, 'backendConfig' => $pageData['setup_authentication_backend'], 'resourceName' => $authType === 'db' ? $pageData['setup_auth_db_resource']['name'] : ($authType === 'ldap' ? $pageData['setup_ldap_resource']['name'] : null))));
     if (isset($pageData['setup_auth_db_resource']) || isset($pageData['setup_config_db_resource']) || isset($pageData['setup_ldap_resource'])) {
         $setup->addStep(new ResourceStep(array('dbResourceConfig' => isset($pageData['setup_auth_db_resource']) ? array_diff_key($pageData['setup_auth_db_resource'], array('skip_validation' => null)) : (isset($pageData['setup_config_db_resource']) ? array_diff_key($pageData['setup_config_db_resource'], array('skip_validation' => null)) : null), 'ldapResourceConfig' => isset($pageData['setup_ldap_resource']) ? array_diff_key($pageData['setup_ldap_resource'], array('skip_validation' => null)) : null)));
     }
     foreach ($this->getWizards() as $wizard) {
         if ($wizard->isComplete()) {
             $setup->addSteps($wizard->getSetup()->getSteps());
         }
     }
     $setup->addStep(new EnableModuleStep(array_keys($this->getPage('setup_modules')->getCheckedModules())));
     return $setup;
 }
Esempio n. 26
0
 protected function config()
 {
     if ($this->config === null) {
         $this->config = Config::module('director');
     }
     return $this->config;
 }
<?php

use Icinga\Application\Config;
$section = $this->menuSection(N_('Maps'))->setUrl('nagvis/show/map')->setIcon('globe');
foreach (Config::module('nagvis')->getSection('menu') as $name => $caption) {
    $section->add($caption, array('url' => 'nagvis/show/map', 'urlParameters' => array('map' => $name)));
}
$this->providePermission('nagvis/read', $this->translate('Show NagVis maps'));
$this->providePermission('nagvis/edit', $this->translate('Modify NagVis maps'));
$this->providePermission('nagvis/admin', $this->translate('Nagvis administration'));
$this->provideRestriction('nagvis/map/filter', $this->translate('Filter NagVis maps'));
 public function getDb()
 {
     $resourceName = Config::module('director')->get('db', 'resource');
     $db = Db::fromResourceName($resourceName);
     return $db;
 }
 /**
  * Create a new EventTypeRepository object
  *
  * Data source is configured automatically.
  */
 public function __construct()
 {
     $config = Config::module('elasticsearch', 'event-types');
     $config->getConfigObject()->setKeyColumn('name');
     parent::__construct($config);
 }
 public function Config($file = null)
 {
     if ($this->config === null) {
         $module = $this->getRequest()->getModuleName();
         if ($module === 'default') {
             if ($file === null) {
                 $this->config = Config::app();
             } else {
                 $this->config = Config::app($file);
             }
         } else {
             if ($file === null) {
                 $this->config = Config::module($module);
             } else {
                 $this->config = Config::module($module, $file);
             }
         }
     }
     return $this->config;
 }