[comment]: # translation:outdated

[comment]: # ({65bbffce-65bbffce})
# host.get

[comment]: # ({/65bbffce-65bbffce})

[comment]: # ({98edab8b-93035b19})
### תיאור

`integer/array host.get(object parameters)`

השיטה מאפשרת לאחזר מארחים לפי הפרמטרים הנתונים.

::: noteclassic
שיטה זו זמינה למשתמשים מכל סוג. הרשאות
כדי לקרוא את השיטה ניתן לבטל בהגדרות תפקיד המשתמש. ראה [משתמש
תפקידים](/manual/web_interface/frontend_sections/administration/user_roles)
למידע נוסף.
:::

[comment]: # ({/98edab8b-93035b19})

[comment]: # ({98edab8b-77a8fabb})
### תיאור

`integer/array host.get(object parameters)`

השיטה מאפשרת לאחזר מארחים לפי הפרמטרים הנתונים.

::: noteclassic
שיטה זו זמינה למשתמשים מכל סוג. הרשאות
כדי לקרוא את השיטה ניתן לבטל בהגדרות תפקיד המשתמש. ראה [משתמש
תפקידים](/manual/web_interface/frontend_sections/administration/user_roles)
למידע נוסף.
:::

[comment]: # ({/98edab8b-77a8fabb})

[comment]: # ({7223bab1-7223bab1})
### החזר ערכים

`(מספר שלם/מערך)` מחזיר אחד:

- מערך של חפצים;
- ספירת האובייקטים שאוחזרו, אם יש לפרמטר `countOutput`
     נעשה שימוש.

[comment]: # ({/7223bab1-7223bab1})

[comment]: # ({b41637d2-b41637d2})
### דוגמאות

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({36e9e6e3-c6ea3cce})
#### אחזור נתונים לפי שם

אחזר את כל הנתונים על שני מארחים בשם "שרת Zabbix" ו-"Linux
שרת".

בַּקָשָׁה:

``` json
{
     "jsonrpc": "2.0",
     "method": "host.get",
     "params": {
         "מסנן": {
             "מנחה": [
                 "שרת Zabbix",
                 "שרת לינוקס"
             ]
         }
     },
     "auth": "038e1d7b1735c6a5436ee9eae095879e",
     "מזהה": 1
}
```

תְגוּבָה:

``` json
{
     "jsonrpc": "2.0",
     "תוצאה": [
         {
             "hostid": "10160",
             "proxy_hostid": "0",
             "host": "שרת Zabbix",
             "status": "0",
             "lastaccess": "0",
             "ipmi_authtype": "-1",
             "ipmi_privilege": "2",
             "ipmi_username": "",
             "ipmi_password": "",
             "maintenanceid": "0",
             "maintenance_status": "0",
             "maintenance_type": "0",
             "maintenance_from": "0",
             "name": "שרת Zabbix",
             "flags": "0",
             "description": "שרת הניטור של Zabbix.",
             "tls_connect": "1",
             "tls_accept": "1",
             "tls_issuer": "",
             "tls_subject": "",
             "inventory_mode": "1"
         },
         {
             "hostid": "10167",
             "proxy_hostid": "0",
             "host": "שרת לינוקס",
             "status": "0",
             "lastaccess": "0",
             "ipmi_authtype": "-1",
             "ipmi_privilege": "2",
             "ipmi_username": "",
             "ipmi_password": "",
             "maintenanceid": "0",
             "maintenance_status": "0",
             "maintenance_type": "0",
             "maintenance_from": "0",
             "name": "שרת לינוקס",
             "flags": "0",
             "תיאור": "",
             "tls_connect": "1",
             "tls_accept": "1",
             "tls_issuer": "",
             "tls_subject": "",
             "inventory_mode": "1"
         }
     ],
     "מזהה": 1
}
```

[comment]: # ({/36e9e6e3-c6ea3cce})

[comment]: # ({c020032f-9078aff7})
#### מאחזר קבוצות מארחות

אחזר שמות של הקבוצות המארח "שרת Zabbix" הוא חבר, אבל לא
פרטי המארח עצמם.

בַּקָשָׁה:

``` json
{
     "jsonrpc": "2.0",
     "method": "host.get",
     "params": {
         "output": ["hostid"],
         "selectGroups": "להרחיב",
         "מסנן": {
             "מנחה": [
                 "שרת Zabbix"
             ]
         }
     },
     "auth": "038e1d7b1735c6a5436ee9eae095879e",
     "מזהה": 2
}
```

