当前位置:网站首页>钉钉报警工具
钉钉报警工具
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);
}
}
}
边栏推荐
- 一位软件投资者的独白:我为什么不追逐快速增长的公司
- Security-001
- 微信安装包11年膨胀575倍,UP主:“98%的文件是垃圾”;苹果应用商店被曝大量色情App;四大科技巨头呼吁废除闰秒|极客头条
- The wechat installation package has expanded 575 times in 11 years, and the up owner: "98% of the documents are garbage"; Apple App store was exposed to a large number of pornographic apps; Four techn
- 强化学习——PyTorch 实现 Advantage Actor-Critic (A2C)
- Vulnhub range double trouble
- 360入选中国安全产业全景图63个领域 ISC2022共话安全服务方向
- 【信号处理】基于高阶统计量特征的通信系统中微弱信号检测附matlab代码
- Helm chart explanation and common commands: helm template / package / plugin
- 【数字识别】基于知识库实现手写体数字识别附matlab代码
猜你喜欢

Simple and practical data visualization cases

How to narrow the gap between project planning and implementation?

LANproxy mapping local development environment

如何快捷地查看H.265视频播放器EasyPlayer的API属性及其使用方法?

习题 --- BFS

回Mixlab三天,“创造力团队”治好了我的精神内耗

Network development socket and UDP, TCP protocols

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

NDK series (6): let's talk about the way and time to register JNI functions

Lanproxy映射本地开发环境
随机推荐
Basic lighting of unity
Flink怎么使用Savepoint
Blender plug-in of 2022
Keming food: the average increase in the sales price of various series of products is about 5%
Gstore weekly gstore source code analysis (V): log tracking of security mechanism
[number recognition] recognize 0-9 numbers based on Hopfield neural network with matlab code
Safety Fundamentals 1
On data management of data warehouse
Security-001
Visual display method of machine learning project
一位软件投资者的独白:我为什么不追逐快速增长的公司
XML external entity (xxE) vulnerability and its repair method
Main security risks and Countermeasures of cloud computing services
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
他山之石 | 蚂蚁超大规模知识图谱构建及应用
2022/7/26
Introduction to the paper | distributed graph simulation
Figure basic knowledge code
MySQL basic installation and startup
kubevela通过CLI部署应用