获取

描述

integer/array graphitem.get(object parameters)

该方法允许根据给定的参数来检索图表监控项。

这种方法对任何类型的用户都适用。调用该方法的权限可以在用户角色设置中撤销。前往用户角色以获取更多信息。

参数

(object) 定义所需输出的参数。

该方法支持以下参数。

参数类型描述
graphidsstring/array只返回属于给定图表的图表监控项。
itemidsstring/array只返回具有给定监控项ID的图表监控项。
typeinteger只返回具有给定类型的图表监控项。

请参考图表监控项对象页,了解支持的图表监控项类型列表。
selectGraphsquery返回一个图表属性,其中包含该监控项所属的图表的数组。
sortfieldstring/array按给定的属性对结果进行排序。

可用值: gitemid
countOutputboolean这些参数是所有 “get “方法的共同参数,在参考说明页面中有详细描述。
editableboolean
limitinteger
outputquery
preservekeysboolean
sortorderstring/array

返回值

返回值是 (integer/array) 其中之一:

  • 一个对象的数组;
  • 如果使用了countOutput参数,则为检索到的对象的数量。

示例

从图表中检索图表监控项

检索一个图表中使用的所有图表监控项,以及关于监控项和主机的额外信息。

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "graphitem.get",
  4. "params": {
  5. "output": "extend",
  6. "graphids": "387"
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "gitemid": "1242",
  6. "graphid": "387",
  7. "itemid": "22665",
  8. "drawtype": "1",
  9. "sortorder": "1",
  10. "color": "FF5555",
  11. "yaxisside": "0",
  12. "calc_fnc": "2",
  13. "type": "0",
  14. "key_": "system.cpu.util[,steal]",
  15. "hostid": "10001",
  16. "flags": "0",
  17. "host": "Linux"
  18. },
  19. {
  20. "gitemid": "1243",
  21. "graphid": "387",
  22. "itemid": "22668",
  23. "drawtype": "1",
  24. "sortorder": "2",
  25. "color": "55FF55",
  26. "yaxisside": "0",
  27. "calc_fnc": "2",
  28. "type": "0",
  29. "key_": "system.cpu.util[,softirq]",
  30. "hostid": "10001",
  31. "flags": "0",
  32. "host": "Linux"
  33. },
  34. {
  35. "gitemid": "1244",
  36. "graphid": "387",
  37. "itemid": "22671",
  38. "drawtype": "1",
  39. "sortorder": "3",
  40. "color": "009999",
  41. "yaxisside": "0",
  42. "calc_fnc": "2",
  43. "type": "0",
  44. "key_": "system.cpu.util[,interrupt]",
  45. "hostid": "10001",
  46. "flags": "0",
  47. "host": "Linux"
  48. }
  49. ],
  50. "id": 1
  51. }

另见

来源

ui/include/classes/api/services/CGraphItem.php 中的 CGraphItem::get()。