Class: OpsviewRest::Host
- Inherits:
-
Object
- Object
- OpsviewRest::Host
- Includes:
- Mixin
- Defined in:
- lib/opsview_rest/host.rb
Instance Attribute Summary collapse
-
#opsview ⇒ Object
Returns the value of attribute opsview.
-
#options ⇒ Object
Returns the value of attribute options.
-
#resource_type ⇒ Object
Returns the value of attribute resource_type.
Instance Method Summary collapse
-
#initialize(opsview, options = {}) ⇒ Host
constructor
A new instance of Host.
Methods included from Mixin
#resource_path, #save, #to_json
Constructor Details
#initialize(opsview, options = {}) ⇒ Host
Returns a new instance of Host.
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/opsview_rest/host.rb', line 10 def initialize(opsview, = {}) # Default set of attributes to send to Opsview: = { :flap_detection_enabled => false, :snmpv3_privprotocol => nil, :hosttemplates => [], :keywords => [], :check_period => "24x7", :hostattributes => [], :notification_period => "24x7", :name => "unknown", :rancid_vendor => nil, :snmp_community => "public", :hostgroup => "Unknown", :enable_snmp => false, :monitored_by => "Master Monitoring Server", :alias => "Managed Host", :uncommitted => false, :parents => [], :icon => { "name" => "LOGO - Opsview" }, :retry_check_interval => 1, :ip => "localhost", :use_mrtg => false, :servicechecks => [], :use_rancid => false, :nmis_node_type => "router", :snmp_version => "2c", :snmp_authpassword => "", :use_nmis => false, :rancid_connection_type => "ssh", :snmpv3_authprotocol => nil, :rancid_username => nil, :rancid_password => nil, :check_command => "ping", :check_attempts => 2, :check_interval => 0, :notification_interval => 60, :snmp_port => 161, :snmpv3_username => "", :snmpv3_privpassword => "", :other_addresses => "", :save => true, :replace => false }.update @opsview = opsview @resource_type = [:type] # Add any weird exceptions here (like hostgroups having to be mapped # to "name" => hostgroup, etc.): [:flap_detection_enabled] = if [:flap_detection_enabled] then 1 else 0 end [:enable_snmp] = if [:enable_snmp] then 1 else 0 end [:use_mrtg] = if [:use_mrtg] then 1 else 0 end [:use_rancid] = if [:use_rancid] then 1 else 0 end [:use_nmis] = if [:use_nmis] then 1 else 0 end [:uncommitted] = if [:uncommitted] then 1 else 0 end [:check_period] = { "name" => [:check_period] } [:hostgroup] = { "name" => [:hostgroup] } [:notification_period] = { "name" => [:notification_period] } [:monitored_by] = { "name" => [:monitored_by] } [:servicechecks] = [:servicechecks].map { |x| { "name" => x } } [:check_command] = { "name" => [:check_command] } save([:replace]) if [:save] end |
Instance Attribute Details
#opsview ⇒ Object
Returns the value of attribute opsview.
8 9 10 |
# File 'lib/opsview_rest/host.rb', line 8 def opsview @opsview end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/opsview_rest/host.rb', line 8 def end |
#resource_type ⇒ Object
Returns the value of attribute resource_type.
8 9 10 |
# File 'lib/opsview_rest/host.rb', line 8 def resource_type @resource_type end |