mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-11-03 20:27:54 +00:00 
			
		
		
		
	kpi: Generate test-bed history web page.
Includes historical graphs for each data set, and links to test bed runs.
This commit is contained in:
		@@ -5,6 +5,7 @@ set ylabel "Data"
 | 
				
			|||||||
set xlabel "Test#"
 | 
					set xlabel "Test#"
 | 
				
			||||||
#set xdata time
 | 
					#set xdata time
 | 
				
			||||||
set grid
 | 
					set grid
 | 
				
			||||||
set key outside
 | 
					#set key outside
 | 
				
			||||||
plot filename using 1:2
 | 
					set key off
 | 
				
			||||||
 | 
					plot filename using 1:2 with lines
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										97
									
								
								gui/kpi.java
									
									
									
									
									
								
							
							
						
						
									
										97
									
								
								gui/kpi.java
									
									
									
									
									
								
							@@ -37,6 +37,7 @@ public class kpi {
 | 
				
			|||||||
   public static int SHORT_DESC_IDX = 8;
 | 
					   public static int SHORT_DESC_IDX = 8;
 | 
				
			||||||
   public static int NUMERIC_SCORE_IDX = 10;
 | 
					   public static int NUMERIC_SCORE_IDX = 10;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   public static String TESTBED_TEMPLATE = "testbed_template.html";
 | 
				
			||||||
   public static String AP_AUTO_BASIC_CX = "ap_auto_basic_cx";
 | 
					   public static String AP_AUTO_BASIC_CX = "ap_auto_basic_cx";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   public kpi() {
 | 
					   public kpi() {
 | 
				
			||||||
@@ -60,8 +61,13 @@ public class kpi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
   public static void main(String[] args) {
 | 
					   public static void main(String[] args) {
 | 
				
			||||||
      kpi k = new kpi();
 | 
					      kpi k = new kpi();
 | 
				
			||||||
 | 
					      try {
 | 
				
			||||||
         k.work(args);
 | 
					         k.work(args);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					      catch (Exception ee) {
 | 
				
			||||||
 | 
					         ee.printStackTrace();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   public void work(String[] args) {
 | 
					   public void work(String[] args) {
 | 
				
			||||||
      String dir = null;
 | 
					      String dir = null;
 | 
				
			||||||
@@ -161,6 +167,9 @@ public class kpi {
 | 
				
			|||||||
         }
 | 
					         }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      StringBuffer plots = new StringBuffer();
 | 
				
			||||||
 | 
					      StringBuffer runs_rows = new StringBuffer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // For all history, print out csv files
 | 
					      // For all history, print out csv files
 | 
				
			||||||
      v = new Vector(hist_data.keySet());
 | 
					      v = new Vector(hist_data.keySet());
 | 
				
			||||||
      for (Object hk : v) {
 | 
					      for (Object hk : v) {
 | 
				
			||||||
@@ -184,7 +193,22 @@ public class kpi {
 | 
				
			|||||||
               System.out.println(exec.getError());
 | 
					               System.out.println(exec.getError());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
               File png = new File("plot.png");
 | 
					               File png = new File("plot.png");
 | 
				
			||||||
               png.renameTo(new File(dir + File.separator + hk + "::" + ck + ".png"));
 | 
					               String npng = hk + "::" + ck + ".png";
 | 
				
			||||||
 | 
					               png.renameTo(new File(dir + File.separator + npng));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					               exec = new ShellExec(true, true);
 | 
				
			||||||
 | 
					               rv = exec.execute("gnuplot", null, true, "-e", "filename='" + cf + "'",
 | 
				
			||||||
 | 
					                                     "mini.plot");
 | 
				
			||||||
 | 
					               System.out.println("mini gnuplot for filename: " + cf + " rv: " + rv);
 | 
				
			||||||
 | 
					               System.out.println(exec.getOutput());
 | 
				
			||||||
 | 
					               System.out.println(exec.getError());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					               png = new File("plot.png");
 | 
				
			||||||
 | 
					               String npngt = hk + "::" + ck + "-thumb.png";
 | 
				
			||||||
 | 
					               png.renameTo(new File(dir + File.separator + npngt));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					               plots.append("<tr><td>" + hk + "</td><td>" + title + "</td><td><a href=\"" + npng + "\"><img src=\"" + npngt + "\"></a></td></tr>\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            catch (Exception ee) {
 | 
					            catch (Exception ee) {
 | 
				
			||||||
               ee.printStackTrace();
 | 
					               ee.printStackTrace();
 | 
				
			||||||
@@ -192,7 +216,56 @@ public class kpi {
 | 
				
			|||||||
         }
 | 
					         }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      boolean cp = true;
 | 
				
			||||||
 | 
					      for (int i = 0; i<runs.size(); i++) {
 | 
				
			||||||
 | 
					         Run run = runs.elementAt(i);
 | 
				
			||||||
 | 
					         runs_rows.append("<tr><td><a href=\"" + run.getName() + "/index.html\">" + run.getName() + "</a></td><td>" + run.getDate() + "</td></tr>\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         if (cp) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					               String fname;
 | 
				
			||||||
 | 
					               copy("CandelaLogo2-90dpi-200x90-trans.png", dir + File.separator + run.getName(), dir);
 | 
				
			||||||
 | 
					               copy("candela_swirl_small-72h.png", dir + File.separator + run.getName(), dir);
 | 
				
			||||||
 | 
					               copy("canvil.ico", dir + File.separator + run.getName(), dir);
 | 
				
			||||||
 | 
					               copy("custom.css", dir + File.separator + run.getName(), dir);
 | 
				
			||||||
 | 
					               copy("report.css", dir + File.separator + run.getName(), dir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					               cp = false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ee) {
 | 
				
			||||||
 | 
					               ee.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      try {
 | 
				
			||||||
 | 
					         // Read in the testbed_template.html and update it with our info
 | 
				
			||||||
 | 
					         BufferedReader br = new BufferedReader(new FileReader(new File(kpi.TESTBED_TEMPLATE)));
 | 
				
			||||||
 | 
					         String ofile = dir + File.separator + "index.html";
 | 
				
			||||||
 | 
					         BufferedWriter bw = new BufferedWriter(new FileWriter(ofile));
 | 
				
			||||||
 | 
					         String line;
 | 
				
			||||||
 | 
					         while ((line = br.readLine()) != null) {
 | 
				
			||||||
 | 
					            line = line.replace("___TITLE___", "Test-Bed Report History");
 | 
				
			||||||
 | 
					            line = line.replace("___DATA_GRAPHS___", plots.toString());
 | 
				
			||||||
 | 
					            line = line.replace("___TEST_RUNS___", runs_rows.toString());
 | 
				
			||||||
 | 
					            bw.write(line);
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
 | 
					         
 | 
				
			||||||
 | 
					         br.close();
 | 
				
			||||||
 | 
					         bw.close();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         System.out.println("See " + ofile);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      catch (Exception eee) {
 | 
				
			||||||
 | 
					         eee.printStackTrace();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
   } // ~work()
 | 
					   } // ~work()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   public void copy(String fname, String from, String to) throws Exception {
 | 
				
			||||||
 | 
					      Path fromp = Paths.get(from + File.separator + fname);
 | 
				
			||||||
 | 
					      Path top = Paths.get(to + File.separator + fname);
 | 
				
			||||||
 | 
					      Files.copy(fromp, top, StandardCopyOption.REPLACE_EXISTING);
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class History {
 | 
					class History {
 | 
				
			||||||
@@ -253,6 +326,7 @@ class Test {
 | 
				
			|||||||
   Vector<Row> data = new Vector();
 | 
					   Vector<Row> data = new Vector();
 | 
				
			||||||
   Hashtable<String, String> descs = new Hashtable();
 | 
					   Hashtable<String, String> descs = new Hashtable();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   public String date = "";
 | 
				
			||||||
   public String test_rig;
 | 
					   public String test_rig;
 | 
				
			||||||
   public String dut_hw_version;
 | 
					   public String dut_hw_version;
 | 
				
			||||||
   public String dut_sw_version;
 | 
					   public String dut_sw_version;
 | 
				
			||||||
@@ -263,6 +337,10 @@ class Test {
 | 
				
			|||||||
      name = n;
 | 
					      name = n;
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   String getDate() {
 | 
				
			||||||
 | 
					      return date;
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   String getName() {
 | 
					   String getName() {
 | 
				
			||||||
      return name;
 | 
					      return name;
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
@@ -308,7 +386,7 @@ class Test {
 | 
				
			|||||||
               last_was_sep = false;
 | 
					               last_was_sep = false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (data.size() == 1) { // first row is being added
 | 
					            if ((data.size() == 1) && !last_was_sep) { // first row is being added
 | 
				
			||||||
               if (titles.elementAt(idx - 1).equalsIgnoreCase("test-rig")) {
 | 
					               if (titles.elementAt(idx - 1).equalsIgnoreCase("test-rig")) {
 | 
				
			||||||
                  test_rig = rtok;
 | 
					                  test_rig = rtok;
 | 
				
			||||||
               }
 | 
					               }
 | 
				
			||||||
@@ -321,6 +399,10 @@ class Test {
 | 
				
			|||||||
               else if (titles.elementAt(idx - 1).equalsIgnoreCase("dut-model-num")) {
 | 
					               else if (titles.elementAt(idx - 1).equalsIgnoreCase("dut-model-num")) {
 | 
				
			||||||
                  dut_model_num = rtok;
 | 
					                  dut_model_num = rtok;
 | 
				
			||||||
               }
 | 
					               }
 | 
				
			||||||
 | 
					               else if (titles.elementAt(idx - 1).equalsIgnoreCase("Date")) {
 | 
				
			||||||
 | 
					                  System.out.println("idx: " + idx + " rtok: " + rtok);
 | 
				
			||||||
 | 
					                  date = new Date(Long.valueOf(rtok).longValue()).toString();
 | 
				
			||||||
 | 
					               }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            //System.out.println("idx: " + idx);
 | 
					            //System.out.println("idx: " + idx);
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
@@ -341,6 +423,17 @@ class Run {
 | 
				
			|||||||
      name = n;
 | 
					      name = n;
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   String getDate() {
 | 
				
			||||||
 | 
					      try {
 | 
				
			||||||
 | 
					         Test first = tests.elements().nextElement();
 | 
				
			||||||
 | 
					         return first.getDate();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      catch (Exception ee) {
 | 
				
			||||||
 | 
					         return "";
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   String getName() {
 | 
					   String getName() {
 | 
				
			||||||
      return name;
 | 
					      return name;
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										17
									
								
								gui/mini.plot
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								gui/mini.plot
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					set term pngcairo size 150,100
 | 
				
			||||||
 | 
					set output "plot.png"
 | 
				
			||||||
 | 
					set datafile separator "\t"
 | 
				
			||||||
 | 
					#set ylabel "Data"
 | 
				
			||||||
 | 
					#set xlabel "Test#"
 | 
				
			||||||
 | 
					set ylabel
 | 
				
			||||||
 | 
					set xlabel
 | 
				
			||||||
 | 
					#set xdata time
 | 
				
			||||||
 | 
					#set grid
 | 
				
			||||||
 | 
					#set key outside
 | 
				
			||||||
 | 
					set key off
 | 
				
			||||||
 | 
					unset xtics
 | 
				
			||||||
 | 
					unset ytics
 | 
				
			||||||
 | 
					unset border
 | 
				
			||||||
 | 
					set title
 | 
				
			||||||
 | 
					plot filename using 1:2 with lines
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										46
									
								
								gui/testbed_template.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								gui/testbed_template.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					<!DOCTYPE html>
 | 
				
			||||||
 | 
					<html>
 | 
				
			||||||
 | 
					  <head>
 | 
				
			||||||
 | 
					    <meta charset='utf-8' />
 | 
				
			||||||
 | 
					    <meta name='viewport' content='width=device-width, initial-scale=1' />
 | 
				
			||||||
 | 
					    <title>___TITLE___</title>    <link rel='shortcut icon' href='canvil.ico' type='image/x-icon' />
 | 
				
			||||||
 | 
					    <link rel='stylesheet' href='report.css' />
 | 
				
			||||||
 | 
					    <link rel='stylesheet' href='custom.css' />
 | 
				
			||||||
 | 
					    <style>
 | 
				
			||||||
 | 
					     pre {
 | 
				
			||||||
 | 
					        overflow: auto;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					     img {
 | 
				
			||||||
 | 
					        width: 100%;
 | 
				
			||||||
 | 
					        max-width: 8in;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					    </style>
 | 
				
			||||||
 | 
					  </head>
 | 
				
			||||||
 | 
					  <body>
 | 
				
			||||||
 | 
					<div class='HeaderStyle'>
 | 
				
			||||||
 | 
					<h1 class='TitleFontPrint'>___TITLE___</h1><br/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class='contentDiv'>
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					<br>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<h3>Historical graphs for each Data Set.</h3>
 | 
				
			||||||
 | 
					<table border="1" cellpadding="6" cellspacing="0" style="border-top-color: gray; border-top-style: solid; border-top-width: 1px; border-right-color: gray; border-right-style: solid; border-right-width: 1px; border-bottom-color: gray; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: gray; border-left-style: solid; border-left-width: 1px">
 | 
				
			||||||
 | 
					  <!-- <tr><td>Test-ID</td><td>Short-Desc</td><td>Image</td></tr> -->
 | 
				
			||||||
 | 
					  <tr><th>Test-Id</th><th>Description</th><th>Plot Thumbnail</th></tr>
 | 
				
			||||||
 | 
					  ___DATA_GRAPHS___
 | 
				
			||||||
 | 
					</table>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<h3>Individual Test Run Details.</h3>
 | 
				
			||||||
 | 
					<table border="1" cellpadding="6" cellspacing="0" style="border-top-color: gray; border-top-style: solid; border-top-width: 1px; border-right-color: gray; border-right-style: solid; border-right-width: 1px; border-bottom-color: gray; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: gray; border-left-style: solid; border-left-width: 1px">
 | 
				
			||||||
 | 
					  <tr><th>Test Run</th><th>Date</th></tr>
 | 
				
			||||||
 | 
					  ___TEST_RUNS___
 | 
				
			||||||
 | 
					</table>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</div><!--end content-div -->
 | 
				
			||||||
 | 
					<div class='FooterStyle'><span class='Gradient'>Generated by Candela Technologies LANforge network testing tool.<br/>
 | 
				
			||||||
 | 
					  <a href='https://www.candelatech.com/' target='_blank'>www.candelatech.com</a>
 | 
				
			||||||
 | 
					</span>
 | 
				
			||||||
 | 
					<a class='LogoImgLink' href='https://www.candelatech.com/' target='_blank'><img align='right' src='candela_swirl_small-72h.png'></a></div><br/>
 | 
				
			||||||
 | 
					  </body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user