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

📄 reportdetailsbean.java

📁 report trafiic for java bean
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    // Fetch Target IP traffic IP Groups
    public Hashtable getDstTrafficIPGroup()
    {
        long times = System.currentTimeMillis() - 0x36ee80L;
        String dstQuery = "select IPGroups.IP_GROUP_ID, IPGroups.IP_GROUP_NAME, sum(OCTETS * 8), COLLECTION_TIME, IPGroups.IP_GROUP_SPEED from IPGroups, DstIf10Min where IP_GROUP_ID = DST_IF and IP_GROUP_STATE = 0 and DstIf10Min.COLLECTION_TIME >= '" + getUtil().getTimeStamp(times) + "' group by DstIf10Min.DST_IF order by null";
        nfLogger.finer("query in getDstTraffic is " + dstQuery);
        return DBQueryUtil.getInstance().getTrafficForInterfacesIP(dstQuery);
    }

    // Create Customing Reporting
    public Vector getCustomReport(long sTime, long eTime, Vector iI, String inOut, String logicOp,
            ArrayList crit, String getWhat, int count, boolean isIPGroup, boolean isOctets, int pageCount)
        throws NetFlowClientException
    {
        Vector retVect = getQuery().getCustomReportQuery(sTime, eTime, iI, inOut, logicOp, crit, count, isIPGroup, isOctets, pageCount);
        if(retVect != null && getWhat != null && getWhat.equalsIgnoreCase("dnsname"))
        {
            int colNos[] = {
                0, 1
            };
            retVect = getUtil().replaceIpWithDns(retVect, colNos);
        }
        return retVect;
    }

    // Create AS System Reporting
    public Vector getASReport(String iI, String inOut, String getWhat, int count, boolean isOctets, int pageCount, String groupBy)
        throws NetFlowClientException
    {
        Vector retVect = getQuery().getASReportQuery(iI, inOut, count, isOctets, pageCount, groupBy);
        if(retVect != null && getWhat != null && getWhat.equalsIgnoreCase("dnsname"))
        {
            int colNos[] = {
                0, 1
            };
            retVect = getUtil().replaceIpWithDns(retVect, colNos);
        }
        return retVect;
    }

    // Create TroubleShoot Details Reporting
    public Vector getTroubleShootReport(long sTime, long eTime, Vector iI, String inOut, String logicOp,
            ArrayList crit, String getWhat, int count, boolean isOctets, int pageCount, String groupBy, long tim, ArrayList crit1)
        throws NetFlowClientException
    {
        Vector retVect = getQuery().getTroubleShootQuery(sTime, eTime, iI, inOut, logicOp, crit, count, isOctets, pageCount, groupBy, tim, crit1);
        nfLogger.finer("Inside getTroubleShootReport");
        if(retVect != null && getWhat != null && getWhat.equalsIgnoreCase("dnsname"))
        {
            int colNos[] = {
                0, 1
            };
            retVect = getUtil().replaceIpWithDns(retVect, colNos);
        }
        return retVect;
    }

    //Create TroubleShoot Traffic graphics
    public Hashtable getTroubleShootGraph(long stTime, long edTime, Vector index, String logicOp, ArrayList crit,
            int count, boolean isOctets, int pageCount, String groupBy, long tim, HttpSession session,
            String graphOption, long speed, int threshold, long ptTime)
    {
        String graphLoc = "";
        long t_Value = 0L;
        TimeTableXYDataset dataset = new TimeTableXYDataset();
        Hashtable result = getQuery().getTroubleShootTraffic(stTime, edTime, index, logicOp, crit, count, isOctets, pageCount, groupBy, tim, dataset, graphOption, speed, threshold);
        String yAxis = (String)result.get("yaxis");
        Long thresholdValue = (Long)result.get("T_Value");
        if(thresholdValue != null)
            t_Value = thresholdValue.longValue();
        if(dataset != null)
        {
            DateAxis xAxis = new DateAxis("Time");
            graphLoc = generateGraphTimeSeries_troubleshoot(dataset, xAxis, yAxis, session, graphOption, stTime, edTime, t_Value, ptTime);
        }
        result.put("fileLoc", graphLoc);
        return result;
    }

    public String generatePieChartHandler(Vector vect, String dataKey, String title, HttpSession session)
    {
        DefaultPieDataset dp = new DefaultPieDataset();
        vect = getUtil().getPieVector(vect);
        for(int i = 0; i < vect.size(); i++)
        {
            Vector temp = (Vector)vect.get(i);
            dp.setValue((String)temp.get(1), ((Double)temp.get(0)).doubleValue());
        }

        pieDataMap.put(dataKey, dp);
        StandardPieItemLabelGenerator spg = new StandardPieItemLabelGenerator("{2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance());
        int pieSize[] = {
            260, 260
        };
        return generatePieChart(dp, "", spg, pieSize, session);
    }

    public String generatePieChartHandler(String dataKey, String title, String graphSize, HttpSession session)
    {
        if(pieDataMap == null || !pieDataMap.containsKey(dataKey))
            return null;
        DefaultPieDataset dp = (DefaultPieDataset)pieDataMap.get(dataKey);
        StandardPieItemLabelGenerator spg = new StandardPieItemLabelGenerator("{0}: ({1}, {2})", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance());
        int pieSize[] = {
            500, 500
        };
        if(graphSize != null && graphSize.equalsIgnoreCase("small"))
        {
            spg = new StandardPieItemLabelGenerator("{2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance());
            pieSize = (new int[] {
                260, 260
            });
            title = "";
        }
        return generatePieChart(dp, title, spg, pieSize, session);
    }

    public String generatePieChart(DefaultPieDataset dp, String title, StandardPieItemLabelGenerator spg, int pieSize[], HttpSession session)
    {
        long ttime = System.currentTimeMillis();
        int cols[][] = {
            {
                0, 255, 0
            }, {
                0, 0, 255
            }, {
                255, 0, 0
            }, {
                255, 255, 0
            }, {
                255, 0, 204
            }, {
                0, 51, 51
            }, {
                102, 0, 102
            }, {
                0, 102, 255
            }, {
                102, 51, 0
            }, {
                255, 153, 0
            }
        };
        JFreeChart chart = ChartFactory.createPieChart(null, dp, true, false, false);
        chart.setBackgroundPaint(new Color(239, 239, 239));
        if(pieSize[0] == 500)
        {
            chart.setBackgroundPaint(new Color(255, 255, 255));
            Font fnt = new Font("SansSerif", 1, 8);
            if(!title.equals(""))
            {
                TextTitle tTit = new TextTitle(title);
                HorizontalAlignment hria = null;
                tTit.setFont(fnt);
                tTit.setHorizontalAlignment(HorizontalAlignment.CENTER);
                chart.setTitle(tTit);
            }
        }
        PiePlot pp = (PiePlot)chart.getPlot();
        pp.setLabelGenerator(spg);
        pp.setNoDataMessage("No data available");
        int k = 0;
        if(dp.getItemCount() <= 10)
            k = dp.getItemCount();
        for(int i = 0; i < k; i++)
            pp.setSectionPaint(i, new Color(cols[i][0], cols[i][1], cols[i][2]));

        long currTime = System.currentTimeMillis();
        String filenamePrefix = "pieChart" + String.valueOf(currTime);
        ServletUtilities.setTempFilePrefix(filenamePrefix);
        String filePIEName = null;
        String filePDFName = null;
        String fileN = filenamePrefix + ".png";
        String tempFile = System.getProperty("java.io.tmpdir") + File.separator + filenamePrefix + ".png";
        try
        {
            ChartUtilities.saveChartAsPNG(new File(tempFile), chart, pieSize[0], pieSize[1], null);
            registerChartForDeletion(new File(tempFile), session);
            nfLogger.finer("PNG File Name After PNG Chart Generation  : " + tempFile);
            if(pieSize[0] == 500)
            {
                String saveAs = System.getProperty("java.io.tmpdir") + File.separator + filenamePrefix + ".pdf";
                saveChartAsPDF(new File(saveAs), chart, 440, 440, new DefaultFontMapper());
                registerChartForDeletion(new File(saveAs), session);
                nfLogger.finer("PNG File Name After PDF Chart Generation  : " + saveAs);
            }
        }
        catch(Exception ee)
        {
            nfLogger.severe("Error in generatePieChart Method   :  " + ee.getMessage());
            ee.printStackTrace();
        }
        return fileN;
    }

    protected static void registerChartForDeletion(File tempFile, HttpSession session)
    {
        if(session != null)
        {
            ChartDeleter chartDeleter = (ChartDeleter)session.getAttribute("JFreeChart_Deleter");
            if(chartDeleter == null)
            {
                chartDeleter = new ChartDeleter();
                session.setAttribute("JFreeChart_Deleter", chartDeleter);
            }
            chartDeleter.addChart(tempFile.getName());
        } else
        {
            nfLogger.finer("Session is null - chart will not be deleted");
        }
    }

    public static void saveChartAsPDF(File file, JFreeChart chart, int width, int height, FontMapper mapper)
        throws IOException
    {
        OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
        writeChartAsPDF(out, chart, width, height, mapper);
        out.close();
    }

    public static void writeChartAsPDF(OutputStream out, JFreeChart chart, int width, int height, FontMapper mapper)
        throws IOException
    {
        Rectangle pagesize = new Rectangle(width, height);
        Document document = new Document(pagesize, 50F, 50F, 50F, 50F);
        try
        {
            PdfWriter writer = PdfWriter.getInstance(document, out);
            document.addAuthor("JFreeChart");
            document.addSubject("Demonstration");
            document.open();
            PdfContentByte cb = writer.getDirectContent();
            PdfTemplate tp = cb.createTemplate(width, height);
            Graphics2D g2 = tp.createGraphics(width, height, mapper);
            Rectangle2D r2D = new java.awt.geom.Rectangle2D.Double(0.0D, 0.0D, width, height);
            chart.draw(g2, r2D);
            g2.dispose();
            cb.addTemplate(tp, 0.0F, 0.0F);
        }
        catch(DocumentException de)
        {
            System.err.println(de.getMessage());
        }
        document.close();
    }

    public Vector getDeviceList()
    {
        String query = "select SQL_CACHE RouterIP from NetFlowRouter";
        return DBQueryUtil.getInstance().executeQueryForSingleColumn(query);
    }

    public Vector getDeviceInfo(String deviceName)
    {
        String query = "select SQL_CACHE NetFlow_Router.ROUTER_ID, Snmp_Connection.COMMUNITY, Snmp_Connection.SNMP_PORT from NetFlow_Router, Router_Snmp_Map, Snmp_Connection where NetFlow_Router.ROUTER_ID = Router_Snmp_Map.ROUTER_ID and Router_Snmp_Map.SNMP_ID = Snmp_Connection.SNMP_ID";
        return DBQueryUtil.getInstance().executeQueryForSingleRow(query, 3);
    }

    public boolean updateNetFlowRouter(long rID, String routerIP, String sComm, int sPort, boolean su, String oid)
    {
        String query = "update NetFlow_Router, Router_Snmp_Map, Snmp_Connection set Snmp_Connection.COMMUNITY = '" + sComm + "', Snmp_Connection.SNMP_PORT = '" + sPort + "' where NetFlow_Router.ROUTER_ID = Router_Snmp_Map.ROUTER_ID and Router_Snmp_Map.SNMP_ID = Snmp_Connection.SNMP_ID and NetFlow_Router.ROUTER_ID = '" + rID + "'";
        DBQueryUtil.getInstance().executeUpdate(query);
        String selectQuery = "select INTERFACE_ID, INTERFACE_INDEX from NetFlow_Interface where ROUTER_ID = " + rID + " and (STATE = " + 0 + " OR STATE = " + 1 + ") order by INTERFACE_INDEX";
        Vector ress = DBQueryUtil.getInstance().getResult(selectQuery, 2);
        nfLogger.finer("query for updateNetFlowRouter is " + selectQuery);
        int size = ress.size();
        int idArr[] = new int[size];
        int indexArr[] = new int[size]

⌨️ 快捷键说明

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