-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathcheck-system-cpu-memory.rule
More file actions
452 lines (449 loc) · 20.4 KB
/
check-system-cpu-memory.rule
File metadata and controls
452 lines (449 loc) · 20.4 KB
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
/*
* Monitors system cpu, memory utlilization and notifies when anomalies are found.
*
* Four inputs control detection
*
* 1) "re-slot-no" is a regular expression that matches the routing engine
* that you would like to monitor. By default it's '0-1', which matches
* both the routing engines. Use something like '0' to match only
* routing engine 0.
*
* 2) "memory-buffer-re-high-threshold" is the threshold that causes the
* rule to report an anomaly. By default it's 75.
*
* 3) "re-cpu-high-threshold" is the threshold that causes the
* rule to report an anomaly. By default it's 80.
*
* 4) "re-cpu-low-threshold" is the threshold that causes the
* rule to report an anomaly. By default it's 50.
*
* 5) "memory-buffer-re-low-threshold" is the threshold that causes the
* rule to report an anomaly. By default it's 50.
*/
healthbot {
topic hardware.system {
rule check-system-cpu-memory {
/*
* Monitors the system cpu, memory utlilization and notifies via dashboard, red color
* when threshold is exceeded else green.
*
* Use routing-engine as key for rule.
*/
keys routing-engine;
synopsis "CPU and Memory analyzer";
description "Collects system RE CPU and Memory statistics periodically and notifies anomalies";
/*
* Sensor configuration to get data from network devices.
*/
sensor components-oc {
synopsis "system cpu and memory KPI";
description "/components open-config sensor to collect telemetry data from network device";
open-config {
sensor-name /components/component;
frequency 60s;
}
}
/*
* Fields defined using sensor path. Map the longer sensor names
* to the shorter field names used in the rules.
*/
field re-cpu-utilization {
sensor components-oc {
where "/components/component/properties/property/@name == 'cpu-utilization-total'";
path /components/component/properties/property/state/value;
zero-suppression;
}
type float;
description "Collects RE CPU utilization";
plots re-cpu-utilization-plots {
unit percentage;
triggers routing-engine-cpu-utilization;
thresholds re-cpu-high-threshold {
field-name "$re-cpu-utilization-high-threshold";
severity critical;
}
thresholds re-cpu-low-threshold {
field-name "$re-cpu-utilization-low-threshold";
severity minor;
}
thresholds re-cpu-utilization-anomaly {
field-name "$re-cpu-utilization-anomaly";
severity minor;
type jaiml-threshold;
}
}
}
field re-cpu-utilization-anomaly {
formula {
jaiml-anomaly-detection {
field-name "$re-cpu-utilization";
}
}
type integer;
description "JAIML anomaly detection on re-cpu-utilization field";
}
field re-cpu-utilization-high-threshold {
constant {
value "{{re-cpu-high-threshold}}";
}
type integer;
description "RE CPU utilization high threshold";
}
field re-cpu-utilization-low-threshold {
constant {
value "{{re-cpu-low-threshold}}";
}
type integer;
description "RE CPU utilization low threshold";
}
field re-memory-buffer {
sensor components-oc {
where "/components/component/properties/property/@name == 'memory-utilization-buffer'";
path /components/component/properties/property/state/value;
zero-suppression;
}
type integer;
description "RE system memory buffer value";
plots re-memory-buffer-plots {
unit percentage;
triggers routing-engine-memory-buffer-utilization;
thresholds re-memory-high-threshold {
field-name "$re-memory-buffer-high-threshold";
severity critical;
}
thresholds re-memory-low-threshold {
field-name "$re-memory-buffer-low-threshold";
severity minor;
}
thresholds re-memory-buffer-anomaly {
field-name "$re-memory-buffer-anomaly";
severity minor;
type jaiml-threshold;
}
}
}
field re-memory-buffer-anomaly {
formula {
jaiml-anomaly-detection {
field-name "$re-memory-buffer";
}
}
type integer;
description "JAIML anomaly detection on re-memory-buffer field";
}
field re-memory-buffer-high-threshold {
constant {
value "{{memory-buffer-re-high-threshold}}";
}
type integer;
description "RE system memory buffer high threshold";
}
field re-memory-buffer-low-threshold {
constant {
value "{{memory-buffer-re-low-threshold}}";
}
type integer;
description "RE system memory buffer low threshold";
}
field routing-engine {
sensor components-oc {
where "/components/component/@name =~ /^Routing Engine[{{re-slot-no}}]$|^RE[{{re-slot-no}}]$|^CHASSIS[{{re-slot-no}}]:RE[{{re-slot-no}}]$/";
path "/components/component/@name";
}
description "RE name to monitor";
}
/*
* Anomaly detection logic.
*/
trigger routing-engine-cpu-utilization {
alert-type hardware.cpu.routing_engine.routing-engine-cpu-utilization;
synopsis "Routing engine CPU KPI";
description "Sets health based on increase in RE CPU utilization";
frequency 1offset;
/*
* Sets color to green when re-cpu utilization is less-than re-cpu-utilization-low-threshold
*/
term re-cpu-utilization-normal {
when {
less-than "$re-cpu-utilization" "$re-cpu-utilization-low-threshold";
less-than-or-equal-to "$re-cpu-utilization-anomaly" 0;
}
then {
status {
color green;
message "$routing-engine CPU utilization($re-cpu-utilization%) is normal";
}
}
}
/*
* Sets color to yellow when re-cpu utilization is below low threshold ($re-cpu-utilization-low-threshold)
* and the temperature value is anomalous.
*/
term is-re-cpu-utilization-anomalous {
when {
less-than "$re-cpu-utilization" "$re-cpu-utilization-low-threshold";
equal-to "$re-cpu-utilization-anomaly" 1;
}
then {
status {
color yellow;
message "$routing-engine CPU utilization is anomalous";
}
}
}
/*
* Sets color to green when re-cpu utilization is less-than re-cpu-utilization-low-threshold
*
*/
term is-re-cpu-utilization-less-than-low-threshold {
when {
less-than "$re-cpu-utilization" "$re-cpu-utilization-low-threshold";
}
then {
status {
color green;
message "$routing-engine CPU utilization($re-cpu-utilization%) is normal";
}
}
}
/*
* Sets color to yellow when re-cpu utilization is greater-than-or-equal-to re-cpu-utilization-low-threshold
*/
term is-re-cpu-utilization-middle {
when {
greater-than-or-equal-to "$re-cpu-utilization" "$re-cpu-utilization-low-threshold";
less-than "$re-cpu-utilization" "$re-cpu-utilization-high-threshold";
}
then {
status {
color yellow;
message "$routing-engine CPU utilization($re-cpu-utilization%) is greater than or equal to high threshold ($re-cpu-utilization-low-threshold%)";
}
}
}
/*
* Sets color to red when re-cpu utilization is greater-than-or-equal-to re-cpu-utilization-high-threshold
*/
term is-re-cpu-utilization-abnormal {
when {
greater-than-or-equal-to "$re-cpu-utilization" "$re-cpu-utilization-high-threshold";
}
then {
status {
color red;
message "$routing-engine CPU utilization($re-cpu-utilization%) exceeds critical threshold($re-cpu-utilization-high-threshold%)";
}
}
}
}
trigger routing-engine-memory-buffer-utilization {
alert-type hardware.memory.routing_engine.routing-engine-memory-buffer-utilization;
synopsis "RE system memory buffer utilization kpi";
description "Sets health based on increase in system memory buffer utilization";
frequency 1offset;
/*
* Sets color to green when re-memory-buffer utilization is less-than re-memory-buffer-low-threshold
*/
term is-re-memory-buffer-utilization-normal {
when {
less-than "$re-memory-buffer" "$re-memory-buffer-low-threshold";
less-than-or-equal-to "$re-memory-buffer-anomaly" 0;
}
then {
status {
color green;
message "$routing-engine memory buffer utilization($re-memory-buffer%) is normal";
}
}
}
/*
* Sets color to yellow when re-memory-buffer utilization is below low threshold ($re-memory-buffer-low-threshold)
* and the re-memory-buffer value is anomalous.
*/
term is-re-memory-buffer-anomalous {
when {
less-than "$re-memory-buffer" "$re-memory-buffer-low-threshold";
equal-to "$re-memory-buffer-anomaly" 1;
}
then {
status {
color yellow;
message "$routing-engine memory buffer utilization is anomalous";
}
}
}
/*
* Sets color to green when re-memory-buffer utilization is below low threshold ($re-memory-buffer-low-threshold)
*
*/
term is-re-memory-buffer-utilization-less-than-low-threshold {
when {
less-than "$re-memory-buffer" "$re-memory-buffer-low-threshold";
}
then {
status {
color green;
message "$routing-engine memory buffer utilization($re-memory-buffer%) is normal";
}
}
}
/*
* Sets color to yellow when re-memory-buffer utilization is greater-than-or-equal-to re-memory-buffer-low-threshold
*/
term is-re-memory-buffer-utilization-middle {
when {
greater-than-or-equal-to "$re-memory-buffer" "$re-memory-buffer-low-threshold";
less-than "$re-memory-buffer" "$re-memory-buffer-high-threshold";
}
then {
status {
color yellow;
message "$routing-engine memory buffer utilization($re-memory-buffer%) is greater than or equal to high threshold($re-memory-buffer-low-threshold%)";
}
}
}
/*
* Sets color to red when re-memory-buffer utilization is greater-than-or-equal-to re-memory-buffer-high-threshold
*/
term is-re-memory-buffer-utilization-abnormal {
when {
greater-than-or-equal-to "$re-memory-buffer" "$re-memory-buffer-high-threshold";
}
then {
status {
color red;
message "$routing-engine memory buffer utilization($re-memory-buffer%) exceed critical threshold($re-memory-buffer-high-threshold%)";
}
}
}
}
/*
* Variables with default values. Default values can be changed
* while deploying playbook instance.
*/
variable memory-buffer-re-high-threshold {
value 75;
description "Memory buffer high threshold: Utilization increase between metrics, before we report anomaly";
type int;
}
variable memory-buffer-re-low-threshold {
value 50;
description "Memory buffer low threshold: Utilization increase between metrics, before we report anomaly";
type int;
}
variable re-cpu-high-threshold {
value 80;
description "RE CPU utilization high threshold: Utilization increase between metrics, before we report anomaly";
type int;
}
variable re-cpu-low-threshold {
value 50;
description "RE CPU utilization low threshold: Utilization increase between metrics, before we report anomaly";
type int;
}
variable re-slot-no {
value 0-1;
description "Routing engine numbers to monitor, regular expression, e.g. '0'";
type string;
}
rule-properties {
version 1;
domain-name system;
contributor juniper;
category advanced;
supported-healthbot-version 4.2.0;
supported-devices {
juniper {
operating-system junosEvolved {
sensors components-oc;
products ACX {
sensors components-oc;
platforms ACX7024 {
releases 22.3R1 {
release-support min-supported-release;
}
}
platforms ACX7024X {
releases 22.3R1 {
release-support min-supported-release;
}
}
platforms ACX7100 {
releases 22.3R1 {
release-support min-supported-release;
}
}
platforms ACX7348 {
releases 22.3R1 {
release-support min-supported-release;
}
}
platforms ACX7509 {
releases 22.3R1 {
release-support min-supported-release;
}
}
}
products PTX {
platforms PTX10008 {
releases 22.2R3 {
release-support min-supported-release;
}
}
}
}
operating-system junos {
sensors components-oc;
products MX {
sensors components-oc;
platforms MX204 {
releases 22.2R3 {
release-support min-supported-release;
}
}
platforms MX304 {
releases 22.2R3 {
release-support min-supported-release;
}
}
platforms MX10004 {
releases 22.3R1 {
release-support min-supported-release;
}
}
platforms MX10008 {
releases 22.3R1 {
release-support min-supported-release;
}
}
platforms MX10016 {
releases 22.3R1 {
release-support min-supported-release;
}
}
}
products JNP {
sensors components-oc;
platforms JNP10004 {
releases 22.3R1 {
release-support min-supported-release;
}
}
platforms JNP10008 {
releases 22.3R1 {
release-support min-supported-release;
}
}
platforms JNP10016 {
releases 22.3R1 {
release-support min-supported-release;
}
}
}
}
}
}
}
}
}
}