Search in sources :

Example 16 with NotificationEvent

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));
        }
    }
}
Also used : LogAgent(com.creditease.agent.feature.LogAgent) NotificationEvent(com.creditease.agent.monitor.api.NotificationEvent) LogPatternInfo(com.creditease.agent.feature.logagent.objects.LogPatternInfo) File(java.io.File)

Example 17 with NotificationEvent

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);
}
Also used : NotificationEvent(com.creditease.agent.monitor.api.NotificationEvent)

Example 18 with NotificationEvent

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.");
    }
}
Also used : NotificationCenter(com.creditease.agent.feature.NotificationCenter) NotificationEvent(com.creditease.agent.monitor.api.NotificationEvent) LinkedHashMap(java.util.LinkedHashMap)

Example 19 with NotificationEvent

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);
}
Also used : NotificationEvent(com.creditease.agent.monitor.api.NotificationEvent)

Aggregations

NotificationEvent (com.creditease.agent.monitor.api.NotificationEvent)19 Map (java.util.Map)6 LogPatternInfo (com.creditease.agent.feature.logagent.objects.LogPatternInfo)4 ArrayList (java.util.ArrayList)4 LogAgent (com.creditease.agent.feature.LogAgent)3 LinkedHashMap (java.util.LinkedHashMap)3 NotifyStrategy (com.creditease.uav.feature.runtimenotify.NotifyStrategy)2 Slice (com.creditease.uav.feature.runtimenotify.Slice)2 StrategyJudgement (com.creditease.uav.feature.runtimenotify.StrategyJudgement)2 File (java.io.File)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ConfigurationContext (com.creditease.agent.ConfigurationContext)1 NotificationCenter (com.creditease.agent.feature.NotificationCenter)1 GlobalNotificationManager (com.creditease.agent.feature.globalnotify.GlobalNotificationManager)1 TaildirLogComponent (com.creditease.agent.feature.logagent.TaildirLogComponent)1 LogFilterAndRule (com.creditease.agent.feature.logagent.api.LogFilterAndRule)1 Event (com.creditease.agent.feature.logagent.event.Event)1 NCJudgementWorker (com.creditease.agent.feature.notifycenter.NCJudgementWorker)1 PersistentTask (com.creditease.agent.feature.notifycenter.task.PersistentTask)1