Class: IcingaResult::Service
- Inherits:
-
Object
- Object
- IcingaResult::Service
- Defined in:
- lib/icinga_result/service.rb
Overview
Represents an Icinga2 service object
Constant Summary collapse
- DEFAULT_OPTONS =
{ interval: 3600, description: '', groups: [] }.freeze
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(name, options = DEFAULT_OPTONS) ⇒ Service
constructor
A new instance of Service.
- #timeout ⇒ Object
Constructor Details
#initialize(name, options = DEFAULT_OPTONS) ⇒ Service
Returns a new instance of Service.
8 9 10 11 12 13 |
# File 'lib/icinga_result/service.rb', line 8 def initialize(name, = DEFAULT_OPTONS) @name = name @interval = [:interval] || DEFAULT_OPTONS[:interval] @description = [:description] || DEFAULT_OPTONS[:description] @groups = [:groups] || DEFAULT_OPTONS[:groups] end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/icinga_result/service.rb', line 4 def description @description end |
#groups ⇒ Object
Returns the value of attribute groups.
4 5 6 |
# File 'lib/icinga_result/service.rb', line 4 def groups @groups end |
#interval ⇒ Object
Returns the value of attribute interval.
4 5 6 |
# File 'lib/icinga_result/service.rb', line 4 def interval @interval end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/icinga_result/service.rb', line 4 def name @name end |
Instance Method Details
#data ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/icinga_result/service.rb', line 19 def data { 'templates' => ['generic-service'], 'attrs' => { 'check_command' => 'passive', 'enable_active_checks' => true, 'check_interval' => timeout, 'vars.description' => @description, 'groups' => @groups } } end |
#timeout ⇒ Object
15 16 17 |
# File 'lib/icinga_result/service.rb', line 15 def timeout 3 * @interval + 120 end |