BatchInspectionOperation.jsp 2.57 KB
<%@ include file="/templetecheck/filecheck/CheckUserIsSysadmin.jsp" %>
<%@ page import="weaver.templetecheck.filecheck.CheckRule" %>
<%@ page import="weaver.general.GCONST" %>
<%@ page import="java.io.File" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.templetecheck.filecheck.DoCheckAllPartThread" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.Set" %>
<%@ page import="org.json.JSONObject" %>


<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
    String operation= Util.null2String(request.getParameter("operation"));
    if("startcheckrule".equals(operation)){//开始检测规则
        try{
            if(DoCheckAllPartThread.runstatus==0){
                if(CheckRule.isrunpartStatus!=0){
                    CheckRule.isrunpartStatus=0;
                }
                DoCheckAllPartThread doCheckAllPartThread=new DoCheckAllPartThread();
                Thread thread=new Thread(doCheckAllPartThread);
                thread.setName("executeCheckRule");
                thread.start();
            }else{
                new BaseBean().writeLog("文件正在检测");
            }
        }catch(Exception e){
            new BaseBean().writeLog("文件检测错误");
        }
    }else if("stopcheckrule".equals(operation)){
        new BaseBean().writeLog("start to kill thread 开始杀死进程");
        try{
            if(DoCheckAllPartThread.runstatus==1){
                Set<Thread> runningThreads=Thread.getAllStackTraces().keySet();
                for(Thread runningThread:runningThreads){
                    if(runningThread.getName().equals("executeCheckRule")){
                        runningThread.stop();//关闭线程
                        DoCheckAllPartThread.runstatus=0;
                        break;
                    }
                }
            }else{
                new BaseBean().writeLog("文件检测程序未运行");
            }
        }catch(Exception e){
            new BaseBean().writeLog("error to kill thread errormessage:"+e.toString());
        }
        new BaseBean().writeLog("end to kill thread 结束进程");
    }else  if("getexecuteinfo".equals(operation)){
        JSONObject json=new JSONObject();
        if(DoCheckAllPartThread.runstatus==1){
            json.put("step",CheckRule.isrunpartStatus);
        }else{
            if(CheckRule.isrunpartStatus==6){
                json.put("step","6");
            }else{
                json.put("step","0");
            }

        }
        response.getWriter().print(json.toString());
    }

%>