Class: ZabbixManager::Scripts

Inherits:
Basic
  • Object
show all
Defined in:
lib/zabbix_manager/classes/scripts.rb

Instance Method Summary collapse

Methods inherited from Basic

#add, #all, #create, #create_or_update, #create_raw, #default_options, #delete, #delete_raw, #destroy, #dump_by_id, #get, #get_full_data, #get_id, #get_or_create, #get_raw, #hash_equals?, #identity_filter, #initialize, #key, #keys, #log, #normalize_hash, #parse_keys, #update, #update_raw

Constructor Details

This class inherits a constructor from ZabbixManager::Basic

Instance Method Details

#execute(data) ⇒ Hash

在指定主机上执行 Zabbix 脚本。

示例: execute({ scriptid: '12', hostid: '32 })

Parameters:

  • data (Hash)

    包含 scriptid 和 hostid 的执行参数

Returns:

  • (Hash)

    Zabbix API 返回的脚本执行结果



26
27
28
29
30
31
32
33
34
# File 'lib/zabbix_manager/classes/scripts.rb', line 26

def execute(data)
  @client.api_request(
    method: "script.execute",
    params: {
      scriptid: data[:scriptid],
      hostid: data[:hostid]
    }
  )
end

#getscriptsbyhost(data) ⇒ Array<Hash>

查询指定主机可用的脚本。

Parameters:

  • data (Hash)

    Zabbix scripts.getscriptsbyhosts 查询参数

Returns:

  • (Array<Hash>)

    主机可用脚本列表



40
41
42
# File 'lib/zabbix_manager/classes/scripts.rb', line 40

def getscriptsbyhost(data)
  @client.api_request(method: "script.getscriptsbyhosts", params: data)
end

#identifyString

返回用于唯一识别脚本的业务字段名。

Returns:

  • (String)

    脚本对象的业务标识字段名



15
16
17
# File 'lib/zabbix_manager/classes/scripts.rb', line 15

def identify
  "name"
end

#method_nameString

返回 Zabbix API 中脚本对象的方法名前缀。

Returns:

  • (String)

    脚本对象的方法名前缀



8
9
10
# File 'lib/zabbix_manager/classes/scripts.rb', line 8

def method_name
  "script"
end