Module: Zenoss::JSONAPI::EventsRouter

Included in:
Connection
Defined in:
lib/zenoss/jsonapi/events_router.rb

Instance Method Summary collapse

Instance Method Details

#close_events(data = {}) ⇒ Object

Parameters:

  • data (Hash) (defaults to: {})

    evids that should be closed

Options Hash (data):

  • :evids (Array)

    Array of evids that is closed



62
63
64
# File 'lib/zenoss/jsonapi/events_router.rb', line 62

def close_events(data = {})    
  json_request('EventsRouter', 'close', [data])
end

#ev_query(uid, opts) ⇒ Object

Parameters:

  • uid (String)

    the uid to query events for. If this isn’t specified the query may take a very long time

  • opts (Hash)

    misc options to limit/filter events

See Also:



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/zenoss/jsonapi/events_router.rb', line 77

def ev_query(uid, opts)
  data = {
    :limit    => opts[:limit],
    :start    => opts[:start],
    :sort     => opts[:sort],
    :dir      => opts[:dir],
  }
  data[:uid] = uid unless uid.nil?
  data[:params] = opts[:params] if opts.has_key?(:params)
  data[:criteria] = opts[:criteria] if opts.has_key?(:criteria)

  json_request('EventsRouter', 'query', [data])
end

#query_events(uid = nil, opts = {}) ⇒ Object

Query events for the given parameters.

Parameters:

  • uid (String) (defaults to: nil)

    the uid to query events for. If this isn’t specified the query may take a very long time

  • opts (Hash) (defaults to: {})

    misc options to limit/filter events

Options Hash (opts):

  • :limit (Fixnum)

    the Max index of events to retrieve

  • :start (Fixnum)

    the Min index of events to retrieve

  • :sort (String)

    Key on which to sort the return results (default: ‘lastTime’)

  • :dir (String)

    Sort order; can be either ‘ASC’ or ‘DESC’

  • :params (Hash)

    Key-value pair of filters for this search. (default: None)

  • :history (Boolean<true>)

    True to search the event history table instead of active events (default: False)

  • :criteria (Array<Hash>)

    A list of key-value pairs to to build query’s where clause (default: None)

  • :device (String)

    limit events to a specific device. This only makes sense if the uid being passed is not a device.

  • :component (String)

    limit events to a specific component

  • :event_class (String)

    limit events to a specific eventClass



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/zenoss/jsonapi/events_router.rb', line 41

def query_events(uid=nil, opts = {})
  defaults = {
    :limit    => 100,
    :start    => 0,
    :sort     => 'lastTime',
    :dir      => 'DESC',
    :history  => false,
  }
  opts = defaults.merge(opts)

  resp = self.ev_query(uid, opts)

  events = []
  resp['events'].each do |ev|
    events << Events::ZEvent.new(self, ev)
  end
  events
end

#write_log(data = {}) ⇒ Object

Parameters:

  • data (Hash) (defaults to: {})

    data specifying event that should have a logmessage appended

Options Hash (data):

  • :evid (String)

    evid that message should be appended to

  • :message (String)

    text that should be appended to the event log



69
70
71
# File 'lib/zenoss/jsonapi/events_router.rb', line 69

def write_log(data= {})
  json_request('EventsRouter','write_log', [data])
end