Class: ZabbixApi::Graphs
Instance Method Summary collapse
- #_update(data) ⇒ Object
-
#create_or_update(data) ⇒ Integer
Create or update Graph object using Zabbix API.
-
#get_full_data(data) ⇒ Hash
Get full/extended Graph data from Zabbix API.
-
#get_ids_by_host(data) ⇒ Array
Get Graph ids for Host from Zabbix API.
-
#get_items(data) ⇒ Hash
Get Graph Item object using Zabbix API.
-
#get_or_create(data) ⇒ Integer
Get or Create Graph object using Zabbix API.
-
#indentify ⇒ String
The id field name used for identifying specific Graph objects via Zabbix API.
-
#method_name ⇒ String
The method name used for interacting with Graphs via Zabbix API.
Methods inherited from Basic
#add, #all, #create, #default_options, #delete, #destroy, #dump_by_id, #get, #get_id, #get_raw, #hash_equals?, #initialize, #key, #keys, #log, #merge_params, #normalize_array, #normalize_hash, #parse_keys, #symbolize_keys, #update
Constructor Details
This class inherits a constructor from ZabbixApi::Basic
Instance Method Details
#_update(data) ⇒ Object
116 117 118 119 |
# File 'lib/zabbixapi/classes/graphs.rb', line 116 def _update(data) data.delete(:name) update(data) end |
#create_or_update(data) ⇒ Integer
Create or update Graph object using Zabbix API
111 112 113 114 |
# File 'lib/zabbixapi/classes/graphs.rb', line 111 def create_or_update(data) graphid = get_id(:name => data[:name], :templateid => data[:templateid]) graphid ? _update(data.merge(:graphid => graphid)) : create(data) end |
#get_full_data(data) ⇒ Hash
Get full/extended Graph data from Zabbix API
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/zabbixapi/classes/graphs.rb', line 23 def get_full_data(data) log "[DEBUG] Call get_full_data with parametrs: #{data.inspect}" @client.api_request( :method => "#{method_name}.get", :params => { :search => { indentify.to_sym => data[indentify.to_sym], }, :output => 'extend', } ) end |
#get_ids_by_host(data) ⇒ Array
Get Graph ids for Host from Zabbix API
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 |
# File 'lib/zabbixapi/classes/graphs.rb', line 43 def get_ids_by_host(data) ids = [] graphs = {} result = @client.api_request( :method => 'graph.get', :params => { :filter => { :host => data[:host], }, :output => 'extend', } ) result.each do |graph| num = graph['graphid'] name = graph['name'] graphs[name] = num filter = data[:filter] if filter.nil? ids.push(graphs[name]) elsif /#{filter}/ =~ name ids.push(graphs[name]) end end ids end |
#get_items(data) ⇒ Hash
Get Graph Item object using Zabbix API
79 80 81 82 83 84 85 86 87 |
# File 'lib/zabbixapi/classes/graphs.rb', line 79 def get_items(data) @client.api_request( :method => 'graphitem.get', :params => { :graphids => [data], :output => 'extend', } ) end |
#get_or_create(data) ⇒ Integer
Get or Create Graph object using Zabbix API
95 96 97 98 99 100 101 102 103 |
# File 'lib/zabbixapi/classes/graphs.rb', line 95 def get_or_create(data) log "[DEBUG] Call get_or_create with parameters: #{data.inspect}" unless (id = get_id(:name => data[:name], :templateid => data[:templateid])) id = create(data) end id end |
#indentify ⇒ String
The id field name used for identifying specific Graph objects via Zabbix API
13 14 15 |
# File 'lib/zabbixapi/classes/graphs.rb', line 13 def indentify 'name' end |
#method_name ⇒ String
The method name used for interacting with Graphs via Zabbix API
6 7 8 |
# File 'lib/zabbixapi/classes/graphs.rb', line 6 def method_name 'graph' end |