Class: OpsviewRest::Servicecheck

Inherits:
Object
  • Object
show all
Includes:
Mixin
Defined in:
lib/opsview_rest/servicecheck.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin

#resource_path, #save, #to_json

Constructor Details

#initialize(opsview, options = {}) ⇒ Servicecheck

Returns a new instance of Servicecheck.



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
45
46
47
48
49
50
# File 'lib/opsview_rest/servicecheck.rb', line 10

def initialize(opsview, options = {})
  @options = {
    :name => "Unknown",
    :description => "Unknown",
    :keywords => [],
    :attribute => nil,
    :servicegroup => "Unknown",
    :dependencies => [ "Opsview Agent" ],
    :check_period => "24x7",
    :check_interval => "5",
    :check_attempts => "3",
    :retry_check_interval => "1",
    :plugin => "check_nrpe",
    :args => "",
    :stalking => nil,
    :volatile => false,
    :invertresults => false,
    :notification_options => "w,c,r",
    :notification_period => nil,
    :notification_interval => nil,
    :flap_detection_enabled => true,
    :checktype => "Active Plugin",
    :save    => true,
    :replace => false
  }.update options

  @opsview = opsview
  @resource_type = @options[:type]

  @options[:keywords] = @options[:keywords].map { |x| { "name" => x } }
  @options[:servicegroup] = { "name" => @options[:servicegroup] }
  @options[:dependencies] = @options[:dependencies].map { |x| { "name" => x } }
  @options[:check_period] = { "name" => @options[:check_period] }
  @options[:plugin] = { "name" => @options[:plugin] }
  @options[:volatile] = if @options[:volatile] then 1 else 0 end
  @options[:invertresults] = if @options[:invertresults] then 1 else 0 end
  @options[:flap_detection_enabled] = if @options[:flap_detection_enabled] then 1 else 0 end
  @options[:checktype] = { "name" => @options[:checktype] }

  save(@options[:replace]) if @options[:save]
end

Instance Attribute Details

#opsviewObject

Returns the value of attribute opsview.



8
9
10
# File 'lib/opsview_rest/servicecheck.rb', line 8

def opsview
  @opsview
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/opsview_rest/servicecheck.rb', line 8

def options
  @options
end

#resource_typeObject

Returns the value of attribute resource_type.



8
9
10
# File 'lib/opsview_rest/servicecheck.rb', line 8

def resource_type
  @resource_type
end