תְגוּבָה:

``` json
{
     "jsonrpc": "2.0",
     "תוצאה": [
         {
             "hostid": "10085",
             "קבוצות": [
                 {
                     "groupid": "2",
                     "name": "שרתי לינוקס",
                     "internal": "0",
                     "flags": "0"
                 },
                 {
                     "groupid": "4",
                     "name": "שרתי Zabbix",
                     "internal": "0",
                     "flags": "0"
                 }
             ]
         }
     ],
     "מזהה": 2
}
```

[comment]: # ({/c020032f-9078aff7})

[comment]: # ({32d48903-59c8a46a})
#### אחזור תבניות מקושרות

אחזר את המזהים והשמות של תבניות המקושרות למארח "10084".

בַּקָשָׁה:

``` json
{
     "jsonrpc": "2.0",
     "method": "host.get",
     "params": {
         "output": ["hostid"],
         "selectPrentTemplates": [
             "תבנית תבנית",
             "שֵׁם"
         ],
         "hostids": "10084"
     },
     "מזהה": 1,
     "auth": "70785d2b494a7302309b48afcdb3a401"
}
```

תְגוּבָה:

``` json
{
     "jsonrpc": "2.0",
     "תוצאה": [
         {
             "hostid": "10084",
             "parentTemplates": [
                 {
                     "name": "לינוקס",
                     "templateid": "10001"
                 },
                 {
                     "name": "שרת Zabbix",
                     "templateid": "10047"
                 }
             ]
         }
     ],
     "מזהה": 1
}
```

[comment]: # ({/32d48903-59c8a46a})

[comment]: # ({new-b9e6a4c4})
#### Retrieving hosts by template

