标签:point tcl net dem ddr author element ram rop
官方文档
https://naver.github.io/pinpoint/alarm.html
修改 batch.properties文件,batch.enable设置为true.ip能连接的ip
#batch enable config batch.enable=true #batch server ip to execute batch batch.server.ip=127.0.0.127
/* * Copyright 2018 NAVER Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.navercorp.pinpoint.web.util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.net.Inet4Address; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Collections; import java.util.Enumeration; /** * @author minwoo.jung */ public class BatchUtils { private final static Logger logger = LoggerFactory.getLogger(BatchUtils.class); public static boolean decisionBatchServer(String ip) { Enumeration<NetworkInterface> interfaces; try { interfaces = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { logger.error("not found network interface", e); return false; } if (interfaces == null) { return false; } while (interfaces.hasMoreElements()) { NetworkInterface network = interfaces.nextElement(); Enumeration<InetAddress> inets = network.getInetAddresses(); while (inets.hasMoreElements()) { InetAddress next = inets.nextElement(); if (next instanceof Inet4Address) { if (next.getHostAddress().equals(ip)) { return true; } } } } return false; } }
BatchUtils类有对IP进行校验。
com.navercorp.pinpoint.web.config.ConfigProperties读取配置文件
com.navercorp.pinpoint.web.alarm.AlarmWriter 默认配置的EmptyMessageSender,需要自定义个发送对象需要继承AlarmMessageSender,修改AlarmWriter为自己定义对象
@Autowired(required = false) private AlarmMessageSender alarmMessageSender = new AlarmMessageSenderImple();
新建AlarmMessageSenderImple
package com.navercorp.pinpoint.web.alarm; import com.navercorp.pinpoint.web.alarm.checker.AlarmChecker; import com.navercorp.pinpoint.web.service.UserGroupService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import java.util.List; public class AlarmMessageSenderImple implements AlarmMessageSender { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private UserGroupService userGroupService; @Override public void sendSms(AlarmChecker checker, int sequenceCount) { List<String> receivers = userGroupService.selectPhoneNumberOfMember(checker.getuserGroupId()); if (receivers.size() == 0) { return; } List<String> sms = checker.getSmsMessage(); for (String message : sms) { logger.info("send SMS : {}", message); System.out.println("send SMS : {}" + message); } } @Override public void sendEmail(AlarmChecker checker, int sequenceCount) { List<String> receivers = userGroupService.selectPhoneNumberOfMember(checker.getuserGroupId()); if (receivers.size() == 0) { return; } for (String receiver : receivers) { System.out.println("receiver:"+receiver); } String mail = checker.getEmailMessage(); logger.info("mail : {}", mail); } }
batch.server.ip
标签:point tcl net dem ddr author element ram rop
原文地址:https://www.cnblogs.com/zhanchaohan/p/12217684.html