6 仪表盘组件

说明

各个仪表盘组件字段对象中的这些参数和可用属性值允许在dashboard.createdashboard.update 方法中配置仪表盘(Gauge)组件。

在创建或更新仪表盘期间不会验证组件的 fields 属性。 这个方法允许用户修改内置组件和创建自定义组件,但也会导致存在错误创建或更新组件的风险。 为确保成功创建或更新仪表盘(Gauge)组件,请参阅下表中概述的参数行为。

参数

以下参数适用于 Gauge 部件。

参数 type name value
刷新间隔 0 rf_rate 0 - 不刷新;
10 - 10 秒;
30 - 30 秒;
60 - (默认) 1 分钟;
120 - 2 分钟;
600 - 10 分钟;
900 - 15 分钟。
监控项 4 itemid.0 Item ID。

参数行为
- 如果未设置 Item (Widget),则为 必填
Item (Widget) 1 itemid._reference 用于代替 Item ID:
ABCDE._itemid - 将兼容部件(其 Reference 参数设置为 "ABCDE")设为监控项的数据源。

参数行为
- 如果未设置 Item,则为 必填
最小值 1 min 任意数值。后缀(例如 "1d"、"2w"、"4K"、"8G")受支持。

默认值:"0"。
最大值 1 max 任意数值。后缀(例如 "1d"、"2w"、"4K"、"8G")受支持。

默认值:"100"。
值弧 1 value_arc_color 十六进制颜色代码(例如 FF0000)。

默认值:""(空)。
弧背景 1 empty_color 十六进制颜色代码(例如 FF0000)。

默认值:""(空)。
背景 1 bg_color 十六进制颜色代码(例如 FF0000)。

默认值:""(空)。
显示 0 show.0 1 - 描述;
2 - 值;
3 - 指针;
4 - 刻度;
5 - 值弧。

注意:要配置多个值,请为每个值创建一个 dashboard widget field 对象,并在属性名称中使用递增编号。

默认值:1、2、4、5。

如果同时满足以下两项,则不支持值“指针”和“刻度”:
- 未设置值为“值弧”的 显示 dashboard widget field 对象;
- 显示弧 高级配置 参数设置为“已禁用”。

如果未设置具有相应值的 显示 dashboard widget field 对象,则不支持 显示 选项的高级配置参数。
覆盖主机 1 override_hostid._reference ABCDE._hostid - 将兼容部件(其 Reference 参数设置为 "ABCDE")设为主机的数据源;
DASHBOARD._hostid - 将仪表板主机选择器设为主机的数据源。

如果在模板仪表板上配置该部件,则不支持此参数。

高级配置

Gauge 小组件支持以下高级配置参数。

Thresholds 属性名称中的数字(例如,thresholds.0.color)表示列表中的阈值位置,列表按升序排序。 但是,如果阈值的配置顺序不同,在 Zabbix 前端更新小组件配置后,值将按升序排序 (例如,"thresholds.0.threshold":"5""thresholds.0.threshold":"1""thresholds.1.threshold":"1""thresholds.1.threshold": "5")。

Parameter type name value
Angle 0 angle 可选值:180 (默认) 或 270。
Description
Description 1 description 任意字符串值,包括宏。
支持的宏:{HOST.*}{ITEM.*}{INVENTORY.*}、用户宏。

默认值:{ITEM.NAME}
Size 0 desc_size 可选范围:1-100。

默认值:15。
Vertical position 0 desc_v_pos 0 - 顶部;
1 - (默认) 底部。
Bold 0 desc_bold 0 - (默认) 禁用;
1 - 启用。
Color 1 desc_color 十六进制颜色代码(例如 FF0000)。

默认值:""(空)。
Value
Decimal places 0 decimal_places 可选范围:1-10。

默认值:2。
Size 0 value_size 可选范围:1-100。

默认值:25。
Bold 0 value_bold 0 - (默认) 禁用;
1 - 启用。
Color 1 value_color 十六进制颜色代码(例如 FF0000)。

默认值:""(空)。
Units
Units (checkbox) 0 units_show 0 - 禁用;
1 - (默认) 启用。
Units (value) 1 units 任意字符串值。

参数行为
- 当 Units (checkbox) 设置为“启用”时,supported
Size 0 units_size 可选范围:1-100。

默认值:25。

参数行为
- 当 Units (checkbox) 设置为“启用”时,supported
Bold 0 units_bold 0 - (默认) 禁用;
1 - 启用。

参数行为
- 当 Units (checkbox) 设置为“启用”时,supported
Position 0 units_pos 0 - 值前;
1 - 值上方;
2 - (默认) 值后;
3 - 值下方。

参数行为
- 当 Units (checkbox) 设置为“启用”时,supported

如果将此参数设置为以下任一时间相关单位:unixtime、uptime、s,则会忽略该参数。
Color 1 units_color 十六进制颜色代码(例如 FF0000)。

默认值:""(空)。
Value arc
Arc size 0 value_arc_size 可选范围:1-100。

默认值:20。
Needle
Color 1 needle_color 十六进制颜色代码(例如 FF0000)。

默认值:""(空)。

参数行为
- 当为 Show 设置值为“Value arc”的仪表板小组件字段对象,或 Show arc 设置为“启用”时,supported
Scale
Show units 0 scale_show_units 0 - 禁用;
1 - (默认) 启用。

