Class: ZabbixManager::Graphs
- Defined in:
- lib/zabbix_manager/classes/graphs.rb
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.
-
#identify ⇒ 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, #create_raw, #default_options, #delete, #delete_raw, #destroy, #dump_by_id, #get, #get_hostgroup_ids, #get_id, #get_or_create_hostgroups, #get_raw, #hash_equals?, #initialize, #key, #keys, #log, #merge_params, #mojo_update, #normalize_array, #normalize_hash, #parse_keys, #symbolize_keys, #update, #update_raw
Constructor Details
This class inherits a constructor from ZabbixManager::Basic
Instance Method Details
#_update(data) ⇒ Object
108 109 110 111 |
# File 'lib/zabbix_manager/classes/graphs.rb', line 108 def _update(data) data.delete(:name) update(data) end |
#create_or_update(data) ⇒ Integer
Create or update Graph object using Zabbix API
103 104 105 106 |
# File 'lib/zabbix_manager/classes/graphs.rb', line 103 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
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/zabbix_manager/classes/graphs.rb', line 25 def get_full_data(data) log "[DEBUG] Call get_full_data with parameters: #{data.inspect}" @client.api_request( method: "#{method_name}.get", params: { search: { identify.to_sym => data[identify.to_sym] }, output: "extend" } ) end |
#get_ids_by_host(data) ⇒ Array
Get Graph ids for Host from Zabbix API
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/zabbix_manager/classes/graphs.rb', line 45 def get_ids_by_host(data) result = @client.api_request( method: "graph.get", params: { filter: { host: data[:host] }, output: "extend" } ) result.filter_map do |graph| num = graph["graphid"] name = graph["name"] filter = data[:filter] num if filter.nil? || /#{filter}/ =~ name end end |
#get_items(data) ⇒ Hash
Get Graph Item object using Zabbix API
71 72 73 74 75 76 77 78 79 |
# File 'lib/zabbix_manager/classes/graphs.rb', line 71 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
87 88 89 90 91 92 93 94 95 |
# File 'lib/zabbix_manager/classes/graphs.rb', line 87 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 |
#identify ⇒ String
The id field name used for identifying specific Graph objects via Zabbix API
15 16 17 |
# File 'lib/zabbix_manager/classes/graphs.rb', line 15 def identify "name" end |
#method_name ⇒ String
The method name used for interacting with Graphs via Zabbix API
8 9 10 |
# File 'lib/zabbix_manager/classes/graphs.rb', line 8 def method_name "graph" end |