Class: Nagios::API::Service
Instance Attribute Summary
Attributes inherited from Resource
#api_client, #attributes
Instance Method Summary
collapse
Methods inherited from Resource
#initialize, #method_missing, #to_hash
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Nagios::API::Resource
Instance Method Details
#downtimes ⇒ Object
43
44
45
46
47
48
|
# File 'lib/nagios/api/service.rb', line 43
def downtimes
return nil unless state
dts = state['downtimes'] ? state['downtimes'].values : []
dts.collect { |dt| Nagios::API::Downtime.new(dt.merge(service: self, api_client: api_client)) }
end
|
#name ⇒ Object
33
34
35
|
# File 'lib/nagios/api/service.rb', line 33
def name
service
end
|
#schedule_downtime(params = {}) ⇒ Object
schedule_downtime arguments:
author
start_time
fixed
duration
end_time
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/nagios/api/service.rb', line 57
def schedule_downtime(params = {})
params = params.dup
params[:host] = host.name
params[:service] = name
params[:start_time] = params[:start_time].to_i if params[:start_time]
params[:end_time] = params[:end_time].to_i if params[:end_time]
result = api_client.api.post("/schedule_downtime", params)
raise StandardError, "Unknown response scheduling downtime: #{result}" unless result == "scheduled"
true
end
|
#state ⇒ Object
37
38
39
40
41
|
# File 'lib/nagios/api/service.rb', line 37
def state
return nil unless host
host.state['services'][name]
end
|
#status ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/nagios/api/service.rb', line 71
def status
case current_state.to_i
when 0
:ok
when 1
:warning
when 2
:critical
else
:unknown
end
end
|
#status_details ⇒ Object
84
85
86
|
# File 'lib/nagios/api/service.rb', line 84
def status_details
plugin_output
end
|