-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDiscovery_FOR_Example.tpl
44 lines (32 loc) · 1.19 KB
/
Discovery_FOR_Example.tpl
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
tpl 1.15 module Traversys.forExample;
metadata
origin:= "Traversys";
_name:= "FOR Loop Example";
tree_path:= "Custom", "Traversys", "FOR Loop Example";
end metadata;
pattern forExample 1.0
""" FOR Loop Example """
overview
tags traversys, example;
end overview;
triggers
on si := SoftwareInstance created, confirmed where type = "BMC Discovery";
end triggers;
body
host:= model.host(si);
failures := [];
baseline := discovery.runCommand(host, "/usr/tideway/bin/tw_baseline --no-highlight");
messages := regex.extractAll(baseline.result, regex ":\s(.*)\s\(\w+\)");
highest := regex.extract(baseline.result, regex "Highest severity failure was (\w+)", raw "\1");
log.info("Looping baseline failures...");
for message in messages do
if message matches regex "(INFO|MINOR|MAJOR|CRITICAL):\s" then
list.append(failures, message);
log.info("%message%");
end if;
end for;
si.highest_baseline_failure := highest;
si.baseline_failure_messages := failures;
model.addDisplayAttribute(si, [ "highest_baseline_failure", "baseline_failure_messages" ] );
end body;
end pattern;