Skip to content

Commit 758c344

Browse files
authored
Merge pull request #1719 from it-novum/ITC-3371
ITC-3371 Log of notification events
2 parents 4a987c1 + 0c60096 commit 758c344

20 files changed

+1116
-53
lines changed

UPDATE.sh

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
11
#!/bin/bash
2+
#
3+
# Copyright (C) <2015-present> <it-novum GmbH>
4+
#
5+
# This file is dual licensed
6+
#
7+
# 1.
8+
# This program is free software: you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation, version 3 of the License.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
#
20+
# 2.
21+
# If you purchased an openITCOCKPIT Enterprise Edition you can use this file
22+
# under the terms of the openITCOCKPIT Enterprise Edition license agreement.
23+
# License agreement and license key will be shipped with the order
24+
# confirmation.
25+
#
26+
227
if [[ $1 == "--help" ]]; then
328
echo "Supported parameters:"
429
echo "--rights Reset file permissions"
@@ -112,6 +137,7 @@ mysqldump --defaults-extra-file=${DUMPINIFILE} --databases $dbc_dbname --flush-p
112137
--ignore-table=$dbc_dbname.statusengine_host_acknowledgements \
113138
--ignore-table=$dbc_dbname.statusengine_host_downtimehistory \
114139
--ignore-table=$dbc_dbname.statusengine_host_notifications \
140+
--ignore-table=$dbc_dbname.statusengine_host_notifications_log \
115141
--ignore-table=$dbc_dbname.statusengine_host_scheduleddowntimes \
116142
--ignore-table=$dbc_dbname.statusengine_host_statehistory \
117143
--ignore-table=$dbc_dbname.statusengine_hostchecks \
@@ -122,6 +148,7 @@ mysqldump --defaults-extra-file=${DUMPINIFILE} --databases $dbc_dbname --flush-p
122148
--ignore-table=$dbc_dbname.statusengine_service_acknowledgements \
123149
--ignore-table=$dbc_dbname.statusengine_service_downtimehistory \
124150
--ignore-table=$dbc_dbname.statusengine_service_notifications \
151+
--ignore-table=$dbc_dbname.statusengine_service_notifications_log \
125152
--ignore-table=$dbc_dbname.statusengine_service_scheduleddowntimes \
126153
--ignore-table=$dbc_dbname.statusengine_service_statehistory \
127154
--ignore-table=$dbc_dbname.statusengine_servicechecks \
@@ -218,7 +245,6 @@ done
218245

