manual:api:reference:graph:get

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
manual:api:reference:graph:get [2016/01/04 09:40]
iivs removed link to graph.getobjects page
manual:api:reference:graph:get [2019/01/28 14:50]
sasha <code js> => <code java>
Line 1: Line 1:
-===== graph.get ===== 
  
-==== Description ==== 
- 
-''​integer/​array graph.get(object **parameters**)''​ 
- 
-The method allows to retrieve graphs according to the given parameters. 
- 
-==== Parameters ==== 
- 
-''​(object)''​ Parameters defining the desired output. 
- 
-The method supports the following parameters. 
- 
-^ Parameter ^ Type ^ Description ^ 
-| graphids | string/​array | Return only graphs with the given IDs. | 
-| groupids | string/​array | Return only graphs that belong to hosts in the given host groups. | 
-| templateids | string/​array | Return only graph that belong to the given templates. | 
-| hostids | string/​array | Return only graphs that belong to the given hosts. | 
-| itemids | string/​array | Return only graphs that contain the given items. | 
-| templated | boolean | If set to ''​true''​ return only graphs that belong to templates. | 
-| inherited | boolean | If set to ''​true''​ return only graphs inherited from a template. | 
-^ ||| 
-| expandName | flag | Expand macros in the graph name. | 
-| selectGroups | query | Return the host groups that the graph belongs to in the ''​groups''​ property. | 
-| selectTemplates | query | Return the templates that the graph belongs to in the ''​templates''​ property. | 
-| selectHosts | query | Return the hosts that the graph belongs to in the ''​hosts''​ property. | 
-| selectItems | query | Return the items used in the graph in the ''​items''​ property. | 
-| selectGraphDiscovery | query | Return the graph discovery object in the ''​graphDiscovery''​ property. The graph discovery objects links the graph to a graph prototype from which it was created. \\ \\ It has the following properties: \\ ''​graphid''​ - ''​(string)''​ ID of the graph; \\   ''​parent_graphid''​ - ''​(string)''​ ID of the graph prototype from which the graph has been created. | 
-| selectGraphItems | query | Return the graph items used in the graph in the ''​gitems''​ property. | 
-| selectDiscoveryRule | query | Return the low-level discovery rule that created the graph in the ''​discoveryRule''​ property. | 
-^ ||| 
-| filter | object | Return only those results that exactly match the given filter.\\ \\ Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against. \\ \\ Supports additional filters: \\ ''​host''​ - technical name of the host that the graph belongs to; \\ ''​hostid''​ - ID of the host that the graph belongs to. | 
-| sortfield | string/​array | Sort the result by the given properties. \\ \\ Possible values are: ''​graphid'',​ ''​name''​ and ''​graphtype''​. ​ | 
-| countOutput |flag|These parameters being common for all ''​get''​ methods are described in detail in the [[manual:​api:​reference_commentary#​common_get_method_parameters|reference commentary]] page.  | 
-| editable |boolean|:::​| 
-| excludeSearch |flag|:::| 
-| limit |integer|:::​| 
-| output |query|:::| 
-| preservekeys |flag|:::| 
-| search | object |:::| 
-| searchByAny |boolean|:::​| 
-| searchWildcardsEnabled |boolean|:::​| 
-| sortorder | string/​array | ::: | 
-| startSearch |flag|:::| 
-==== Return values ==== 
- 
-''​(integer/​array)''​ Returns either: 
-  * an array of objects; 
-  * the count of retrieved objects, if the ''​countOutput''​ parameter has been used. 
- 
-==== Examples ==== 
- 
-=== Retrieving graphs from hosts === 
- 
-Retrieve all graphs from host "​10107"​ and sort them by name. 
- 
-Request: 
-<code js> 
-{ 
-    "​jsonrpc":​ "​2.0",​ 
-    "​method":​ "​graph.get",​ 
-    "​params":​ { 
-        "​output":​ "​extend",​ 
-        "​hostids":​ 10107, 
-        "​sortfield":​ "​name"​ 
-    }, 
-    "​auth":​ "​038e1d7b1735c6a5436ee9eae095879e",​ 
-    "​id":​ 1 
-} 
-</​code>​ 
- 
-Response: 
-<code js> 
-{ 
-    "​jsonrpc":​ "​2.0",​ 
-    "​result":​ [ 
-        { 
-            "​graphid":​ "​612",​ 
-            "​name":​ "CPU jumps",​ 
-            "​width":​ "​900",​ 
-            "​height":​ "​200",​ 
-            "​yaxismin":​ "​0.0000",​ 
-            "​yaxismax":​ "​100.0000",​ 
-            "​templateid":​ "​439",​ 
-            "​show_work_period":​ "​1",​ 
-            "​show_triggers":​ "​1",​ 
-            "​graphtype":​ "​0",​ 
-            "​show_legend":​ "​1",​ 
-            "​show_3d":​ "​0",​ 
-            "​percent_left":​ "​0.0000",​ 
-            "​percent_right":​ "​0.0000",​ 
-            "​ymin_type":​ "​0",​ 
-            "​ymax_type":​ "​0",​ 
-            "​ymin_itemid":​ "​0",​ 
-            "​ymax_itemid":​ "​0",​ 
-            "​flags":​ "​0"​ 
-        }, 
-        { 
-            "​graphid":​ "​613",​ 
-            "​name":​ "CPU load", 
-            "​width":​ "​900",​ 
-            "​height":​ "​200",​ 
-            "​yaxismin":​ "​0.0000",​ 
-            "​yaxismax":​ "​100.0000",​ 
-            "​templateid":​ "​433",​ 
-            "​show_work_period":​ "​1",​ 
-            "​show_triggers":​ "​1",​ 
-            "​graphtype":​ "​0",​ 
-            "​show_legend":​ "​1",​ 
-            "​show_3d":​ "​0",​ 
-            "​percent_left":​ "​0.0000",​ 
-            "​percent_right":​ "​0.0000",​ 
-            "​ymin_type":​ "​1",​ 
-            "​ymax_type":​ "​0",​ 
-            "​ymin_itemid":​ "​0",​ 
-            "​ymax_itemid":​ "​0",​ 
-            "​flags":​ "​0"​ 
-        }, 
-        { 
-            "​graphid":​ "​614",​ 
-            "​name":​ "CPU utilization",​ 
-            "​width":​ "​900",​ 
-            "​height":​ "​200",​ 
-            "​yaxismin":​ "​0.0000",​ 
-            "​yaxismax":​ "​100.0000",​ 
-            "​templateid":​ "​387",​ 
-            "​show_work_period":​ "​1",​ 
-            "​show_triggers":​ "​0",​ 
-            "​graphtype":​ "​1",​ 
-            "​show_legend":​ "​1",​ 
-            "​show_3d":​ "​0",​ 
-            "​percent_left":​ "​0.0000",​ 
-            "​percent_right":​ "​0.0000",​ 
-            "​ymin_type":​ "​1",​ 
-            "​ymax_type":​ "​1",​ 
-            "​ymin_itemid":​ "​0",​ 
-            "​ymax_itemid":​ "​0",​ 
-            "​flags":​ "​0"​ 
-        }, 
-        { 
-            "​graphid":​ "​645",​ 
-            "​name":​ "Disk space usage /", 
-            "​width":​ "​600",​ 
-            "​height":​ "​340",​ 
-            "​yaxismin":​ "​0.0000",​ 
-            "​yaxismax":​ "​0.0000",​ 
-            "​templateid":​ "​0",​ 
-            "​show_work_period":​ "​0",​ 
-            "​show_triggers":​ "​0",​ 
-            "​graphtype":​ "​2",​ 
-            "​show_legend":​ "​1",​ 
-            "​show_3d":​ "​1",​ 
-            "​percent_left":​ "​0.0000",​ 
-            "​percent_right":​ "​0.0000",​ 
-            "​ymin_type":​ "​0",​ 
-            "​ymax_type":​ "​0",​ 
-            "​ymin_itemid":​ "​0",​ 
-            "​ymax_itemid":​ "​0",​ 
-            "​flags":​ "​4"​ 
-        } 
-    ], 
-    "​id":​ 1 
-} 
-</​code>​ 
- 
-==== See also ==== 
- 
-  * [[manual:​api:​reference:​discoveryrule:​object#​discovery_rule|Discovery rule]] 
-  * [[manual:​api:​reference:​graphitem:​object#​graph_item|Graph item]] 
-  * [[manual:​api:​reference:​item:​object#​item|Item]] 
-  * [[manual:​api:​reference:​host:​object#​host|Host]] 
-  * [[manual:​api:​reference:​hostgroup:​object#​host_group|Host group]] 
-  * [[manual:​api:​reference:​template:​object#​template|Template]] 
- 
-==== Source ==== 
- 
-CGraph::​get() in //​frontends/​php/​include/​classes/​api/​services/​CGraph.php//​.