Áú»¢¶Ä²©

This is a translation of the original English documentation page. Help us make it better.

host.create

?????

object host.create(object/array hosts)

???? ?? ?????? ????? ?????? ?????.

???? ?? ????? ?? ?-Admin ?-Super Admin ???? ???????. ???? ???? ?????? ????? ????? ?????? ????? ??????. ??? ????? ??????? ????? ????.

???????

(???????/????) ?????? ??????.

????? ???????? ????? ??????????, ????? ???? ?? ???????? ?????.

????? ??? ?????
??????
(????)
object/array ???? ?????? ??? ?????? ?? ????? ????.

??????? ??????? ?????? ????? ??????? '??????' ??????.
interfaces object/array ?????? ???????? ???? ?????.
tags object/array ???? ????.
templates object/array Templates ?????? ?????.

?? ??????? ????? ????? ??????? 'templateid'.
macros object/array ?????? ????? ????? ???????? ???? ?????.
inventory object ???? ????.

???? ?????

(object) ?????? ??????? ????? ?? ?????? ?? ??????? ?????? ??? ???? hostids. ??? ?????? ???????? ???? ?? ??? ??????? ?????.

???????

????? ????

??? ???? ??? "??? ??????" ?? ???? IP ?????, ???? ?? ??????, ??? ???? ????? ????? ?? ?????? ?-MAC ?- ???? ?????.

?????????:

{
            "jsonrpc": "2.0",
            "method": "host.create",
            "params": {
                "host": "??? ??????",
                "??????": [
                    {
                        "??? 1,
                        "????": 1,
                        "useip": 1,
                        "ip": "192.168.3.1",
                        "dns": "",
                        "port": "10050"
                    }
                ],
                "??????": [
                    {
                        "groupid": "50"
                    }
                ],
                "????": [
                    {
                        "tag": "?? ????",
                        "value": "??? ??????"
                    }
                ],
                "??????": [
                    {
                        "templateid": "20045"
                    }
                ],
                "?????": [
                    {
                        "macro": "{$USER_ID}",
                        "value": "123321"
                    },
                    {
                        "macro": "{$USER_LOCATION}",
                        "value": "0:0:0",
                        "description": "??????????? ?? ???? ????, ?? ???? ?????"
                    }
                ],
                "???_????": 0,
                "????": {
                    "macaddress_a": "01234",
                    "macaddress_b": "56768"
                }
            },
            "auth": "038e1d7b1735c6a5436ee9eae095879e",
            "????": 1
       }

????????:

{
            "jsonrpc": "2.0",
            "?????": {
                "hostids": [
                    "107819"
                ]
            },
            "????": 1
       }

????? ???? ?? ???? SNMP

??? ???? ??? "???? SNMP" ?? ???? SNMPv3 ?? ?????.

?????????:

{
            "jsonrpc": "2.0",
            "method": "host.create",
            "params": {
                "host": "???? SNMP",
                "??????": [
                    {
                        "???": 2,
                        "????": 1,
                        "useip": 1,
                        "ip": "127.0.0.1",
                        "dns": "",
                        "port": "161",
                        "?????": {
                            "????": 3,
                            "???? ?????": 0,
                            "securityname": "mysecurityname",
                            "contextname": "",
                            "??? ?????": 1
                        }
                    }
                ],
                "??????": [
                    {
                        "groupid": "4"
                    }
                ]
            },
            "auth": "038e1d7b1735c6a5436ee9eae095879e",
            "????": 1
       }

????????:

{
            "jsonrpc": "2.0",
            "?????": {
                "hostids": [
                    "10658"
                ]
            },
            "????": 1
       }

Creating a host with PSK encryption

Create a host called "PSK host" with PSK encryption configured. Note that the host has to be pre-configured to use PSK.

Request:

{
           "jsonrpc": "2.0",
           "method": "host.create",
           "params": {
               "host": "PSK host",
               "interfaces": [
                   {
                       "type": 1,
                       "ip": "192.168.3.1",
                       "dns": "",
                       "port": "10050",
                       "useip": 1,
                       "main": 1
                   }
               ],
               "groups": [
                   {
                       "groupid": "2"
                   }
               ],
               "tls_accept": 2,
               "tls_connect": 2,
               "tls_psk_identity": "PSK 001",
               "tls_psk": "1f87b595725ac58dd977beef14b97461a7c1045b9a1c963065002c5473194952"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "hostids": [
                   "10590"
               ]
           },
           "id": 1
       }

??? ??

????

CHost::create()? ???? ui/include/classes/api/services/CHost.php.