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
}