summaryrefslogtreecommitdiffstats
path: root/modules/monitoring/application/views/scripts/list/hosts.phtml
blob: 6d7674e28212cbbea488f62bc77082237334581b (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
<?php
use Icinga\Date\DateFormatter;
use Icinga\Module\Monitoring\Object\Host;

if (! $this->compact): ?>
<div class="controls">
    <?= $this->tabs ?>
    <?= $this->paginator ?>
    <div class="sort-controls-container">
        <?= $this->limiter ?>
        <?= $this->sortBox ?>
    </div>
    <?= $this->filterEditor ?>
</div>
<?php endif ?>
<div class="content">
<?php if (! $hosts->hasResult()): ?>
    <p><?= $this->translate('No hosts found matching the filter.') ?></p>
</div>
<?php return; endif ?>
    <table data-base-target="_next"
           class="table-row-selectable state-table multiselect"
           data-icinga-multiselect-url="<?= $this->href('monitoring/hosts/show') ?>"
           data-icinga-multiselect-controllers="<?= $this->href("monitoring/hosts") ?>"
           data-icinga-multiselect-data="host">
    <thead class="print-only">
        <tr>
            <th><?= $this->translate('State') ?></th>
            <th><?= $this->translate('Host') ?></th>
        <?php foreach($this->addColumns as $col): ?>
            <th><?= $this->escape($col) ?></th>
        <?php endforeach ?>
        </tr>
    </thead>
    <tbody>
    <?php foreach($hosts->peekAhead($this->compact) as $host):
        $hostStateName = Host::getStateText($host->host_state);
        $hostLink = $this->href('monitoring/host/show', array('host' => $host->host_name));
        $hostCheckOverdue = $host->host_next_update < time();?>
        <tr<?= $hostCheckOverdue ? ' class="state-outdated"' : '' ?>>
            <td class="state-col state-<?= $hostStateName ?><?= $host->host_handled ? ' handled' : '' ?>">
                <div class="state-label">
                <?php if ($hostCheckOverdue): ?>
                    <?= $this->icon('clock', sprintf($this->translate('Overdue %s'), DateFormatter::timeSince($host->host_next_update))) ?>
                <?php endif ?>
                    <?= Host::getStateText($host->host_state, true) ?>
                </div>
                <?php if ((int) $host->host_state !== 99): ?>
                    <div class="state-meta">
                        <?= $this->timeSince($host->host_last_state_change, $this->compact) ?>
                    <?php if ((int) $host->host_state > 0 && (int) $host->host_state_type === 0): ?>
                        <div><?= $this->translate('Soft', 'Soft state') ?> <?= $host->host_attempt ?></div>
                    <?php endif ?>
                    </div>
                <?php endif ?>
            </td>
            <td>
                <div class="state-header">
                    <?= $this->iconImage()->host($host) ?>
                    <?= $this->qlink(
                        $host->host_display_name,
                        $hostLink,
                        null,
                        array(
                            'title' => sprintf(
                                $this->translate('Show detailed information for host %s'),
                                $host->host_display_name
                            ),
                            'class' => 'rowaction'
                        )
                    ) ?>
                    <span class="state-icons"><?= $this->hostFlags($host) ?></span>
                </div>
                <p class="overview-plugin-output"><?= $this->pluginOutput($this->ellipsis($host->host_output, 10000), true, $host->host_check_command) ?></p>
            </td>
        <?php foreach($this->addColumns as $col): ?>
          <?php if ($host->$col && preg_match('~^_(host|service)_([a-zA-Z0-9_]+)$~', $col, $m)): ?>
            <td><?= $this->escape(\Icinga\Module\Monitoring\Object\MonitoredObject::protectCustomVars([$m[2] => $host->$col])[$m[2]]) ?></td>
          <?php else: ?>
            <td><?= $this->escape($host->$col) ?></td>
          <?php endif ?>
        <?php endforeach ?>
        </tr>
    <?php endforeach ?>
    </tbody>
    </table>
<?php if ($hosts->hasMore()): ?>
    <div class="dont-print action-links">
        <?= $this->qlink(
            $this->translate('Show More'),
            $this->url()->without(array('showCompact', 'limit')),
            null,
            array(
                'class'             => 'action-link',
                'data-base-target'  => '_next'
            )
        ) ?>
    </div>
<?php endif ?>
</div>
<?php if (! $this->compact): ?>
<div class="monitoring-statusbar dont-print">
    <?= $this->render('list/components/hostssummary.phtml') ?>
    <?= $this->render('list/components/selectioninfo.phtml') ?>
</div>
<?php endif ?>