Skip to content

Commit b7971c9

Browse files
committed
Add pending state to cube badges and queries
Include the pending state in host and service status cube queries and render it in the state badge rows.
1 parent 127e5f8 commit b7971c9

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
@@ -32,6 +32,11 @@ public function createFacts(object $facts): HtmlDocument
3232
$partsObj->hosts_unreachable_unhandled = $facts->hosts_unhandled_unreachable;
3333
}
3434

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

@@ -54,12 +59,17 @@ public function createFacts(object $facts): HtmlDocument
5459
if (
5560
$facts->hosts_cnt > $facts->hosts_down
5661
&& (! isset($facts->hosts_unreachable) || $facts->hosts_cnt > $facts->hosts_unreachable)
62+
&& (! isset($facts->hosts_pending) || $facts->hosts_cnt > $facts->hosts_pending)
5763
) {
5864
$ok = $facts->hosts_cnt - $facts->hosts_down;
5965
if (isset($facts->hosts_unreachable)) {
6066
$ok -= $facts->hosts_unreachable;
6167
}
6268

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

library/Cube/CubeRenderer/ServiceStatusCubeRenderer.php

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

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

@@ -62,10 +66,15 @@ public function createFacts(object $facts): HtmlDocument
6266
$facts->services_cnt > $facts->services_critical
6367
&& $facts->services_cnt > $facts->services_warning
6468
&& $facts->services_cnt > $facts->services_unknown
69+
&& (! isset($facts->services_pending) || $facts->services_cnt > $facts->services_pending)
6570
) {
6671
$ok = $facts->services_cnt - $facts->services_critical - $facts->services_warning -
6772
$facts->services_unknown;
6873

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

library/Cube/IcingaDb/IcingaDbHostStatusCube.php

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

1413
class IcingaDbHostStatusCube extends IcingaDbCube
1514
{
@@ -24,6 +23,7 @@ public function getAvailableFactColumns()
2423
'hosts_cnt' => 'hosts_total',
2524
'hosts_down' => 'hosts_down_handled + f.hosts_down_unhandled',
2625
'hosts_unhandled_down' => 'hosts_down_unhandled',
26+
'hosts_pending' => 'hosts_pending',
2727
];
2828
}
2929

library/Cube/IcingaDb/IcingaDbServiceStatusCube.php

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

1413
class IcingaDbServiceStatusCube extends IcingaDbCube
1514
{
@@ -39,6 +38,7 @@ public function getAvailableFactColumns()
3938
'services_unhandled_warning' => 'services_warning_unhandled',
4039
'services_unknown' => 'services_unknown_handled + f.services_unknown_unhandled',
4140
'services_unhandled_unknown' => 'services_unknown_unhandled',
41+
'services_pending' => 'services_pending'
4242
];
4343
}
4444

library/Cube/Web/Widget/HostDimensionWidget.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ protected function getDimensionClasses(): array
4141
$severityClass = ['critical'];
4242
} elseif (isset($sums->hosts_unhandled_unreachable) && $sums->hosts_unhandled_unreachable > 0) {
4343
$severityClass = ['unreachable'];
44+
} elseif (isset($sums->hosts_pending) && $sums->hosts_pending > 0) {
45+
$severityClass = ['pending'];
4446
} elseif ($sums->hosts_down > 0) {
4547
$severityClass = ['critical', 'handled'];
4648
} 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
@@ -43,6 +43,8 @@ protected function getDimensionClasses(): array
4343
$severityClass = ['unknown'];
4444
} elseif ($sums->services_unhandled_warning > 0) {
4545
$severityClass = ['warning'];
46+
} elseif (isset($sums->services_pending) && $sums->services_pending > 0) {
47+
$severityClass = ['pending'];
4648
} elseif ($sums->services_critical > 0) {
4749
$severityClass = ['critical', 'handled'];
4850
} elseif ($sums->services_unknown > 0) {

public/css/module.less

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

68+
&.pending {
69+
> .header {
70+
color: @color-pending;
71+
border-color: @color-pending;
72+
}
73+
}
74+
6875
&.ok {
6976
> .header {
7077
color: @color-ok;
@@ -141,6 +148,10 @@ div.cube {
141148
}
142149
}
143150

151+
&.pending {
152+
border-left-color: @color-pending;
153+
}
154+
144155
&.ok {
145156
border-left-color: @color-ok;
146157
}
@@ -203,6 +214,10 @@ div.cube {
203214
}
204215
}
205216

217+
&.pending {
218+
background: @color-pending;
219+
}
220+
206221
&.ok {
207222
background: @color-ok;
208223
}
@@ -219,7 +234,7 @@ div.cube {
219234
}
220235

221236
span {
222-
&.critical, &.warning, &.unknown, &.unreachable, &.ok {
237+
&.critical, &.warning, &.unknown, &.unreachable, &.pending, &.ok {
223238
display: inline;
224239
border-radius: 0.1em;
225240
padding: 0.05em 0.2em;
@@ -259,6 +274,10 @@ div.cube {
259274
}
260275
}
261276

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

0 commit comments

Comments
 (0)