本文整理汇总了PHP中Centreon\Internal\Di类的典型用法代码示例。如果您正苦于以下问题:PHP Di类的具体用法?PHP Di怎么用?PHP Di使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Di类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @param \CentreonConfiguration\Events\EngineProcess $event
* @throws \Centreon\Internal\Exception
* @todo send command to centreon.d
*/
public static function execute(EngineProcessEvent $event)
{
/*$action = $event->getAction();
if (!in_array($action, array('reload', 'restart', 'forcereload'))) {
throw new Exception(sprintf('Invalid action for Engine: %s', $action));
}
$engineParams = Engine::get($event->getPollerId(), 'init_script');
if (!isset($engineParams['init_script'])) {
throw new Exception(sprintf("Could not find init script for poller %s", $event->getPollerId()));
}
$initScript = $engineParams['init_script'];
$command = "sudo {$initScript} {$action} 2>&1";
$status = 0;
$output = array();
exec($command, $output, $status);
foreach ($output as $line) {
$event->setOutput($line);
}
$event->setStatus(
$status ? false : true
);*/
$action = $event->getAction();
if ($action == "restart") {
$cmd = "[%u] RESTART_PROGRAM\n";
} else {
if ($action == "reload") {
$cmd = "[%u] RELOAD_PROGRAM\n";
} else {
throw new \Exception("Bad type of command.");
}
}
$extCommand = new ExternalCommand($event->getPollerId(), sprintf($cmd, time()), 'engine');
Di::getDefault()->get('events')->emit('centreon-realtime.command.send', array($extCommand));
}
开发者ID:NicolasLarrouy,项目名称:centreon,代码行数:39,代码来源:EngineProcess.php
示例2: addValidation
/**
*
* @param array $element
* @return array
*/
public static function addValidation($element)
{
$validations = parent::addValidation($element);
$validationUrl = Di::getDefault()->get('router')->getPathFor('/validator/email');
$validations['eventValidation'] .= ' $("#' . $element['name'] . '").on("blur", function() {
$.ajax({
url: "' . $validationUrl . '",
type: "POST",
data: {"email":$("#' . $element['name'] . '").val()},
context: document.body
})
.success(function(data, status, jqxhr) {
if (data.success) {
$("#' . $element['name'] . '_email").removeClass("has-error has-feedback");
$("#' . $element['name'] . '_email_span").removeClass("glyphicon glyphicon-remove form-control-feedback");
$("#' . $element['name'] . '_email").addClass("has-success has-feedback");
$("#' . $element['name'] . '_email_span").addClass("glyphicon glyphicon-ok form-control-feedback");
} else {
$("#' . $element['name'] . '_email").removeClass("has-error has-feedback");
$("#' . $element['name'] . '_email_span").removeClass("glyphicon glyphicon-ok form-control-feedback");
$("#' . $element['name'] . '_email").addClass("has-error has-feedback");
$("#' . $element['name'] . '_email_span").addClass("glyphicon glyphicon-remove form-control-feedback");
}
});
});';
return $validations;
}
开发者ID:rk4an,项目名称:centreon,代码行数:32,代码来源:Email.php
示例3: execute
public static function execute(SlideMenuEvent $event)
{
$router = Di::getDefault()->get('router');
try {
$event->setDefaultMenu(array('name' => 'service', 'url' => $router->getPathFor('/centreon-configuration/service/snapshotslide/') . $event->getId(), 'icon' => '', 'order' => 0, 'tpl' => "/viewtpl/CentreonConfigurationModule/service_slide"));
$event->addMenu(array('name' => 'template', 'url' => $router->getPathFor('/centreon-configuration/servicetemplate/viewconfslide/') . $event->getId(), 'icon' => '', 'order' => 2, 'tpl' => "/viewtpl/CentreonConfigurationModule/service_templates_slide"));
$event->addMenu(array('name' => 'tag', 'url' => $router->getPathFor('/centreon-configuration/service/' . $event->getId() . '/tags'), 'icon' => '', 'order' => 1, 'tpl' => "/viewtpl/CentreonConfigurationModule/tags_slide", 'default' => 1));
/*
$event->addMenu(
array(
'name' => 'service',
'url' => $router->getPathFor('/centreon-configuration/host/'.$event->getId().'/service'),
'icon' => '',
'order' => 4,
'tpl' => "/viewtpl/CentreonConfigurationModule/services_slide"
)
);
$event->addMenu(
array(
'name' => 'command',
'url' => $router->getPathFor('/centreon-configuration/host/'.$event->getId().'/command'),
'icon' => '',
'order' => 5,
'tpl' => "/viewtpl/CentreonConfigurationModule/command_slide"
)
);
*/
} catch (Exception $e) {
}
}
开发者ID:rk4an,项目名称:centreon,代码行数:31,代码来源:SlideMenuService.php
示例4: generate
/**
* Generate modules configuration files
* @param array $filesList
* @param int $pollerId
* @param string $path
* @param object $event
* @return value
*/
public function generate(&$filesList, $pollerId, $path, $event)
{
$di = Di::getDefault();
/* Get Database Connexion */
$dbconn = $di->get('db_centreon');
$modules = array();
/* Retrieve broker modules */
$events = Di::getDefault()->get('events');
$moduleEvent = new BrokerModuleEvent($pollerId);
$events->emit('centreon-configuration.broker.module', array($moduleEvent));
$brokerModules = $moduleEvent->getModules();
foreach ($brokerModules as $brokerModule) {
$modules[]['broker_module'] = $brokerModule;
}
/* External command module */
$moduleDir = Engine::getParameters($pollerId, 'module_dir');
$modules[]['broker_module'] = rtrim($moduleDir['module_dir'], '/') . '/externalcmd.so';
/* Write modules configuration files */
foreach ($modules as $module) {
$filename = preg_match('/\\/?(\\w+)\\.so/', $module['broker_module'], $matches);
if (!empty($matches[1])) {
WriteConfigFile::writeParamsFile($module, $path . $pollerId . "/conf.d/" . $matches[1] . '.cfg', $filesList, $user = "API");
}
}
}
开发者ID:NicolasLarrouy,项目名称:centreon,代码行数:33,代码来源:ConfigGenerateModulesRepository.php
示例5: execute
/**
*
* @param \CentreonConfiguration\Events\RunTest $event
*/
public static function execute(RunTestEvent $event)
{
$di = Di::getDefault();
$dbconn = $di->get('db_centreon');
$tmpdir = $di->get('config')->get('global', 'centreon_generate_tmp_dir');
$pollerId = $event->getPollerId();
$enginePath = '/usr/sbin/centengine';
$path = "{$tmpdir}/engine/generate/{$pollerId}/centengine-testing.cfg";
$command = "sudo {$enginePath} -v {$path} 2>&1";
exec($command, $output, $status);
if ($status == 0) {
// We are only selecting warning/errors here
// Colors/formatting is performed either in Command (centreonConsole) or JS (web => API thru JSON)
foreach ($output as $out) {
if (preg_match("/warning|error/i", $out)) {
$out = preg_replace("/\\[\\d+\\] /", "", $out);
$event->setOutput($out);
}
}
} else {
$event->setOutput('Error while executing test command');
foreach ($output as $out) {
$event->setOutput($out);
}
}
}
开发者ID:NicolasLarrouy,项目名称:centreon,代码行数:30,代码来源:RunTest.php
示例6: pollerStatus
public function pollerStatus()
{
$router = Di::getDefault()->get('router');
$orgId = Di::getDefault()->get('organization');
$dbconn = Di::getDefault()->get('db_centreon');
$query = 'SELECT c.name, r.last_alive, r.running, r.instance_id
FROM cfg_pollers c
LEFT OUTER JOIN rt_instances r
ON r.instance_id = c.poller_id
WHERE c.organization_id = :org_id';
$stmt = $dbconn->prepare($query);
$stmt->bindParam(':org_id', $orgId, \PDO::PARAM_INT);
$stmt->execute();
$now = time();
$pollers = array();
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$row['latency'] = 0;
if (is_null($row['last_alive']) || $row['last_alive'] - $now > 60) {
$row['disconnect'] = 1;
} else {
$row['disconnect'] = 0;
}
$pollers[] = $row;
}
return $pollers;
}
开发者ID:rk4an,项目名称:centreon,代码行数:26,代码来源:PollerRepository.php
示例7: getUseNumber
/**
*
* @param int $id
* @param string $object
* @return string
*/
public static function getUseNumber($id, $object)
{
$di = Di::getDefault();
/* Get Database Connexion */
$dbconn = $di->get('db_centreon');
$result = "";
if ($object == 'host') {
$objectTable = 'cfg_hosts';
} elseif ($object == 'service') {
$objectTable = 'cfg_services';
}
/* Get Object Stats */
for ($i = 1; $i != -1; $i--) {
$stmt = $dbconn->prepare("SELECT count(*) AS number " . "FROM {$objectTable} " . "WHERE (command_command_id = '{$id}' " . "OR command_command_id2 = '{$id}') " . "AND " . $object . "_register = '{$i}'");
$stmt->execute();
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
if (isset($row["number"])) {
if ($i) {
$result .= $row["number"];
} else {
$result .= " (" . $row["number"] . ")";
}
}
}
return $result;
}
开发者ID:rk4an,项目名称:centreon,代码行数:32,代码来源:CommandRepository.php
示例8: __construct
/**
* Constructor
*
* @param int $serviceId The service ID
* @param int $startTime The start time for graph
* @param int $endTime The end time for graph
*/
public function __construct($serviceId, $startTime, $endTime)
{
$di = Di::getDefault();
$dbconn = $di->get('db_centreon');
/* Get the list of metrics */
$query = "SELECT i.index_id, i.service_description, m.metric_id, m.metric_name, m.unit_name, m.warn, m.warn_low, m.crit, m.crit_low, m.min, m.max\n FROM rt_index_data i, rt_metrics m\n WHERE i.service_id = :service_id\n AND i.index_id = m.index_id\n AND m.hidden = '0'";
$stmt = $dbconn->prepare($query);
$stmt->bindParam(':service_id', $serviceId);
$stmt->execute();
/* List of service template */
$svcTmpls = ServiceRepository::getListTemplates($serviceId);
/* Get the graph template */
$graphInfos = null;
foreach ($svcTmpls as $svcTmplId) {
$graphInfos = GraphTemplate::getByServiceTemplate($svcTmplId);
if (count($graphInfos) > 0) {
break;
}
}
while ($row = $stmt->fetch()) {
$metric = array('id' => $row['metric_id'], 'unit' => $row['unit_name'], 'color' => null, 'legend' => $row['metric_name'], 'is_negative' => false, 'graph_type' => 'line');
if (count($graphInfos) > 0 && isset($graphInfos['metrics'][$row['metric_name']])) {
$metric = array_merge($metric, $graphInfos['metrics'][$row['metric_name']]);
}
$this->metrics[] = $metric;
}
parent::__construct($startTime, $endTime);
}
开发者ID:rk4an,项目名称:centreon,代码行数:35,代码来源:Service.php
示例9: doCommand
/**
* Send command for each object returned by the sql query.
*
* @param int $cmdId
* @param str $sql
* @param array $additionalParams
*/
public static function doCommand($cmdId, $sql, $additionalParams)
{
$db = Di::getDefault()->get('db_centreon');
$stmt = $db->prepare($sql);
$stmt->execute();
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
switch ($cmdId) {
case static::SCHEDULE_CHECK:
$options = array(time());
break;
case static::ACKNOWLEDGE:
$options = array(isset($additionalParams['sticky']) ? 1 : 0, isset($additionalParams['notify']) ? $additionalParams['notify'] : 0, isset($additionalParams['persistent']) ? 1 : 0, $additionalParams['author'], $additionalParams['comment']);
break;
case static::DOWNTIME:
$options = array($additionalParams['start_time'], $additionalParams['end_time'], isset($additionalParams['fixed']) ? 1 : 0, 0, isset($additionalParams['fixed']) ? 0 : $additionalParams['duration'], $additionalParams['author'], $additionalParams['comment']);
break;
case static::REMOVE_ACKNOWLEDGE:
break;
case static::REMOVE_DOWNTIME:
break;
default:
$options = array();
break;
}
$instanceId = $row['instance_id'];
unset($row['instance_id']);
self::sendCommand($cmdId, $instanceId, array_merge($row, $options));
}
}
开发者ID:rk4an,项目名称:centreon,代码行数:36,代码来源:ObjectdetailRepository.php
示例10: formatDatas
/**
*
* @param array $resultSet
*/
protected function formatDatas(&$resultSet)
{
$previousType = '';
foreach ($resultSet as &$myBaSet) {
$sideMenuCustom = new SlideMenu($myBaSet['ba_id']);
$events = Di::getDefault()->get('events');
$events->emit('centreon-bam.slide.menu.business.activity', array($sideMenuCustom));
$myBaSet['DT_RowData']['right_side_menu_list'] = $sideMenuCustom->getMenu();
$myBaSet['DT_RowData']['right_side_default_menu'] = $sideMenuCustom->getDefaultMenu();
// Set business activity type
$baType = \CentreonBam\Models\BusinessActivityType::getParameters($myBaSet['ba_type_id'], array('name'));
$myBaSet['ba_type_id'] = $baType['name'];
if ($myBaSet['ba_type_id'] === $previousType) {
$myBaSet['ba_type_id'] = '';
} else {
$previousType = $myBaSet['ba_type_id'];
}
// set business activity name
$myBaSet['name'] = BusinessActivityRepository::getIconImage($myBaSet['name']) . $myBaSet['name'];
/* Tags */
$myBaSet['tagname'] = "";
$aTags = TagsRepository::getList('ba', $myBaSet['ba_id'], 2);
foreach ($aTags as $oTags) {
$myBaSet['tagname'] .= TagsRepository::getTag('ba', $myBaSet['ba_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], $oTags['template_id']);
}
$myBaSet['tagname'] .= TagsRepository::getAddTag('ba', $myBaSet['ba_id']);
}
}
开发者ID:rk4an,项目名称:centreon,代码行数:32,代码来源:BusinessActivityDatatable.php
示例11: __construct
/**
*
* @param int $pollerId
* @return type
*/
public function __construct($pollerId)
{
$this->di = Di::getDefault();
$this->output = array();
$this->pollerId = $pollerId;
$this->status = true;
}
开发者ID:rk4an,项目名称:centreon,代码行数:12,代码来源:ConfigRepositoryAbstract.php
示例12: addValidation
/**
*
* @param array $element
* @return array
*/
public static function addValidation($element)
{
$validations = parent::addValidation($element);
$resolveUrl = Di::getDefault()->get('router')->getPathFor('/validator/resolvedns');
$validations['eventValidation']['extraJs'] = '$("#' . $element['name'] . '_resolve_dns").on("click", function(){
$.ajax({
url: "' . $resolveUrl . '",
type: "POST",
data: {"dnsname":$("#' . $element['name'] . '").val()},
dataType: "json",
context: document.body
})
.success(function(data, status, jqxhr) {
alertClose();
if (data["success"]) {
$("#' . $element['name'] . '").val(data["value"]);
$("#' . $element['name'] . '").trigger("blur");
} else {
alertMessage(data["error"], "alert-danger");
}
});
});';
$validations['eventValidation'][$element['name']] = array('ipaddress' => array());
return $validations;
}
开发者ID:NicolasLarrouy,项目名称:centreon,代码行数:30,代码来源:Ipaddress.php
示例13: migrateCentreon
/**
*
*/
public static function migrateCentreon()
{
if (!self::checkForMigration()) {
Install::installCentreon();
} else {
$di = Di::getDefault();
$config = $di->get('config');
$dbName = $config->get('db_centreon', 'dbname');
echo Colorize::colorizeMessage("Starting to migrate to Centreon 3.0", "info") . "\n";
echo "Preparing Migration... ";
self::prepareDb();
echo Colorize::colorizeText('Done', 'green', 'black', true) . "\n";
echo "Migrating " . Colorize::colorizeText('centreon', 'blue', 'black', true) . " database... ";
Db::update($dbName);
echo Colorize::colorizeText('Done', 'green', 'black', true) . "\n";
$modulesToInstall = self::getCoreModules();
$dependencyResolver = new Dependency($modulesToInstall['modules']);
$installOrder = $dependencyResolver->resolve();
foreach ($installOrder as $moduleName) {
$currentModule = $modulesToInstall['modules'][$moduleName];
$moduleInstaller = new $currentModule['classCall']($currentModule['directory'], $currentModule['infos'], 'console');
echo "Installing " . Colorize::colorizeText($moduleName, 'purple', 'black', true) . " module... ";
$moduleInstaller->install(false);
echo Colorize::colorizeText('Done', 'green', 'black', true) . "\n";
}
echo Colorize::colorizeMessage("Your Centreon has been successfully migrated to Centreon 3.0", "success") . "\n";
}
}
开发者ID:rk4an,项目名称:centreon,代码行数:31,代码来源:Migrate.php
示例14: smarty_modifier_url
function smarty_modifier_url($url)
{
$di = \Centreon\Internal\Di::getDefault();
$config = $di->get('config');
$fullUrl = rtrim($config->get('global', 'base_url'), '/') . $url;
return $fullUrl;
}
开发者ID:rk4an,项目名称:centreon,代码行数:7,代码来源:modifier.url.php
示例15: updateAction
/**
*
* @cmdForm /centreon-administration/aclresource/update optional
* @cmdObject string aclresource the acl resource
* @cmdParam boolean|true all-hosts optional all host
* @cmdParam boolean|true all-bas optional all bas
* @cmdParam boolean|false no-hosts optional no host
* @cmdParam boolean|false no-bas optional no bas
*/
public function updateAction($object, $params)
{
$events = Di::getDefault()->get('events');
$aclTagsEvent = new aclTagsEvent($params);
$events->emit('centreon-administration.acl.tag', array($aclTagsEvent));
$params = $aclTagsEvent->getParams();
parent::updateAction($object, $params);
}
开发者ID:rk4an,项目名称:centreon,代码行数:17,代码来源:AclresourceCommand.php
示例16: listAction
/**
* The page structure for display
*
* @method get
* @route /indicator/realtime/list
*/
public function listAction()
{
$di = Di::getDefault();
$router = $di->get('router');
$myDatatable = new $this->datatableObject($this->getParams('get'), $this->objectClass);
$myDataForDatatable = $myDatatable->getDatas();
$router->response()->json($myDataForDatatable);
}
开发者ID:rk4an,项目名称:centreon,代码行数:14,代码来源:IndicatorRealtimeController.php
示例17: testExecute
public function testExecute()
{
$eventParams = new GenerateEngineEvent(1);
GenerateEngine::execute($eventParams);
$genPath = Di::getDefault()->get('config')->get('global', 'centreon_generate_tmp_dir');
$this->assertFileExists($genPath . "/1/centengine.cfg");
$this->assertFileExists($genPath . "/1/centengine-testing.cfg");
}
开发者ID:NicolasLarrouy,项目名称:centreon,代码行数:8,代码来源:GenerateEngineTest.php
示例18: smarty_modifier_img
function smarty_modifier_img($imgFile)
{
$di = \Centreon\Internal\Di::getDefault();
$config = $di->get('config');
$baseUrl = rtrim($config->get('global', 'base_url'), '/') . '/static/centreon/img/';
$imgIncludeLine = '<img alt="' . $imgFile . '"' . 'src="' . $baseUrl . $imgFile . '" />';
return $imgIncludeLine;
}
开发者ID:NicolasLarrouy,项目名称:centreon,代码行数:8,代码来源:modifier.img.php
示例19: listAction
/**
*
* @method get
* @route /businessactivitytype/configuration
*/
public function listAction()
{
$router = Di::getDefault()->get('router');
$this->tpl->addJs('hogan-3.0.0.min.js');
$urls = array();
$this->tpl->append('jsUrl', $urls, true);
parent::listAction();
}
开发者ID:NicolasLarrouy,项目名称:centreon,代码行数:13,代码来源:BusinessActivityTypeController.php
示例20: listAction
/**
*
* @method get
* @route /businessview/configuration
*/
public function listAction()
{
$router = Di::getDefault()->get('router');
$this->tpl->addJs('hogan-3.0.0.min.js')->addJs('centreon.tag.js', 'bottom', 'centreon-administration');
$urls = array('tag' => array('add' => $router->getPathFor('/centreon-administration/tag/add'), 'del' => $router->getPathFor('/centreon-administration/tag/delete')));
$this->tpl->append('jsUrl', $urls, true);
parent::listAction();
}
开发者ID:rk4an,项目名称:centreon,代码行数:13,代码来源:BusinessViewController.php
注:本文中的Centreon\Internal\Di类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论