参数行为
- 当 Units (checkbox) 设置为“启用”,且为 Show 设置值为“Value arc”的仪表板小组件字段对象,或 Show arc 设置为“启用”时,supported
Size 0 scale_size 可选范围:1-100。

默认值:15。

参数行为
- 当为 Show 设置值为“Value arc”的仪表板小组件字段对象,或 Show arc 设置为“启用”时,supported
Decimal places 0 scale_decimal_places 可选范围:1-10。

默认值:0。

参数行为
- 当为 Show 设置值为“Value arc”的仪表板小组件字段对象,或 Show arc 设置为“启用”时,supported
Thresholds
Color 1 thresholds.0.color 十六进制颜色代码(例如 FF0000)。
Threshold 1 thresholds.0.threshold 任意数值。支持后缀(例如 "1d"、"2w"、"4K"、"8G")。
Show labels 0 th_show_labels 0 - (默认) 禁用;
1 - 启用。

参数行为
- 当已设置 Thresholds,且为 Show 设置值为“Value arc”的仪表板小组件字段对象,或 Show arc 设置为“启用”时,supported
Show arc 0 th_show_arc 0 - (默认) 禁用;
1 - 启用。

参数行为
- 当已设置 Thresholds 时,supported
Arc size 0 th_arc_size 可选范围:1-100。

默认值:5。

参数行为
- 当 Show arc 设置为“启用”时,supported

示例

以下示例仅用于介绍如何在仪表盘组件字段对象中配置仪表盘(Gauge)组件。 更多信息,请参考 创建仪表盘

配置一个仪表盘(Gauge)组件

配置一个仪表盘(Gauge)组件,用于展示监控项 "44474" 上由接口 enp0s3 发送的监控项值 另外,通过包含阈值在内的多个高级选项对组件进行视觉微调。

请求:

{
    "jsonrpc": "2.0",
    "method": "dashboard.create",
    "params": {
        "name": "My dashboard",
        "display_period": 30,
        "auto_start": 1,
        "pages": [
            {
                "widgets": [
                    {
                        "type": "gauge",
                        "name": "Gauge",
                        "x": 0,
                        "y": 0,
                        "width": 18,
                        "height": 5,
                        "view_mode": 0,
                        "fields": [
                            {
                                "type": 4,
                                "name": "itemid.0",
                                "value": 44474
                            },
                            {
                                "type": 1,
                                "name": "min",
                                "value": "100000"
                            },
                            {
                                "type": 1,
                                "name": "max",
                                "value": "1000000"
                            },
                            {
                                "type": 0,
                                "name": "show.0",
                                "value": 1
                            },
                            {
                                "type": 0,
                                "name": "show.1",
                                "value": 2
                            },
                            {
                                "type": 0,
                                "name": "show.2",
                                "value": 3
                            },
                            {
                                "type": 0,
                                "name": "show.4",
                                "value": 4
                            },
                            {
                                "type": 0,
                                "name": "show.5",
                                "value": 5
                            },
                            {
                                "type": 0,
                                "name": "angle",
                                "value": 270
                            },
                            {
                                "type": 0,
                                "name": "desc_size",
                                "value": 10
                            },
                            {
                                "type": 0,
                                "name": "desc_bold",
                                "value": 1
                            },
                            {
                                "type": 0,
                                "name": "decimal_places",
                                "value": 0
                            },
                            {
                                "type": 0,
                                "name": "value_bold",
                                "value": 1
                            },
                            {
                                "type": 0,
                                "name": "units_size",
                                "value": 15
                            },
                            {
                                "type": 0,
                                "name": "units_pos",
                                "value": 3
                            },
                            {
                                "type": 1,
                                "name": "needle_color",
                                "value": "3C3C3C"
                            },
                            {
                                "type": 1,
                                "name": "thresholds.0.color",
                                "value": "FF465C"
                            },
                            {
                                "type": 1,
                                "name": "thresholds.0.threshold",
                                "value": "700000"
                            },
                            {
                                "type": 1,
                                "name": "thresholds.1.color",
                                "value": "FFD54F"
                            },
                            {
                                "type": 1,
                                "name": "thresholds.1.threshold",
                                "value": "500000"
                            },
                            {
                                "type": 1,
                                "name": "thresholds.2.color",
                                "value": "0EC9AC"
                            },
                            {
                                "type": 1,
                                "name": "thresholds.2.threshold",
                                "value": "100000"
                            },
                            {
                                "type": 0,
                                "name": "th_show_labels",
                                "value": 1
                            },
                            {
                                "type": 0,
                                "name": "th_show_arc",
                                "value": 1
                            },
                            {
                                "type": 0,
                                "name": "th_arc_size",
                                "value": 15
                            }
                        ]
                    }
                ]
            }
        ],
        "userGroups": [
            {
                "usrgrpid": 7,
                "permission": 2
            }
        ],
        "users": [
            {
                "userid": 1,
                "permission": 3
            }
        ]
    },
    "id": 1
}

响应:

{
    "jsonrpc": "2.0",
    "result": {
        "dashboardids": [
            "3"
        ]
    },
    "id": 1
}

参考