Class: Proxy::Monitoring::Icinga2::Provider
- Inherits:
-
Provider
- Object
- Provider
- Proxy::Monitoring::Icinga2::Provider
show all
- Includes:
- Log, Util
- Defined in:
- lib/smart_proxy_monitoring_icinga2/monitoring_icinga2_main.rb
Constant Summary
collapse
- ICINGA_HOST_ATTRS =
%w(display_name address address6 templates)
- ICINGA_ATTR_MAPPING =
{
'ip' => 'address',
'ip6' => 'address6',
}.freeze
Instance Method Summary
collapse
Instance Method Details
#create_host(host, attributes) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/smart_proxy_monitoring_icinga2/monitoring_icinga2_main.rb', line 24
def create_host(host, attributes)
request_url = "/objects/hosts/#{host}"
result = with_errorhandling("Create #{host}") do
Icinga2Client.put(request_url, host_data(attributes).to_json)
end
result.to_json
end
|
#query_host(host) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/smart_proxy_monitoring_icinga2/monitoring_icinga2_main.rb', line 15
def query_host(host)
request_url = "/objects/hosts/#{host}?attrs=vars&attrs=address&attrs=address6&attrs=templates"
result = with_errorhandling("Query #{host}") do
Icinga2Client.get(request_url)
end
host_attributes(host, result['results'][0]['attrs'])
end
|
#remove_downtime_host(host, author, comment) ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'lib/smart_proxy_monitoring_icinga2/monitoring_icinga2_main.rb', line 51
def remove_downtime_host(host, author, )
request_url = "/actions/remove-downtime?type=Host&filter=#{uri_encode_filter("host.name==\"#{host}\"\&\&author==\"#{author}\"\&\&comment=\"#{}\"")}"
data = {}
result = with_errorhandling("Remove downtime from #{host}") do
Icinga2Client.post(request_url, data.to_json)
end
result.to_json
end
|
#remove_host(host) ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/smart_proxy_monitoring_icinga2/monitoring_icinga2_main.rb', line 42
def remove_host(host)
request_url = "/objects/hosts/#{host}?cascade=1"
result = with_errorhandling("Remove #{host}") do
Icinga2Client.delete(request_url)
end
result.to_json
end
|
#set_downtime_host(host, author, comment, start_time, end_time) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/smart_proxy_monitoring_icinga2/monitoring_icinga2_main.rb', line 61
def set_downtime_host(host, author, , start_time, end_time)
request_url = "/actions/schedule-downtime?type=Host&filter=#{uri_encode_filter("host.name==\"#{host}\"")}"
data = {
'author' => author,
'comment' => ,
'start_time' => start_time,
'end_time' => end_time,
'duration' => 1000
}
result = with_errorhandling("Set downtime on #{host}") do
Icinga2Client.post(request_url, data.to_json)
end
result.to_json
end
|
#update_host(host, attributes) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/smart_proxy_monitoring_icinga2/monitoring_icinga2_main.rb', line 33
def update_host(host, attributes)
request_url = "/objects/hosts/#{host}"
result = with_errorhandling("Update #{host}") do
Icinga2Client.post(request_url, host_data(attributes).to_json)
end
result.to_json
end
|