/** * @param @param args 设定文件 * @return void 返回类型 * @throws */ public static void main(String[] args) { ApplicationContext content = new ClassPathXmlApplicationContext( new String[] { "classpath:applicationContext.xml", "classpath:winsensor/applicationContext-event.xml" }); EventSender eventSender = (EventSender) content.getBean("sensorSender"); AlertInfoBO alertinfo = new AlertInfoBO(); alertinfo.setNodeid(Long.valueOf("2222222222")); alertinfo.setSrcIP("127.0.0.1"); alertinfo.setDomain_id(Integer.parseInt("22")); alertinfo.setLevel(1); alertinfo.setAlertType("阈值告警"); alertinfo.setAlertSubType("pc"); alertinfo.setAlertReason("超出阈值"); alertinfo.setTime(long2Timestamp(System.currentTimeMillis())); eventSender.send(alertinfo); }
/** * Frame 跳转专用 * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward alertRuleFwd( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String alertId = request.getParameter("alertId"); try { init(); if (alertId != null && (!alertId.equals(""))) { AlertInfoBO alertInfobo = alertService.getByIdAlertService(Integer.parseInt(alertId)); if (alertInfobo != null) { request.setAttribute("alertInfobo", alertInfobo); String fusion = alertInfobo.getFusioin(); int fusionCount = 0; List fustionTimeList = new ArrayList(); if (fusion != null && fusion.trim().length() > 0) { String strs[] = fusion.split(","); if (strs != null && strs.length > 0) { fusionCount = strs.length; for (String string : strs) { fustionTimeList.add(string); } } } request.setAttribute("fusionCount", fusionCount); request.setAttribute("fustionTimeAll", fustionTimeList); if (alertInfobo.getStatus() != null && alertInfobo.getStatus() == 1) { // 如果状态是未读 就更新状态为只读 alertInfobo.setStatus(0); alertService.updateAlertService(alertInfobo); } if (alertInfobo.getIfnew() != null && alertInfobo.getIfnew() == 1) { alertInfobo.setIfnew(0); alertService.updateAlertService(alertInfobo); } if (alertInfobo != null && alertInfobo.getDomain_id() != null) { Integer domain_id = alertInfobo.getDomain_id(); Domain domain = domainService.findById(domain_id); request.setAttribute("department", domain); } // 触发规则列表 List alertRuleList = new ArrayList(); if (alertInfobo.getRule() != null && alertInfobo.getRule().trim().length() != 0) { String strs[] = alertInfobo.getRule().split(","); for (int i = 0; i < strs.length; i++) { AlertRuleBO rule = alertRuleService.getByIdAlertRuleService(Integer.parseInt(strs[i])); alertRuleList.add(rule); } } request.setAttribute("alertruleList", alertRuleList); } } log.setUsername(username); log.setRoleName(rolenames); log.setTime(new Timestamp(new Date().getTime())); log.setModuleName(SystemModelInfo.MOD_AIM); log.setOperationDesc("查询告警类型信息详情"); log.setControl("成功"); systemlogService.saveSystemLog(log); return mapping.findForward("alertLinkage"); } catch (Exception e) { log.setUsername(username); log.setRoleName(rolenames); log.setTime(new Timestamp(new Date().getTime())); log.setModuleName(SystemModelInfo.MOD_AIM); log.setOperationDesc("查询告警类型信息详情"); log.setControl("失败"); systemlogService.saveSystemLog(log); return null; } }