class DogapiDemo::V1::MonitorService

Constants

API_VERSION

Public Instance Methods

cancel_downtime(downtime_id) click to toggle source
    # File lib/dogapi-demo/v1/monitor.rb
203 def cancel_downtime(downtime_id)
204   begin
205     params = {
206       :api_key => @api_key,
207       :application_key => @application_key
208     }
209 
210     request(Net::HTTP::Delete, "/api/#{API_VERSION}/downtime/#{downtime_id}", params, nil, false)
211   rescue Exception => e
212     suppress_error_if_silent e
213   end
214 end
delete_monitor(monitor_id) click to toggle source
   # File lib/dogapi-demo/v1/monitor.rb
63 def delete_monitor(monitor_id)
64   begin
65     params = {
66       :api_key => @api_key,
67       :application_key => @application_key
68     }
69 
70     request(Net::HTTP::Delete, "/api/#{API_VERSION}/monitor/#{monitor_id}", params, nil, false)
71   rescue Exception => e
72     suppress_error_if_silent e
73   end
74 end
get_all_downtimes(options = {}) click to toggle source
    # File lib/dogapi-demo/v1/monitor.rb
216 def get_all_downtimes(options = {})
217   begin
218     params = {
219       :api_key => @api_key,
220       :application_key => @application_key
221     }
222 
223     if options[:current_only]
224       params[:current_only] = options[:current_only]
225       options.delete :current_only
226     end
227 
228     request(Net::HTTP::Get, "/api/#{API_VERSION}/downtime", params, nil, false)
229   rescue Exception => e
230     suppress_error_if_silent e
231   end
232 end
get_all_monitors(options = {}) click to toggle source
    # File lib/dogapi-demo/v1/monitor.rb
 76 def get_all_monitors(options = {})
 77   begin
 78     params = {
 79       :api_key => @api_key,
 80       :application_key => @application_key
 81     }
 82 
 83     # :group_states is an optional list of statuses to filter returned
 84     # groups. If no value is given then no group states will be returned.
 85     # Possible values are: "all", "ok", "warn", "alert", "no data".
 86     if options[:group_states]
 87       params[:group_states] = options[:group_states]
 88       params[:group_states] = params[:group_states].join(',') if params[:group_states].respond_to?(:join)
 89     end
 90 
 91     # :tags is an optional list of scope tags to filter the list of monitors
 92     # returned. If no value is given, then all monitors, regardless of
 93     # scope, will be returned.
 94     if options[:tags]
 95       params[:tags] = options[:tags]
 96       params[:tags] = params[:tags].join(',') if params[:tags].respond_to?(:join)
 97     end
 98 
 99     request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor", params, nil, false)
100   rescue Exception => e
101     suppress_error_if_silent e
102   end
103 end
get_downtime(downtime_id) click to toggle source
    # File lib/dogapi-demo/v1/monitor.rb
190 def get_downtime(downtime_id)
191   begin
192     params = {
193       :api_key => @api_key,
194       :application_key => @application_key
195     }
196 
197     request(Net::HTTP::Get, "/api/#{API_VERSION}/downtime/#{downtime_id}", params, nil, false)
198   rescue Exception => e
199     suppress_error_if_silent e
200   end
201 end
get_monitor(monitor_id, options = {}) click to toggle source
   # File lib/dogapi-demo/v1/monitor.rb
45 def get_monitor(monitor_id, options = {})
46   begin
47     params = {
48       :api_key => @api_key,
49       :application_key => @application_key
50     }
51 
52     # :group_states is an optional list of statuses to filter returned
53     # groups. If no value is given then no group states will be returned.
54     # Possible values are: "all", "ok", "warn", "alert", "no data".
55     params[:group_states] = options[:group_states].join(',') if options[:group_states]
56 
57     request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor/#{monitor_id}", params, nil, false)
58   rescue Exception => e
59     suppress_error_if_silent e
60   end
61 end
monitor(type, query, options = {}) click to toggle source
   # File lib/dogapi-demo/v1/monitor.rb
10 def monitor(type, query, options = {})
11   begin
12     params = {
13       :api_key => @api_key,
14       :application_key => @application_key
15     }
16 
17     body = {
18       'type' => type,
19       'query' => query,
20     }.merge options
21 
22     request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor", params, body, true)
23   rescue Exception => e
24     suppress_error_if_silent e
25   end
26 end
mute_host(hostname, options = {}) click to toggle source

