mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-20 23:00:16 -05:00
CLI: Add options --downtime-is-ok and --ack-is-ok
This commit is contained in:
parent
1414e76d94
commit
8ef1dfcbdc
2 changed files with 61 additions and 12 deletions
|
|
@ -60,6 +60,17 @@ class ProcessCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function listConfigNames($withTitle)
|
||||||
|
{
|
||||||
|
foreach ($this->storage->listProcesses() as $key => $title) {
|
||||||
|
if ($withTitle) {
|
||||||
|
echo $title . "\n";
|
||||||
|
} else {
|
||||||
|
echo $key . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check a specific process
|
* Check a specific process
|
||||||
*
|
*
|
||||||
|
|
@ -81,6 +92,10 @@ class ProcessCommand extends Command
|
||||||
* --root-cause Used in combination with --blame. Only shows
|
* --root-cause Used in combination with --blame. Only shows
|
||||||
* the path of the nodes which are responsible for
|
* the path of the nodes which are responsible for
|
||||||
* the state of the business process
|
* the state of the business process
|
||||||
|
* --downtime-is-ok Treat hosts/services in downtime always as
|
||||||
|
* UP/OK.
|
||||||
|
* --ack-is-ok Treat acknowledged hosts/services always as
|
||||||
|
* UP/OK.
|
||||||
*/
|
*/
|
||||||
public function checkAction()
|
public function checkAction()
|
||||||
{
|
{
|
||||||
|
|
@ -112,6 +127,14 @@ class ProcessCommand extends Command
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->params->shift('ack-is-ok')) {
|
||||||
|
Node::setAckIsOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->params->shift('downtime-is-ok')) {
|
||||||
|
Node::setDowntimeIsOk();
|
||||||
|
}
|
||||||
|
|
||||||
printf("Business Process %s: %s\n", $node->getStateName(), $node->getAlias());
|
printf("Business Process %s: %s\n", $node->getStateName(), $node->getAlias());
|
||||||
if ($this->params->shift('details')) {
|
if ($this->params->shift('details')) {
|
||||||
echo $this->renderProblemTree($node->getProblemTree(), $this->params->shift('colors'));
|
echo $this->renderProblemTree($node->getProblemTree(), $this->params->shift('colors'));
|
||||||
|
|
@ -126,17 +149,6 @@ class ProcessCommand extends Command
|
||||||
exit($node->getState());
|
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)
|
protected function listBpNames(BpConfig $config)
|
||||||
{
|
{
|
||||||
foreach ($config->listBpNodes() as $title) {
|
foreach ($config->listBpNodes() as $title) {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,12 @@ abstract class Node
|
||||||
const ICINGA_UNREACHABLE = 2;
|
const ICINGA_UNREACHABLE = 2;
|
||||||
const ICINGA_PENDING = 99;
|
const ICINGA_PENDING = 99;
|
||||||
|
|
||||||
|
/** @var bool Whether to treat acknowledged hosts/services always as UP/OK */
|
||||||
|
protected static $ackIsOk = false;
|
||||||
|
|
||||||
|
/** @var bool Whether to treat hosts/services in downtime always as UP/OK */
|
||||||
|
protected static $downtimeIsOk = false;
|
||||||
|
|
||||||
protected $sortStateToStateMap = array(
|
protected $sortStateToStateMap = array(
|
||||||
4 => self::ICINGA_CRITICAL,
|
4 => self::ICINGA_CRITICAL,
|
||||||
3 => self::ICINGA_UNKNOWN,
|
3 => self::ICINGA_UNKNOWN,
|
||||||
|
|
@ -111,6 +117,26 @@ abstract class Node
|
||||||
|
|
||||||
abstract public function __construct($object);
|
abstract public function __construct($object);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether to treat acknowledged hosts/services always as UP/OK
|
||||||
|
*
|
||||||
|
* @param bool $ackIsOk
|
||||||
|
*/
|
||||||
|
public static function setAckIsOk($ackIsOk = true)
|
||||||
|
{
|
||||||
|
self::$ackIsOk = $ackIsOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether to treat hosts/services in downtime always as UP/OK
|
||||||
|
*
|
||||||
|
* @param bool $downtimeIsOk
|
||||||
|
*/
|
||||||
|
public static function setDowntimeIsOk($downtimeIsOk = true)
|
||||||
|
{
|
||||||
|
self::$downtimeIsOk = $downtimeIsOk;
|
||||||
|
}
|
||||||
|
|
||||||
public function setBpConfig(BpConfig $bp)
|
public function setBpConfig(BpConfig $bp)
|
||||||
{
|
{
|
||||||
$this->bp = $bp;
|
$this->bp = $bp;
|
||||||
|
|
@ -219,13 +245,24 @@ abstract class Node
|
||||||
|
|
||||||
public function getSortingState()
|
public function getSortingState()
|
||||||
{
|
{
|
||||||
$sort = $this->stateToSortState($this->getState());
|
$state = $this->getState();
|
||||||
|
|
||||||
|
if (self::$ackIsOk && $this->isAcknowledged()) {
|
||||||
|
$state = self::ICINGA_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self::$downtimeIsOk && $this->isInDowntime()) {
|
||||||
|
$state = self::ICINGA_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sort = $this->stateToSortState($state);
|
||||||
$sort = ($sort << self::SHIFT_FLAGS)
|
$sort = ($sort << self::SHIFT_FLAGS)
|
||||||
+ ($this->isInDowntime() ? self::FLAG_DOWNTIME : 0)
|
+ ($this->isInDowntime() ? self::FLAG_DOWNTIME : 0)
|
||||||
+ ($this->isAcknowledged() ? self::FLAG_ACK : 0);
|
+ ($this->isAcknowledged() ? self::FLAG_ACK : 0);
|
||||||
if (! ($sort & (self::FLAG_DOWNTIME | self::FLAG_ACK))) {
|
if (! ($sort & (self::FLAG_DOWNTIME | self::FLAG_ACK))) {
|
||||||
$sort |= self::FLAG_NONE;
|
$sort |= self::FLAG_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sort;
|
return $sort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue