[小 迪 导读]:在制作企业工厂、工业化工厂以及机房内,各业主都会抉择装置安防监控设施,如:红外探测器,湿度报警,门禁,烟感,监控等报警设施。现如今,dgiot提供短信联动告警服务,让告警及时被送到管理人员手中,不漏发报警信息,不错过一个危险揭示,全面保障/工厂零碎的稳固运行,缩小隐患。

整体架构

一、平台告警模板

1.创立告警低代码

进入产品详情,点击告警,点击新增

点击设计

告警模板低代码:

{  "type": "page",  "body": [    {      "id": "u:2c72c2d76916",      "api": {        "url": "iotapi/sendsms/parse_objectid",        "data": {          "tplid": "${tplid}",          "params": [            "${updatedAt}",            "${product_name}",            "${name}",            "${devaddr}",            "${alarm_level}",            "${alarm_message}"          ]        },        "method": "post",        "headers": {          "store": "localStorage",          "dgiotReplace": "parse_objectid"        },        "dataType": "json",        "requestAdaptor": "console.log('ffds ', ...api.data)\r\nreturn {\r\n    ...api,\r\n    data: {\r\n        tplid: ...api.data.tplid\r\n    }\r\n}"      },      "body": [        {          "hint": "1519757",          "name": "tplid",          "type": "input-text",          "label": "模板编号",          "value": "",          "visible": false,          "disabled": "",          "readOnly": true,          "visibleOn": "",          "clearValueOnHidden": false        },        {          "mode": "horizontal",          "name": "alarm_createdAt",          "size": "md",          "type": "input-text",          "label": "告警工夫",          "format": "YYYY-MM-DD HH:mm:ss",          "maxDate": "",          "minDate": "",          "disabled": false,          "readOnly": true,          "clearable": false,          "horizontal": {            "left": 2,            "right": 10,            "leftFixed": "sm"          },          "placeholder": "请抉择日期工夫",          "validateApi": ""        },        {          "id": "u:55d89cd2eb42",          "api": "",          "body": [            {              "hint": "",              "mode": "horizontal",              "name": "product_name",              "size": "md",              "type": "input-text",              "label": "产品名称",              "inline": false,              "readOnly": true,              "horizontal": {                "left": 2,                "right": 10,                "leftFixed": "sm"              },              "submitOnChange": false            }          ],          "mode": "inline",          "type": "form",          "title": "",          "target": "alarm_form",          "initApi": {            "url": "iotapi/classes/Product/${_productid}",            "data": null,            "method": "get",            "adaptor": "return {\r\n  \"status\":0,\r\n  \"msg\":\"\",\r\n  \"data\":response.data\r\n  }",            "responseData": {              "product_name": "${name}"            },            "requestAdaptor": ""          },          "className": "m-t-lg m-b-lg",          "horizontal": {            "left": 2,            "right": 10,            "leftFixed": "normal"          },          "submitText": "",          "wrapWithPanel": false        },        {          "id": "u:55d89cd2eb42",          "api": "",          "body": [            {              "hint": "",              "mode": "horizontal",              "name": "name",              "size": "md",              "type": "input-text",              "label": "设施名称",              "inline": false,              "readOnly": true,              "horizontal": {                "left": 2,                "right": 10,                "leftFixed": "sm"              }            },            {              "id": "u:a656b5747025",              "hint": "",              "mode": "horizontal",              "name": "devaddr",              "size": "md",              "type": "input-text",              "label": "设施地址",              "inline": false,              "readOnly": true,              "horizontal": {                "left": 1,                "right": 11,                "leftFixed": "sm"              }            }          ],          "mode": "normal",          "type": "form",          "title": "",          "target": "alarm_form",          "initApi": {            "url": "iotapi/classes/Device/${_deviceid}",            "data": null,            "method": "get",            "adaptor": "return {\r\n  \"status\":0,\r\n  \"msg\":\"\",\r\n  \"data\":response.data\r\n  }",            "responseData": {              "name": "${name}",              "devaddr": "${devaddr}"            },            "requestAdaptor": ""          },          "className": "m-b-lg",          "horizontal": {            "left": 2,            "right": 10,            "leftFixed": "normal"          },          "submitText": "",          "wrapWithPanel": false        },        {          "id": "u:b5d871f9d40f",          "mode": "horizontal",          "name": "alarm_level",          "size": "md",          "type": "input-text",          "label": "告警等级",          "value": "二级告警(自行填写)",          "horizontal": {            "left": 2,            "right": 10,            "leftFixed": "sm"          }        },        {          "id": "u:2739169db893",          "mode": "horizontal",          "name": "alarm_message",          "size": "md",          "type": "input-text",          "label": "告警信息",          "value": "温度过高(自行填写)",          "horizontal": {            "left": 2,            "right": 10,            "leftFixed": "sm"          }        },        {          "id": "u:cdfa428176ab",          "hint": "",          "mode": "horizontal",          "name": "dgiot_alarmvalue",          "size": "md",          "type": "input-text",          "label": "告警值",          "readOnly": true,          "horizontal": {            "left": 2,            "right": 10,            "leftFixed": "sm"          }        }      ],      "name": "alarm_form",      "type": "form",      "rules": [      ],      "title": "",      "initApi": "",      "submitText": ""    }  ],  "style": {  },  "initApi": {    "url": "/iotapi/classes/Notification/parse_notificationid",    "method": "get",    "adaptor": "return {\r\n  \"status\":0,\r\n  \"msg\":\"\",\r\n  \"data\":response.data.content\r\n  }",    "headers": {      "store": "localStorage",      "dgiotReplace": "parse_notificationid"    },    "dataType": "json"  },  "messages": {  },  "initFetch": true}

2.关联物模型,生成告警规定

点击关联,抉择告警产生/告警复原

配置规定,以下图为例

[小 迪 揭示]
告警产生后必须告警复原后,同一个设施才会再次告警,因而须要自行关联告警复原(期待设施复原)或者平台点击手动复原/误报

平台告警配置实现

二、短信告警模板

1.填写短信模板前置信息,菜单抉择云零碎-告诉治理,填写信息,点击保留

2.创立低代码

进入产品详情点击可视化,点击增加


以下图为例:

3.点击设计

短信告警模板低代码:

{  "type": "page",  "body": [    {      "id": "u:258c50b2e0c0",      "type": "grid",      "columns": [        {          "body": [            {              "id": "u:2c72c2d76916",              "api": {                "url": "iotapi/classes/Product/parse_objectid",                "data": null,                "method": "put",                "headers": {                  "store": "localStorage",                  "dgiotReplace": "parse_objectid"                },                "dataType": "json",                "requestAdaptor": "return {\r\n  ...api,\r\n  data:{\r\n    content:{\r\n      sms:{\r\n        tplid:api.data.tplid,\r\n        params:api.data.params\r\n      }\r\n    }    \r\n  }\r\n}"              },              "body": [                {                  "mode": "horizontal",                  "name": "tplid",                  "size": "lg",                  "type": "input-text",                  "label": "模板编号",                  "readOnly": false,                  "horizontal": {                    "left": 2,                    "right": 10,                    "leftFixed": "sm"                  }                },                {                  "flat": true,                  "mode": "inline",                  "name": "params",                  "size": "lg",                  "type": "combo",                  "items": [                    {                      "id": "u:ae0d88f0b31b",                      "name": "text",                      "type": "input-text",                      "label": "短信字段",                      "options": [                        {                          "label": "设施名称",                          "value": "%DEVICENAME%"                        },                        {                          "label": "设施地址",                          "value": "%DEVICEADDR%"                        },                        {                          "label": "产品名称",                          "value": "%PRODUCTNAME%"                        },                        {                          "label": "日期",                          "value": "%DATE%"                        },                        {                          "label": "用户名称",                          "value": "%USERNAME%"                        },                        {                          "label": "报警工夫",                          "value": "%TRIGGERTIME%"                        },                        {                          "label": "变量名称",                          "value": "%DATAPOINTNAME%"                        },                        {                          "label": "以后值",                          "value": "%NOWVALUE%"                        }                      ]                    }                  ],                  "label": "字段程序",                  "messages": {                  },                  "multiple": true,                  "className": "",                  "maxLength": "",                  "minLength": "",                  "multiLine": true,                  "horizontal": {                    "left": 2,                    "right": 10,                    "leftFixed": "sm"                  },                  "joinValues": false,                  "labelClassName": "",                  "typeSwitchable": true                }              ],              "name": "alarm_form",              "type": "form",              "title": "告警短信模板",              "initApi": "",              "multiLine": false            }          ]        },        {          "body": [            {              "id": "u:9b96b2b0313b",              "body": [                {                  "tpl": "<p>字段解释:</p>\n<p>模板编号:云服务器短信模板编号</p>\n<p>字段程序:一条短信字段则是短信模板中的一个变量,按程序进行增加</p>\n<p>短信字段:一条短信字段可包含多个参数</p>\n<p>产品名称:%PRODUCTNAME%</p>\n<p>设施名称:%DEVICENAME%</p>\n<p>设施地址:%DEVICEADDR%</p>\n<p>产品名称:%PRODUCTNAME%</p>\n<p>日期:%DATE%</p>\n<p>工夫:%DATETIME%</p>\n<p>用户名称:%USERNAME%</p>\n<p>报警工夫:%TRIGGERTIME%</p>\n<p>变量名称:%DATAPOINTNAME%</p>\n<p>以后值:%NOWVALUE%</p>\n<p>触发形容:%TRIGGERDESCRIPTION%</p>\n<p> </p>",                  "type": "tpl",                  "style": {                  },                  "trigger": [                    "hover"                  ]                }              ],              "type": "tooltip-wrapper",              "tooltip": "提醒文字"            }          ]        }      ]    }  ],  "style": {  },  "initApi": {    "url": "iotapi/classes/Product/parse_objectid",    "method": "get",    "adaptor": "return {\r\n  \"status\":0,\r\n  \"msg\":\"\",\r\n  \"data\":response.data.content.sms\r\n  }",    "headers": {      "store": "localStorage",      "dgiotReplace": "parse_objectid"    },    "dataType": "json"  },  "messages": {  },  "initFetch": true}

4.配置短信模板进行提交

在产品可视化下新创建的告警短信模板点击预览

依据提醒配置短信模板,以下图为例:

此例子与dgiot短信字段与腾讯云服务器短信字段的对应关系一文中注释模板的自定义内容程序统一

点击提交

三、触发告警

云运维-告警核心

手机接管短信

[小 迪 点评]

  • dgiot平台提供发送短信,指定模板短信告诉。
  • 在老本方面dgiot为升高用户应用老本,在短信方面在腾讯云指定配置即可应用。
    想理解更多 dgiot 的具体细节,欢送大家在GitHub上查看相干源代码。

想理解更多 dgiot 的具体细节,欢送大家在GitHub上查看相干源代码。