219246
echo "---------------------------------------------------------------"
220247
echo "Convert MySQL Tables from utf8_general_ci to utf8mb4_general_ci..."
221-
222248
# Disabled - this takes ages!
223249
#mysql --defaults-extra-file=${INIFILE} -e "ALTER DATABASE ${dbc_dbname} CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
224250

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
<?php
2+
// Copyright (C) <2015-present> <it-novum GmbH>
3+
//
4+
// This file is dual licensed
5+
//
6+
// 1.
7+
// This program is free software: you can redistribute it and/or modify
8+
// it under the terms of the GNU General Public License as published by
9+
// the Free Software Foundation, version 3 of the License.
10+
//
11+
// This program is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU General Public License for more details.
15+
//
16+
// You should have received a copy of the GNU General Public License
17+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
//
19+
// 2.
20+
// If you purchased an openITCOCKPIT Enterprise Edition you can use this file
21+
// under the terms of the openITCOCKPIT Enterprise Edition license agreement.
22+
// License agreement and license key will be shipped with the order
23+
// confirmation.
24+
25+
declare(strict_types=1);
26+
27+
use Migrations\AbstractMigration;
28+
29+
/**
30+
* Class StatusengineNotificationsLog
31+
* This creates tables for Statusengine 3. The table structure can be modified with new migrations later on.
32+
* The partitions will be created and managed by the CleanupCronjob.
33+
*
34+
* Created:
35+
* oitc migrations create StatusengineNotificationsLog
36+
*
37+
* Usage:
38+
* openitcockpit-update
39+
*/
40+
class StatusengineNotificationsLog extends AbstractMigration {
41+
/**
42+
* Whether the tables created in this migration
43+
* should auto-create an `id` field or not
44+
*
45+
* This option is global for all tables created in the migration file.
46+
* If you set it to false, you have to manually add the primary keys for your
47+
* tables using the Migrations\Table::addPrimaryKey() method
48+
*
49+
* @var bool
50+
*/
51+
public $autoId = false;
52+
53+
/**
54+
* Change Method.
55+
*
56+
* More information on this method is available here:
57+
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
58+
* @return void
59+
*/
60+
public function change(): void {
61+
62+
if (!$this->hasTable('statusengine_host_notifications_log')) {
63+
$this->table('statusengine_host_notifications_log')
64+
->addColumn('hostname', 'string', [
65+
'limit' => 255,
66+
'null' => false,
67+
])
68+
->addColumn('start_time', 'biginteger', [
69+
'limit' => 20,
70+
'null' => false,
71+
'signed' => true,
72+
])
73+
->addColumn('start_time_usec', 'integer', [
74+
'limit' => 10,
75+
'null' => false,
76+
'signed' => false,
77+
'default' => 0,
78+
])
79+
->addPrimaryKey(['hostname', 'start_time', 'start_time_usec'])
80+
->addColumn('end_time', 'biginteger', [
81+
'limit' => 20,
82+
'null' => false,
83+
'signed' => true,
84+
])
85+
->addColumn('state', 'smallinteger', [
86+
'null' => true,
87+
'default' => 0,
88+
'signed' => false,
89+
])
90+
->addColumn('reason_type', 'smallinteger', [
91+
'null' => true,
92+
'default' => 0,
93+
'signed' => false,
94+
])
95+
->addColumn('is_escalated', 'boolean', [
96+
'default' => false,
97+
'limit' => null,
98+
'null' => false,
99+
])
100+
->addColumn('contacts_notified_count', 'smallinteger', [
101+
'null' => false,
102+
'default' => 0,
103+
'signed' => false,
104+
])
105+
->addColumn('output', 'string', [
106+
'null' => true,
107+
'default' => null,
108+
'limit' => 1024,
109+
])
110+
->addColumn('ack_author', 'string', [
111+
'null' => true,
112+
'default' => null,
113+
'limit' => 1024,
114+
])
115+
->addColumn('ack_data', 'string', [
116+
'null' => true,
117+
'default' => null,
118+
'limit' => 1024,
119+
])
120+
->addIndex(
121+
[
122+
'hostname',
123+
], ['name' => 'hostname']
124+
)
125+
->addIndex(
126+
[
127+
'start_time',
128+
'end_time',
129+
'reason_type',
130+
'state',
131+
], ['name' => 'filter']
132+
)
133+
->create();
134+
}
135+
136+
if (!$this->hasTable('statusengine_service_notifications_log')) {
137+
$this->table('statusengine_service_notifications_log')
138+
->addColumn('hostname', 'string', [
139+
'limit' => 255,
140+
'null' => false,
141+
])
142+
->addColumn('service_description', 'string', [
143+
'limit' => 255,
144+
'null' => false,
145+
])
146+
->addColumn('start_time', 'biginteger', [
147+
'limit' => 20,
148+
'null' => false,
149+
'signed' => true,
150+
])
151+
->addColumn('start_time_usec', 'integer', [
152+
'limit' => 10,
153+
'null' => false,
154+
'signed' => false,
155+
'default' => 0,
156+
])
157+
->addPrimaryKey(['hostname', 'service_description', 'start_time', 'start_time_usec'])
158+
->addColumn('end_time', 'biginteger', [
159+
'limit' => 20,
160+
'null' => false,
161+
'signed' => true,
162+
])
163+
->addColumn('state', 'smallinteger', [
164+
'null' => true,
165+
'default' => 0,
166+
'signed' => false,
167+
])
168+
->addColumn('reason_type', 'smallinteger', [
169+
'null' => true,
170+
'default' => 0,
171+
'signed' => false,
172+
])
173+
->addColumn('is_escalated', 'boolean', [
174+
'default' => false,
175+
'limit' => null,
176+
'null' => false,
177+
])
178+
->addColumn('contacts_notified_count', 'smallinteger', [
179+
'null' => false,
180+
'default' => 0,
181+
'signed' => false,
182+
])
183+
->addColumn('output', 'string', [
184+
'null' => true,
185+
'default' => null,
186+
'limit' => 1024,
187+
])
188+
->addColumn('ack_author', 'string', [
189+
'null' => true,
190+
'default' => null,
191+
'limit' => 1024,
192+
])
193+
->addColumn('ack_data', 'string', [
194+
'null' => true,
195+
'default' => null,
196+
'limit' => 1024,
197+
])
198+
->addIndex(
199+
[
200+
'hostname',
201+
'service_description',
202+
], ['name' => 'servicename']
203+
)
204+
->addIndex(
205+
[
206+
'start_time',
207+
'end_time',
208+
'reason_type',
209+
'state',
210+
], ['name' => 'filter']
211+
)
212+
->create();
213+
}
214+
215+
216+
}
217+
}

