このページで
device.get
このメソッドを使用すると、Zabbixモバイルアプリで使用するモバイルデバイスを取得できます。
このメソッドは、EnableMobileDevicesが有効で、ユーザーがデバイスへのアクセス権を持っている場合、User、Admin、およびSuper adminユーザーが使用できます。
APIメソッドへのアクセスは、ユーザーロールの設定で取り消すことができます。
UserおよびAdminユーザーは、自分のデバイスのみ取得できます。
メソッドのシグネチャ: integer/array device.get(object parameters)
メソッドのソース: ui/include/classes/api/services/CDevice.phpのCDevice::get()
パラメータ
| Parameter | Type | Description |
|---|---|---|
| deviceids | ID/array | 指定したデバイスIDを持つデバイスのみを返します。 |
| userids | ID/array | 指定したユーザーIDを持つユーザーに属するデバイスのみを返します。 |
| roleids | ID/array | 指定したユーザーロールIDを持つユーザーに属するデバイスのみを返します。 |
| usrgrpids | ID/array | 指定したユーザーグループIDを持つユーザーに属するデバイスのみを返します。 |
| sortfield | string/array | 指定したプロパティで結果をソートします。 指定可能な値: deviceid、name。 |
| countOutput | boolean | これらのパラメータについては、リファレンス解説で説明しています。 |
| excludeSearch | boolean | |
| filter | object | |
| limit | integer | |
| output | query | |
| preservekeys | boolean | |
| search | object | |
| searchByAny | boolean | |
| searchWildcardsEnabled | boolean | |
| sortorder | string/array | |
| startSearch | boolean |
戻り値
オブジェクトの配列、または取得したオブジェクト数(countOutput を使用した場合)を返します。
例
デバイスの取得
次のユーザーIDを持つユーザーに属するデバイスを取得します: 1、2、3。
ユーザー 2(ゲスト)にはデバイスがなく、デバイス 3 はまだZabbixモバイルアプリに追加または認証されていないことに注意してください。
{
"jsonrpc": "2.0",
"method": "device.get",
"params": {
"output": "extend",
"userids": [1, 2, 3]
},
"id": 1
}
レスポンス:
{
"jsonrpc": "2.0",
"result": [
{
"deviceid": "1",
"userid": "1",
"uuid": "019f930e-0ea2-7c1f-9dcc-0fbb60c40664",
"name": "Google Pixel 10",
"status": "1",
"activated_at": "1784533122",
"lastaccess": "1784879933"
},
{
"deviceid": "2",
"userid": "1",
"uuid": "019d00fb-9e87-7ad5-bb4e-978467254aff",
"name": "Apple iPhone 15 Pro",
"status": "1",
"activated_at": "1784533225",
"lastaccess": "0"
},
{
"deviceid": "3",
"userid": "3",
"uuid": "019d00fb-9e87-7ad5-bb4e-6ed88a2297ee",
"name": "",
"status": "0",
"activated_at": "0",
"lastaccess": "0"
}
],
"id": 1
}