parent
5a913881a6
commit
7b55f3a2bd
|
@ -244,18 +244,22 @@ class Manager
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
clearstatcache(true);
|
||||
$target = $this->installedBaseDirs[$name];
|
||||
$link = $this->enableDir . '/' . $name;
|
||||
|
||||
if (!is_writable($this->enableDir)) {
|
||||
throw new SystemPermissionException(
|
||||
'Can not enable module "' . $name . '". '
|
||||
. 'Insufficient system permissions for enabling modules.'
|
||||
);
|
||||
}
|
||||
|
||||
if (file_exists($link) && is_link($link)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!@symlink($target, $link)) {
|
||||
$error = error_get_last();
|
||||
if (strstr($error["message"], "File exists") === false) {
|
||||
|
@ -266,7 +270,12 @@ class Manager
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->enabledDirs[$name] = $link;
|
||||
|
||||
$this->loadModule($name);
|
||||
$this->getModule($name)->launchRegisterScript();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,6 +101,13 @@ class Module
|
|||
*/
|
||||
private $runScript;
|
||||
|
||||
/**
|
||||
* Module initialization script
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $registerScript;
|
||||
|
||||
/**
|
||||
* Module configuration script
|
||||
*
|
||||
|
@ -145,17 +152,18 @@ class Module
|
|||
*/
|
||||
public function __construct(ApplicationBootstrap $app, $name, $basedir)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->name = $name;
|
||||
$this->basedir = $basedir;
|
||||
$this->cssdir = $basedir. '/public/css';
|
||||
$this->libdir = $basedir. '/library';
|
||||
$this->configdir = $basedir. '/config';
|
||||
$this->localedir = $basedir. '/application/locale';
|
||||
$this->formdir = $basedir. '/application/forms';
|
||||
$this->controllerdir = $basedir. '/application/controllers';
|
||||
$this->runScript = $basedir. '/register.php';
|
||||
$this->configScript = $basedir. '/configuration.php';
|
||||
$this->app = $app;
|
||||
$this->name = $name;
|
||||
$this->basedir = $basedir;
|
||||
$this->cssdir = $basedir . '/public/css';
|
||||
$this->libdir = $basedir . '/library';
|
||||
$this->configdir = $basedir . '/config';
|
||||
$this->localedir = $basedir . '/application/locale';
|
||||
$this->formdir = $basedir . '/application/forms';
|
||||
$this->controllerdir = $basedir . '/application/controllers';
|
||||
$this->runScript = $basedir . '/run.php';
|
||||
$this->registerScript = $basedir . '/register.php';
|
||||
$this->configScript = $basedir . '/configuration.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -503,6 +511,16 @@ class Module
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run module registration script
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function launchRegisterScript()
|
||||
{
|
||||
return $this->includeScript($this->registerScript);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run module bootstrap script
|
||||
*
|
||||
|
@ -510,13 +528,26 @@ class Module
|
|||
*/
|
||||
protected function launchRunScript()
|
||||
{
|
||||
if (file_exists($this->runScript)
|
||||
&& is_readable($this->runScript)) {
|
||||
include($this->runScript);
|
||||
return $this->includeScript($this->runScript);
|
||||
}
|
||||
|
||||
/**
|
||||
* Include a php script if it is readable
|
||||
*
|
||||
* @param string $file File to include
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
protected function includeScript($file)
|
||||
{
|
||||
if (is_readable($file) === true) {
|
||||
include($file);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run module config script
|
||||
*/
|
||||
|
|
|
@ -1,48 +1,10 @@
|
|||
<?php
|
||||
/*
|
||||
* register.php
|
||||
*
|
||||
* This file runs only on installation
|
||||
*/
|
||||
|
||||
use Icinga\Authentication\Manager as AuthManager;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Module\Monitoring\DataView\StatusSummary as StatusSummaryView;
|
||||
use Icinga\Web\Topbar;
|
||||
use Icinga\Application\Logger;
|
||||
|
||||
if (Icinga::app()->isCli()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$request = Icinga::app()->getFrontController()->getRequest();
|
||||
|
||||
if (AuthManager::getInstance()->isAuthenticated()) {
|
||||
$hostSummary = StatusSummaryView::fromRequest(
|
||||
$request,
|
||||
array(
|
||||
'hosts_up',
|
||||
'hosts_unreachable_handled',
|
||||
'hosts_unreachable_unhandled',
|
||||
'hosts_down_handled',
|
||||
'hosts_down_unhandled',
|
||||
'hosts_pending'
|
||||
)
|
||||
)->getQuery()->fetchRow();
|
||||
|
||||
$serviceSummary = StatusSummaryView::fromRequest(
|
||||
$request,
|
||||
array(
|
||||
'services_ok',
|
||||
'services_critical_handled',
|
||||
'services_critical_unhandled',
|
||||
'services_warning_handled',
|
||||
'services_warning_unhandled',
|
||||
'services_unknown_handled',
|
||||
'services_unknown_unhandled',
|
||||
'services_pending'
|
||||
)
|
||||
)->getQuery()->fetchRow();
|
||||
|
||||
Topbar::addPartial(
|
||||
'topbar.phtml',
|
||||
'monitoring',
|
||||
array('hostSummary' => $hostSummary, 'serviceSummary' => $serviceSummary)
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
Logger::debug('Monitor/register');
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
/*
|
||||
* run.php
|
||||
*
|
||||
* This file runs every request to register runtime functionality
|
||||
*
|
||||
*/
|
||||
use Icinga\Application\Logger;
|
||||
|
||||
Logger::debug('Monitor/run');
|
Loading…
Reference in New Issue