Class: PagerDuty::Incident
- Inherits:
-
Report::Item
- Object
- Report::Item
- PagerDuty::Incident
- Defined in:
- lib/pagerduty_tools/pagerduty.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
Returns the value of attribute event.
-
#resolver ⇒ Object
Returns the value of attribute resolver.
-
#service ⇒ Object
Returns the value of attribute service.
-
#status ⇒ Object
Returns the value of attribute status.
-
#trigger ⇒ Object
Returns the value of attribute trigger.
Attributes inherited from Report::Item
Instance Method Summary collapse
-
#initialize(incident) ⇒ Incident
constructor
A new instance of Incident.
- #resolved? ⇒ Boolean
- #trigger_name ⇒ Object
Methods inherited from Report::Item
#between?, #graveyard?, #off_hours?
Constructor Details
#initialize(incident) ⇒ Incident
Returns a new instance of Incident.
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/pagerduty_tools/pagerduty.rb', line 210 def initialize(incident) super(Time.xmlschema(incident['created_on'])) @status = incident['status'] @service = incident['service']['name'] @trigger = incident['trigger_details'] @event = incident['trigger_details']['event'] if status == 'resolved' if incident['resolved_by'].nil? # nil resolvers are automatic, e.g. Nagios @resolver = "[Automatic]" else @resolver = incident['resolved_by']['name'] end end end |
Instance Attribute Details
#event ⇒ Object
Returns the value of attribute event.
208 209 210 |
# File 'lib/pagerduty_tools/pagerduty.rb', line 208 def event @event end |
#resolver ⇒ Object
Returns the value of attribute resolver.
208 209 210 |
# File 'lib/pagerduty_tools/pagerduty.rb', line 208 def resolver @resolver end |
#service ⇒ Object
Returns the value of attribute service.
208 209 210 |
# File 'lib/pagerduty_tools/pagerduty.rb', line 208 def service @service end |
#status ⇒ Object
Returns the value of attribute status.
208 209 210 |
# File 'lib/pagerduty_tools/pagerduty.rb', line 208 def status @status end |
#trigger ⇒ Object
Returns the value of attribute trigger.
208 209 210 |
# File 'lib/pagerduty_tools/pagerduty.rb', line 208 def trigger @trigger end |
Instance Method Details
#resolved? ⇒ Boolean
226 227 228 |
# File 'lib/pagerduty_tools/pagerduty.rb', line 226 def resolved? status == 'resolved' end |
#trigger_name ⇒ Object
230 231 232 233 234 235 236 |
# File 'lib/pagerduty_tools/pagerduty.rb', line 230 def trigger_name if trigger['type'] == 'nagios_trigger' return "#{service}: #{event['host']} - #{event['service']}" else return "#{service}: #{event['description']}" end end |