Verified Commit a1a5f997 authored by David Kunz's avatar David Kunz

Adding upstream version 2.1.0.

Signed-off-by: David Kunz's avatarDavid Kunz <david.kunz@dknet.ch>
parent 20ee50e8
Pipeline #34144 failed with stages
stages:
- Coding Standards
- Unit-Tests
- Build Packages
variables:
BASE_VERSION: "2.0.0"
VERSION_SUFFIX: "-b${CI_BUILD_ID}-${CI_BUILD_REF_SLUG}"
PSR2 CS Test:
stage: Coding Standards
tags:
- xenial
script:
- phpcs --report-width=auto --report-full --report-gitblame --report-summary -p --standard=PSR2 --extensions=php --encoding=utf-8 -w -s library/Businessprocess/ application/ configuration.php run.php test
Ubuntu Xenial:
stage: Unit-Tests
tags:
- xenial
- businessprocess
script:
- phpunit --testdox --coverage-html=coverage || phpunit --verbose
artifacts:
expire_in: 1 week
name: code-coverage
paths:
- coverage/*
Debian Jessie:
stage: Unit-Tests
tags:
- jessie
- businessprocess
script:
- phpunit --testdox || phpunit --verbose
CentOS 6:
stage: Unit-Tests
tags:
- centos6
- businessprocess
script:
- phpunit --testdox || phpunit --verbose
CentOS 7:
stage: Unit-Tests
tags:
- centos7
- businessprocess
script:
- phpunit --testdox || phpunit --verbose
Xenial Packages:
stage: Build Packages
tags:
- xenial
- businessprocess
script:
- cp -a packaging/debian debian
- dch --no-conf -U -M --empty -v "${BASE_VERSION}${VERSION_SUFFIX}-${CI_BUILD_REF:0:7}" "Automated build triggered by ${GITLAB_USER_ID} <${GITLAB_USER_EMAIL}>"
- cp LICENSE debian/copyright
- dpkg-buildpackage -us -uc
- mkdir build
- mv ../icingaweb2-module-businessprocess*.deb build/
artifacts:
expire_in: 1 week
paths:
- build/*
Jessie Packages:
stage: Build Packages
tags:
- jessie
- businessprocess
script:
- cp -a packaging/debian debian
- dch --no-conf -U -M --empty -v "${BASE_VERSION}${VERSION_SUFFIX}-${CI_BUILD_REF:0:7}" "Automated build triggered by ${GITLAB_USER_ID} <${GITLAB_USER_EMAIL}>"
- cp LICENSE debian/copyright
- dpkg-buildpackage -us -uc
- mkdir build
- mv ../icingaweb2-module-businessprocess*.deb build/
artifacts:
expire_in: 1 week
paths:
- build/*
language: php
php:
- '5.3'
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- nightly
before_script:
- curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
- wget https://github.com/Icinga/icingaweb2/archive/v2.4.0.tar.gz
- tar xfz v2.4.0.tar.gz
- ln -s icingaweb2-2.4.0/library/Icinga
- ln -s icingaweb2-2.4.0/library/vendor/Zend
script:
- php phpcs.phar --report-width=auto --report-full --report-gitblame --report-summary -p --standard=PSR2 --extensions=php --encoding=utf-8 -w -s library/Businessprocess/ application/ configuration.php run.php test
- phpunit --testdox || phpunit --verbose
This diff is collapsed.
Business Processes - Icinga Web 2 module
========================================
If you want to visualize and monitor hierarchical business processes based on
any or all objects monitored by Icinga, the Icinga Web 2 business process
module is the way to go.
[![Tile View](doc/screenshot/00_preview/0005_preview-smaller-tile-view.png)](doc/13-Web-Components-Tile-Renderer.md)
[![Tree View](doc/screenshot/00_preview/0006_preview-smaller-tree-view.png)](doc/14-Web-Components-Tree-Renderer.md)
[![Dashboard](doc/screenshot/00_preview/0007_preview-smallerbusinessprocesses-on-dashboard.png)](doc/16-Add-To-Dashboard.md)
Want to create custom process-based dashboards? Trigger notifications at
process or sub-process level? Provide a quick top-level view for thousands of
components on a single screen? That's what this module has been designed for!
You're running a huge cloud, want to get rid of the monitoring noise triggered
by your auto-scaling platform but still want to have detailed information just
a couple of clicks away in case you need them? You will love this little module!
[![Build Status](https://travis-ci.org/Icinga/icingaweb2-module-businessprocess.svg?branch=master)](https://travis-ci.org/Icinga/icingaweb2-module-businessprocess)
Documentation
-------------
### Basics
* [Installation](doc/01-Installation.md)
* [Getting Started](doc/02-Getting-Started.md)
* [Create your first process node](doc/03-Create-your-first-process-node.md)
### Web Components
* [Breadcrumb](doc/12-Web-Components-Breadcrumb.md)
* [Tile Renderer](doc/13-Web-Components-Tile-Renderer.md)
* [Tree Renderer](doc/14-Web-Components-Tree-Renderer.md)
* [Show Processes on a Dashboard](doc/16-Add-To-Dashboard.md)
### Storage
* [Store your Configuration](doc/21-Store-Config.md)
* [Upload an existing Configuration](doc/22-Upload-Config.md)
### Monitoring
* [~~Discover the CLI~~](doc/31-Discover-the-CLI.md)
* [~~Create related Service Checks~~](doc/32-Create-Service-Checks.md)
### Business Impact
* [~~Apply Simulations~~](doc/41-Simulations.md)
* [~~Show Business Impact~~](doc/42-Business-Impact.md)
### The Project
* [Project History](doc/81-History.md)
* [Changelog](doc/82-Changelog.md)
* [Contributing](doc/84-Contributing.md)
<?php
namespace Icinga\Module\Businessprocess\Clicommands;
class CheckCommand extends ProcessCommand
{
public function listActions()
{
return array('process');
}
/**
* 'check process' is DEPRECATED, please use 'process check' instead
*
* USAGE
*
* icingacli businessprocess check process [--config <name>] <process>
*/
public function processAction()
{
$this->checkAction();
}
}
<?php
namespace Icinga\Module\Businessprocess\Clicommands;
use Icinga\Cli\Command;
use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\HostNode;
use Icinga\Module\Businessprocess\Node;
use Icinga\Module\Businessprocess\State\MonitoringState;
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
class ProcessCommand extends Command
{
/**
* @var LegacyStorage
*/
protected $storage;
protected $hostColors = array(
0 => array('black', 'lightgreen'),
1 => array('lightgray', 'lightred'),
2 => array('black', 'brown'),
99 => array('black', 'lightgray'),
);
protected $serviceColors = array(
0 => array('black', 'lightgreen'),
1 => array('black', 'yellow'),
2 => array('lightgray', 'lightred'),
3 => array('black', 'lightpurple'),
99 => array('black', 'lightgray'),
);
public function init()
{
$this->storage = new LegacyStorage($this->Config()->getSection('global'));
}
/**
* List all available Business Process Configurations
*
* ...or their BusinessProcess Nodes in case a Configuration name is given
*
* USAGE
*
* icingacli businessprocess list processes [<config-name>] [options]
*
* OPTIONS
*
* <config-name>
* --no-title Show only names and no related title
*/
public function listAction()
{
if ($config = $this->params->shift()) {
$this->listBpNames($this->storage->loadProcess($config));
} else {
$this->listConfigNames(! (bool) $this->params->shift('no-title'));
}
}
/**
* Check a specific process
*
* USAGE
*
* icingacli businessprocess process check <process> [options]
*
* OPTIONS
*
* --config <configname> Name of the config that contains <process>
* --details Show problem details as a tree
* --colors Show colored output
* --state-type <type> Define which state type to look at. Could be
* either soft or hard, overrides an eventually
* configured default
*/
public function checkAction()
{
$name = $this->params->get('config');
if ($name === null) {
$name = $this->getFirstProcessName();
}
$bp = $this->storage->loadProcess($name);
if (null !== ($stateType = $this->params->get('state-type'))) {
if ($stateType === 'soft') {
$bp->useSoftStates();
}
if ($stateType === 'hard') {
$bp->useHardStates();
}
}
/** @var BpNode $node */
$node = $bp->getNode($this->params->shift());
MonitoringState::apply($bp);
if ($bp->hasErrors()) {
printf(
"Checking Business Process %s failed: %s\n",
$node->getAlias(),
implode("\n", $bp->getErrors())
);
exit(3);
}
printf("Business Process %s: %s\n", $node->getStateName(), $node->getAlias());
if ($this->params->shift('details')) {
echo $this->renderProblemTree($node->getProblemTree(), $this->params->shift('colors'));
}
exit($node->getState());
}
protected function listConfigNames($withTitle)
{
foreach ($this->storage->listProcesses() as $key => $title) {
if ($withTitle) {
echo $title . "\n";
} else {
echo $key . "\n";
}
}
}
protected function listBpNames(BpConfig $config)
{
foreach ($config->listBpNodes() as $title) {
echo $title . "\n";
}
}
protected function renderProblemTree($tree, $useColors = false, $depth = 0)
{
$output = '';
foreach ($tree as $name => $subtree) {
/** @var Node $node */
$node = $subtree['node'];
if ($node instanceof HostNode) {
$colors = $this->hostColors[$node->getState()];
} else {
$colors = $this->serviceColors[$node->getState()];
}
$state = sprintf('[%s]', $node->getStateName());
if ($useColors) {
$state = $this->screen->colorize($state, $colors[0], $colors[1]);
}
$output .= sprintf(
"%s%s %s %s\n",
str_repeat(' ', $depth),
$node instanceof BpNode ? $node->getOperator() : '-',
$state,
$node->getAlias()
);
$output .= $this->renderProblemTree($subtree['children'], $useColors, $depth + 1);
}
return $output;
}
protected function getFirstProcessName()
{
$list = $this->storage->listProcessNames();
return key($list);
}
}
<?php
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Module\Businessprocess\Web\Controller;
use Icinga\Module\Businessprocess\Web\Component\Dashboard;
class IndexController extends Controller
{
/**
* Show an overview page
*/
public function indexAction()
{
$this->setTitle($this->translate('Business Process Overview'));
$this->controls()->add($this->overviewTab());
$this->content()->add(Dashboard::create($this->Auth(), $this->storage()));
$this->setAutorefreshInterval(15);
}
}
<?php
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Module\Businessprocess\Renderer\Breadcrumb;
use Icinga\Module\Businessprocess\Renderer\TileRenderer;
use Icinga\Module\Businessprocess\Simulation;
use Icinga\Module\Businessprocess\State\MonitoringState;
use Icinga\Module\Businessprocess\Web\Controller;
use Icinga\Module\Businessprocess\Web\Url;
class NodeController extends Controller
{
public function impactAction()
{
$this->setAutorefreshInterval(10);
$content = $this->content();
$this->controls()->add(
$this->singleTab($this->translate('Node Impact'))
);
$name = $this->params->get('name');
$this->addTitle($this->translate('Business Impact (%s)'), $name);
$simulation = Simulation::fromSession($this->session());
foreach ($this->storage()->listProcessNames() as $configName) {
$config = $this->storage()->loadProcess($configName);
// TODO: Fix issues with children, they do not exist unless resolved :-/
// This is a workaround:
foreach ($config->getRootNodes() as $node) {
$node->getState();
}
foreach ($config->getRootNodes() as $node) {
$node->clearState();
}
if (! $config->hasNode($name)) {
continue;
}
MonitoringState::apply($config);
$config->applySimulation($simulation);
foreach ($config->getNode($name)->getPaths() as $path) {
array_pop($path);
$node = array_pop($path);
$renderer = new TileRenderer($config, $config->getNode($node));
$renderer->setUrl(
Url::fromPath(
'businessprocess/process/show',
array('config' => $configName)
)
)->setPath($path);
$bc = Breadcrumb::create($renderer);
$bc->attributes()->set('data-base-target', '_next');
$content->add($bc);
}
}
}
}
This diff is collapsed.
This diff is collapsed.
<?php
namespace Icinga\Module\Businessprocess\Forms;
use Icinga\Authentication\Auth;
use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\Web\Form\BpConfigBaseForm;
class BpConfigForm extends BpConfigBaseForm
{
protected $deleteButtonName;
public function setup()
{
$this->addElement('text', 'name', array(
'label' => $this->translate('Name'),
'required' => true,
'validators' => array(
array(
'validator' => 'StringLength',
'options' => array(
'min' => 2,
'max' => 40
)
),
array(
'validator' => 'Regex',
'options' => array(
'pattern' => '/^[a-zA-Z0-9](?:[a-zA-Z0-9 ._-]*)?[a-zA-Z0-9_]$/'
)
)
),
'description' => $this->translate(
'This is the unique identifier of this process'
),
));
$this->addElement('text', 'Title', array(
'label' => $this->translate('Title'),
'description' => $this->translate(
'Usually this title will be shown for this process. Equals name'
. ' if not given'
),
));
$this->addElement('textarea', 'Description', array(
'label' => $this->translate('Description'),
'description' => $this->translate(
'A slightly more detailed description for this process, about 100-150 characters long'
),
'rows' => 4,
));
$this->addElement('select', 'Backend', array(
'label' => $this->translate('Backend'),
'description' => $this->translate(
'Icinga Web Monitoring Backend where current object states for'
. ' this process should be retrieved from'
),
'multiOptions' => array(
null => $this->translate('Use the configured default backend'),
) + $this->listAvailableBackends()
));
$this->addElement('select', 'Statetype', array(
'label' => $this->translate('State Type'),
'required' => true,
'description' => $this->translate(
'Whether this process should be based on Icinga hard or soft states'
),
'multiOptions' => array(
'soft' => $this->translate('Use SOFT states'),
'hard' => $this->translate('Use HARD states'),
)
));
$this->addElement('select', 'AddToMenu', array(
'label' => $this->translate('Add to menu'),
'required' => true,
'description' => $this->translate(
'Whether this process should be linked in the main Icinga Web 2 menu'
),
'multiOptions' => array(
'yes' => $this->translate('Yes'),
'no' => $this->translate('No'),
)
));
if ($this->config === null) {
$this->setSubmitLabel(
$this->translate('Add')
);
} else {
$config = $this->config;
$meta = $config->getMetadata();
foreach ($meta->getProperties() as $k => $v) {
if ($el = $this->getElement($k)) {
$el->setValue($v);
}
}
$this->getElement('name')
->setValue($config->getName())
->setAttrib('readonly', true);
$this->setSubmitLabel(
$this->translate('Store')
);
$label = $this->translate('Delete');
$el = $this->createElement('submit', $label, array(
'data-base-target' => '_main'
))->setLabel($label)->setDecorators(array('ViewHelper'));
$this->deleteButtonName = $el->getName();
$this->addElement($el);
}
}
protected function onRequest()
{
$name = $this->getValue('name');
if ($this->shouldBeDeleted()) {
$this->config->clearAppliedChanges();
$this->storage->deleteProcess($name);
$this->setSuccessUrl('businessprocess');
$this->redirectOnSuccess(sprintf('Process %s has been deleted', $name));
}
}
public function onSuccess()
{
$name = $this->getValue('name');
if ($this->config === null) {
// New config
$config = new BpConfig();
$config->setName($name);
if (! $this->prepareMetadata($config)) {
return;
}
$this->setSuccessUrl(
$this->getSuccessUrl()->setParams(
array('config' => $name, 'unlocked' => true)
)
);
$this->setSuccessMessage(sprintf('Process %s has been created', $name));
} else {
$config = $this->config;
$this->setSuccessMessage(sprintf('Process %s has been stored', $name));
}
$meta = $config->getMetadata();
foreach ($this->getValues() as $key => $value) {
if ($value === null || $value === '') {
continue;
}
if ($meta->hasKey($key)) {
$meta->set($key, $value);
}
}
$this->storage->storeProcess($config);
$config->clearAppliedChanges();
$this->setSuccessUrl('businessprocess/process/show', array('config' => $name));
parent::onSuccess();
}
public function hasDeleteButton()
{
return $this->deleteButtonName !== null;
}
public function shouldBeDeleted()
{
if (! $this->hasDeleteButton()) {
return false;
}
$name = $this->deleteButtonName;
return $this->getSentValue($name) === $this->getElement($name)->getLabel();
}
}