Skip to content

Commit 5354def

Browse files
committed
Add pending state
1 parent be2b07d commit 5354def

7 files changed

Lines changed: 45 additions & 3 deletions

File tree

library/Cube/CubeRenderer/HostStatusCubeRenderer.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public function createFacts(object $facts): HtmlDocument
3131
$partsObj->hosts_unreachable_unhandled = $facts->hosts_unhandled_unreachable;
3232
}
3333

34+
if (isset($facts->hosts_pending) && $facts->hosts_pending > 0) {
35+
$parts['pending'] = $facts->hosts_pending;
36+
$partsObj->hosts_pending = $facts->hosts_pending;
37+
}
38+
3439
if ($facts->hosts_down > 0 && $facts->hosts_down > $facts->hosts_unhandled_down) {
3540
$downHandled = $facts->hosts_down - $facts->hosts_unhandled_down;
3641

@@ -53,12 +58,17 @@ public function createFacts(object $facts): HtmlDocument
5358
if (
5459
$facts->hosts_cnt > $facts->hosts_down
5560
&& (! isset($facts->hosts_unreachable) || $facts->hosts_cnt > $facts->hosts_unreachable)
61+
&& (! isset($facts->hosts_pending) || $facts->hosts_cnt > $facts->hosts_pending)
5662
) {
5763
$ok = $facts->hosts_cnt - $facts->hosts_down;
5864
if (isset($facts->hosts_unreachable)) {
5965
$ok -= $facts->hosts_unreachable;
6066
}
6167

68+
if (isset($facts->hosts_pending)) {
69+
$ok -= $facts->hosts_pending;
70+
}
71+
6272
$parts['ok'] = $ok;
6373
$partsObj->hosts_up = $ok;
6474
}

library/Cube/CubeRenderer/ServiceStatusCubeRenderer.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public function createFacts(object $facts): HtmlDocument
3636
$partsObj->services_warning_unhandled = $facts->services_unhandled_warning;
3737
}
3838

39+
if (isset($facts->services_pending) && $facts->services_pending > 0) {
40+
$partsObj->services_pending = $facts->services_pending;
41+
}
42+
3943
if ($facts->services_critical > 0 && $facts->services_critical > $facts->services_unhandled_critical) {
4044
$criticalHandled = $facts->services_critical - $facts->services_unhandled_critical;
4145

@@ -61,10 +65,15 @@ public function createFacts(object $facts): HtmlDocument
6165
$facts->services_cnt > $facts->services_critical
6266
&& $facts->services_cnt > $facts->services_warning
6367
&& $facts->services_cnt > $facts->services_unknown
68+
&& (! isset($facts->services_pending) || $facts->services_cnt > $facts->services_pending)
6469
) {
6570
$ok = $facts->services_cnt - $facts->services_critical - $facts->services_warning -
6671
$facts->services_unknown;
6772

73+
if (isset($facts->services_pending)) {
74+
$ok -= $facts->services_pending;
75+
}
76+
6877
$parts['ok'] = $ok;
6978
$partsObj->services_ok = $ok;
7079
}

library/Cube/IcingaDb/IcingaDbHostStatusCube.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Icinga\Module\Icingadb\Model\Host;
99
use Icinga\Module\Icingadb\Model\HoststateSummary;
1010
use ipl\Stdlib\Filter;
11-
use ipl\Stdlib\Str;
1211

1312
class IcingaDbHostStatusCube extends IcingaDbCube
1413
{
@@ -23,6 +22,7 @@ public function getAvailableFactColumns()
2322
'hosts_cnt' => 'hosts_total',
2423
'hosts_down' => 'hosts_down_handled + f.hosts_down_unhandled',
2524
'hosts_unhandled_down' => 'hosts_down_unhandled',
25+
'hosts_pending' => 'hosts_pending',
2626
];
2727
}
2828

library/Cube/IcingaDb/IcingaDbServiceStatusCube.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Icinga\Module\Icingadb\Model\Service;
99
use Icinga\Module\Icingadb\Model\ServicestateSummary;
1010
use ipl\Stdlib\Filter;
11-
use ipl\Stdlib\Str;
1211

1312
class IcingaDbServiceStatusCube extends IcingaDbCube
1413
{
@@ -38,6 +37,7 @@ public function getAvailableFactColumns()
3837
'services_unhandled_warning' => 'services_warning_unhandled',
3938
'services_unknown' => 'services_unknown_handled + f.services_unknown_unhandled',
4039
'services_unhandled_unknown' => 'services_unknown_unhandled',
40+
'services_pending' => 'services_pending'
4141
];
4242
}
4343

library/Cube/Web/Widget/HostDimensionWidget.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ protected function getDimensionClasses(): array
4040
$severityClass = ['critical'];
4141
} elseif (isset($sums->hosts_unhandled_unreachable) && $sums->hosts_unhandled_unreachable > 0) {
4242
$severityClass = ['unreachable'];
43+
} elseif (isset($sums->hosts_pending) && $sums->hosts_pending > 0) {
44+
$severityClass = ['pending'];
4345
} elseif ($sums->hosts_down > 0) {
4446
$severityClass = ['critical', 'handled'];
4547
} elseif (isset($sums->hosts_unreachable) && $sums->hosts_unreachable > 0) {

library/Cube/Web/Widget/ServiceDimensionWidget.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ protected function getDimensionClasses(): array
4242
$severityClass = ['unknown'];
4343
} elseif ($sums->services_unhandled_warning > 0) {
4444
$severityClass = ['warning'];
45+
} elseif (isset($sums->services_pending) && $sums->services_pending > 0) {
46+
$severityClass = ['pending'];
4547
} elseif ($sums->services_critical > 0) {
4648
$severityClass = ['critical', 'handled'];
4749
} elseif ($sums->services_unknown > 0) {

public/css/module.less

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ div.cube {
6464
}
6565
}
6666

67+
&.pending {
68+
> .header {
69+
color: @color-pending;
70+
border-color: @color-pending;
71+
}
72+
}
73+
6774
&.ok {
6875
> .header {
6976
color: @color-ok;
@@ -140,6 +147,10 @@ div.cube {
140147
}
141148
}
142149

150+
&.pending {
151+
border-left-color: @color-pending;
152+
}
153+
143154
&.ok {
144155
border-left-color: @color-ok;
145156
}
@@ -202,6 +213,10 @@ div.cube {
202213
}
203214
}
204215

216+
&.pending {
217+
background: @color-pending;
218+
}
219+
205220
&.ok {
206221
background: @color-ok;
207222
}
@@ -218,7 +233,7 @@ div.cube {
218233
}
219234

220235
span {
221-
&.critical, &.warning, &.unknown, &.unreachable, &.ok {
236+
&.critical, &.warning, &.unknown, &.unreachable, &.pending, &.ok {
222237
display: inline;
223238
border-radius: 0.1em;
224239
padding: 0.05em 0.2em;
@@ -258,6 +273,10 @@ div.cube {
258273
}
259274
}
260275

276+
&.pending {
277+
background: @color-pending;
278+
}
279+
261280
&.ok {
262281
background: @color-ok;
263282
}

0 commit comments

Comments
 (0)