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
|
# File 'lib/ymlex/argusyml.rb', line 19
def get_alert lvl={}
level = @default_level.merge(lvl)
oncall = level["oncall"]
manager = level["manager"]
mail = ""
sms = ""
hi = ""
web = ""
level.each do |role, lvl|
if ["op","rd","qa"].include? role
mail = "#{@contacts[role]};#{mail}" if lvl != nil
if lvl =~ /fatal/ or (lvl =~ /(warn|err)/ and role != "op")
sms = "#{@contacts[role]};#{sms}"
end
end
end
lvl = level["op"]
mail = "#{mail}" if lvl != nil
sms = "#{oncall};#{sms}" if lvl =~ /err/ or lvl =~ /fatal/
if lvl =~ /fatal/
remind_time = "900"
elsif lvl =~ /err/
remind_time = "0"
else
remind_time = "0"
end
if lvl =~ /fatal/
merge_window = "0"
rule_level = "4"
elsif lvl =~ /err/
merge_window = "300"
rule_level = "3"
elsif lvl =~ /warn/
merge_window = "600"
rule_level = "2"
elsif lvl =~ /info/
merge_window = "600"
rule_level = "1"
else
merge_window = "600"
rule_level = "1"
end
web = "g_ecomop_maop_all;g_ecomop_maop_manager;" if sms.include? "g_ecomop_maop_all" or sms.include? "#z_ecomop_maop_oncall" or (lvl =~ /fatal/ and (manager.include? "#z_ecomop_maop_oncall" or manager.include? "g_ecomop_maop_manager"))
sms.gsub!(/g_ecomop_maop_all/,'#z_ecomop_maop_oncall')
mail.gsub!(/g_ecomop_maop_all/,'ma-op')
mail_list = mail.split ";"
mail_list_uniq = mail_list.uniq
if mail_list_uniq.nil? mail = ""
else
mail_list_uniq.delete ""
mail = mail_list_uniq.join ";"
end
sms_list = sms.split ";"
sms_list_uniq = sms_list.uniq
if sms_list_uniq.nil? sms = ""
else
sms_list_uniq.delete ""
sms = sms_list_uniq.join ";"
end
hi_list = hi.split ";"
hi_list_uniq = hi_list.uniq
if hi_list_uniq.nil? hi = ""
else
hi_list_uniq.delete ""
hi = hi_list_uniq.join ";"
end
alt = {
"max_alert_times" => level["max_alert_times"] || "1",
"alert_threshold_percent" => level["alert_threshold_percent"] || "0",
"sms_threshold_percent" => level["sms_threshold_percent"] || "0",
"remind_interval_second" => level["remind_interval_second"] || remind_time,
"other" => {
"merge_window" => merge_window,
"level" => rule_level,
"lvl" => lvl,
},
"mail" => mail,
"sms" => sms,
"hi" => hi,
"web" => web,
}
if lvl =~ /fatal/ and manager != ""
alt["level1_upgrade_interval"] = "900"
alt["level1_upgrade_sms"] = "#{manager};"
end
alt
end
|