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

📄 availcalculations.java

📁 opennms得相关源码 请大家看看
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        //        if (!format.equals("SVG")) {            if (log.isDebugEnabled())                log.debug("Now computing LAST_MTD_TOTAL_LABEL ");            label = AvailabilityConstants.LAST_MTD_TOTAL_LABEL;            descr = AvailabilityConstants.LAST_MTD_TOTAL_DESCR;            if (label == null || label.length() == 0)                label = "Month To Date Total Availability";            if (descr == null || descr.length() == 0)                descr = "Average of svc monitored and availability of svcs dividedby total svc minutes of month frm 1st till date";            lastMoTotalAvailability(numDaysInMonth, m_endTime, catSections, label, descr);            if (log.isDebugEnabled())                log.debug("Computed MTDTotalAvailability");        }        m_services = new HashMap();        ListIterator lstIter = nodes.listIterator();        while (lstIter.hasNext()) {            Node node = (Node) lstIter.next();            if (node != null) {                List interfaces = node.getInterfaces();                ListIterator lstIterIntf = interfaces.listIterator();                while (lstIterIntf.hasNext()) {                    Interface intf = (Interface) lstIterIntf.next();                    if (intf != null) {                        List svcs = intf.getServices();                        ListIterator lstIterSvcs = svcs.listIterator();                        while (lstIterSvcs.hasNext()) {                            Service svc = (Service) lstIterSvcs.next();                            if (svc != null) {                                OutageSvcTimesList outages = svc.getOutages();                                if (outages != null) {                                    IfService ifservice = new IfService(node.getNodeID(), intf.getName(), -1, node.getName(), svc.getName());                                    Map svcOutages = (Map) m_services.get(svc.getName());                                    if (svcOutages == null)                                        svcOutages = new HashMap();                                    svcOutages.put(ifservice, outages);                                    m_services.put(svc.getName(), svcOutages);                                }                            }                        }                    }                }            }        }        if (log.isDebugEnabled())            log.debug("Services " + m_services);        m_nodes = null;        //        // N Days Daily Service Availability        //        if (!format.equals("SVG")) {            if (log.isDebugEnabled())                log.debug("Now computing LAST_30_DAYS_SVC_AVAIL_LABEL ");            label = AvailabilityConstants.LAST_30_DAYS_SVC_AVAIL_LABEL;            descr = AvailabilityConstants.LAST_30_DAYS_SVC_AVAIL_DESCR;            if (label == null || label.length() == 0)                label = "The last 30 days Daily Service Availability";            if (descr == null || descr.length() == 0)                descr = "The last 30 days Daily Service Availability is the daily average of services";            lastNDaysDailyServiceAvailability(THIRTY, m_endTime, catSections, label, descr);            if (log.isDebugEnabled())                log.debug("Computed lastNDaysDailyServiceAvailability");        }        //        // Last Months Daily Service Availability        //        if (!format.equals("SVG")) {            if (log.isDebugEnabled())                log.debug("Now computing LAST_MONTH_SVC_AVAIL_LABE");            label = AvailabilityConstants.LAST_MONTH_SVC_AVAIL_LABEL;            descr = AvailabilityConstants.LAST_MONTH_SVC_AVAIL_DESCR;            if (label == null || label.length() == 0)                label = "The last Months Daily Service Availability";            if (descr == null || descr.length() == 0)                descr = "The last Months Daily Service Availability is the daily average of services and devices";            lastNDaysDailyServiceAvailability(m_daysInLastMonth, m_endLastMonthTime, catSections, label, descr);            if (log.isDebugEnabled())                log.debug("Computed lastNDaysDailyServiceAvailability");        }        //        // Top N Service Outages        //        if (!format.equals("SVG")) {            if (log.isDebugEnabled())                log.debug("Now computing TOP20_SVC_OUTAGES_LABEL");            label = AvailabilityConstants.TOP20_SVC_OUTAGES_LABEL;            descr = AvailabilityConstants.TOP20_SVC_OUTAGES_DESCR;            if (label == null || label.length() == 0)                label = "Last Month Top Service Outages for ";            if (descr == null || descr.length() == 0)                descr = "Last Month Top Service Outages for ";            lastMonTopNServiceOutages(catSections, label, descr);            if (log.isDebugEnabled())                log.debug("Computed lastMonTopNServiceOutages");        }        m_services = null;        category.addCatSections(catSections);        categories.addCategory(category);        m_report.setCategories(categories);        report = m_report;        if (log.isDebugEnabled())            log.debug("Leaving AvailCalculations");    }    public int getSectionIndex() {        return m_sectionIndex;    }    /**     * Last Months Top N Service Outages.     *      * @param catSections     *            Castors sections     * @param label     *            Section name in the xml     * @param descr     *            Section descr.     */    private void lastMonTopNServiceOutages(CatSections catSections, String label, String descr) {        ThreadCategory.setPrefix(LOG4J_CATEGORY);        org.apache.log4j.Category log = ThreadCategory.getInstance(this.getClass());        // Result is a map of outage / lost time        //        // For each monitored service, get all individual outages.        //        TreeMap treeMap = null;        Set serviceNames = m_services.keySet();        Iterator iterator = serviceNames.iterator();        while (iterator.hasNext()) {            treeMap = new TreeMap();            String service = (String) iterator.next();            Map ifSvcOutageList = (Map) m_services.get(service);            Set keysIfServices = ifSvcOutageList.keySet();            Iterator ifSvcIter = keysIfServices.iterator();            while (ifSvcIter.hasNext()) {                IfService ifservice = (IfService) ifSvcIter.next();                if (ifservice != null) {                    OutageSvcTimesList outageSvcList = (OutageSvcTimesList) ifSvcOutageList.get(ifservice);                    if (outageSvcList != null) {                        long rollingWindow = m_daysInLastMonth * ROLLING_WINDOW;                        List svcOutages = outageSvcList.getServiceOutages(ifservice.getNodeName(), m_endLastMonthTime, rollingWindow);                        Iterator iter = svcOutages.iterator();                        while (iter.hasNext()) {                            OutageSince outageSince = (OutageSince) iter.next();                            if (outageSince != null) {                                long outage = outageSince.getOutage() / 1000;                                List tmpList = (List) treeMap.get(new Long(outage));                                if (tmpList == null)                                    tmpList = new ArrayList();                                tmpList.add(outageSince);                                treeMap.put(new Long(-1 * outage), tmpList);                            }                        }                    }                }            }            log.debug("Top 20 service outages from the list " + treeMap);            Set outageKeys = treeMap.keySet();            Iterator lstIter = outageKeys.iterator();            int top20Count = 0;            Rows rows = new Rows();            loop: while (lstIter.hasNext()) {                Long outage = (Long) lstIter.next();                List list = (List) treeMap.get(outage);                ListIterator listIterator = list.listIterator();                while (listIterator.hasNext()) {                    OutageSince outageSince = (OutageSince) listIterator.next();                    top20Count++;                    String nodeName = outageSince.getNodeName();                    Value nodeValue = new Value();                    nodeValue.setContent(nodeName);                    nodeValue.setType("title");                    Value value = new Value();                    long outtime = outageSince.getOutage() / 1000;                    int hrs = (new Long(outtime / (60 * 60))).intValue();                    int remain = (new Long(outtime % (60 * 60))).intValue();                    int mins = remain / (60);                    remain = remain % (60);                    int secs = remain;                    log.debug("Outage : " + outtime + " in mins " + hrs + " hrs " + mins + " mins " + secs + " secs ");                    value.setContent(hrs + " hrs " + mins + " mins " + secs + " secs ");                    value.setType("data");                    Value datevalue = new Value();                    SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss");                    datevalue.setContent(fmt.format(new Date(outageSince.getOutTime())));                    datevalue.setType("other");                    Row row = new Row();                    row.addValue(nodeValue);                    row.addValue(value);                    row.addValue(datevalue);                    rows.addRow(row);                    if (top20Count >= 20) {                        break loop;                    }                }            }            Col col = new Col();            col.addColTitle(0, "Node Name");            col.addColTitle(1, "Duration Of Outage");            col.addColTitle(2, "Service Lost Time");			ClassicTable table = new ClassicTable();			table.setCol(col);			table.setRows(rows);			Section section = new Section();			section.setClassicTable(table);            section.setSectionName(label + " " + service);            section.setSectionTitle(label + " " + service);            section.setSectionDescr(descr + " " + service);            section.setSectionIndex(m_sectionIndex);            m_sectionIndex++;            catSections.addSection(section);        }    }    /**     * Last Month To Date Daily Availability     *      * @param days     *            Number of days for which the availability computations are     *            made.     * @param endTime     *            End time     * @param sections     *            Castors sections     * @param label     *            Section name in the xml     * @param descr     *            Section descr.     * @param sectionName     *            Section name.     */    private void lastMTDDailyAvailability(int days, long endTime, CatSections sections, String label, String descr, String sectionName) {        lastNDaysDailyAvailability(days, endTime, sections, label, descr, sectionName);    }    /**     * Last Month To Date Daily Availability     *      * @param days     *            Number of days for which the availability computations are     *            made.     * @param endTime     *            End time     * @param sections     *            Castors sections     * @param label     *            Section name in the xml     * @param descr     *            Section descr.     * @param sectionName     *            Section name.     */    private void lastCalMTDDailyAvailability(int days, long endTime, CatSections sections, String label, String descr, String sectionName) {        lastNDaysCalDailyAvailability(days, endTime, sections, label, descr, sectionName);    }    /**     * Last N Days Total Availability.     *      * @param days     *            Number of days for which the availability computations are     *            made.     * @param endTime     *            End time     * @param catSections     *            Castors sections     * @param label     *            Section name in the xml     * @param descr     *            Section descr.     */    private void lastMoTotalAvailability(int days, long endTime, CatSections catSections, String label, String descr) {        lastNDaysTotalAvailability(days, endTime, catSections, label, descr);    }		    /**     *      * Last Months Top N offenders.     *      * @param offenders     *            Top Offenders     * @param catSections     *            Castors sections     * @param label     *            Section name in the xml     * @param descr     *            Section descr.     *      */    private void lastMoTopNOffenders(TreeMap offenders, CatSections catSections, String label, String descr) {        // copy this method from the outage data code.        //        ThreadCategory.setPrefix(LOG4J_CATEGORY);        org.apache.log4j.Category log = ThreadCategory.getInstance(this.getClass());        if (log.isDebugEnabled()) {            log.debug("Offenders " + offenders);            log.debug("Inside lastMoTopNOffenders");        }        Set percentValues = offenders.keySet();        Iterator iter = percentValues.iterator();        Rows rows = new Rows();        int top20Count = 0;        loop: while (iter.hasNext()) {            Double percent = (Double) iter.next();            if (percent.doubleValue() < 100.0) {                List nodes = (List) offenders.get(percent);                if (nodes != null) {                    ListIterator lstIter = nodes.listIterator();                    while (lstIter.hasNext()) {                        top20Count++;                        String nodeName = (String) lstIter.next();                        Value dateValue = new Value();                        dateValue.setContent(nodeName);                        dateValue.setType("title");                        Value value = new Value();

⌨️ 快捷键说明

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