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
9 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 |
# File 'lib/opsview_rest/host.rb', line 9 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] = ([:flap_detection_enabled] ? 1 : 0) [:enable_snmp] = ([:enable_snmp] ? 1 : 0) [:use_mrtg] = ([:use_mrtg] ? 1 : 0) [:use_rancid] = ([:use_rancid] ? 1 : 0) [:use_nmis] = ([:use_nmis] ? 1 : 0) [:uncommitted] = ([:uncommitted] ? 1 : 0) [: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.
7 8 9 |
# File 'lib/opsview_rest/host.rb', line 7 def opsview @opsview end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/opsview_rest/host.rb', line 7 def end |
#resource_type ⇒ Object
Returns the value of attribute resource_type.
7 8 9 |
# File 'lib/opsview_rest/host.rb', line 7 def resource_type @resource_type end |