List of usage examples for java.util Hashtable keySet
Set keySet
To view the source code for java.util Hashtable keySet.
Click Source Link
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_monthhostall(String filename) { if (impReport.getTable() == null) { fileName = null;/*from ww w . j a v a 2 s . c o m*/ return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("equipname"); WritableSheet sheet = wb.createSheet(hostname + "", sheetNum); sheetNum = sheetNum + 1; Hashtable CPU = (Hashtable) report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); Calendar colTime = Calendar.getInstance(); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) report_has.get("Memory"); Hashtable Disk = (Hashtable) report_has.get("Disk"); Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) report_has.get("memavghash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "" }; String[] memoryItem = { "Capability" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); String reporttime = (String) report_has.get("reporttime"); if (reporttime == null || reporttime.trim().length() == 0) { tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); } else { tmpLabel = new Label(0, 1, ":" + reporttime); } sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ":" + sdf.format(cc)); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ping_month" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "CPU", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", _labelFormat); sheet.addCell(tmpLabel); if (CPU == null) { tmpLabel = new Label(1, 15, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15, "", p_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(1, 15, (String) CPU.get("cpumax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15, (String) CPU.get("avgcpu"), p_labelFormat); sheet.addCell(tmpLabel); } int allRow = 15; // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu_month" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); allRow = allRow + 6; int memoryRow = 0; if (Memory != null && Memory.size() > 0) { memoryRow = Memory.size(); allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // allRow = allRow; Label label = new Label(1, allRow, "", _labelFormat); sheet.addCell(label); for (int i = 0; i < memoryItemch.length; i++) { label = new Label(i + 2, allRow, memoryItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < Memory.size(); i++) { Hashtable mhash = (Hashtable) (Memory.get(new Integer(i))); String name = (String) mhash.get("name"); allRow = allRow + 1; label = new Label(1, allRow, name); sheet.addCell(label); for (int j = 0; j < memoryItem.length; j++) { String value = ""; if (mhash != null) { if (mhash.get(memoryItem[j]) != null) { value = (String) mhash.get(memoryItem[j]); } } label = new Label(j + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String value = ""; if (memMaxHash != null) { if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat); sheet.addCell(label); } } else { label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String avgvalue = ""; if (memAvgHash != null) { if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } } else { label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory_month" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); } if (Disk != null && Disk.size() > 0) { // memoryRow = Disk.size(); allRow = allRow + 1 + 7; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // allRow = allRow; Label label = new Label(1, allRow, "", _labelFormat); // CellFormat cf = new CellFormat(); // label.setCellFormat(cf) sheet.addCell(label); for (int i = 0; i < diskItemch.length; i++) { label = new Label(i + 2, allRow, diskItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < Disk.size(); i++) { Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); if (diskhash != null && diskhash.size() > 0) { String name = (String) diskhash.get("name"); if (name == null) name = ""; allRow = allRow + 1; label = new Label(1, allRow, name); sheet.addCell(label); for (int j = 0; j < diskItem.length; j++) { String value = ""; if (diskhash.get(diskItem[j]) != null) { value = (String) diskhash.get(diskItem[j]); } label = new Label(j + 2, allRow, value, p_labelFormat); sheet.addCell(label); } } } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "disk" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, allRow + 2, 9, 9, file)); /* * if(impReport.getChart()!=null){ ByteArrayOutputStream * baos = new ByteArrayOutputStream(); try { * ChartUtilities.writeChartAsPNG(baos, * impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); } * catch (IOException ioe){} WritableImage wi = new * WritableImage(2,40, 8, 12, baos.toByteArray()); * sheet.addImage(wi); } */ } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_networkall(String filename) { if (impReport.getTable() == null) { fileName = null;//from ww w . j a v a2s . c o m return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; CellView cv = new CellView(); cv.setAutosize(true); while (keys.hasNext()) { ip = keys.next().toString(); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("equipname"); WritableSheet sheet = wb.createSheet(hostname + "", sheetNum); // for (int i = 0; i < 8; i++) { // // // sheet.setColumnView(i, cv); // } sheetNum = sheetNum + 1; Hashtable CPU = (Hashtable) report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); String newip = doip(ip); Calendar colTime = Calendar.getInstance(); Date cc = colTime.getTime(); Vector netifVector = (Vector) report_has.get("netifVector"); int netiSize = 0; int iprouterSize = 0; if (netifVector != null) { netiSize = netifVector.size(); } Hashtable portconfigHash = (Hashtable) report_has.get("portconfigHash"); List reportports = (List) report_has.get("reportports"); Vector iprouterVector = (Vector) report_has.get("iprouterVector"); if (iprouterVector != null) { iprouterSize = iprouterVector.size(); } // Hashtable Memory = (Hashtable)report_has.get("Memory"); // Hashtable Disk = (Hashtable)report_has.get("Disk"); // String hostname = (String)report_has.get("equipname"); Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] netIfItemch = { "", "", "", "(M)", "", "", "" }; String[] ipRouterItemch = { "", "", "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize", "INodeUtilization" }; String[] diskItemch = { "", "", "", "i-node", "i-node" }; String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" }; String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" }; WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); labelFormat.setAlignment(Alignment.CENTRE); labelFormat.setBackground(Colour.GREY_25_PERCENT); labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); _labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // p_labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); WritableCellFormat p_labelFormat1 = new WritableCellFormat(); // p_labelFormat1.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setAlignment(Alignment.CENTRE); // b_labelFormat.setVerticalAlignment(VerticalAlignment.CENTRE); b_labelFormat.setBackground(jxl.format.Colour.GREY_25_PERCENT); b_labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); String reporttime = (String) report_has.get("reporttime"); if (reporttime == null || reporttime.trim().length() == 0) { tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); } else { tmpLabel = new Label(0, 1, ":" + reporttime); } sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ":" + sdf.format(cc)); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 4, 2, 4); sheet.mergeCells(3, 4, 4, 4); sheet.mergeCells(5, 4, 7, 4); sheet.mergeCells(1, 5, 2, 5); if (maxping != null) { tmpLabel = new Label(3, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, 5, 4, 5); sheet.mergeCells(5, 5, 7, 5); } // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "CPU", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 15, (String) CPU.get("cpu") + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15, (String) CPU.get("cpumax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 15, (String) CPU.get("avgcpu"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 14, 2, 14); sheet.mergeCells(3, 14, 4, 14); sheet.mergeCells(5, 14, 7, 14); sheet.mergeCells(1, 15, 2, 15); sheet.mergeCells(3, 15, 4, 15); sheet.mergeCells(5, 15, 7, 15); int allRow = 15; // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 1; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); allRow = allRow + 7; if (netifVector != null && netifVector.size() > 0) { allRow = allRow + 1; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // // allRow = allRow; for (int i = 0; i < netIfItemch.length; i++) { Label label = new Label(i + 1, allRow, netIfItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < netifVector.size(); i++) { allRow = allRow + 1; String[] strs = (String[]) netifVector.get(i); String ifname = strs[1]; String index = strs[0]; for (int j = 0; j < strs.length; j++) { if (j == 1) { String linkuse = ""; if (portconfigHash != null && portconfigHash.size() > 0) { if (portconfigHash.get(ip + ":" + index) != null) linkuse = (String) portconfigHash.get(ip + ":" + index); } Label label = new Label(j + 1, allRow, strs[j], i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(j + 2, allRow, linkuse, i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); } else if (j > 1) { Label label = new Label(j + 2, allRow, strs[j], i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); } else { Label label = new Label(j + 1, allRow, strs[j], i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); } } // end } } if (iprouterVector != null && iprouterVector.size() > 0) { allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // // allRow = allRow+1; for (int i = 0; i < ipRouterItemch.length; i++) { Label label = new Label(i + 1, allRow, ipRouterItemch[i], _labelFormat); sheet.addCell(label); if (i == ipRouterItemch.length - 1) { Label labeledn = new Label(i + 1, allRow, ipRouterItemch[i], _labelFormat); sheet.addCell(labeledn); } sheet.mergeCells(ipRouterItemch.length, allRow, ipRouterItemch.length + 1, allRow); } // for (int i = 0; i < iprouterVector.size(); i++) { allRow = allRow + 1; IpRouter iprouter = (IpRouter) iprouterVector.get(i); Label label = new Label(1, allRow, iprouter.getIfindex(), i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(2, allRow, iprouter.getDest(), i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(3, allRow, iprouter.getNexthop(), i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(4, allRow, iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")], i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(5, allRow, iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")], i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(6, allRow, iprouter.getMask(), i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); sheet.mergeCells(6, allRow, 7, allRow); } } allRow = allRow + 2; if (reportports != null && reportports.size() > 0) { // for (int i = 0; i < reportports.size(); i++) { com.afunms.config.model.Portconfig portconfig = (com.afunms.config.model.Portconfig) reportports .get(i); tmpLabel = new Label(0, allRow, "" + portconfig.getPortindex() + "(" + portconfig.getName() + ")", b_labelFormat); sheet.addCell(tmpLabel); if (portconfig.getLinkuse() == null) portconfig.setLinkuse(""); tmpLabel = new Label(1, allRow, ":" + portconfig.getLinkuse()); sheet.addCell(tmpLabel); // file = new File( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + portconfig.getPortindex() + "ifspeed_day.png"); // sheet,0,0,5,1,,, allRow = allRow + 1; sheet.addImage(new WritableImage(1, allRow, 8, 7, file)); allRow = allRow + 8; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } // sheet.mergeCells(0, 0, 7, 0); sheet.mergeCells(0, 1, 7, 1); sheet.mergeCells(0, 2, 7, 2); sheet.mergeCells(0, 4, 0, 12); sheet.mergeCells(0, 14, 0, 22); sheet.mergeCells(0, 24, 0, 24 + netiSize); sheet.mergeCells(0, 24 + netiSize + 1 + 1, 0, 24 + netiSize + 1 + 1 + iprouterSize); } wb.write(); } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_oraall2(String filename) { if (impReport.getTable() == null) { fileName = null;/* w w w .j av a2 s . com*/ return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreport_has = new Hashtable(); allreport_has = reportHash; if (allreport_has != null && allreport_has.size() > 0) { Iterator keys = allreport_has.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreport_has.get(ip); reportHash = report_has; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; String hostname = (String) reportHash.get("dbname"); // String ip = (String) reportHash.get("ip"); // String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; // ip this.dbTitlePing(sheet, ip, reportHash); int row = 18; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "10", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, buffercache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, dictionarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, librarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, pctmemorysorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pctbufgets, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, opencurstr, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row += 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, sysItemch2[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sysItemch2[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sysItemch2[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysItemch1[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sysItemch1[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, sysItemch1[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, sysItemch1[3], b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, memValue.get(sysItem2[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, memValue.get(sysItem2[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, memValue.get(sysItem2[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, memValue.get(sysItem1[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, memValue.get(sysItem1[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, memValue.get(sysItem1[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, memValue.get(sysItem1[3]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row += 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START1 tmpLabel = new Label(6, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END1 // HONGLI MODIFY START1 tmpLabel = new Label(10, row, "", b_labelFormat); // HONGLI MODIFY END1 sheet.addCell(tmpLabel); // row = row++; Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 for (int i = 0; i < tableinfo_v.size(); i++) { p_labelFormat = super.colorChange(i); Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 tmpLabel = new Label(0, row, String.valueOf(i + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, _filename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tablespace, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, percent, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START4 tmpLabel = new Label(6, row, pyr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pbr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, pyw, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, pbw, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END4 tmpLabel = new Label(10, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } // row++; this.addEventReport(sheet, report_has, row); row += 2; // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { SysLogger.error("", ioe); } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } sheetNum++; } wb.write(); } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @param filename//from w w w .j av a2 s . c om */ public void createReport_weblogicAll(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; Hashtable allreport_has = new Hashtable(); allreport_has = reportHash; wb = Workbook.createWorkbook(new File(fileName)); if (allreport_has != null && allreport_has.size() > 0) { Iterator keys = allreport_has.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreport_has.get(ip); reportHash = report_has; fileName = ResourceCenter.getInstance().getSysPath() + filename; String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); Weblogic weblogic = (Weblogic) reportHash.get("weblogic"); String weblogicnow = (String) reportHash.get("weblogicnow"); WritableSheet sheet = wb.createSheet(hostname + "", sheetNum); sheetNum++; Calendar colTime = (Calendar) reportHash.get("time"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 7, 0); sheet.mergeCells(0, 1, 7, 1); sheet.mergeCells(0, 2, 7, 2); sheet.mergeCells(0, 4, 0, 12); sheet.mergeCells(1, 4, 2, 4); sheet.mergeCells(3, 4, 4, 4); sheet.mergeCells(5, 4, 7, 4); tmpLabel = new Label(1, 5, weblogicnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 5, 2, 5); sheet.mergeCells(3, 5, 4, 5); sheet.mergeCells(5, 5, 7, 5); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "WeblogicPing" + ".png"); sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // Hashtable hash = (Hashtable) report_has.get("weblogicnmphash"); // Hashtable hash = null; // WeblogicSnmp weblogicsnmp = null; // WeblogicConfigDao weblogicconfigdao = new // WeblogicConfigDao(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic // .getPortnum()); // hash = weblogicsnmp.collectData(); List queuedatalist = new ArrayList(); tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 14, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(6, 14, 7, 14); if (hash != null) { queuedatalist = (List) hash.get("queueValue"); } sheet.mergeCells(0, 14, 0, 14 + queuedatalist.size()); int row = 0; for (int i = 0; i < queuedatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicQueue vo = (WeblogicQueue) queuedatalist.get(i); tmpLabel = new Label(1, 15 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15 + i, vo.getExecuteQueueRuntimeName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15 + i, vo.getThreadPoolRuntimeExecuteThreadIdleCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15 + i, vo.getExecuteQueueRuntimePendingRequestOldestTime(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 15 + i, vo.getExecuteQueueRuntimePendingRequestCurrentCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 15 + i, vo.getExecuteQueueRuntimePendingRequestTotalCount(), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(6, 15 + i, 7, 15 + i); row++; } // jdbc int row1 = 15 + row + 1; tmpLabel = new Label(0, row1, "JDBC", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row1, "", _labelFormat); sheet.addCell(tmpLabel); List jdbcdatalist = new ArrayList(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic // .getPortnum()); // hash = weblogicsnmp.collectData(); jdbcdatalist = (List) hash.get("jdbcValue"); sheet.mergeCells(0, row1, 0, row1 + jdbcdatalist.size()); int row2 = 0; for (int i = 0; i < jdbcdatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicJdbc vo = (WeblogicJdbc) jdbcdatalist.get(i); tmpLabel = new Label(1, row1 + 1 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row1 + 1 + i, vo.getJdbcConnectionPoolName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeActiveConnectionsCurrentCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeVersionJDBCDriver(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeMaxCapacity(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeActiveConnectionsAverageCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeHighestNumAvailable(), p_labelFormat); sheet.addCell(tmpLabel); row2++; } // jvm int row3 = row1 + 1 + row2 + 1; // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic // .getPortnum()); // hash = weblogicsnmp.collectData(); List heapdatalist = new ArrayList(); heapdatalist = (List) hash.get("heapValue"); tmpLabel = new Label(0, row3, "JVM", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row3, 0, row3 + heapdatalist.size()); tmpLabel = new Label(1, row3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row3, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(2, row3, 3, row3); sheet.mergeCells(4, row3, 5, row3); sheet.mergeCells(6, row3, 7, row3); int row4 = 0; for (int i = 0; i < heapdatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicHeap vo = (WeblogicHeap) heapdatalist.get(i); tmpLabel = new Label(1, row3 + 1 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row3 + 1 + i, vo.getJvmRuntimeName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row3 + 1 + i, vo.getJvmRuntimeHeapSizeCurrent(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row3 + 1 + i, vo.getJvmRuntimeHeapFreeCurrent(), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(2, row3 + 1 + i, 3, row3 + 1 + i); sheet.mergeCells(4, row3 + 1 + i, 5, row3 + 1 + i); sheet.mergeCells(6, row3 + 1 + i, 7, row3 + 1 + i); row4++; } int row5 = row3 + 1 + row4 + 1; tmpLabel = new Label(0, row5, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row5, "Socket", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row5, "IP", _labelFormat); sheet.addCell(tmpLabel); List serverdatalist = new ArrayList(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic // .getPortnum()); // hash = weblogicsnmp.collectData(); serverdatalist = (List) hash.get("serverValue"); sheet.mergeCells(0, row5, 0, row5 + serverdatalist.size()); for (int i = 0; i < serverdatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicServer vo = (WeblogicServer) serverdatalist.get(i); tmpLabel = new Label(1, row5 + 1 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row5 + 1 + i, vo.getServerRuntimeName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row5 + 1 + i, vo.getServerRuntimeListenAddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row5 + 1 + i, vo.getServerRuntimeListenPort(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row5 + 1 + i, vo.getServerRuntimeOpenSocketsCurrentCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row5 + 1 + i, vo.getServerRuntimeState(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row5 + 1 + i, weblogic.getIpAddress(), p_labelFormat); sheet.addCell(tmpLabel); } } } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_informixall(String filename) { if (impReport.getTable() == null) { fileName = null;/* www. ja v a 2s . c o m*/ return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) report_has.get("Ping"); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) report_has.get("dbValue"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.dbTitlePing(sheet, ip, report_has); int row = 18; Label tmpLabel = null; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; // ArrayList dbspaces = new ArrayList(); if (dbinfo != null) { dbspaces = (ArrayList) dbinfo.get("informixspaces");// } if (dbspaces != null) { if (dbspaces.size() > 0) { DecimalFormat df = new DecimalFormat("#.###"); for (int i = 0; i < dbspaces.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable tablesVO = (Hashtable) dbspaces.get(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("dbspace"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) tablesVO.get("owner"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, (String) tablesVO.get("fname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } } row = row + 2; // Informix tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; List dbsession = (ArrayList) dbinfo.get("sessionList");// if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable tablesVO = (Hashtable) dbsession.get(i); String seqscans = String.valueOf(tablesVO.get("seqscans")); if ("null".equals(seqscans)) { seqscans = ""; } String total_sorts = String.valueOf(tablesVO.get("total_sorts")); if ("null".equals(total_sorts)) { total_sorts = ""; } String dsksorts = String.valueOf(tablesVO.get("dsksorts")); if ("null".equals(dsksorts)) { dsksorts = ""; } tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) tablesVO.get("hostname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tablesVO.get("access") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tablesVO.get("locksheld") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, seqscans, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, total_sorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, dsksorts, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } row = row + 2; // Informix tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; List dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, (String) tablesVO.get("hostname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, tablesVO.get("dbsname") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, tablesVO.get("tabname") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, desc, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } row = row + 2; // Informix tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "ID ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; List dblog = (ArrayList) dbinfo.get("informixlog");// if (dblog != null && dblog.size() > 0) { for (int i = 0; i < dblog.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable tablesVO = (Hashtable) dblog.get(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, String.valueOf(tablesVO.get("uniqid")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, String.valueOf(tablesVO.get("size")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, String.valueOf(tablesVO.get("used")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, String.valueOf(tablesVO.get("is_used")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, String.valueOf(tablesVO.get("is_current")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, String.valueOf(tablesVO.get("is_backed_up")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, String.valueOf(tablesVO.get("is_archived")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, String.valueOf(tablesVO.get("is_temp")), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } row = row + 2; // InformixIO tmpLabel = new Label(0, row, "IO ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; List dbio = (ArrayList) dbinfo.get("iolist");// IO if (dbio != null && dbio.size() > 0) { for (int i = 0; i < dbio.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable tablesVO = (Hashtable) dbio.get(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, String.valueOf(tablesVO.get("chunknum")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, String.valueOf(tablesVO.get("reads")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, String.valueOf(tablesVO.get("pagesread")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, String.valueOf(tablesVO.get("writes")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, String.valueOf(tablesVO.get("pageswritten")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, String.valueOf(tablesVO.get("mreads")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, String.valueOf(tablesVO.get("mpagesread")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, String.valueOf(tablesVO.get("mwrites")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, String.valueOf(tablesVO.get("mpageswritten")), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; } } row = row + 2; // this.addEventReport(sheet, report_has, row); row += 2; // this.addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { SysLogger.error("", ioe); } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_syball2(String filename) { if (impReport.getTable() == null) { fileName = null;/*from ww w .j a v a2 s . c om*/ return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) report_has.get("Ping"); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); Hashtable mems = (Hashtable) report_has.get("mems");// Hashtable sysValue = (Hashtable) report_has.get("sysValue");// String typename = (String) report_has.get("typename"); String runstr = (String) report_has.get("runstr"); String grade = (String) report_has.get("grade"); String pingnow = (String) report_has.get("pingnow"); String pingmin = (String) report_has.get("pingmin"); String pingconavg = (String) report_has.get("pingconavg"); DBVo vo = (DBVo) report_has.get("vo"); Hashtable maxping = (Hashtable) report_has.get("ping"); SybaseVO sysbaseVO = (SybaseVO) report_has.get("sysbaseVO"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 9, 7, 7, file)); // allRow = allRow+7; int row = 15; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(%)", b_labelFormat); sheet.addCell(tmpLabel); row++; List dbInfo = (ArrayList) sysbaseVO.getDbInfo(); if (dbInfo != null && dbInfo.size() > 0) { for (int i = 0; i < dbInfo.size(); i++) { TablesVO tempSpace = (TablesVO) dbInfo.get(i); String db_name = (String) tempSpace.getDb_name(); String db_size = (String) tempSpace.getDb_size(); String db_freesize = (String) tempSpace.getDb_freesize(); String db_usedperc = (String) tempSpace.getDb_usedperc(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, db_size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, db_freesize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, db_usedperc, p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "(MB) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "Metadata(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "(MB) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(MB) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "(%)", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, sysbaseVO.getTotal_dataCache(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sysbaseVO.getTotal_physicalMemory(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sysbaseVO.getMetadata_cache(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysbaseVO.getProcedure_cache(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, sysbaseVO.getTotal_logicalMemory(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sysbaseVO.getData_hitrate(), p_labelFormat); sheet.addCell(tmpLabel); row++; // Sysbase tmpLabel = new Label(0, row, "Sysbase ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List serverlist = (List) sysbaseVO.getServersInfo(); if (serverlist != null && serverlist.size() > 0) { for (int k = 0; k < serverlist.size(); k++) { TablesVO tVO = (TablesVO) serverlist.get(k); tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tVO.getServer_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tVO.getServer_network_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tVO.getServer_class(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tVO.getServer_status(), p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // Sysbase tmpLabel = new Label(0, row, "Sysbase ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "id ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List userlist = (List) sysbaseVO.getUserInfo(); if (userlist != null && userlist.size() > 0) { for (int k = 0; k < userlist.size(); k++) { TablesVO tVO = (TablesVO) userlist.get(k); tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tVO.getUsers_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tVO.getID_in_db(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tVO.getGroup_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tVO.getLogin_name(), p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // Sysbase tmpLabel = new Label(0, row, "Sysbase ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List devicelist = (List) sysbaseVO.getDeviceInfo(); if (devicelist != null && devicelist.size() > 0) { for (int k = 0; k < devicelist.size(); k++) { TablesVO tVO = (TablesVO) devicelist.get(k); tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tVO.getDevice_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tVO.getDevice_physical_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tVO.getDevice_description(), p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, (String) report_has.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, report_has.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); // WritableCellFormat red_labelFormat = new WritableCellFormat(); WritableCellFormat orange_labelFormat = new WritableCellFormat(); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); row = row + 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); row++; int index = 0; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); List list = (ArrayList) report_has.get("list"); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { index++; EventList eventlist = (EventList) list.get(i); Date cc = eventlist.getRecordtime().getTime(); Integer eventid = eventlist.getId(); String eventlocation = eventlist.getEventlocation(); String content = eventlist.getContent(); String level = String.valueOf(eventlist.getLevel1()); String status = String.valueOf(eventlist.getManagesign()); String s = status; String showlevel = null; String act = ""; if ("1".equals(level)) { showlevel = ""; } else if ("2".equals(level)) { showlevel = ""; } else { showlevel = ""; } if ("0".equals(status)) { status = ""; } if ("1".equals(status)) { status = ""; } if ("2".equals(status)) { status = ""; } String rptman = eventlist.getReportman(); String rtime1 = _sdf.format(cc); tmpLabel = new Label(0, row, String.valueOf(index), p_labelFormat); sheet.addCell(tmpLabel); if ("3".equals(level)) { tmpLabel = new Label(1, row, showlevel, red_labelFormat); sheet.addCell(tmpLabel); } else if ("2".equals(level)) { tmpLabel = new Label(1, row, showlevel, orange_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(1, row, showlevel, yellow_labelFormat); sheet.addCell(tmpLabel); } tmpLabel = new Label(2, row, content, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rtime1, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, rptman, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_db2all2(String filename) { if (impReport.getTable() == null) { fileName = null;//from www. j a v a2 s . co m return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); reportHash = report_has; String hostname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) report_has.get("Ping"); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); Hashtable mems = (Hashtable) report_has.get("mems");// Hashtable sysValue = (Hashtable) report_has.get("sysValue");// String typename = (String) report_has.get("typename"); String runstr = (String) report_has.get("runstr"); String grade = (String) report_has.get("grade"); String pingnow = (String) report_has.get("pingnow"); String pingmin = (String) report_has.get("pingmin"); String pingconavg = (String) report_has.get("pingconavg"); DBVo vo = (DBVo) report_has.get("vo"); Hashtable conn = (Hashtable) report_has.get("conn");// if (conn == null) conn = new Hashtable(); Hashtable poolInfo = (Hashtable) report_has.get("poolInfo");// if (poolInfo == null) poolInfo = new Hashtable(); Hashtable log = (Hashtable) report_has.get("log");// if (log == null) log = new Hashtable(); Hashtable spaceInfo = (Hashtable) report_has.get("spaceInfo");// if (spaceInfo == null) spaceInfo = new Hashtable(); String[] sysDbStatus = { "", "", "", "" }; Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, // false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); // WritableCellFormat red_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); WritableCellFormat orange_labelFormat = new WritableCellFormat(); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); Label tmpLabel = null; // ip this.dbTitlePing(sheet, ip, report_has); // tmpLabel = new Label(0, 18, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 18, 10, 18); tmpLabel = new Label(0, 19, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 19, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 19, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 19, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 19, " %", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 19, 4, 19); sheet.mergeCells(5, 19, 6, 19); sheet.mergeCells(7, 19, 8, 19); sheet.mergeCells(9, 19, 10, 19); List toolsdb = (ArrayList) spaceInfo.get("toolsdb"); int row = 20; if (toolsdb != null && toolsdb.size() > 0) { for (int i = 0; i < toolsdb.size(); i++) { Hashtable tempSpace = new Hashtable(); tempSpace = (Hashtable) toolsdb.get(i); String tablespace_name = (String) tempSpace.get("tablespace_name"); String totalspac = (String) tempSpace.get("totalspac"); String usablespac = (String) tempSpace.get("usablespac"); String usableper = (String) tempSpace.get("usableper"); if (usableper == null || "0".equals(totalspac.trim())) { usableper = "100"; } p_labelFormat = this.colorChange(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tablespace_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, totalspac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, usablespac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, usableper, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } row++; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "SQL ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "SQL", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs = conn.keys(); Hashtable<String, Object> allhash = new Hashtable(); List poolList = new ArrayList(); while (dbs.hasMoreElements()) { String obj = (String) dbs.nextElement(); List connList = (List) conn.get(obj); for (int i = 0; i < connList.size(); i++) { Hashtable ht = (Hashtable) connList.get(i); String db_name = ht.get("db_name").toString(); String db_path = ht.get("db_path").toString(); String db_status = ht.get("db_status").toString(); String sqlm_elm_last_backup = ht.get("sqlm_elm_last_backup").toString(); String total_cons = ht.get("total_cons").toString(); String connections_top = ht.get("connections_top").toString(); String appls_cur_cons = ht.get("appls_cur_cons").toString(); String failedsql = ht.get("failedsql").toString(); String commitsql = ht.get("commitsql").toString(); p_labelFormat = this.colorChange(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, db_path, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysDbStatus[Integer.parseInt(db_status)], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, sqlm_elm_last_backup, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, total_cons, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, connections_top, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, appls_cur_cons, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, failedsql, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, commitsql, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; } } // row++; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); row++; Enumeration dbs2 = poolInfo.keys(); Hashtable<String, Object> allhash2 = new Hashtable(); List poolList2 = new ArrayList(); while (dbs2.hasMoreElements()) { String obj = (String) dbs2.nextElement(); allhash = (Hashtable) poolInfo.get(obj); poolList = (List) allhash.get("poolValue"); List lockList = (List) allhash.get("lockValue"); List readList = (List) allhash.get("readValue"); List writeList = (List) allhash.get("writeValue"); for (int i = 0; i < poolList.size(); i++) { Hashtable ht = (Hashtable) poolList.get(i); String bp_name = ht.get("bp_name").toString(); String data_hit_ratio = ht.get("data_hit_ratio").toString(); String index_hit_ratio = ht.get("index_hit_ratio").toString(); String BP_hit_ratio = ht.get("BP_hit_ratio").toString(); String Async_read_pct = ht.get("Async_read_pct").toString(); String Direct_RW_Ratio = ht.get("Direct_RW_Ratio").toString(); p_labelFormat = this.colorChange(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, bp_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, data_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, index_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, BP_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, Async_read_pct, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, row, Direct_RW_Ratio, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); row++; } } // row++; tmpLabel = new Label(0, row, " ", labelFormat); sheet.mergeCells(0, row, 10, row); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs3 = poolInfo.keys(); Hashtable<String, Object> allhash3 = new Hashtable(); List poolList3 = new ArrayList(); while (dbs3.hasMoreElements()) { String obj = (String) dbs3.nextElement(); allhash3 = (Hashtable) poolInfo.get(obj); poolList3 = (List) allhash3.get("poolValue"); // System.out.println("poolList size === // "+poolList.size()); List lockList = (List) allhash3.get("lockValue"); List readList = (List) allhash3.get("readValue"); List writeList = (List) allhash3.get("writeValue"); for (int i = 0; i < lockList.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable ht = (Hashtable) lockList.get(i); String db_name = ht.get("db_name").toString(); String rows_read = ht.get("rows_read").toString(); String rows_selected = ht.get("rows_selected").toString(); String lock_waits = ht.get("lock_waits").toString(); String lock_wait_time = ht.get("lock_wait_time").toString(); String deadlocks = ht.get("deadlocks").toString(); String lock_escals = ht.get("lock_escals").toString(); String total_sorts = ht.get("total_sorts").toString(); String total_sort_time = ht.get("total_sort_time").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_selected, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, lock_waits, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, lock_wait_time, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, deadlocks, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, lock_escals, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, total_sorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, total_sort_time, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; } } // row++; tmpLabel = new Label(0, row, " ", labelFormat); sheet.mergeCells(0, row, 10, row); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "(%) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "/ ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs4 = log.keys(); Hashtable<String, Object> allhash4 = new Hashtable(); List poolList4 = new ArrayList(); int cc = 0; while (dbs4.hasMoreElements()) { String obj = (String) dbs4.nextElement(); List logList = (List) log.get(obj); p_labelFormat = this.colorChange(cc); cc++; for (int i = 0; i < logList.size(); i++) { Hashtable ht = (Hashtable) logList.get(i); String logused = ht.get("logused").toString(); String logspacefree = ht.get("logspacefree").toString(); String pctused = ht.get("pctused").toString(); String maxlogused = ht.get("maxlogused").toString(); String maxsecused = ht.get("maxsecused").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, obj, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, logused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, logspacefree, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, pctused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, maxlogused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, maxsecused, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } // 10 row++; tmpLabel = new Label(0, row, "10 ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs5 = poolInfo.keys(); Hashtable<String, Object> allhash5 = new Hashtable(); List poolList5 = new ArrayList(); String obj = null; Hashtable allhash6 = null; List lockList = null; List readList = null; List writeList = null; while (dbs5.hasMoreElements()) { obj = (String) dbs5.nextElement(); allhash6 = (Hashtable) poolInfo.get(obj); poolList = (List) allhash6.get("poolValue"); // System.out.println("poolList size === // "+poolList.size()); lockList = (List) allhash6.get("lockValue"); readList = (List) allhash6.get("readValue"); writeList = (List) allhash6.get("writeValue"); } if (readList != null && readList.size() > 0) { for (int i = 0; i < readList.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable ht = (Hashtable) readList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tbschema, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, rows_written, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, overflow_accesses, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, page_reorgs, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } // 10 row++; tmpLabel = new Label(0, row, "10 ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; if (writeList != null && writeList.size() > 0) { for (int i = 0; i < writeList.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable ht = (Hashtable) writeList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tbschema, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, rows_written, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, overflow_accesses, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, page_reorgs, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } // row++; this.addEventReport(sheet, report_has, row); row += 2; // this.addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } } wb.write(); } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * mysql xls/*from w w w. j av a 2s . c o m*/ * * @param filename */ public void createReport_mysqlall(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) report_has.get("Ping"); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); String typename = (String) report_has.get("typename"); String runstr = (String) report_has.get("runstr"); String grade = (String) report_has.get("grade"); String pingnow = (String) report_has.get("pingnow"); String pingmin = (String) report_has.get("pingmin"); String pingconavg = (String) report_has.get("pingconavg"); DBVo vo = (DBVo) report_has.get("vo"); Vector val = (Vector) report_has.get("Val"); if (val == null) { val = new Vector(); } List sessionlist = (ArrayList) report_has.get("sessionlist"); if (sessionlist == null) { sessionlist = new ArrayList(); } Hashtable tablesHash = (Hashtable) report_has.get("tablesHash"); if (tablesHash == null) { tablesHash = new Hashtable(); } Vector tableinfo_v = (Vector) report_has.get("tableinfo_v"); if (tableinfo_v == null) { tableinfo_v = new Vector(); } Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, // false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 6, 0); sheet.mergeCells(0, 1, 6, 1); sheet.mergeCells(0, 2, 6, 2); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, 4, 4, 4); sheet.mergeCells(5, 4, 6, 4); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, 5, 4, 5); sheet.mergeCells(5, 5, 6, 5); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 7, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 7, 1, 7); sheet.mergeCells(2, 7, 4, 7); sheet.mergeCells(5, 7, 6, 7); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 8, 1, 8); sheet.mergeCells(2, 8, 4, 8); sheet.mergeCells(5, 8, 6, 8); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(0, 9, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 18, " ", b_labelFormat); sheet.mergeCells(0, 18, 6, 18); sheet.addCell(tmpLabel); int row = 19; if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_first")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_key")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_next")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_prev")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_rnd")) { name = "H"; } if (name.equalsIgnoreCase("Handler_read_rnd_next")) { name = ""; } if (name.equalsIgnoreCase("Open_tables")) { name = ""; } if (name.equalsIgnoreCase("Opened_tables")) { name = ""; } if (name.equalsIgnoreCase("Threads_cached")) { name = ""; } if (name.equalsIgnoreCase("Threads_connected")) { name = ""; } if (name.equalsIgnoreCase("Threads_created")) { name = ""; } if (name.equalsIgnoreCase("Threads_running")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_immediate")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_waited")) { name = ""; } if (name.equalsIgnoreCase("Key_read_requests")) { name = ""; } if (name.equalsIgnoreCase("Key_reads")) { name = ""; } if (name.equalsIgnoreCase("log_slow_queries")) { name = ""; } if (name.equalsIgnoreCase("slow_launch_time")) { name = "Slow_launch_threads"; } p_labelFormat = super.colorChange(i); tmpLabel = new Label(0, row, name, p_labelFormat); sheet.mergeCells(0, row, 4, row); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, value, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(5, row, 6, row); row++; } } } // row = row + 2; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 6, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.mergeCells(3, row, 4, row); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; if (sessionlist != null && sessionlist.size() > 0) { for (int i = 0; i < sessionlist.size(); i++) { List ipsessionlist = (List) sessionlist.get(i); if (ipsessionlist != null && ipsessionlist.size() > 0) { for (int k = 0; k < ipsessionlist.size(); k++) { String[] sessions = (String[]) ipsessionlist.get(k); if (sessions != null && sessions.length == 5) { p_labelFormat = super.colorChange(k); tmpLabel = new Label(0, row, String.valueOf(k + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sessions[4], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sessions[0], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sessions[1], p_labelFormat); sheet.mergeCells(3, row, 4, row); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sessions[2], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, sessions[3], p_labelFormat); sheet.addCell(tmpLabel); row++; } } } } } // row = row + 2; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 6, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.mergeCells(1, row, 2, row); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.mergeCells(5, row, 6, row); sheet.addCell(tmpLabel); row++; String[] dbs = vo.getDbName().split(","); if (dbs != null && dbs.length > 0) { for (int i = 0; i < dbs.length; i++) { String dbStr = dbs[i]; // System.out.println(dbStr+"====="+tablesHash.size()); if (tablesHash.containsKey(dbStr)) { List tableslist = (List) tablesHash.get(dbStr); if (tableslist != null && tableslist.size() > 0) { for (int k = 0; k < tableslist.size(); k++) { String[] tables = (String[]) tableslist.get(k); if (tables != null && tables.length == 4) { p_labelFormat = super.colorChange(k); tmpLabel = new Label(0, row, String.valueOf(k + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tables[0], p_labelFormat); sheet.mergeCells(1, row, 2, row); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tables[1], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tables[2], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, tables[3], p_labelFormat); sheet.mergeCells(5, row, 6, row); sheet.addCell(tmpLabel); row++; } } } } } } // row = row + 2; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(0, row, 6, row); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.mergeCells(1, row, 3, row); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.mergeCells(4, row, 6, row); sheet.addCell(tmpLabel); row++; if (tableinfo_v != null) {// HONGLILI for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String size = ht.get("variable_name").toString(); String free = ht.get("value").toString(); if (size.equalsIgnoreCase("auto_increment_increment")) { size = ""; } if (size.equalsIgnoreCase("auto_increment_offset")) { size = "AUTO_INCREMENT"; } if (size.equalsIgnoreCase("automatic_sp_privileges")) { size = "automatic_sp_privileges"; } if (size.equalsIgnoreCase("back_log")) { size = ""; } if (size.equalsIgnoreCase("basedir")) { size = "MySQL"; } if (size.equalsIgnoreCase("binlog_cache_size")) { size = "SQL"; } if (size.equalsIgnoreCase("bulk_insert_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("character_set_client")) { size = ""; } if (size.equalsIgnoreCase("character_set_connection")) { size = ""; } if (size.equalsIgnoreCase("character_set_database")) { size = ""; } if (size.equalsIgnoreCase("character_set_filesystem")) { size = "character_set_filesystem"; } if (size.equalsIgnoreCase("character_set_results")) { size = ""; } if (size.equalsIgnoreCase("character_set_server")) { size = ""; } if (size.equalsIgnoreCase("character_set_system")) { size = ""; } if (size.equalsIgnoreCase("character_sets_dir")) { size = ""; } if (size.equalsIgnoreCase("collation_connection")) { size = ""; } if (size.equalsIgnoreCase("collation_database")) { size = ""; } if (size.equalsIgnoreCase("collation_server")) { size = ""; } if (size.equalsIgnoreCase("completion_type")) { size = ""; } if (size.equalsIgnoreCase("concurrent_insert")) { size = ""; } if (size.equalsIgnoreCase("connect_timeout")) { size = "Bad handshake"; } if (size.equalsIgnoreCase("datadir")) { size = "MySQL"; } if (size.equalsIgnoreCase("date_format")) { size = "date_format()"; } if (size.equalsIgnoreCase("datetime_format")) { size = "datetime_format()"; } if (size.equalsIgnoreCase("default_week_format")) { size = "WEEK() "; } if (size.equalsIgnoreCase("delay_key_write")) { size = "DELAY_KEY_WRITE"; } if (size.equalsIgnoreCase("delayed_insert_limit")) { size = "INSERT DELAYEDSELECT"; } if (size.equalsIgnoreCase("delayed_insert_timeout")) { size = "INSERT DELAYEDINSERT"; } if (size.equalsIgnoreCase("delayed_queue_size")) { size = "INSERT DELAYED"; } if (size.equalsIgnoreCase("div_precision_increment")) { size = "/"; } if (size.equalsIgnoreCase("engine_condition_pushdown")) { size = "NDB"; } if (size.equalsIgnoreCase("expire_logs_days")) { size = ""; } if (size.equalsIgnoreCase("flush")) { size = "flushmysqld"; } if (size.equalsIgnoreCase("flush_time")) { size = ""; } if (size.equalsIgnoreCase("ft_boolean_syntax")) { size = "IN BOOLEAN MODE"; } if (size.equalsIgnoreCase("ft_max_word_len")) { size = "FULLTEXT"; } if (size.equalsIgnoreCase("ft_min_word_len")) { size = "FULLTEXT"; } if (size.equalsIgnoreCase("ft_query_expansion_limit")) { size = "WITH QUERY EXPANSION"; } if (size.equalsIgnoreCase("ft_stopword_file")) { size = ""; } if (size.equalsIgnoreCase("group_concat_max_len")) { size = "GROUP_CONCAT()"; } if (size.equalsIgnoreCase("have_archive")) { size = "mysqldARCHIVE"; } if (size.equalsIgnoreCase("have_bdb")) { size = "mysqldBDB"; } if (size.equalsIgnoreCase("have_blackhole_engine")) { size = "mysqldBLACKHOLE"; } if (size.equalsIgnoreCase("have_compress")) { size = "zlib"; } if (size.equalsIgnoreCase("have_crypt")) { size = "crypt()"; } if (size.equalsIgnoreCase("have_csv")) { size = "mysqldARCHIVE"; } if (size.equalsIgnoreCase("have_example_engine")) { size = "mysqldEXAMPLE"; } if (size.equalsIgnoreCase("have_federated_engine")) { size = "mysqldFEDERATED"; } if (size.equalsIgnoreCase("have_geometry")) { size = ""; } if (size.equalsIgnoreCase("have_innodb")) { size = "mysqldInnoDB"; } if (size.equalsIgnoreCase("have_isam")) { size = ""; } if (size.equalsIgnoreCase("have_ndbcluster")) { size = "mysqldNDB CLUSTER"; } if (size.equalsIgnoreCase("have_openssl")) { size = "mysqld/SSL()"; } if (size.equalsIgnoreCase("have_query_cache")) { size = "mysqld"; } if (size.equalsIgnoreCase("have_raid")) { size = "mysqldRAID"; } if (size.equalsIgnoreCase("have_rtree_keys")) { size = "RTREE"; } if (size.equalsIgnoreCase("have_symlink")) { size = ""; } if (size.equalsIgnoreCase("init_connect")) { size = ""; } if (size.equalsIgnoreCase("init_file")) { size = "--init-file"; } if (size.equalsIgnoreCase("init_slave")) { size = "SQL"; } if (size.equalsIgnoreCase("innodb_additional_mem_pool_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_autoextend_increment")) { size = ""; } if (size.equalsIgnoreCase("innodb_buffer_pool_awe_mem_mb")) { size = "32WindowsAWE"; } if (size.equalsIgnoreCase("innodb_buffer_pool_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_checksums")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_commit_concurrency")) { size = "innodb_commit_concurrency"; } if (size.equalsIgnoreCase("innodb_concurrency_tickets")) { size = "innodb_concurrency_tickets"; } if (size.equalsIgnoreCase("innodb_data_file_path")) { size = ""; } if (size.equalsIgnoreCase("innodb_data_home_dir")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_doublewrite")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_fast_shutdown")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_file_io_threads")) { size = "InnoDBI/O"; } if (size.equalsIgnoreCase("innodb_file_per_table")) { size = "InnoDB.ibd"; } if (size.equalsIgnoreCase("innodb_flush_log_at_trx_commit")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_flush_method")) { size = "InnoDBfsync()"; } if (size.equalsIgnoreCase("innodb_force_recovery")) { size = ""; } if (size.equalsIgnoreCase("innodb_lock_wait_timeout")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_locks_unsafe_for_binlog")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_log_arch_dir")) { size = " "; } if (size.equalsIgnoreCase("innodb_log_archive")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_buffer_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_log_file_size")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_files_in_group")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_group_home_dir")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_max_dirty_pages_pct")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_max_purge_lag")) { size = "INSERT,UPDATEDELETE"; } if (size.equalsIgnoreCase("innodb_mirrored_log_groups")) { size = ""; } if (size.equalsIgnoreCase("innodb_open_files")) { size = "InnoDB.ibd"; } if (size.equalsIgnoreCase("innodb_support_xa")) { size = "InnoDBXA"; } if (size.equalsIgnoreCase("innodb_sync_spin_loops")) { size = "innodb_sync_spin_loops"; } if (size.equalsIgnoreCase("innodb_table_locks")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_thread_concurrency")) { size = "InnoDBInnoDB"; } if (size.equalsIgnoreCase("innodb_thread_sleep_delay")) { size = "InnoDBSHOW INNODB STATUS<datadir>/innodb_status"; } if (size.equalsIgnoreCase("interactive_timeout")) { size = ""; } if (size.equalsIgnoreCase("join_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("key_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("key_cache_age_threshold")) { size = "(sub-chain)(sub-chain)"; } if (size.equalsIgnoreCase("key_cache_block_size")) { size = ""; } if (size.equalsIgnoreCase("key_cache_division_limit")) { size = ""; } if (size.equalsIgnoreCase("language")) { size = ""; } if (size.equalsIgnoreCase("large_files_support")) { size = "mysqld"; } if (size.equalsIgnoreCase("large_page_size")) { size = "large_page_size"; } if (size.equalsIgnoreCase("large_pages")) { size = ""; } if (size.equalsIgnoreCase("license")) { size = ""; } if (size.equalsIgnoreCase("local_infile")) { size = "LOCALLOAD DATA INFILE"; } if (size.equalsIgnoreCase("log")) { size = ""; } if (size.equalsIgnoreCase("log_bin")) { size = ""; } if (size.equalsIgnoreCase("log_bin_trust_function_creators")) { size = ""; } if (size.equalsIgnoreCase("log_error")) { size = ""; } if (size.equalsIgnoreCase("log_slave_updates")) { size = ""; } if (size.equalsIgnoreCase("log_slow_queries")) { size = ""; } if (size.equalsIgnoreCase("log_warnings")) { size = ""; } if (size.equalsIgnoreCase("long_query_time")) { size = "Slow_queries"; } if (size.equalsIgnoreCase("low_priority_updates")) { size = "sqlSELECTLOCK TABLE READ"; } if (size.equalsIgnoreCase("lower_case_file_system")) { size = ""; } if (size.equalsIgnoreCase("lower_case_table_names")) { size = "1"; } if (size.equalsIgnoreCase("max_allowed_packet")) { size = "/"; } if (size.equalsIgnoreCase("max_binlog_cache_size")) { size = ""; } if (size.equalsIgnoreCase("max_binlog_size")) { size = ""; } if (size.equalsIgnoreCase("max_connect_errors")) { size = ""; } if (size.equalsIgnoreCase("max_connections")) { size = ""; } if (size.equalsIgnoreCase("max_delayed_threads")) { size = "INSERT DELAYED"; } if (size.equalsIgnoreCase("max_error_count")) { size = "SHOW ERRORSSHOW WARNINGS"; } if (size.equalsIgnoreCase("max_heap_table_size")) { size = "MEMORY (HEAP)"; } if (size.equalsIgnoreCase("max_insert_delayed_threads")) { size = "INSERT DELAYED(max_delayed_threads)"; } if (size.equalsIgnoreCase("max_join_size")) { size = "max_join_size"; } if (size.equalsIgnoreCase("max_length_for_sort_data")) { size = "filesort"; } if (size.equalsIgnoreCase("max_prepared_stmt_count")) { size = "max_prepared_stmt_count"; } if (size.equalsIgnoreCase("max_relay_log_size")) { size = ""; } if (size.equalsIgnoreCase("max_seeks_for_key")) { size = ""; } if (size.equalsIgnoreCase("max_sort_length")) { size = "BLOBTEXT"; } if (size.equalsIgnoreCase("max_sp_recursion_depth")) { size = "max_sp_recursion_depth"; } if (size.equalsIgnoreCase("max_tmp_tables")) { size = ""; } if (size.equalsIgnoreCase("max_user_connections")) { size = "MySQL"; } if (size.equalsIgnoreCase("max_write_lock_count")) { size = ""; } if (size.equalsIgnoreCase("multi_range_count")) { size = "multi_range_count"; } if (size.equalsIgnoreCase("myisam_data_pointer_size")) { size = ""; } if (size.equalsIgnoreCase("myisam_max_sort_file_size")) { size = "MyISAMMySQL"; } if (size.equalsIgnoreCase("myisam_recover_options")) { size = "myisam-recover"; } if (size.equalsIgnoreCase("myisam_repair_threads")) { size = "1Repair by sortingMyISAM"; } if (size.equalsIgnoreCase("myisam_sort_buffer_size")) { size = "REPAIR TABLECREATE INDEXALTER TABLEMyISAM"; } if (size.equalsIgnoreCase("myisam_stats_method")) { size = "MyISAMNULL"; } if (size.equalsIgnoreCase("named_pipe")) { size = ""; } if (size.equalsIgnoreCase("net_buffer_length")) { size = ""; } if (size.equalsIgnoreCase("net_read_timeout")) { size = ""; } if (size.equalsIgnoreCase("net_retry_count")) { size = ""; } if (size.equalsIgnoreCase("net_write_timeout")) { size = ""; } if (size.equalsIgnoreCase("new")) { size = "MySQL 4.04.1"; } if (size.equalsIgnoreCase("old_passwords")) { size = "MySQLpre-4.1-style"; } if (size.equalsIgnoreCase("open_files_limit")) { size = "mysqld"; } if (size.equalsIgnoreCase("optimizer_prune_level")) { size = " 0"; } if (size.equalsIgnoreCase("optimizer_search_depth")) { size = ""; } if (size.equalsIgnoreCase("pid_file")) { size = "ID (PID)"; } if (size.equalsIgnoreCase("prepared_stmt_count")) { size = "prepared_stmt_count"; } if (size.equalsIgnoreCase("port")) { size = "TCP/IP"; } if (size.equalsIgnoreCase("preload_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("protocol_version")) { size = "MySQL/"; } if (size.equalsIgnoreCase("query_alloc_block_size")) { size = ""; } if (size.equalsIgnoreCase("query_cache_limit")) { size = ""; } if (size.equalsIgnoreCase("query_cache_min_res_unit")) { size = "()"; } if (size.equalsIgnoreCase("query_cache_size")) { size = ""; } if (size.equalsIgnoreCase("query_cache_type")) { size = ""; } if (size.equalsIgnoreCase("query_cache_wlock_invalidate")) { size = "WRITE"; } if (size.equalsIgnoreCase("query_prealloc_size")) { size = ""; } if (size.equalsIgnoreCase("range_alloc_block_size")) { size = ""; } if (size.equalsIgnoreCase("read_buffer_size")) { size = "()"; } if (size.equalsIgnoreCase("read_only")) { size = "ON"; } if (size.equalsIgnoreCase("read_only")) { size = "ON"; } if (size.equalsIgnoreCase("relay_log_purge")) { size = ""; } if (size.equalsIgnoreCase("read_rnd_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("secure_auth")) { size = "--secure-authMySQL(4.1)"; } if (size.equalsIgnoreCase("shared_memory")) { size = "(Windows)"; } if (size.equalsIgnoreCase("shared_memory_base_name")) { size = "(Windows)"; } if (size.equalsIgnoreCase("server_id")) { size = ""; } if (size.equalsIgnoreCase("skip_external_locking")) { size = "mysqld"; } if (size.equalsIgnoreCase("skip_networking")) { size = "(TCP/IP)"; } if (size.equalsIgnoreCase("skip_show_database")) { size = "SHOW DATABASESSHOW DATABASES"; } if (size.equalsIgnoreCase("slave_compressed_protocol")) { size = "/"; } if (size.equalsIgnoreCase("slave_load_tmpdir")) { size = "LOAD DATA INFILE"; } if (size.equalsIgnoreCase("slave_net_timeout")) { size = "/"; } if (size.equalsIgnoreCase("slave_skip_errors")) { size = "()"; } if (size.equalsIgnoreCase("slave_transaction_retries")) { size = "SQLslave_transaction_retries"; } if (size.equalsIgnoreCase("slow_launch_time")) { size = "Slow_launch_threads"; } if (size.equalsIgnoreCase("sort_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("sql_mode")) { size = "SQL"; } if (size.equalsIgnoreCase("storage_engine")) { size = "table_typeisMySQL 5.1,storage_engine"; } if (size.equalsIgnoreCase("sync_binlog")) { size = "sync_binlog'thMySQL"; } if (size.equalsIgnoreCase("sync_frm")) { size = "1,.frm"; } if (size.equalsIgnoreCase("system_time_zone")) { size = ""; } if (size.equalsIgnoreCase("table_cache")) { size = ""; } if (size.equalsIgnoreCase("table_type")) { size = "()"; } if (size.equalsIgnoreCase("thread_cache_size")) { size = ""; } if (size.equalsIgnoreCase("thread_stack")) { size = ""; } if (size.equalsIgnoreCase("time_format")) { size = ""; } if (size.equalsIgnoreCase("time_zone")) { size = ""; } if (size.equalsIgnoreCase("tmp_table_size")) { size = "MySQLMyISAM"; } if (size.equalsIgnoreCase("tmpdir")) { size = ""; } if (size.equalsIgnoreCase("transaction_alloc_block_size")) { size = "()"; } if (size.equalsIgnoreCase("transaction_prealloc_size")) { size = "transaction_alloc_blocks"; } if (size.equalsIgnoreCase("tx_isolation")) { size = ""; } if (size.equalsIgnoreCase("updatable_views_with_limit")) { size = "LIMIT"; } if (size.equalsIgnoreCase("version")) { size = ""; } if (size.equalsIgnoreCase("version_bdb")) { size = "BDB"; } if (size.equalsIgnoreCase("version_comment")) { size = "configure--with-commentMySQL"; } if (size.equalsIgnoreCase("version_compile_machine")) { size = "MySQL"; } if (size.equalsIgnoreCase("version_compile_os")) { size = "MySQL"; } if (size.equalsIgnoreCase("wait_timeout")) { size = ""; } p_labelFormat = super.colorChange(i); tmpLabel = new Label(0, row, String.valueOf(i + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, size, p_labelFormat); sheet.mergeCells(1, row, 3, row); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, free, p_labelFormat); sheet.mergeCells(4, row, 6, row); sheet.addCell(tmpLabel); row++; } } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 6, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 2, row); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 6, row); row++; tmpLabel = new Label(0, row, (String) report_has.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 2, row); tmpLabel = new Label(3, row, report_has.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 6, row); // // WritableCellFormat red_labelFormat = new WritableCellFormat(); WritableCellFormat orange_labelFormat = new WritableCellFormat(); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); row = row + 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 6, row); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(2, row, 3, row); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, "", b_labelFormat); sheet.addCell(tmpLabel); row++; int index = 0; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); List list = (ArrayList) report_has.get("list"); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { p_labelFormat = super.colorChange(i); index++; EventList eventlist = (EventList) list.get(i); Date cc = eventlist.getRecordtime().getTime(); Integer eventid = eventlist.getId(); String eventlocation = eventlist.getEventlocation(); String content = eventlist.getContent(); String level = String.valueOf(eventlist.getLevel1()); String status = String.valueOf(eventlist.getManagesign()); String s = status; String showlevel = null; String act = ""; if ("1".equals(level)) { showlevel = ""; } else if ("2".equals(level)) { showlevel = ""; } else { showlevel = ""; } if ("0".equals(status)) { status = ""; } if ("1".equals(status)) { status = ""; } if ("2".equals(status)) { status = ""; } String rptman = eventlist.getReportman(); String rtime1 = _sdf.format(cc); tmpLabel = new Label(0, row, String.valueOf(index), p_labelFormat); sheet.addCell(tmpLabel); if ("3".equals(level)) { tmpLabel = new Label(1, row, showlevel, red_labelFormat); sheet.addCell(tmpLabel); } else if ("2".equals(level)) { tmpLabel = new Label(1, row, showlevel, orange_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(1, row, showlevel, yellow_labelFormat); sheet.addCell(tmpLabel); } tmpLabel = new Label(2, row, content, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(2, row, 3, row); tmpLabel = new Label(4, row, rtime1, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, rptman, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI DB2excel// w w w. ja va2 s .co m * @param filename * @throws DocumentException * @throws IOException */ public void createReport_DB2CldXls(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { wb = Workbook.createWorkbook(new File(filename)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable mems = (Hashtable) reportHash.get("mems");// Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); Hashtable conn = (Hashtable) reportHash.get("conn");// if (conn == null) conn = new Hashtable(); Hashtable poolInfo = (Hashtable) reportHash.get("poolInfo");// if (poolInfo == null) poolInfo = new Hashtable(); Hashtable log = (Hashtable) reportHash.get("log");// if (log == null) log = new Hashtable(); Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo");// if (spaceInfo == null) spaceInfo = new Hashtable(); String[] sysDbStatus = { "", "", "", "" }; Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); WritableCellFormat red_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); WritableCellFormat orange_labelFormat = new WritableCellFormat(); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 9, 7, 7, file)); // allRow = allRow+7; // tmpLabel = new Label(0, 16, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 17, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 17, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 17, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 17, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 17, " %", b_labelFormat); sheet.addCell(tmpLabel); int row = 18; Iterator iterator = spaceInfo.keySet().iterator(); while (iterator.hasNext()) { String dbName = (String) iterator.next(); List toolsdb = (ArrayList) spaceInfo.get(dbName); if (toolsdb != null && toolsdb.size() > 0) { for (int i = 0; i < toolsdb.size(); i++) { Hashtable tempSpace = new Hashtable(); tempSpace = (Hashtable) toolsdb.get(i); String tablespace_name = (String) tempSpace.get("tablespace_name"); String totalspac = (String) tempSpace.get("totalspac"); String usablespac = (String) tempSpace.get("usablespac"); String usableper = (String) tempSpace.get("usableper"); if (usableper == null || "0".equals(totalspac.trim())) { usableper = "100"; } tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tablespace_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, totalspac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, usablespac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, usableper, p_labelFormat); sheet.addCell(tmpLabel); row++; } } } row = row + 2; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "SQL ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "SQL", b_labelFormat); sheet.addCell(tmpLabel); row++; Enumeration dbs = conn.keys(); Hashtable<String, Object> allhash = new Hashtable(); List poolList = new ArrayList(); while (dbs.hasMoreElements()) { String obj = (String) dbs.nextElement(); List connList = (List) conn.get(obj); for (int i = 0; i < connList.size(); i++) { Hashtable ht = (Hashtable) connList.get(i); String db_name = ht.get("db_name").toString(); String db_path = ht.get("db_path").toString(); String db_status = ht.get("db_status").toString(); String sqlm_elm_last_backup = ht.get("sqlm_elm_last_backup").toString(); String total_cons = ht.get("total_cons").toString(); String connections_top = ht.get("connections_top").toString(); String appls_cur_cons = ht.get("appls_cur_cons").toString(); String failedsql = ht.get("failedsql").toString(); String commitsql = ht.get("commitsql").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, db_path, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysDbStatus[Integer.parseInt(db_status)], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, sqlm_elm_last_backup, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, total_cons, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, connections_top, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, appls_cur_cons, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, failedsql, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, commitsql, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; Enumeration dbs2 = poolInfo.keys(); Hashtable<String, Object> allhash2 = new Hashtable(); List poolList2 = new ArrayList(); while (dbs2.hasMoreElements()) { String obj = (String) dbs2.nextElement(); allhash = (Hashtable) poolInfo.get(obj); poolList = (List) allhash.get("poolValue"); List lockList = (List) allhash.get("lockValue"); List readList = (List) allhash.get("readValue"); List writeList = (List) allhash.get("writeValue"); for (int i = 0; i < poolList.size(); i++) { Hashtable ht = (Hashtable) poolList.get(i); String bp_name = ht.get("bp_name").toString(); String data_hit_ratio = ht.get("data_hit_ratio").toString(); String index_hit_ratio = ht.get("index_hit_ratio").toString(); String BP_hit_ratio = ht.get("BP_hit_ratio").toString(); String Async_read_pct = ht.get("Async_read_pct").toString(); String Direct_RW_Ratio = ht.get("Direct_RW_Ratio").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, bp_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, data_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, index_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, BP_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, Async_read_pct, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, Direct_RW_Ratio, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; Enumeration dbs3 = poolInfo.keys(); Hashtable<String, Object> allhash3 = new Hashtable(); List poolList3 = new ArrayList(); while (dbs3.hasMoreElements()) { String obj = (String) dbs3.nextElement(); allhash3 = (Hashtable) poolInfo.get(obj); poolList3 = (List) allhash3.get("poolValue"); // System.out.println("poolList size === "+poolList.size()); List lockList = (List) allhash3.get("lockValue"); List readList = (List) allhash3.get("readValue"); List writeList = (List) allhash3.get("writeValue"); for (int i = 0; i < lockList.size(); i++) { Hashtable ht = (Hashtable) lockList.get(i); String db_name = ht.get("db_name").toString(); String rows_read = ht.get("rows_read").toString(); String rows_selected = ht.get("rows_selected").toString(); String lock_waits = ht.get("lock_waits").toString(); String lock_wait_time = ht.get("lock_wait_time").toString(); String deadlocks = ht.get("deadlocks").toString(); String lock_escals = ht.get("lock_escals").toString(); String total_sorts = ht.get("total_sorts").toString(); String total_sort_time = ht.get("total_sort_time").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_selected, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, lock_waits, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, lock_wait_time, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, deadlocks, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, lock_escals, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, total_sorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, total_sort_time, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(%) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, "/ ", b_labelFormat); sheet.addCell(tmpLabel); row++; Enumeration dbs4 = log.keys(); Hashtable<String, Object> allhash4 = new Hashtable(); List poolList4 = new ArrayList(); while (dbs4.hasMoreElements()) { String obj = (String) dbs4.nextElement(); List logList = (List) log.get(obj); for (int i = 0; i < logList.size(); i++) { Hashtable ht = (Hashtable) logList.get(i); String logused = ht.get("logused").toString(); String logspacefree = ht.get("logspacefree").toString(); String pctused = ht.get("pctused").toString(); String maxlogused = ht.get("maxlogused").toString(); String maxsecused = ht.get("maxsecused").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, obj, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, logused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, logspacefree, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, pctused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, maxlogused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, maxsecused, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // 10 row = row + 2; tmpLabel = new Label(0, row, "10 ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; Enumeration dbs5 = poolInfo.keys(); Hashtable<String, Object> allhash5 = new Hashtable(); List poolList5 = new ArrayList(); String obj = null; Hashtable allhash6 = null; List lockList = null; List readList = null; List writeList = null; while (dbs5.hasMoreElements()) { obj = (String) dbs5.nextElement(); allhash6 = (Hashtable) poolInfo.get(obj); poolList = (List) allhash6.get("poolValue"); // System.out.println("poolList size === "+poolList.size()); lockList = (List) allhash6.get("lockValue"); readList = (List) allhash6.get("readValue"); writeList = (List) allhash6.get("writeValue"); } if (readList != null && readList.size() > 0) { for (int i = 0; i < readList.size(); i++) { Hashtable ht = (Hashtable) readList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tbschema, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, rows_written, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, overflow_accesses, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, page_reorgs, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // 10 row = row + 2; tmpLabel = new Label(0, row, "10 ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; if (writeList != null && writeList.size() > 0) { for (int i = 0; i < writeList.size(); i++) { Hashtable ht = (Hashtable) writeList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tbschema, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, rows_written, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, overflow_accesses, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, page_reorgs, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, (String) reportHash.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, reportHash.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_serviceworkchoce(String starttime, String totime, String file, String username, String positionname) throws DocumentException, IOException { Hashtable allreporthash = new Hashtable(); allreporthash = reportHash;//from ww w.j ava2 s.co m /* * String starttime = (String) reportHash.get("starttime"); String * totime = (String) reportHash.get("totime"); */ Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont1 = new Font(bfChinese, 14, Font.BOLD); Font titleFont = new Font(bfChinese, 14, Font.BOLD); // Font contextFont = new Font(bfChinese, 14, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); try { fileName = ResourceCenter.getInstance().getSysPath() + file; Table aTable = new Table(13); float[] widths = { 40f, 100f, 40f, 40f, 40f, 40f, 40f, 40f, 40f, 40f, 40f, 40f, 40f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont1)); cell.setColspan(13); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(""); cell = new Cell(new Phrase("" + starttime + "" + totime, contextFont)); cell.setColspan(12); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(username, contextFont)); cell.setColspan(4); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(positionname, contextFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setColspan(11); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setColspan(11); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(13); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); int netsize = 0; Hashtable netreporthash = (Hashtable) allreporthash.get("netreporthash"); if (netreporthash != null) { netsize = netreporthash.size(); } cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(3 + netsize); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("CPU(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("KB/S", titleFont)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); java.text.NumberFormat formatenet = java.text.NumberFormat.getNumberInstance(); formatenet.setMaximumFractionDigits(0);// if (netreporthash != null && netreporthash.size() > 0) { Iterator keys = netreporthash.keySet().iterator(); HostNode node = null; while (keys.hasNext()) { node = (HostNode) keys.next(); Hashtable report_has = (Hashtable) netreporthash.get(node); String hostname = (String) report_has.get("equipname"); // WritableSheet sheet = wb.createSheet(hostname+"", // sheetNum); Hashtable CPU = (Hashtable) report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); String ip = (String) report_has.get("ip"); Calendar colTime = Calendar.getInstance(); Date cc = colTime.getTime(); Vector netifVector = (Vector) report_has.get("netifVector"); Hashtable portconfigHash = (Hashtable) report_has.get("portconfigHash"); List reportports = (List) report_has.get("reportports"); Vector iprouterVector = (Vector) report_has.get("iprouterVector"); Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] netIfItemch = { "", "", "", "(M)", "", "", "" }; String[] ipRouterItemch = { "", "", "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize", "INodeUtilization" }; String[] diskItemch = { "", "", "", "i-node", "i-node" }; String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" }; String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" }; String avginput = (String) report_has.get("avginput"); String avgoutput = (String) report_has.get("avgoutput"); String maxinput = (String) report_has.get("maxinput"); String maxoutput = (String) report_has.get("maxoutput"); String level4 = (String) report_has.get("level4"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String string1 = ((String) maxping.get("pingmax")).replace("%", ""); String string2 = ((String) maxping.get("avgpingcon")).replace("%", ""); cell = new Cell(new Phrase(formatenet.format(Double.valueOf(string2)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatenet.format(Double.valueOf(string1)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); String string3 = avgcpu.replace("%", ""); String string4 = cpumax.replace("%", ""); cell = new Cell(new Phrase(formatenet.format(Double.valueOf(string3)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatenet.format(Double.valueOf(string4)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(""); aTable.addCell(cell); cell = new Cell(""); aTable.addCell(cell); cell = new Cell(new Phrase(avgoutput.replace(".0", ""), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(maxoutput.replace(".0", ""), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(avginput.replace(".0", ""), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(maxinput.replace(".0", ""), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(level4, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } // ===================================================================== Hashtable hostreporthash = (Hashtable) allreporthash.get("hostreporthash"); int hostsize = 0; if (hostreporthash != null) { hostsize = hostreporthash.size(); } cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2 + hostsize); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("CPU(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("KB/S", titleFont)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); java.text.NumberFormat formatehost = java.text.NumberFormat.getNumberInstance(); formatehost.setMaximumFractionDigits(0);// if (hostreporthash != null && hostreporthash.size() > 0) { Iterator keys = hostreporthash.keySet().iterator(); HostNode node = null; while (keys.hasNext()) { node = (HostNode) keys.next(); // String newip = doip(ip); Hashtable report_has = (Hashtable) hostreporthash.get(node); String hostname = (String) report_has.get("equipname"); Hashtable CPU = (Hashtable) report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); Calendar colTime = (Calendar) report_has.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) report_has.get("Memory"); Hashtable Disk = (Hashtable) report_has.get("Disk"); Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) report_has.get("memavghash"); Hashtable maxping = (Hashtable) report_has.get("ping"); String ip = (String) report_has.get("ip"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "c" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "Utilizationvalue" }; String[] diskItemch = { "", "", "" }; String level4 = (String) report_has.get("level4"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= String string7 = ((String) maxping.get("pingmax")).replace("%", ""); String string8 = ((String) maxping.get("avgpingcon")).replace("%", ""); // formate.format(Double.valueOf(string1)); // System.out.println(formate.format(Double.valueOf(string))+"@@@@@@@0000000000"); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string8)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string7)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); String string3 = avgcpu.replace("%", ""); String string4 = cpumax.replace("%", ""); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string3)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string4)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String avgvalue = "0.0%"; if (memAvgHash.get("PhysicalMemory") != null) { avgvalue = (String) memAvgHash.get("PhysicalMemory"); String string5 = avgvalue.replace("%", ""); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string5)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } else { String string5 = avgvalue.replace("%", ""); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string5)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } String value = "0.0%"; if (memMaxHash.get("PhysicalMemory") != null) { value = (String) memMaxHash.get("PhysicalMemory"); String string6 = value.replace("%", ""); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string6)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } else { String string6 = value.replace("%", ""); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string6)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } String value1 = "0"; String value2 = "100"; String name = ""; String name1 = ""; String Utilization = ""; String Utilization1 = ""; if (Disk != null && Disk.size() > 0) { for (int i = 0; i < Disk.size(); i++) { Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); if (diskhash.get(diskItem[3]) != null) { if (value1.compareTo((String) diskhash.get(diskItem[3])) < 0) { value1 = (String) diskhash.get(diskItem[3]); name = (String) diskhash.get("name"); Utilization = (String) diskhash.get(diskItem[2]); } } if (diskhash.get(diskItem[3]) != null) { if (value2.compareTo((String) diskhash.get(diskItem[3])) >= 0) { value2 = (String) diskhash.get(diskItem[3]); name1 = (String) diskhash.get("name"); Utilization1 = (String) diskhash.get(diskItem[2]); } } } cell = new Cell(name + " " + Utilization); cell.setColspan(2); aTable.addCell(cell); cell = new Cell(name1 + " " + Utilization1); cell.setColspan(2); aTable.addCell(cell); } else { cell = new Cell("---"); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell("---"); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase(level4, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } // =========================================================================== Hashtable dbreporthash = (Hashtable) allreporthash.get("dbreporthash"); int dbsize = 0; if (dbreporthash != null) { dbsize = dbreporthash.size(); } cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2 + dbsize); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } java.text.NumberFormat formatedb = java.text.NumberFormat.getNumberInstance(); formatedb.setMaximumFractionDigits(0);// if (dbreporthash != null && dbreporthash.size() > 0) { Iterator keys = dbreporthash.keySet().iterator(); DBVo node = null; while (keys.hasNext()) { // String newip = doip(ip); node = (DBVo) keys.next(); Hashtable report_has = (Hashtable) dbreporthash.get(node); Hashtable maxping = (Hashtable) report_has.get("maxping"); String string1 = ((String) maxping.get("pingmax")).replace("%", ""); String string2 = ((String) maxping.get("avgpingcon")).replace("%", ""); String ip = (String) report_has.get("ip"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String dbtype = (String) report_has.get("dbtype"); cell = new Cell(new Phrase(dbtype, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= cell = new Cell(new Phrase(formatedb.format(Double.valueOf(string2)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatedb.format(Double.valueOf(string1)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String maxspace = ""; String minspace = ""; if ((Integer) report_has.get("maxspace") != 0) { maxspace = (Integer) report_has.get("maxspace") + ""; } if ((Integer) report_has.get("mixspace") != 0) { minspace = (Integer) report_has.get("mixspace") + ""; } if (dbtype.equals("SQLServer") || dbtype.equals("Sybase") || dbtype.equals("Informix")) { maxspace = "---"; minspace = "---"; } cell = new Cell(new Phrase(maxspace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(minspace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } // =================================================================== Hashtable tomcatreporthash = (Hashtable) allreporthash.get("tomcatreporthash"); Hashtable iisreporthash = (Hashtable) allreporthash.get("iisreporthash"); Hashtable weblogicreporthash = (Hashtable) allreporthash.get("weblogicreporthash"); int tomcatsize = 0; if (tomcatreporthash != null) { tomcatsize = tomcatreporthash.size(); } int iissize = 0; if (iisreporthash != null) { iissize = iisreporthash.size(); } int weblogicsize = 0; if (weblogicreporthash != null) { weblogicsize = weblogicreporthash.size(); } cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2 + tomcatsize + iissize + weblogicsize); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 8; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 8; i++) { cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } // tomcat============================================================ java.text.NumberFormat formatetomcat = java.text.NumberFormat.getNumberInstance(); formatetomcat.setMaximumFractionDigits(0);// if (tomcatreporthash != null && tomcatreporthash.size() > 0) { Iterator keys = tomcatreporthash.keySet().iterator(); Node node = null; while (keys.hasNext()) { node = (Node) keys.next(); Hashtable report_has = (Hashtable) tomcatreporthash.get(node); Hashtable maxping = (Hashtable) report_has.get("maxping"); String string1 = ((String) maxping.get("pingmax")).replace("%", ""); String string2 = ((String) maxping.get("avgpingcon")).replace("%", ""); String ip = (String) report_has.get("ip"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String tomcattype = (String) report_has.get("TOMCAT"); cell = new Cell(new Phrase(tomcattype, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= cell = new Cell(new Phrase(formatetomcat.format(Double.valueOf(string2)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatetomcat.format(Double.valueOf(string1)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 8; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } // IIS============================================================================ java.text.NumberFormat formateiis = java.text.NumberFormat.getNumberInstance(); formateiis.setMaximumFractionDigits(0);// if (iisreporthash != null && iisreporthash.size() > 0) { Iterator keys = iisreporthash.keySet().iterator(); Node node = null; while (keys.hasNext()) { node = (Node) keys.next(); Hashtable report_has = (Hashtable) iisreporthash.get(node); Hashtable maxping = (Hashtable) report_has.get("maxping"); String string1 = ((String) maxping.get("pingmax")).replace("%", ""); String string2 = ((String) maxping.get("avgpingcon")).replace("%", ""); String ip = (String) report_has.get("ip"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String tomcattype = (String) report_has.get("IIS"); cell = new Cell(new Phrase(tomcattype, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= cell = new Cell(new Phrase(formateiis.format(Double.valueOf(string2)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formateiis.format(Double.valueOf(string1)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 8; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } // weblogic================================================================ java.text.NumberFormat formateweblogic = java.text.NumberFormat.getNumberInstance(); formateweblogic.setMaximumFractionDigits(0);// if (weblogicreporthash != null && weblogicreporthash.size() > 0) { Iterator keys = weblogicreporthash.keySet().iterator(); Node node = null; while (keys.hasNext()) { node = (Node) keys.next(); Hashtable report_has = (Hashtable) weblogicreporthash.get(node); Hashtable maxping = (Hashtable) report_has.get("maxping"); String string1 = ((String) maxping.get("pingmax")).replace("%", ""); String string2 = ((String) maxping.get("avgpingcon")).replace("%", ""); String ip = (String) report_has.get("ip"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String tomcattype = (String) report_has.get("WEBLOGIC"); cell = new Cell(new Phrase(tomcattype, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= cell = new Cell(new Phrase(formateweblogic.format(Double.valueOf(string2)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formateweblogic.format(Double.valueOf(string1)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 8; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } // ============================================================= cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("0", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("0", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("0", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("SSO", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("0", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } }