Class: Zabbix::Event

Inherits:
API
  • Object
show all
Defined in:
lib/zmonitor/api/event.rb

Instance Attribute Summary collapse

Attributes inherited from API

#event, #server, #token, #trigger, #user, #verbose, #whoami

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Event

Returns a new instance of Event.



6
7
8
9
# File 'lib/zmonitor/api/event.rb', line 6

def initialize(parent)
  @parent = parent
  @verbose = @parent.verbose
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/zmonitor/api/event.rb', line 5

def parent
  @parent
end

Instance Method Details

#acknowledge(events = [], message = "#{@parent.whoami} is working on this.") ⇒ Object

Mark an event acknowledged and leave a message



34
35
36
37
# File 'lib/zmonitor/api/event.rb', line 34

def acknowledge( events = [], message = "#{@parent.whoami} is working on this." )
  request = { 'method' => 'event.acknowledge', 'params' => { 'eventids' => events, 'message' => message } }
  call_api(request)
end

#call_api(message) ⇒ Object



10
11
12
# File 'lib/zmonitor/api/event.rb', line 10

def call_api(message)
  return @parent.call_api(message)
end

#get(options = {}) ⇒ Object

General event.get



14
15
16
17
# File 'lib/zmonitor/api/event.rb', line 14

def get( options = {} )
  request = { 'method' => 'event.get', 'params' => options }
  return call_api(request)
end

#get_last_by_trigger(triggerid = '') ⇒ Object

Get the most recent event’s information for a particular trigger



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/zmonitor/api/event.rb', line 19

def get_last_by_trigger( triggerid = '' )
  request = {
    'method' => 'event.get',
    'params' =>
    {
      'triggerids' => [triggerid.to_s],
      'sortfield' => 'clock',
      'sortorder' => 'DESC',
      'limit' => '1',
      'output' => 'extend'
    }
  }
  return call_api(request)[0]
end