use of com.creditease.agent.monitor.api.NotificationEvent in project uavstack by uavorg.
the class ReliableTaildirEventReader method updatelog.
public void updatelog(Map<String, LogPatternInfo> filePaths) {
for (Entry<String, LogPatternInfo> e : filePaths.entrySet()) {
LogPatternInfo logPatternInfo = e.getValue();
LogAgent logagent = (LogAgent) ConfigurationManager.getInstance().getComponent("logagent", "LogAgent");
LogPatternInfo logPatternInfoTemp = logagent.getLatestLogProfileDataMap().get(logPatternInfo.getAppUUID(), logPatternInfo.getUUID());
List<File> list = getMatchFiles(logPatternInfo.getParentDir(), logPatternInfo.getLogRegxPattern());
if (!list.isEmpty()) {
logPatternInfoTemp.setFlag(StateFlag.EXIST);
} else {
logPatternInfoTemp.setFlag(StateFlag.EXIST_UNKOWN);
}
if (list.isEmpty() && !logPatternInfo.getParentDir().isDirectory()) {
// notify
String title = NetworkHelper.getLocalIP() + "在" + logPatternInfo.getParentDir() + "下没有符合日志文件匹配规则[" + logPatternInfo.getLogRegxPattern() + "]的日志文件。";
String content = "失败原因:1)日志文件匹配规则配置错误,所以不能定位日志文件。2)日志文件的命名已经改变,但没有修过日志文件匹配规则。";
logger.warn(this, title);
NotificationEvent event = new NotificationEvent(NotificationEvent.EVENT_LogNotExist, title, content);
event.addArg("serverid", logPatternInfo.getServId());
event.addArg("appid", logPatternInfo.getAppId());
logagent.putNotificationEvent(event);
}
// <R=filepath,C=logPatternInfo,V=
tailFileTable.put(logPatternInfo.getAbsolutePath(), logPatternInfo);
if (logger.isDebugEnable()) {
logger.debug(this, "update log table. absPath=" + logPatternInfo.getAbsolutePath() + ", info=" + JSONHelper.toString(logPatternInfo));
}
}
}
use of com.creditease.agent.monitor.api.NotificationEvent in project uavstack by uavorg.
the class ProcWatcher method notify.
private void notify(ProcInfo proc, String startedMsg) {
String desc = "发现" + proc.getName() + "进程" + proc.getPid() + "停止,已重启。\n启动参数:" + proc.getCmd() + "\n启动信息:" + startedMsg;
NotificationEvent event = new NotificationEvent(NotificationEvent.EVENT_RT_ALERT_CRASH, "发现" + proc.getName() + "进程停止,已重启进程", desc);
putNotificationEvent(event);
}
use of com.creditease.agent.monitor.api.NotificationEvent in project uavstack by uavorg.
the class NotificationTask method run.
@Override
public void run() {
NotificationEvent event = (NotificationEvent) this.get(NCConstant.NCEventParam);
int priorityLevel = (int) this.get(NCConstant.PRIORITYLEVEL);
NotificationCenter nc = (NotificationCenter) this.getConfigManager().getComponent(this.feature, "NotificationCenter");
if (log.isTraceEnable()) {
log.info(this, "NotificationTask Actions START: event=" + event.toJSONString());
}
/**
* Step 1: get all actions for this event
*/
Map<String, String> args = event.getArgs(true);
Map<String, String> actionMap = new LinkedHashMap<String, String>();
for (String key : args.keySet()) {
if (key.indexOf("action_") != 0) {
continue;
}
String actionTag = key.substring("action_".length());
String actionStr = args.get(key);
/**
* find matched priority action
*/
String actionPrame = getActionParmeByPriorityLevel(actionStr, priorityLevel);
if (!StringHelper.isEmpty(actionPrame)) {
actionMap.put(actionTag, actionPrame);
}
}
/**
* Step 1.5: send notify to push notify event action
*/
String action4pushntf = new String();
actionMap.put("pushntf", action4pushntf);
/**
* Step 2: execute actions
*/
nc.executeNotifyAction(actionMap, event);
if (log.isTraceEnable()) {
log.info(this, "NotificationTask Actions END.");
}
}
use of com.creditease.agent.monitor.api.NotificationEvent in project uavstack by uavorg.
the class BaseNotifyAction method doAction.
@Override
public void doAction(ActionContext context) throws Exception {
NotificationEvent event = (NotificationEvent) context.getParam("event");
String actionParam = (String) context.getParam(NCConstant.ACTIONVALUE);
event.addArg(cName, actionParam);
boolean isSuccess = this.run(event, context);
context.setSucessful(isSuccess);
}
Aggregations