/usr/share/icingaweb2/modules/monitoring/application/forms/StatehistoryForm.php is in icingaweb2-module-monitoring 2.1.0-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | <?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Module\Monitoring\Forms;
use Icinga\Web\Form;
use Icinga\Data\Filter\Filter;
/**
* Configure the filter for the event grid
*/
class StatehistoryForm extends Form
{
/**
* {@inheritdoc}
*/
public function init()
{
$this->setName('form_event_overview');
$this->setSubmitLabel($this->translate('Apply'));
}
/**
* Return the corresponding filter-object
*
* @returns Filter
*/
public function getFilter()
{
$baseFilter = Filter::matchAny(
Filter::expression('type', '=', 'hard_state')
);
if ($this->getValue('objecttype', 'hosts') === 'hosts') {
$objectTypeFilter = Filter::expression('object_type', '=', 'host');
} else {
$objectTypeFilter = Filter::expression('object_type', '=', 'service');
}
$states = array(
'cnt_down_hard' => Filter::expression('state', '=', '1'),
'cnt_unreachable_hard' => Filter::expression('state', '=', '2'),
'cnt_up' => Filter::expression('state', '=', '0'),
'cnt_critical_hard' => Filter::expression('state', '=', '2'),
'cnt_warning_hard' => Filter::expression('state', '=', '1'),
'cnt_unknown_hard' => Filter::expression('state', '=', '3'),
'cnt_ok' => Filter::expression('state', '=', '0')
);
$state = $this->getValue('state', 'cnt_critical_hard');
$stateFilter = $states[$state];
if (in_array($state, array('cnt_ok', 'cnt_up'))) {
return Filter::matchAll($objectTypeFilter, $stateFilter);
}
return Filter::matchAll($baseFilter, $objectTypeFilter, $stateFilter);
}
/**
* {@inheritdoc}
*/
public function createElements(array $formData)
{
$this->addElement(
'select',
'from',
array(
'label' => $this->translate('From'),
'value' => $this->getRequest()->getParam('from', strtotime('3 months ago')),
'multiOptions' => array(
strtotime('midnight 3 months ago') => $this->translate('3 Months'),
strtotime('midnight 4 months ago') => $this->translate('4 Months'),
strtotime('midnight 8 months ago') => $this->translate('8 Months'),
strtotime('midnight 12 months ago') => $this->translate('1 Year'),
strtotime('midnight 24 months ago') => $this->translate('2 Years')
),
'class' => 'autosubmit'
)
);
$this->addElement(
'select',
'to',
array(
'label' => $this->translate('To'),
'value' => $this->getRequest()->getParam('to', time()),
'multiOptions' => array(
time() => $this->translate('Today')
),
'class' => 'autosubmit'
)
);
$objectType = $this->getRequest()->getParam('objecttype', 'services');
$this->addElement(
'select',
'objecttype',
array(
'label' => $this->translate('Object type'),
'value' => $objectType,
'multiOptions' => array(
'services' => $this->translate('Services'),
'hosts' => $this->translate('Hosts')
),
'class' => 'autosubmit'
)
);
if ($objectType === 'services') {
$serviceState = $this->getRequest()->getParam('state', 'cnt_critical_hard');
if (in_array($serviceState, array('cnt_down_hard', 'cnt_unreachable_hard', 'cnt_up'))) {
$serviceState = 'cnt_critical_hard';
}
$this->addElement(
'select',
'state',
array(
'label' => $this->translate('State'),
'value' => $serviceState,
'multiOptions' => array(
'cnt_critical_hard' => $this->translate('Critical'),
'cnt_warning_hard' => $this->translate('Warning'),
'cnt_unknown_hard' => $this->translate('Unknown'),
'cnt_ok' => $this->translate('Ok')
),
'class' => 'autosubmit'
)
);
} else {
$hostState = $this->getRequest()->getParam('state', 'cnt_down_hard');
if (in_array($hostState, array('cnt_ok', 'cnt_critical_hard', 'cnt_warning', 'cnt_unknown'))) {
$hostState = 'cnt_down_hard';
}
$this->addElement(
'select',
'state',
array(
'label' => $this->translate('State'),
'value' => $hostState,
'multiOptions' => array(
'cnt_up' => $this->translate('Up'),
'cnt_down_hard' => $this->translate('Down'),
'cnt_unreachable_hard' => $this->translate('Unreachable')
),
'class' => 'autosubmit'
)
);
}
}
}
|