Retrieve hosts that have the "10001" (*Linux by Zabbix agent*) template linked to them.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "host.get",
    "params": {
        "output": ["hostid", "name"],
        "templateids": "10001"
    },
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "templateid": "10001",
            "hosts": [
                {
                    "hostid": "10084",
                    "name": "Zabbix server"
                },
                {
                    "hostid": "10603",
                    "name": "Host 1"
                },
                {
                    "hostid": "10604",
                    "name": "Host 2"
                }
            ]
        }
    ],
    "id": 1
}
```

[comment]: # ({/new-b9e6a4c4})

[comment]: # ({f123be0a-8be1d99c})
#### חיפוש לפי נתוני מלאי מארח

אחזר מארחים המכילים "Linux" בשדה "OS" של מלאי המארח.

בַּקָשָׁה:

``` json
{
     "jsonrpc": "2.0",
     "method": "host.get",
     "params": {
         "פלט": [
             "מנחה"
         ],
         "selectInventory": [
             "os"
         ],
         "SearchInventory": {
             "os": "לינוקס"
         }
     },
     "מזהה": 2,
     "auth": "7f9e00124c75e8f25facd5c093f3e9a0"
}
```

תְגוּבָה:

``` json
{
     "jsonrpc": "2.0",
     "תוצאה": [
         {
             "hostid": "10084",
             "host": "שרת Zabbix",
             "מלאי": {
                 "os": "לינוקס אובונטו"
             }
         },
         {
             "hostid": "10107",
             "host": "שרת לינוקס",
             "מלאי": {
                 "os": "Linux Mint"
             }
         }
     ],
     "מזהה": 1
}
```

[comment]: # ({/f123be0a-8be1d99c})

[comment]: # ({df4e4ba7-b4e37e5e})
#### חיפוש לפי תגיות מארח

אחזר מארחים שיש להם תג "שם מארח" שווה ל"שרת לינוקס".

בַּקָשָׁה:

``` json
{
     "jsonrpc": "2.0",
     "method": "host.get",
     "params": {
         "output": ["hostid"],
         "selectTags": "להרחיב",
         "evaltype": 0,
         "תגים": [
             {
                 "tag": "שם מארח",
                 "value": "שרת לינוקס",
                 "מפעיל": 1
             }
         ]
     },
     "auth": "7f9e00124c75e8f25facd5c093f3e9a0",
     "מזהה": 1
}
```

תְגוּבָה:

``` json
{
     "jsonrpc": "2.0",
     "תוצאה": [
         {
             "hostid": "10085",
             "תגים": [
                 {
                     "tag": "שם מארח",
                     "value": "שרת לינוקס"
                 },
                 {
                     "tag": "OS",
                     "value": "RHEL 7"
                 }
             ]
         }
     ],
     "מזהה": 1
}
```

אחזר מארחים שיש להם את התגים האלה לא רק ברמת המארח אלא גם בתוך
תבניות האב המקושרות שלהם.

בַּקָשָׁה:

``` json
{
     "jsonrpc": "2.0",
     "method": "host.get",
     "params": {
         "output": ["שם"],
         "tags": [{"tag": "A", "value": "1", "operator": "0"}],
         "תגים בירושה": נכון
     },
     "auth": "038e1d7b1735c6a5436ee9eae095879e",
     "מזהה": 1
}
```

תְגוּבָה:

``` json
{
     "jsonrpc": "2.0",
     "תוצאה": [
         {
             "hostid": "10623",
             "name": "חדר מחשב 1"
         },
         {
             "hostid": "10601",
             "name": "משרד"
         }
     ],
     "מזהה": 1
}
```

[comment]: # ({/df4e4ba7-b4e37e5e})

[comment]: # ({9674473f-9ebae84e})
#### חיפוש מארח עם תגים ותגיות תבנית

אחזר מארח עם תגים וכל התגים המקושרים להורה
תבניות.

בַּקָשָׁה:

``` json
{
     "jsonrpc": "2.0",
     "method": "host.get",
     "params": {
         "output": ["שם"],
         "hostids": 10502,
         "selectTags": ["תג", "ערך"],
         "selectInheritedTags": ["תג", "ערך"]
     },
     "auth": "038e1d7b1735c6a5436ee9eae095879e",
     "מזהה": 1
}
```

תְגוּבָה:

``` json
{
     "jsonrpc": "2.0",
     "תוצאה": [
         {
             "hostid": "10502",
             "name": "שולחן עבודה",
             "תגים": [
                 {
                     "tag": "א",
                     "value": "1"
                 }
             ],
             "תגים בירושה": [
                 {
                     "tag": "B",
                     "value": "2"
                 }
             ]
         }
     ],
     "מזהה": 1
}
```

[comment]: # ({/9674473f-9ebae84e})

[comment]: # ({4c63600d-219d4ee1})
#### חיפוש מארחים לפי חומרת הבעיה

אחזר מארחים שיש להם בעיות "אסון".

בַּקָשָׁה:

``` json
{
     "jsonrpc": "2.0",
     "method": "host.get",
     "params": {
         "output": ["שם"],
         "חומרות": 5
     },
     "auth": "038e1d7b1735c6a5436ee9eae095879e",
     "מזהה": 1
}
```

תְגוּבָה:

``` json
{
     "jsonrpc": "2.0",
     "תוצאה": [
         {
             "hostid": "10160",
             "name": "שרת Zabbix"
         }
     ],
     "מזהה": 1
}
```

אחזר מארחים שיש להם בעיות "ממוצע" ו"גבוה".

בַּקָשָׁה:

``` json
{
     "jsonrpc": "2.0",
     "method": "host.get",
     "params": {
         "output": ["שם"],
         "חומרות": [3, 4]
     },
     "auth": "038e1d7b1735c6a5436ee9eae095879e",
     "מזהה": 1
}
```

תְגוּבָה:

``` json
{
     "jsonrpc": "2.0",
     "תוצאה": [
         {
             "hostid": "20170",
             "name": "בסיס נתונים"
         },
         {
             "hostid": "20183",
             "שם": "תחנת עבודה"
         }
     ],
     "מזהה": 1
}
```

[comment]: # ({/4c63600d-219d4ee1})

[comment]: # ({d660ab0c-06c7fe93})
### ראה גם

- [קבוצת מארח](/manual/api/reference/hostgroup/object#host_group)
- [תבנית](/manual/api/reference/template/object#template)
- [משתמש
     מאקרו](/manual/api/reference/usermacro/object#hosttemplate_level_macro)
-   [מנחה
     ממשק](/manual/api/reference/hostinterface/object#host_interface)

[comment]: # ({/d660ab0c-06c7fe93})

[comment]: # ({55c08f7a-55c08f7a})
### מקור

CHost::get()‎ בתוך *ui/include/classes/api/services/CHost.php*.

[comment]: # ({/55c08f7a-55c08f7a})
