opsview_rest 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/TODO.md DELETED
@@ -1,20 +0,0 @@
1
- TODO List
2
- =========
3
-
4
- 1. Figure out a way to instantiate a ton of methods for all of the different
5
- resource types. There isn't a nice way to deal with, say, hosts, and
6
- hostgroups at the moment (since they all have different parameters.)
7
- The only things that are common between the different resource types
8
- are "name" and "id".
9
- 1a. If not this, then there should be a better way to deal with the plethora
10
- of fields that we could possibly update in Opsview for each resource type.
11
- I've mostly based the code off of Adam Jacob's dynect_rest gem, which
12
- has a much simpler API and a predictable set of parameters - thus, it
13
- makes sense to dynamically create a ton of methods and allow stuff like
14
- "dynect.record.ip.foobar" as an accessor.
15
-
16
- One thought is to simply choose a functional subset of the parameters we
17
- could pass into each type of resource, and add more as the need arises.
18
- Another thought is to simply pass in a hash with a bunch of data in it,
19
- but I'd rather not do this, as it'd make the user guess how best to format
20
- the data.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.0
@@ -1,32 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class Attribute
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :options, :opsview, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :name => "PROCESSES",
13
- :arg1 => "",
14
- :arg2 => "",
15
- :arg3 => "",
16
- :arg4 => "",
17
- :value => "",
18
- :servicechecks => [],
19
- :save => true,
20
- :replace => false
21
- }.update options
22
-
23
- @opsview = opsview
24
- @resource_type = @options[:type]
25
-
26
- @options[:servicechecks] = @options[:servicechecks].map { |x| { "name" => x } }
27
-
28
- save(@options[:replace]) if @options[:save]
29
- end
30
-
31
- end
32
- end
@@ -1,71 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class Contact
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :options, :opsview, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :name => "foobar",
13
- :fullname => "",
14
- :description => "",
15
- :encrypted_password => "$apr1$HTQogYE7$09TNcZWa/WzoBXdUF6Iyr1",
16
- :realm => "local",
17
- :language => "",
18
- :role => "View all, change none",
19
- :variables => [
20
- { :value => "", :name => "EMAIL" },
21
- { :value => 1, :name => "RSS_COLLAPSED" },
22
- { :value => 1440, :name => "RSS_MAXIMUM_AGE" },
23
- { :value => 30, :name => "RSS_MAXIMUM_ITEMS" }
24
- ],
25
- :notificationprofiles => [
26
- { :name => "24x7",
27
- :host_notification_options => "u,d,r,f",
28
- :notificationmethods => [
29
- { :name => "Email" }
30
- ],
31
- :servicegroups => [],
32
- :all_servicegroups => 1,
33
- :all_hostgroups => 0,
34
- :keywords => [],
35
- :service_notification_options => "w,c,r,u,f",
36
- :hostgroups => [],
37
- :notification_level => 1,
38
- :notification_period => { :name => "24x7" } },
39
- { :name => "8x5",
40
- :host_notification_options => "u,d,r,f",
41
- :notificationmethods => [
42
- { :name => "Email" }
43
- ],
44
- :servicegroups => [],
45
- :all_servicegroups => 1,
46
- :all_hostgroups => 0,
47
- :keywords => [],
48
- :service_notification_options => "w,c,r,u,f",
49
- :hostgroups => [],
50
- :notification_level => 1,
51
- :notification_period => { :name => "workhours" } }
52
- ],
53
- :save => true,
54
- :replace => false
55
- }.update options
56
-
57
- @opsview = opsview
58
- @resource_type = @options[:type]
59
-
60
- @options[:all_servicegroups] = if @options[:all_servicegroups] then 1 else 0 end
61
- @options[:all_hostgroups] = if @options[:all_hostgroups] then 1 else 0 end
62
- @options[:servicegroups] = @options[:servicegroups].map { |x| { "name" => x } }
63
- @options[:keywords] = @options[:keywords].map { |x| { "name" => x } }
64
- @options[:hostgroups] = @options[:hostgroups].map { |x| { "name" => x } }
65
- @options[:role] = { "name" => @options[:role] }
66
-
67
- save(@options[:replace]) if @options[:save]
68
- end
69
-
70
- end
71
- end
@@ -1,77 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class Host
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :options, :opsview, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- # Default set of attributes to send to Opsview:
12
- @options = {
13
- :flap_detection_enabled => false,
14
- :snmpv3_privprotocol => nil,
15
- :hosttemplates => [],
16
- :keywords => [],
17
- :check_period => "24x7",
18
- :hostattributes => [],
19
- :notification_period => "24x7",
20
- :name => "unknown",
21
- :rancid_vendor => nil,
22
- :snmp_community => "public",
23
- :hostgroup => "Unknown",
24
- :enable_snmp => false,
25
- :monitored_by => "Master Monitoring Server",
26
- :alias => "Managed Host",
27
- :uncommitted => false,
28
- :parents => [],
29
- :icon => { "name" => "LOGO - Opsview" },
30
- :retry_check_interval => 1,
31
- :ip => "localhost",
32
- :use_mrtg => false,
33
- :servicechecks => [],
34
- :use_rancid => false,
35
- :nmis_node_type => "router",
36
- :snmp_version => "2c",
37
- :snmp_authpassword => "",
38
- :use_nmis => false,
39
- :rancid_connection_type => "ssh",
40
- :snmpv3_authprotocol => nil,
41
- :rancid_username => nil,
42
- :rancid_password => nil,
43
- :check_command => "ping",
44
- :check_attempts => 2,
45
- :check_interval => 0,
46
- :notification_interval => 60,
47
- :snmp_port => 161,
48
- :snmpv3_username => "",
49
- :snmpv3_privpassword => "",
50
- :other_addresses => "",
51
- :save => true,
52
- :replace => false
53
- }.update options
54
-
55
- @opsview = opsview
56
- @resource_type = @options[:type]
57
-
58
- # Add any weird exceptions here (like hostgroups having to be mapped
59
- # to "name" => hostgroup, etc.):
60
- @options[:flap_detection_enabled] = if @options[:flap_detection_enabled] then 1 else 0 end
61
- @options[:enable_snmp] = if @options[:enable_snmp] then 1 else 0 end
62
- @options[:use_mrtg] = if @options[:use_mrtg] then 1 else 0 end
63
- @options[:use_rancid] = if @options[:use_rancid] then 1 else 0 end
64
- @options[:use_nmis] = if @options[:use_nmis] then 1 else 0 end
65
- @options[:uncommitted] = if @options[:uncommitted] then 1 else 0 end
66
- @options[:check_period] = { "name" => @options[:check_period] }
67
- @options[:hostgroup] = { "name" => @options[:hostgroup] }
68
- @options[:notification_period] = { "name" => @options[:notification_period] }
69
- @options[:monitored_by] = { "name" => @options[:monitored_by] }
70
- @options[:servicechecks] = @options[:servicechecks].map { |x| { "name" => x } }
71
- @options[:check_command] = { "name" => @options[:check_command] }
72
-
73
- save(@options[:replace]) if @options[:save]
74
- end
75
-
76
- end
77
- end
@@ -1,32 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class Hostcheckcommand
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :opsview, :options, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :name => "ping",
13
- :args => "-H $HOSTADDRESS$ -t 3 -w 500.0,80% -c 1000.0,100%",
14
- :priority => 1,
15
- :plugin => "check_icmp",
16
- :uncommitted => false,
17
- :save => true,
18
- :replace => false
19
- }.update options
20
-
21
- @opsview = opsview
22
- @resource_type = @options[:type]
23
-
24
- @options[:plugin] = { "name" => @options[:plugin] }
25
- @options[:hosts] = @options[:hosts].map { |x| { "name" => x } }
26
- @options[:uncommitted] = if @options[:uncommitted] then 1 else 0 end
27
-
28
- save(@options[:replace]) if @options[:save]
29
- end
30
-
31
- end
32
- end
@@ -1,29 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class Hostgroup
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :opsview, :options, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :parent => "Opsview",
13
- :name => "unknown",
14
- :save => true,
15
- :replace => false
16
- }.update options
17
-
18
- @opsview = opsview
19
- @resource_type = @options[:type]
20
-
21
- @options[:parent] = { "name" => @options[:parent] }
22
- @options[:hosts] = @options[:hosts].map { |x| { "name" => x } }
23
- @options[:children] = @options[:children].map { |x| { "name" => x } }
24
-
25
- save(@options[:replace]) if @options[:save]
26
- end
27
-
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class Hosttemplate
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :options, :opsview, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :name => "Unknown",
13
- :description => "Unknown",
14
- :servicechecks => [],
15
- :managementurls => [],
16
- :save => true,
17
- :replace => false
18
- }.update options
19
-
20
- @opsview = opsview
21
- @resource_type = @options[:type]
22
-
23
- @options[:servicechecks] = @options[:servicechecks].map { |x| { "name" => x } }
24
-
25
- save(@options[:replace]) if @options[:save]
26
- end
27
-
28
- end
29
- end
@@ -1,39 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class Keyword
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :options, :opsview, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :name => "Unknown",
13
- :all_hosts => false,
14
- :hosts => [],
15
- :roles => [ "View some, change none" ],
16
- :all_servicechecks => false,
17
- :servicechecks => [],
18
- :description => "",
19
- :style => "group_by_host",
20
- :enabled => true,
21
- :save => true,
22
- :replace => false
23
- }.update options
24
-
25
- @opsview = opsview
26
- @resource_type = @options[:type]
27
-
28
- @options[:all_hosts] = if @options[:all_hosts] then 1 else 0 end
29
- @options[:all_servicechecks] = if @options[:all_servicechecks] then 1 else 0 end
30
- @options[:enabled] = if @options[:enabled] then 1 else 0 end
31
- @options[:servicechecks] = @options[:servicechecks].map { |x| { "name" => x } }
32
- @options[:hosts] = @options[:hosts].map { |x| { "name" => x } }
33
- @options[:roles] = @options[:roles].map { |x| { "name" => x } }
34
-
35
- save(@options[:replace]) if @options[:save]
36
- end
37
-
38
- end
39
- end
@@ -1,25 +0,0 @@
1
- class OpsviewRest
2
- module Mixin
3
-
4
- def resource_path(full=false)
5
- if (full == true || full == :full)
6
- "/rest/config/#{self.resource_type}"
7
- else
8
- "config/#{self.resource_type}"
9
- end
10
- end
11
-
12
- def save(replace=false)
13
- if replace == true || replace == :replace
14
- self.opsview.put(self.resource_path, self)
15
- else
16
- self.opsview.post(self.resource_path, self)
17
- end
18
- end
19
-
20
- def to_json
21
- self.options.to_json
22
- end
23
-
24
- end
25
- end
@@ -1,33 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class MonitoringServer
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :options, :opsview, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :name => "Slave",
13
- :roles => [],
14
- :activated => true,
15
- :monitors => [],
16
- :nodes => [],
17
- :save => true,
18
- :replace => false
19
- }.update options
20
-
21
- @opsview = opsview
22
- @resource_type = @options[:type]
23
-
24
- @option[:roles] = @option[:roles].map { |x| { "name" => x } }
25
- @option[:monitors] = @option[:monitors].map { |x| { "name" => x } }
26
- @option[:nodes] = @option[:nodes].map { |x| { "host" => { "name" => x } } }
27
- @options[:activated] = if @options[:activated] then 1 else 0 end
28
-
29
- save(@options[:replace]) if @options[:save]
30
- end
31
-
32
- end
33
- end
@@ -1,31 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class NotificationMethod
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :options, :opsview, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :name => "Unknown",
13
- :master => false,
14
- :active => true,
15
- :command => "notify_by_email",
16
- :contact_variables => "EMAIL"
17
- :save => true,
18
- :replace => false
19
- }.update options
20
-
21
- @opsview = opsview
22
- @resource_type = @options[:type]
23
-
24
- @options[:master] = if @options[:master] then 1 else 0 end
25
- @options[:active] = if @options[:active] then 1 else 0 end
26
-
27
- save(@options[:replace]) if @options[:save]
28
- end
29
-
30
- end
31
- end
@@ -1,41 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class Role
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :options, :opsview, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :name => "Unknown",
13
- :description => "",
14
- :all_hostgroups => true,
15
- :all_servicegroups => true,
16
- :all_keywords => false,
17
- :access_hostgroups => [],
18
- :access_servicegroups => [],
19
- :access_keywords => [],
20
- :hostgroups => [],
21
- :monitoringservers => [],
22
- :accesses => [ "NOTIFYSOME", "PASSWORDSAVE", "VIEWALL" ],
23
- :save => true,
24
- :replace => false
25
- }.update options
26
-
27
- @opsview = opsview
28
- @resource_type = @options[:type]
29
-
30
- @options[:hostgroups] = @options[:hostgroups].map { |x| { "name" => x } }
31
- @options[:monitoringservers] = @options[:monitoringservers].map { |x| { "name" => x } }
32
- @options[:accesses] = @options[:accesses].map { |x| { "name" => x } }
33
- @options[:all_hostgroups] = if @options[:all_hostgroups] then 1 else 0 end
34
- @options[:all_servicegroups] = if @options[:all_servicegroups] then 1 else 0 end
35
- @options[:all_keywords] = if @options[:all_keywords] then 1 else 0 end
36
-
37
- save(@options[:replace]) if @options[:save]
38
- end
39
-
40
- end
41
- end
@@ -1,53 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class Servicecheck
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :options, :opsview, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :name => "Unknown",
13
- :description => "Unknown",
14
- :keywords => [],
15
- :attribute => nil,
16
- :servicegroup => "Unknown",
17
- :dependencies => [ "Opsview Agent" ],
18
- :check_period => "24x7",
19
- :check_interval => "5",
20
- :check_attempts => "3",
21
- :retry_check_interval => "1",
22
- :plugin => "check_nrpe",
23
- :args => "",
24
- :stalking => nil,
25
- :volatile => false,
26
- :invertresults => false,
27
- :notification_options => "w,c,r",
28
- :notification_period => nil,
29
- :notification_interval => nil,
30
- :flap_detection_enabled => true,
31
- :checktype => "Active Plugin",
32
- :save => true,
33
- :replace => false
34
- }.update options
35
-
36
- @opsview = opsview
37
- @resource_type = @options[:type]
38
-
39
- @options[:keywords] = @options[:keywords].map { |x| { "name" => x } }
40
- @options[:servicegroup] = { "name" => @options[:servicegroup] }
41
- @options[:dependencies] = @options[:dependencies].map { |x| { "name" => x } }
42
- @options[:check_period] = { "name" => @options[:check_period] }
43
- @options[:plugin] = { "name" => @options[:plugin] }
44
- @options[:volatile] = if @options[:volatile] then 1 else 0 end
45
- @options[:invertresults] = if @options[:invertresults] then 1 else 0 end
46
- @options[:flap_detection_enabled] = if @options[:flap_detection_enabled] then 1 else 0 end
47
- @options[:checktype] = { "name" => @options[:checktype] }
48
-
49
- save(@options[:replace]) if @options[:save]
50
- end
51
-
52
- end
53
- end
@@ -1,27 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class Servicegroup
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :options, :opsview, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :name => "Unknown",
13
- :servicechecks => [ "" ],
14
- :save => true,
15
- :replace => false
16
- }.update options
17
-
18
- @opsview = opsview
19
- @resource_type = @options[:type]
20
-
21
- @options[:servicechecks] = @options[:servicechecks].map { |x| { "name" => x } }
22
-
23
- save(@options[:replace]) if @options[:save]
24
- end
25
-
26
- end
27
- end
@@ -1,41 +0,0 @@
1
- require 'opsview_rest/mixin'
2
-
3
- class OpsviewRest
4
- class Timeperiod
5
-
6
- include OpsviewRest::Mixin
7
-
8
- attr_accessor :options, :opsview, :resource_type
9
-
10
- def initialize(opsview, options = {})
11
- @options = {
12
- :name => "nonworkhours",
13
- :monday => "00:00-09:00,17:00-24:00",
14
- :tuesday => "00:00-09:00,17:00-24:00",
15
- :wednesday => "00:00-09:00,17:00-24:00",
16
- :thursday => "00:00-09:00,17:00-24:00",
17
- :friday => "00:00-09:00,17:00-24:00",
18
- :saturday => "00:00-24:00",
19
- :sunday => "00:00-24:00",
20
- :servicecheck_notification_periods => [],
21
- :servicecheck_check_periods => [],
22
- :host_check_periods => [],
23
- :alias => "Non-work hours",
24
- :host_notification_periods => [],
25
- :save => true,
26
- :replace => false
27
- }.update options
28
-
29
- @opsview = opsview
30
- @resource_type = @options[:type]
31
-
32
- @option[:servicecheck_notification_periods] = @option[:servicecheck_notification_periods].map { |x| { "name" => x } }
33
- @option[:servicecheck_check_periods] = @option[:servicecheck_check_periods].map { |x| { "name" => x } }
34
- @option[:host_check_periods] = @option[:host_check_periods].map { |x| { "name" => x } }
35
- @option[:host_notification_periods] = @option[:host_notification_periods].map { |x| { "name" => x } }
36
-
37
- save(@options[:replace]) if @options[:save]
38
- end
39
-
40
- end
41
- end