⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alert.java

📁 “JSP数据库项目案例导航”一书从第一章到第十一章各章实例的源程序文件以及数据库文件。 注意: 1. 本书中的案例提供的数据库环境不同
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        }
        catch(NullPointerException ne)
        {}
        catch(Exception e)
        {
            System.err.println("在生成\"文件系统\"自动运行脚本时产生异常。");
            e.printStackTrace();
        }

        if(AlertProperties.isWarning(AlertProperties.cics_transaction_level))
        {
            try
            { //cics transaxion 数目
                String[] timestamp = DBAccess.getLatestData(
                    "select timestamp from cicslogspace where ipaddress='" + hostip +
                    "' order by id desc");
                Vector usagesV = DBAccess.getBatchData(
                    "select freepages ,total, name from cicslogspace where ipaddress='" +
                    hostip +
                    "' and timestamp='" + timestamp[0] + "'");
                for(int i = 0; i < usagesV.size(); )
                {
                    int freepages = Integer.parseInt( (String)usagesV.elementAt(i++));
                    int total = Integer.parseInt( (String)usagesV.elementAt(i++));
                    int ratio = freepages / total;
                    if(ratio > AlertProperties.cics_transaction_min)
                    {
                        scripts += "cics." + (String)usagesV.elementAt(i) + ".ritem@";

                    }
                    i++;
                }
            }
            catch(NullPointerException ne)
            {}
            catch(Exception e)
            {
                System.err.println("在查询\"cicslogspace \"数据时产生异常");
                e.printStackTrace();
            }

        }

        return scripts;

    }

    /**
     * 电话报警信息。得到{}{}{}格式的内容
     * @return
     */
    public static String getTeleMsg(String hostip, String hostname)
    {
        String init = "{" + hostip + "}{" + hostname + "}";
        String msg = init;

        if(AlertProperties.isWarning(AlertProperties.cpu_busy_level))
        { //cpu
            try
            {
                Vector v = DBAccess.getGivingTimesData(
                    "select idle from cpu where ipaddress='" + hostip +
                    "'  order by id desc",
                    AlertProperties.cpu_busy_times);
                int cputimes = 0;
                for(; cputimes < AlertProperties.cpu_busy_times; cputimes++)
                {
                    int busy = 100 - Integer.parseInt( (String)v.elementAt(cputimes));
                    if(busy > AlertProperties.cpu_busy_min)
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }

                }
                if( (cputimes == AlertProperties.cpu_busy_times))
                {
                    msg += WarningMsg.CPU_CODE;
                }

            }
            catch(NullPointerException ne)
            {}
            catch(Exception e)
            {
                System.err.println("在生成\"CPU\"警报数据时产生异常");
                e.printStackTrace();

            }
        }

        if(AlertProperties.isWarning(AlertProperties.pg_use_level))
        { //pg
            try
            {
                String[] value = DBAccess.getLatestData(
                    "select totalsize,inuse from pg where ipaddress='" + hostip +
                    "'  order by id desc");
                if(Integer.parseInt(Tools.findNumberInString(value[1])) * 100 /
                   Integer.parseInt(Tools.findNumberInString(value[0])) >
                   AlertProperties.pg_use_min)
                {
                    msg += WarningMsg.PG_CODE;
                }
            }
            catch(NullPointerException ne)
            {}
            catch(Exception e)
            {
                System.err.println("在生成\"页交换空间\"警报数据时产生异常");
                e.printStackTrace();
            }
        }

        if(AlertProperties.isWarning(AlertProperties.disk_io_level))
        { //diskio
            try
            {
                Vector v = DBAccess.getGivingTimesData(
                    "select act from diskio where ipaddress='" + hostip +
                    "'  order by id desc",
                    AlertProperties.disk_io_times);
                int diskiotimes = 0;
                for(; diskiotimes < AlertProperties.disk_io_times; diskiotimes++)
                {
                    float act = Float.parseFloat( (String)v.elementAt(diskiotimes));
                    if(act > AlertProperties.disk_io_min)
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }

                }
                if(diskiotimes == AlertProperties.disk_io_times)
                {
                    msg += WarningMsg.DISKIO_CODE;
                }
            }
            catch(NullPointerException ne)
            {}
            catch(Exception e)
            {
                System.err.println("在生成\"系统硬盘\"警报数据时产生异常");
                e.printStackTrace();
            }
        }

        if(AlertProperties.isWarning(AlertProperties.fs_use_level))
        { //fs
            try
            {
                String[] timestamp = DBAccess.getLatestData(
                    "select timestamp from fs where ipaddress='" + hostip +
                    "' order by id desc");
                Vector result = DBAccess.getBatchData(
                    "select used from fs where ipaddress='" + hostip +
                    "' and timestamp='" + timestamp[0] + "'");
                for(int i = 0; i < result.size(); i++)
                {
                    String temp = (String)result.elementAt(i);
                    int value = Integer.parseInt(temp);
                    if( (value > AlertProperties.fs_use_min) &&
                       (AlertProperties.fs_use_level == AlertProperties.WARNING))
                    {
                        msg += WarningMsg.FS_CODE;
                        break;
                    }
                }
            }
            catch(NullPointerException ne)
            {}
            catch(Exception e)
            {
                System.err.println("在生成\"文件系统\"警报数据时产生异常");
                e.printStackTrace();
            }

            if(AlertProperties.isWarning(AlertProperties.engine_busy_level))
            {
                try
                { //engine 计算engine的平均值
                    Vector timestampV = DBAccess.getGivingTimesData(
                        "select timestamp from engine where ipaddress='" + hostip +
                        "'  group by timestamp order by id desc",
                        AlertProperties.engine_busy_times);
                    int i = 0;
                    for(; i < timestampV.size(); i++)
                    {
                        String timestamp = (String)timestampV.elementAt(i);
                        Vector usagesV = DBAccess.getBatchData(
                            "select usages from engine where ipaddress='" + hostip +
                            "' and timestamp='" + timestamp + "'");
                        float total = 0;
                        for(int t = 0; t < usagesV.size(); t++)
                        {
                            total += Float.parseFloat( (String)usagesV.elementAt(t));
                        }
                        float avg = total / usagesV.size();
                        if(avg > AlertProperties.engine_busy_min)
                        {
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    }
                    if(i == AlertProperties.engine_busy_times)
                    {
                        msg += WarningMsg.ENGINE_CODE;
                    }
                }
                catch(NullPointerException ne)
                {}
                catch(Exception e)
                {
                    System.err.println("在生成\"Sybase Engine\"警报数据时产生异常");
                    e.printStackTrace();
                }
            }
        }

        if(AlertProperties.isWarning(AlertProperties.Sybase_tranx_level))
        {
            try
            { //cicsregions status
                String[] timestamp = DBAccess.getLatestData(
                    "select distinct timestamp from sybtran where ipaddress='" + hostip +
                    "' order by id desc");
                Vector result = DBAccess.getBatchData(
                    "select runtime from sybtran where ipaddress='" + hostip +
                    "' and timestamp='" + timestamp[0] + "'");
                for(int i = 0; i < result.size(); i++)
                {
                    int value = Integer.parseInt( (String)result.elementAt(i));
                    if(value > AlertProperties.Sybase_tranx_min)
                    {
                        msg += WarningMsg.TRANX_CODE;
                        break;
                    }
                }
            }
            catch(NumberFormatException nfe)
            {}
            catch(NullPointerException ne)
            {}
            catch(Exception e)
            {
                System.err.println("在生成\"sybtran\"警报数据时产生异常");
                e.printStackTrace();
            }
        }

        if(AlertProperties.isWarning(AlertProperties.sfs_server_level))
        {
            try
            { //sfs_server
                String[] timestamp = DBAccess.getLatestData(
                    "select timestamp from cicsfs where ipaddress='" + hostip +
                    "' order by id desc");
                Vector result = DBAccess.getBatchData(
                    "select status from cicsfs where ipaddress='" + hostip +
                    "' and timestamp='" + timestamp[0] + "'");
                for(int i = 0; i < result.size(); i++)
                {
                    String status = (String)result.elementAt(i);
                    if(!status.equalsIgnoreCase(AlertProperties.sfs_server_normal))
                    {
                        msg += WarningMsg.SFSSERVER_CODE;
                        break;
                    }
                }
            }
            catch(NullPointerException ne)
            {}
            catch(Exception e)
            {
                System.err.println("在生成\"CICS FS Server\"警报数据时产生异常");
                e.printStackTrace();
            }
        }

        if(AlertProperties.isWarning(AlertProperties.sfs_server_warninglog_level))
        {
            try
            { //sfs server 的warning数
                String[] warnings = DBAccess.getLatestData(
                    "select warning from sfserror where ipaddress='" + hostip +
                    "' order by id desc");
                int warning = Integer.parseInt(warnings[0]);
                if(warning > AlertProperties.sfs_server_warninglog_min)
                {
                    msg += WarningMsg.SFSSERVER_WARNINGLOG_CODE;
                }
            }
            catch(NullPointerException ne)
            {}
            catch(Exception e)
            {
                System.err.println("在生成\"CICS FS Server\"警报数据时产生异常");
                e.printStackTrace();
            }
        }

        if(AlertProperties.isWarning(AlertProperties.sfs_server_errorlog_level))
        {
            try
            { //sfs server 的error数
                String[] warnings = DBAccess.getLatestData(
                    "select error from sfserror where ipaddress='" + hostip +
                    "' order by id desc");
                int error = Integer.parseInt(warnings[0]);
                if(error > AlertProperties.sfs_server_errorlog_min)
                {
                    msg += WarningMsg.SFSSERVER_ERRORLOG_CODE;
                }
            }
            catch(NullPointerException ne)
            {}
            catch(Exception e)
            {
                System.err.println("在生成\"CICS FS Server\"警报数据时产生异常");
                e.printStackTrace();
            }
        }

        if(AlertProperties.isWarning(AlertProperties.region_level))
        {
            try
            { //cicsregions status
                String[] timestamp = DBAccess.getLatestData(
                    "select timestamp from cicsregions where ipaddress='" + hostip +

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -