当前位置:网站首页>钉钉报警工具
钉钉报警工具
2022-07-27 20:42:00 【风铃峰顶】
建立一个群,群内的成员可以添加机器人,群管理员可以修改群内的所有机器人。机器人有对应的Webhook,向这个地址发送信息,可以显示在群内。安全设置方向有信息内含有自定义关键词、地址加入验签信息、限制发送的IP地址段三种方式。
ding:
url: 对应机器人设置里的Webhook地址
atMobiles:
功能名: @的人员手机号列表,逗号隔开,可以在群内的成员名片中看到,不带+86-
@Slf4j
@Configuration
public class DingDingAlarmUtil {
@Value("${ding.url}")
private String url;
@Value("${spring.profiles.active}")
private String pretext;
private static DingTalkClient client;
private static String staticPretext;
@PostConstruct
public void init() {
client = new DefaultDingTalkClient(url);
staticPretext = String.format("[%s]", pretext);
}
public static void alarm(String content, String atMobiles) {
try {
OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
String time = TimeUtil.formatDateTime(LocalDateTime.now(), TimeUtil.TimeFormat.LONG_DATE_PATTERN_LINE);
// 内容
text.setContent(staticPretext + time + "[ERROR]" + content);
OapiRobotSendRequest request = new OapiRobotSendRequest();
// 格式
request.setMsgtype("text");
request.setText(text);
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
String[] atMobileArray = atMobiles.replace(" ", "").split(",");
List<String> atMobileList = new ArrayList<>(Arrays.asList(atMobileArray));
// @的人员手机号列表
at.setAtMobiles(atMobileList);
request.setAt(at);
client.execute(request);
} catch (Exception e) {
log.error("alarm error:", e);
}
}
}
边栏推荐
- Promise solves asynchrony
- kubevela通过CLI部署应用
- 【StoneDB故障诊断】数据库实例crash
- [image detection] realize the detection of nostrils and pupil circles based on combined separation filter matlab source code
- Excel VBA finds out the maximum and minimum values of a column of time, and repeatedly pastes multiple values according to the actual situation
- What are the advantages of Tita's OKR system over other similar products or shared documents?
- Parameter transmission of components
- Shuffle, partition and read of tfrecord
- 华为鸿蒙 3 正式发布,这个安全功能解决了一大痛点
- Arm32 for remote debugging
猜你喜欢

Complete Guide to IOT architecture

Deploy dolphin scheduler high availability cluster based on rainbow
![[signal processing] weak signal detection in communication system based on the characteristics of high-order statistics with matlab code](/img/a7/8f0d929457d285adc8020c7f5d33ea.png)
[signal processing] weak signal detection in communication system based on the characteristics of high-order statistics with matlab code

Introduction to the paper | language model for long text under transformer architecture

Excel VBA finds out the maximum and minimum values of a column of time, and repeatedly pastes multiple values according to the actual situation

Flink怎么使用Savepoint

The security dilemma of software supply chain faced by enterprises

Www 2019 | Han: heterograph attention network

Nature综述:微生物群落形成过程中的优先效应
![[signal denoising] signal denoising based on Kalman filter with matlab code](/img/9e/9e569c83dc3106570cf7571056867f.png)
[signal denoising] signal denoising based on Kalman filter with matlab code
随机推荐
【ELM分类】基于核极限学习机和极限学习机实现UCI数据集分类附matlab代码
Figure basic knowledge code
Tita 的OKR系统与其他同类型产品,或者是共享文档等相比,有什么优势?
Excel VBA finds out the maximum and minimum values of a column of time, and repeatedly pastes multiple values according to the actual situation
VIM editor tutorial
Basic SQL general syntax and classification
看GAN如何一步步控制图像生成风格?详解StyleGAN进化过程
华为鸿蒙 3 正式发布,这个安全功能解决了一大痛点
毕设-基于SSM高校后勤管理系统
Node red series (30): use persistent UI table to refresh the page without emptying the last table data
containerd ctr运行ansible容器执行ansible-playbook任务完整命令
一位软件投资者的独白:我为什么不追逐快速增长的公司
How to quickly view the API properties and usage of the h.265 video player easyplayer?
【数字识别】基于Hopfield神经网络识别0-9数字附Matlab代码
Basic SQL DML
iMeta | 国际标准刊号ISSN印刷版正式确认,双ISSN申请完成
常用泰勒展开
一篇文章读懂人工神经网络
Solve the problem that the last bit of IP address access is odd and even, or even and odd (the problem encountered when the cloud encryption machine connects to the cloud server, the whole process is
怎么使用xshell免费版