HOST MUTING

    # File lib/dogapi-demo/v1/monitor.rb
237 def mute_host(hostname, options = {})
238   begin
239     params = {
240       :api_key => @api_key,
241       :application_key => @application_key
242     }
243 
244     request(Net::HTTP::Post, "/api/#{API_VERSION}/host/#{hostname}/mute", params, options, true)
245   rescue Exception => e
246     suppress_error_if_silent e
247   end
248 end
mute_monitor(monitor_id, options = {}) click to toggle source
    # File lib/dogapi-demo/v1/monitor.rb
131 def mute_monitor(monitor_id, options = {})
132   begin
133     params = {
134       :api_key => @api_key,
135       :application_key => @application_key
136     }
137 
138     request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/#{monitor_id}/mute", params, options, true)
139   rescue Exception => e
140     suppress_error_if_silent e
141   end
142 end
mute_monitors() click to toggle source
    # File lib/dogapi-demo/v1/monitor.rb
105 def mute_monitors()
106   begin
107     params = {
108       :api_key => @api_key,
109       :application_key => @application_key
110     }
111 
112     request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/mute_all", params, nil, false)
113   rescue Exception => e
114     suppress_error_if_silent e
115   end
116 end
schedule_downtime(scope, options = {}) click to toggle source

DOWNTIMES

    # File lib/dogapi-demo/v1/monitor.rb
160 def schedule_downtime(scope, options = {})
161   begin
162     params = {
163       :api_key => @api_key,
164       :application_key => @application_key
165     }
166 
167     body = {
168       'scope' => scope
169     }.merge options
170 
171     request(Net::HTTP::Post, "/api/#{API_VERSION}/downtime", params, body, true)
172   rescue Exception => e
173     suppress_error_if_silent e
174   end
175 end
unmute_host(hostname) click to toggle source
    # File lib/dogapi-demo/v1/monitor.rb
249 def unmute_host(hostname)
250   begin
251     params = {
252       :api_key => @api_key,
253       :application_key => @application_key
254     }
255 
256     request(Net::HTTP::Post, "/api/#{API_VERSION}/host/#{hostname}/unmute", params, nil, true)
257   rescue Exception => e
258     suppress_error_if_silent e
259   end
260 end
unmute_monitor(monitor_id, options = {}) click to toggle source
    # File lib/dogapi-demo/v1/monitor.rb
144 def unmute_monitor(monitor_id, options = {})
145   begin
146     params = {
147       :api_key => @api_key,
148       :application_key => @application_key
149     }
150 
151     request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/#{monitor_id}/unmute", params, options, true)
152   rescue Exception => e
153     suppress_error_if_silent e
154   end
155 end
unmute_monitors() click to toggle source
    # File lib/dogapi-demo/v1/monitor.rb
118 def unmute_monitors()
119   begin
120     params = {
121       :api_key => @api_key,
122       :application_key => @application_key
123     }
124 
125     request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/unmute_all", params, nil, false)
126   rescue Exception => e
127     suppress_error_if_silent e
128   end
129 end
update_downtime(downtime_id, options = {}) click to toggle source
    # File lib/dogapi-demo/v1/monitor.rb
177 def update_downtime(downtime_id, options = {})
178   begin
179     params = {
180       :api_key => @api_key,
181       :application_key => @application_key
182     }
183 
184     request(Net::HTTP::Put, "/api/#{API_VERSION}/downtime/#{downtime_id}", params, options, true)
185   rescue Exception => e
186     suppress_error_if_silent e
187   end
188 end
update_monitor(monitor_id, query, options) click to toggle source
   # File lib/dogapi-demo/v1/monitor.rb
28 def update_monitor(monitor_id, query, options)
29   begin
30     params = {
31       :api_key => @api_key,
32       :application_key => @application_key
33     }
34 
35     body = {
36       'query' => query,
37     }.merge options
38 
39     request(Net::HTTP::Put, "/api/#{API_VERSION}/monitor/#{monitor_id}", params, body, true)
40   rescue Exception => e
41     suppress_error_if_silent e
42   end
43 end