这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.
2022 Zabbix中国峰会
2022 Zabbix中国峰会

创建

描述

object map.create(object/array maps)

这个方法允许创建一个新的拓扑图。

参数

(object/array) Maps to create.

除了standard map properties之外,该方法还接受以下参数。

Parameter Type Description
links array 拓扑图上创建拓扑图链接
selements array 拓扑图上创建拓扑图元素
urls array 拓扑图上创建拓扑图URL
users array 拓扑图共享用户
userGroups array 拓扑图共享用户组
shapes array 拓扑图上创建拓扑图图形
lines array 拓扑图上创建拓扑图线

To create map links you'll need to set a map elements selementid to an arbitrary value and then use this value to reference this element in the links selementid1 or selementid2 properties. When the element is created, this value will be replaced with the correct ID generated by Zabbix. See example. 要创建映射链接,您需要将映射元素设置为任意值,然后使用该值在链接selectd1selemand2属性中引用该元素。在创建元素时,将用Zabbix生成的正确ID替换该值。

返回值

(对象)返回一个对象,该对象包含在“sysmapid”属性下创建的拓扑图的id。返回id的顺序与传递的拓扑图的顺序相匹配。

例子

创建一个空的拓扑图

创建一个拓扑图没有任何元素。

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Map",
               "width": 600,
               "height": 600
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "8"
               ]
           },
           "id": 1
       }

创建一个主机拓扑图

创建一个关于两个主机的拓扑图,并且关联他们,需要注意的是在地图上临时使用"selementid1"和"selementid2"的值来引用地图元素。

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Host map",
               "width": 600,
               "height": 600,
               "selements": [
                   {
                       "selementid": "1",
                       "elements": [
                           {"hostid": "1033"}
                       ],
                       "elementtype": 0,
                       "iconid_off": "2"
                   },
       
                   {
                       "selementid": "2",
                       "elements": [
                           {"hostid": "1037"}
                       ],
                       "elementtype": 0,
                       "iconid_off": "2"
                   }
               ],
               "links": [
                   {
                       "selementid1": "1",
                       "selementid2": "2"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "9"
               ]
           },
           "id": 1
       }

创建一个触发器拓扑图

创建一个关于触发器元素的拓扑图,包含两个触发器。

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Trigger map",
               "width": 600,
               "height": 600,
               "selements": [
                   {
                       "elements": [
                           {"triggerid": "12345"},
                           {"triggerid": "67890"}
                       ],
                       "elementtype": 2,
                       "iconid_off": "2"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "10"
               ]
           },
           "id": 1
       }

拓扑图共享

创建一个关于两种共享类项(用户和用户组)的拓扑图。

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Map sharing",
               "width": 600,
               "height": 600,
               "users": [
                   {
                       "userid": "4",
                       "permission": "3"
                   }
               ],
               "userGroups": [
                   {
                       "usrgrpid": "7",
                       "permission": "2"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "9"
               ]
           },
           "id": 1
       }

拓扑图形状

创建一个带有主题的拓扑图。

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Host map",
               "width": 600,
               "height": 600,
               "shapes": [
                   {
                       "type": 0,
                       "x": 0,
                       "y": 0,
                       "width": 600,
                       "height": 11,
                       "text": "{MAP.NAME}"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "10"
               ]
           },
           "id": 1
       }

Map lines

Create a map line.

Request:

{
           "jsonrpc": "2.0",
           "method": "map.create",
           "params": {
               "name": "Map API lines",
               "width": 500,
               "height": 500,
               "lines": [
                   {
                       "x1": 30,
                       "y1": 10,
                       "x2": 100,
                       "y2": 50,
                       "line_type": 1,
                       "line_width": 10,
                       "line_color": "009900"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "sysmapids": [
                   "11"
               ]
           },
           "id": 1
       }

See also

Source

CMap::create() in frontends/php/include/classes/api/services/CMap.php.