summaryrefslogtreecommitdiffstats
path: root/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml
blob: 73a3b575d7c5bf45faebf7ad18e7c0491f7f8dde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
use Icinga\Module\Monitoring\Web\Widget\StateBadges;
use Icinga\Web\Url;

// Don't fetch rows until they are actually needed, to improve dashlet performance
if (! $stats instanceof stdClass) {
    $stats = $stats->fetchRow();
}
?>
<div class="services-summary dont-print">
    <span class="services-link"><?= $this->qlink(
        sprintf($this->translatePlural(
            '%u Service', '%u Services', $stats->services_total),
            $stats->services_total
        ),
        // @TODO(el): Fix that
        Url::fromPath('monitoring/list/services')->setParams(isset($baseFilter) ? $baseFilter->getUrlParams() : array()),
        null,
        array('title' => sprintf(
            $this->translatePlural('List %u service', 'List all %u services', $stats->services_total),
            $stats->services_total
        ))
    ) ?>&#58;</span>
<?php
$stateBadges = new StateBadges();
$stateBadges
    ->setBaseFilter(isset($baseFilter) ? $baseFilter : null)
    ->setUrl('monitoring/list/services')
    ->add(
        StateBadges::STATE_OK,
        $stats->services_ok,
        array(
            'service_state' => 0
        ),
        'List %u service that is currently in state OK',
        'List %u services which are currently in state OK',
        array($stats->services_ok)
    )
    ->add(
        StateBadges::STATE_CRITICAL,
        $stats->services_critical_unhandled,
        array(
            'service_state'     => 2,
            'service_handled'   => 0
        ),
        'List %u service that is currently in state CRITICAL',
        'List %u services which are currently in state CRITICAL',
        array($stats->services_critical_unhandled)
    )
    ->add(
        StateBadges::STATE_CRITICAL_HANDLED,
        $stats->services_critical_handled,
        array(
            'service_state'     => 2,
            'service_handled'   => 1
        ),
        'List %u handled service that is currently in state CRITICAL',
        'List %u handled services which are currently in state CRITICAL',
        array($stats->services_critical_handled)
    )
    ->add(
        StateBadges::STATE_UNKNOWN,
        $stats->services_unknown_unhandled,
        array(
            'service_state'     => 3,
            'service_handled'   => 0
        ),
        'List %u service that is currently in state UNKNOWN',
        'List %u services which are currently in state UNKNOWN',
        array($stats->services_unknown_unhandled)
    )
    ->add(
        StateBadges::STATE_UNKNOWN_HANDLED,
        $stats->services_unknown_handled,
        array(
            'service_state'     => 3,
            'service_handled'   => 1
        ),
        'List %u handled service that is currently in state UNKNOWN',
        'List %u handled services which are currently in state UNKNOWN',
        array($stats->services_unknown_handled)

    )
    ->add(
        StateBadges::STATE_WARNING,
        $stats->services_warning_unhandled,
        array(
            'service_state'     => 1,
            'service_handled'   => 0
        ),
        'List %u service that is currently in state WARNING',
        'List %u services which are currently in state WARNING',
        array($stats->services_warning_unhandled)
    )
    ->add(
        StateBadges::STATE_WARNING_HANDLED,
        $stats->services_warning_handled,
        array(
            'service_state'     => 1,
            'service_handled'   => 1
        ),
        'List %u handled service that is currently in state WARNING',
        'List %u handled services which are currently in state WARNING',
        array($stats->services_warning_handled)
    )
    ->add(
        StateBadges::STATE_PENDING,
        $stats->services_pending,
        array(
            'service_state' => 99
        ),
        'List %u handled service that is currently in state PENDING',
        'List %u handled services which are currently in state PENDING',
        array($stats->services_pending)
    );
echo $stateBadges->render();
?>
</div>