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
106 107 108 109 |
# File 'lib/zabbixapi/classes/graphs.rb', line 106 def _update(data) data.delete(:name) update(data) end |
#create_or_update(data) ⇒ Integer
Create or update Graph object using Zabbix API
101 102 103 104 |
# File 'lib/zabbixapi/classes/graphs.rb', line 101 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 |
# File 'lib/zabbixapi/classes/graphs.rb', line 43 def get_ids_by_host(data) result = @client.api_request( method: 'graph.get', params: { filter: { host: data[:host] }, output: 'extend' } ) result.map do |graph| num = graph['graphid'] name = graph['name'] filter = data[:filter] num if filter.nil? || /#{filter}/ =~ name end.compact end |
#get_items(data) ⇒ Hash
Get Graph Item object using Zabbix API
69 70 71 72 73 74 75 76 77 |
# File 'lib/zabbixapi/classes/graphs.rb', line 69 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
85 86 87 88 89 90 91 92 93 |
# File 'lib/zabbixapi/classes/graphs.rb', line 85 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 |