plugins/Statusengine3Module/src/Model/Entity/NotificationHost.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
<?php
2-
// Copyright (C) <2015> <it-novum GmbH>
2+
// Copyright (C) <2015-present> <it-novum GmbH>
33
//
44
// This file is dual licensed
55
//
66
// 1.
7-
// This program is free software: you can redistribute it and/or modify
8-
// it under the terms of the GNU General Public License as published by
9-
// the Free Software Foundation, version 3 of the License.
7+
// This program is free software: you can redistribute it and/or modify
8+
// it under the terms of the GNU General Public License as published by
9+
// the Free Software Foundation, version 3 of the License.
1010
//
11-
// This program is distributed in the hope that it will be useful,
12-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
// GNU General Public License for more details.
11+
// This program is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU General Public License for more details.
1515
//
16-
// You should have received a copy of the GNU General Public License
17-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
// You should have received a copy of the GNU General Public License
17+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
//
19+
// 2.
20+
// If you purchased an openITCOCKPIT Enterprise Edition you can use this file
21+
// under the terms of the openITCOCKPIT Enterprise Edition license agreement.
22+
// License agreement and license key will be shipped with the order
23+
// confirmation.
1924

2025
// 2.
2126
// If you purchased an openITCOCKPIT Enterprise Edition you can use this file
@@ -28,6 +33,7 @@
2833
namespace Statusengine3Module\Model\Entity;
2934

3035
use Cake\ORM\Entity;
36+
use itnovum\openITCOCKPIT\Core\ValueObjects\NotificationReasonTypes;
3137

3238
/**
3339
* NotificationHost Entity
@@ -40,7 +46,7 @@
4046
* @property int|null $state
4147
* @property int $start_time
4248
* @property int $end_time
43-
* @property int|null $reason_type
49+
* @property int|null|NotificationReasonTypes $reason_type
4450
* @property string|null $output
4551
* @property string|null $ack_author
4652
* @property string|null $ack_data
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
// Copyright (C) <2015-present> <it-novum GmbH>
3+
//
4+
// This file is dual licensed
5+
//
6+
// 1.
7+
// This program is free software: you can redistribute it and/or modify
8+
// it under the terms of the GNU General Public License as published by
9+
// the Free Software Foundation, version 3 of the License.
10+
//
11+
// This program is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU General Public License for more details.
15+
//
16+
// You should have received a copy of the GNU General Public License
17+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
//
19+
// 2.
20+
// If you purchased an openITCOCKPIT Enterprise Edition you can use this file
21+
// under the terms of the openITCOCKPIT Enterprise Edition license agreement.
22+
// License agreement and license key will be shipped with the order
23+
// confirmation.
24+
25+
declare(strict_types=1);
26+
27+
namespace Statusengine3Module\Model\Entity;
28+
29+
use Cake\ORM\Entity;
30+
use itnovum\openITCOCKPIT\Core\ValueObjects\NotificationReasonTypes;
31+
32+
/**
33+
* NotificationHostsLog Entity
34+
*
35+
* @property string $hostname
36+
* @property int $start_time
37+
* @property int $start_time_usec
38+
* @property int $end_time
39+
* @property int|null $state
40+
* @property int|null|NotificationReasonTypes $reason_type
41+
* @property bool $is_escalated
42+
* @property int $contacts_notified_count
43+
* @property string|null $output
44+
* @property string|null $ack_author
45+
* @property string|null $ack_data
46+
*/
47+
class NotificationHostsLog extends Entity {
48+
/**
49+
* Fields that can be mass assigned using newEntity() or patchEntity().
50+
*
51+
* Note that when '*' is set to true, this allows all unspecified fields to
52+
* be mass assigned. For security purposes, it is advised to set '*' to false
53+
* (or remove it), and explicitly make individual fields accessible as needed.
54+
*
55+
* @var array<string, bool>
56+
*/
57+
protected $_accessible = [
58+
'end_time' => true,
59+
'state' => true,
60+
'reason_type' => true,
61+
'is_escalated' => true,
62+
'contacts_notified_count' => true,
63+
'output' => true,
64+
'ack_author' => true,
65+
'ack_data' => true,
66+
];
67+
}

0 commit comments

Comments
 (0)