Class: ZabbixManager::Screens
- Defined in:
- lib/zabbix_manager/classes/screens.rb
Instance Method Summary collapse
-
#delete(data) ⇒ Object
删除 Zabbix API 中的屏幕对象.
-
#get_or_create_for_host(data) ⇒ Object
使用 Zabbix API 为主机获取或创建屏幕对象.
-
#identify ⇒ Object
用于通过 Zabbix API 标识特定屏幕对象的 ID 字段名称.
-
#method_name ⇒ Object
与 Zabbix API 交互的屏幕方法名称.
Methods inherited from Basic
#add, #all, #create, #create_or_update, #default_options, #destroy, #dump_by_id, #get, #get_full_data, #get_id, #get_ids, #get_ids_by_identify, #get_key_ids, #get_key_ids_by_identify, #get_or_create, #get_or_create_keys, #get_raw, #hash_equals?, #initialize, #key, #keys, #log, #merge_hashes, #normalize_array, #normalize_hash, #parse_keys, #request_raw, #symbolize_keys, #update
Constructor Details
This class inherits a constructor from ZabbixManager::Basic
Instance Method Details
#delete(data) ⇒ Object
删除 Zabbix API 中的屏幕对象
35 36 37 38 |
# File 'lib/zabbix_manager/classes/screens.rb', line 35 def delete(data) result = @client.api_request(method: "screen.delete", params: [data]) result.empty? ? nil : result["screenids"][0].to_i end |
#get_or_create_for_host(data) ⇒ Object
使用 Zabbix API 为主机获取或创建屏幕对象
41 42 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 72 73 74 75 76 77 78 79 80 |
# File 'lib/zabbix_manager/classes/screens.rb', line 41 def get_or_create_for_host(data) screen_name = data[:screen_name] graphids = data[:graphids] screenitems = [] hsize = data[:hsize] || 3 valign = data[:valign] || 2 halign = data[:halign] || 2 rowspan = data[:rowspan] || 1 colspan = data[:colspan] || 1 height = data[:height] || 320 width = data[:width] || 200 vsize = data[:vsize] || [1, (graphids.size / hsize).to_i].max screenid = get_id(name: screen_name) unless screenid # 创建屏幕 graphids.each_with_index do |graphid, index| screenitems << { resourcetype: 0, resourceid: graphid, x: (index % hsize).to_i, y: (index % graphids.size / hsize).to_i, valign: valign, halign: halign, rowspan: rowspan, colspan: colspan, height: height, width: width } end screenid = create( name: screen_name, hsize: hsize, vsize: vsize, screenitems: screenitems ) end screenid end |
#identify ⇒ Object
用于通过 Zabbix API 标识特定屏幕对象的 ID 字段名称
30 31 32 |
# File 'lib/zabbix_manager/classes/screens.rb', line 30 def identify "name" end |
#method_name ⇒ Object
与 Zabbix API 交互的屏幕方法名称
25 26 27 |
# File 'lib/zabbix_manager/classes/screens.rb', line 25 def method_name "screen" end |