-
Notifications
You must be signed in to change notification settings - Fork 0
/
Website_Multiple_Certificates_by_Zabbix_Agent2.yaml
437 lines (431 loc) · 16.3 KB
/
Website_Multiple_Certificates_by_Zabbix_Agent2.yaml
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
zabbix_export:
version: '5.4'
date: '2022-02-02T21:11:01Z'
groups:
-
uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
name: Templates/Applications
templates:
-
uuid: 2755baa826974223b11cd07c2cf5f9b5
template: 'Website MULTIPLE certificates by Zabbix agent 2'
name: 'Website MULTIPLE certificates by Zabbix agent 2'
description: |
Inspired by the original single certificate monitoring template, but much cooler:
We need a macro configuring the entire certificate monitoring in the following way, in one string:
HOSTNAME,<PORT>,<ADDRESS>;HOSTNAME,<PORT>,<ADDRESS>;...
This way, we can monitor as many certificates as we want, on one single host with one single template.
A "script" item will run to convert this Macro into a JSON structure that looks as follows:
[
{"hostname":"host1.mycompany.com","port":"","address":""},
{"hostname":"host2.mycompany.com","port":"443","address":"127.0.0.1"}
]
In case "port" or "address" is not needed, it can be omitted, also, in the Macro, double comma syntax can be used if only "hostname" and "address" is to be supplied.
From the above JSON structure, a Low Level Discovery will run and create 14 items and corresponding Triggers for each certificate.
groups:
-
name: Templates/Applications
items:
-
uuid: d30e925bd07842088e7c7c146bdaaa6f
name: 'Certificate Monitoring configuration list'
type: SCRIPT
key: cert.mon.configuration
delay: 1h
history: '0'
trends: '0'
value_type: TEXT
params: |
var macroconf = '{$MULTICERT.CONFIG}'
var splitconf = macroconf.split(';')
var estr = ''
var json = []
for (var i=0; i<splitconf.length; i++) {
var jsonelem = {}
var certmonelems = splitconf[i].split(',')
if (certmonelems.length == 3) {
jsonelem = {"hostname": certmonelems[0], "port": certmonelems[1], "address": certmonelems[2]}
} else if (certmonelems.length == 2) {
jsonelem = {"hostname": certmonelems[0], "port": certmonelems[1], "address": ""}
} else if (certmonelems.length == 1) {
jsonelem = {"hostname": certmonelems[0], "port": "", "address": ""}
}
json.push(jsonelem)
}
return JSON.stringify(json)
tags:
-
tag: Application
value: Certificates
-
tag: Application
value: 'Zabbix raw items'
discovery_rules:
-
uuid: 3290e6b6aa6149d987c5c780c0a3324d
name: 'Certificate discovery'
type: DEPENDENT
key: web.certificate.config.discovery
delay: '0'
lifetime: 7d
item_prototypes:
-
uuid: 83fbaf80d39c41f9bbeebf1fe4f64a76
name: 'Cert {#HOSTNAME}: Subject alternative name'
type: DEPENDENT
key: 'cert.alternative_names[{#HOSTNAME}]'
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
-
type: JSONPATH
parameters:
- $.x509.alternative_names
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
-
uuid: 6de3f567c6ad4eb68cfc7e0057e25183
name: 'Cert {#HOSTNAME}: Days left until expiry'
type: CALCULATED
key: 'cert.days.left[{#HOSTNAME}]'
value_type: FLOAT
units: d
params: '(last(//cert.not_after[{#HOSTNAME}])-now())/ 86400'
preprocessing:
-
type: REGEX
parameters:
- '[^.]*'
- \0
tags:
-
tag: Application
value: Certificates
-
uuid: 3771d2f2fe704a37a3776d455b43e0d8
name: 'Cert {#HOSTNAME}: Issuer'
type: DEPENDENT
key: 'cert.issuer[{#HOSTNAME}]'
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
-
type: JSONPATH
parameters:
- $.x509.issuer
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
-
uuid: 8fffee0b96d640659b30c20a8f92fe42
name: 'Cert {#HOSTNAME}: Last validation status'
type: DEPENDENT
key: 'cert.message[{#HOSTNAME}]'
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
-
type: JSONPATH
parameters:
- $.result.message
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
-
uuid: 4f647af7ab684a928dd9995eff654cae
name: 'Cert {#HOSTNAME}: Expires on'
type: DEPENDENT
key: 'cert.not_after[{#HOSTNAME}]'
delay: '0'
units: unixtime
preprocessing:
-
type: JSONPATH
parameters:
- $.x509.not_after.timestamp
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
trigger_prototypes:
-
uuid: 1b82f73d77e64c6d82d9e6edfa71da48
expression: '(last(/Website MULTIPLE certificates by Zabbix agent 2/cert.not_after[{#HOSTNAME}]) - now()) / 86400 < {$CERT.EXPIRY.WARN.LOW:"{#HOSTNAME}"}'
name: 'Cert {#HOSTNAME}: SSL certificate expires soon (less than {$CERT.EXPIRY.WARN.LOW} days)'
priority: INFO
description: 'The SSL certificate should be updated or it will become untrusted.'
dependencies:
-
name: 'Cert {#HOSTNAME}: SSL certificate is invalid'
expression: 'find(/Website MULTIPLE certificates by Zabbix agent 2/cert.validation[{#HOSTNAME}],,"like","invalid")=1'
-
uuid: e899413730e740d89151f41a14fbe522
expression: '(last(/Website MULTIPLE certificates by Zabbix agent 2/cert.not_after[{#HOSTNAME}]) - now()) / 86400 < {$CERT.EXPIRY.WARN:"{#HOSTNAME}"}'
name: 'Cert {#HOSTNAME}: SSL certificate expires soon (less than {$CERT.EXPIRY.WARN} days)'
priority: WARNING
dependencies:
-
name: 'Cert {#HOSTNAME}: SSL certificate is invalid'
expression: 'find(/Website MULTIPLE certificates by Zabbix agent 2/cert.validation[{#HOSTNAME}],,"like","invalid")=1'
-
uuid: 3118cf23d3cb45c0956e2ddfefa803b2
name: 'Cert {#HOSTNAME}: Valid from'
type: DEPENDENT
key: 'cert.not_before[{#HOSTNAME}]'
delay: '0'
units: unixtime
preprocessing:
-
type: JSONPATH
parameters:
- $.x509.not_before.timestamp
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
-
uuid: 1973f38b0f27467b95fd62ace96bdc12
name: 'Cert {#HOSTNAME}: Public key algorithm'
type: DEPENDENT
key: 'cert.public_key_algorithm[{#HOSTNAME}]'
delay: '0'
trends: '0'
value_type: CHAR
preprocessing:
-
type: JSONPATH
parameters:
- $.x509.public_key_algorithm
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
-
uuid: 9414485f283f47b1856fa9d5d2844d78
name: 'Cert {#HOSTNAME}: Serial number'
type: DEPENDENT
key: 'cert.serial_number[{#HOSTNAME}]'
delay: '0'
trends: '0'
value_type: CHAR
preprocessing:
-
type: JSONPATH
parameters:
- $.x509.serial_number
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
-
uuid: 3fd202dc597c48c29252becfd1a09eb6
name: 'Cert {#HOSTNAME}: Fingerprint'
type: DEPENDENT
key: 'cert.sha1_fingerprint[{#HOSTNAME}]'
delay: '0'
trends: '0'
value_type: CHAR
preprocessing:
-
type: JSONPATH
parameters:
- $.sha1_fingerprint
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
trigger_prototypes:
-
uuid: d4946abea0ae44d7a379f0305d8c02c3
expression: 'last(/Website MULTIPLE certificates by Zabbix agent 2/cert.sha1_fingerprint[{#HOSTNAME}]) <> last(/Website MULTIPLE certificates by Zabbix agent 2/cert.sha1_fingerprint[{#HOSTNAME}],#2)'
name: 'Cert {#HOSTNAME}: Fingerprint has changed (new version: {ITEM.VALUE})'
priority: INFO
description: |
The SSL certificate fingerprint has changed. If you did not update the certificate, it may mean your certificate has been hacked. Ack to close.
There could be multiple valid certificates on some installations. In this case, the trigger will have a false positive. You can ignore it or disable the trigger.
manual_close: 'YES'
-
uuid: 53043e18e1eb49f1bf45bb6943f5b19b
name: 'Cert {#HOSTNAME}: Signature algorithm'
type: DEPENDENT
key: 'cert.signature_algorithm[{#HOSTNAME}]'
delay: '0'
trends: '0'
value_type: CHAR
preprocessing:
-
type: JSONPATH
parameters:
- $.x509.signature_algorithm
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
-
uuid: e98ac29e521444b6be0a7eab71ffadf8
name: 'Cert {#HOSTNAME}: Subject'
type: DEPENDENT
key: 'cert.subject[{#HOSTNAME}]'
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
-
type: JSONPATH
parameters:
- $.x509.subject
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
-
uuid: 6f59fc4433ff4fefb7e75452b75625da
name: 'Cert {#HOSTNAME}: Validation result'
type: DEPENDENT
key: 'cert.validation[{#HOSTNAME}]'
delay: '0'
trends: '0'
value_type: CHAR
preprocessing:
-
type: JSONPATH
parameters:
- $.result.value
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
trigger_prototypes:
-
uuid: 89f239c084024871831b9d026004ce3e
expression: 'find(/Website MULTIPLE certificates by Zabbix agent 2/cert.validation[{#HOSTNAME}],,"like","invalid")=1'
name: 'Cert {#HOSTNAME}: SSL certificate is invalid'
priority: HIGH
-
uuid: 051efa5566164293a36644fcd90e72b4
name: 'Cert {#HOSTNAME}: Version'
type: DEPENDENT
key: 'cert.version[{#HOSTNAME}]'
delay: '0'
trends: '0'
value_type: CHAR
preprocessing:
-
type: JSONPATH
parameters:
- $.x509.version
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
master_item:
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
tags:
-
tag: Application
value: Certificates
-
uuid: 5c3674c148784a0eb5a616c8531e2721
name: 'Cert {#HOSTNAME}: Get'
key: 'web.certificate.get[{#HOSTNAME},{#PORT},{#ADDRESS}]'
delay: 15m
history: '0'
trends: '0'
value_type: TEXT
tags:
-
tag: Application
value: Certificates
-
tag: Application
value: 'Zabbix raw items'
master_item:
key: cert.mon.configuration
lld_macro_paths:
-
lld_macro: '{#HOSTNAME}'
path: $.hostname
-
lld_macro: '{#PORT}'
path: $.port
-
lld_macro: '{#ADDRESS}'
path: $.address
macros:
-
macro: '{$CERT.EXPIRY.WARN}'
value: '14'
description: 'Number of days until the certificate expires. Supports HOSTNAME as context'
-
macro: '{$CERT.EXPIRY.WARN.LOW}'
value: '30'
description: 'Number of days for first informational alert on upcoming expiry. Supports HOSTNAME as context'
-
macro: '{$MULTICERT.CONFIG}'
value: 'Hostname,<port>,<ip>;Hostname,<port>,<ip>'
description: 'Multi-Certificate monitoring configuration'