1 24 25 package edu.rice.rubis.client; 26 27 import java.io.BufferedReader ; 28 import java.io.File ; 29 import java.io.FileNotFoundException ; 30 import java.io.FileOutputStream ; 31 import java.io.IOException ; 32 import java.io.InputStreamReader ; 33 import java.io.PrintStream ; 34 import java.util.GregorianCalendar ; 35 36 import edu.rice.rubis.beans.TimeManagement; 37 import edu.rice.rubis.client.RUBiSProperties; 38 import edu.rice.rubis.client.Stats; 39 import edu.rice.rubis.client.TransitionTable; 40 import edu.rice.rubis.client.URLGenerator; 41 import edu.rice.rubis.client.UserSession; 42 43 51 public class ClientEmulator 52 { 53 private RUBiSProperties rubis = null; private URLGenerator urlGen = null; 55 private static float slowdownFactor = 0; 57 private static boolean endOfSimulation = false; 58 59 63 public ClientEmulator(String propertiesFileName) 64 { 65 rubis = new RUBiSProperties(propertiesFileName); 67 urlGen = rubis.checkPropertiesFileAndGetURLGenerator(); 68 if (urlGen == null) 69 Runtime.getRuntime().exit(1); 70 TransitionTable transition = 72 new TransitionTable( 73 rubis.getNbOfColumns(), 74 rubis.getNbOfRows(), 75 null, 76 rubis.useTPCWThinkTime()); 77 if (!transition.ReadExcelTextFile(rubis.getTransitionTable())) 78 Runtime.getRuntime().exit(1); 79 else 80 transition.displayMatrix(); 81 } 82 83 88 private synchronized void setSlowDownFactor(float newValue) 89 { 90 slowdownFactor = newValue; 91 } 92 93 98 public static synchronized float getSlowDownFactor() 99 { 100 return slowdownFactor; 101 } 102 103 106 private synchronized void setEndOfSimulation() 107 { 108 endOfSimulation = true; 109 } 110 111 115 public static synchronized boolean isEndOfSimulation() 116 { 117 return endOfSimulation; 118 } 119 120 129 private void getMonitoredData(String node, String fileName, 130 String outputDir) 131 { 132 String [] scpCmd = new String [3]; 133 String lastName = fileName.substring(fileName.lastIndexOf('/')+1); 134 135 scpCmd[0] = rubis.getMonitoringScp(); 136 scpCmd[1] = node + ":"+fileName; 137 scpCmd[2] = outputDir+"/" + lastName + ".bin"; 139 140 try 141 { 142 System.out.println( 143 "    Command is: " 144 + scpCmd[0] 145 + " " 146 + scpCmd[1] 147 + " " 148 + scpCmd[2] 149 + "<br>\n"); 150 151 Process p = Runtime.getRuntime().exec(scpCmd); 152 p.waitFor(); 153 int fullTimeInSec = 155 (rubis.getUpRampTime() 156 + rubis.getSessionTime() 157 + rubis.getDownRampTime()) 158 / 1000 159 + 5; 160 String [] convCmd = new String [6]; 161 convCmd[0] = rubis.getMonitoringRsh(); 162 convCmd[1] = "-x"; 163 convCmd[2] = "localhost"; 164 convCmd[3] = "/bin/bash"; 165 convCmd[4] = "-c"; 166 convCmd[5] = "'LANG=en_GB.UTF-8 " 167 + rubis.getMonitoringProgram() 168 + " " 169 + rubis.getMonitoringOptions() 170 + " " 171 + rubis.getMonitoringSampling() 172 + " " 173 + fullTimeInSec 174 + " -f " 175 + outputDir + "/" + lastName 176 + ".bin" 177 + " > " 178 + outputDir 179 + "/" 180 + lastName 181 + "'"; 182 System.out.println("    Command is: "+convCmd[0]+" "+convCmd[1]+" "+convCmd[2]+" "+convCmd[3]+" "+convCmd[4]+" "+convCmd[5]+"<br>\n"); 183 p = Runtime.getRuntime().exec(convCmd); 184 p.waitFor(); 185 } 186 catch (InterruptedException ie) 187 { 188 System.out.println( 189 "An error occured while executing " 190 + "monitoring program (" 191 + ie.getMessage() 192 + ")"); 193 194 } 195 catch (IOException ioe) 196 { 197 System.out.println( 198 "An error occured while executing " 199 + "monitoring program (" 200 + ioe.getMessage() 201 + ")"); 202 } 203 } 204 205 214 private void getHTMLData(String node, String fileName, 215 String outputDir) 216 { 217 String [] scpCmd = new String [3]; 218 219 scpCmd[0] = rubis.getMonitoringScp(); 220 scpCmd[1] = node + ":"+fileName; 221 scpCmd[2] = outputDir+"/"; 222 223 try 224 { 225 System.out.println( 226 "    Command is: " 227 + scpCmd[0] 228 + " " 229 + scpCmd[1] 230 + " " 231 + scpCmd[2] 232 + "<br>\n"); 233 234 Process p = Runtime.getRuntime().exec(scpCmd); 235 p.waitFor(); 236 237 } 238 catch (InterruptedException ie) 239 { 240 System.out.println( 241 "An error occured while executing " 242 + "monitoring program (" 243 + ie.getMessage() 244 + ")"); 245 246 } 247 catch (IOException ioe) 248 { 249 System.out.println( 250 "An error occured while executing " 251 + "monitoring program (" 252 + ioe.getMessage() 253 + ")"); 254 } 255 } 256 257 266 private Process startMonitoringProgram(String node, String outputFileName) 267 { 268 int fullTimeInSec = 269 (rubis.getUpRampTime() 270 + rubis.getSessionTime() 271 + rubis.getDownRampTime()) 272 / 1000 273 + 5; 274 276 try 279 { 280 String [] delFiles = new String [4]; 281 Process delProcess; 282 delFiles[0] = rubis.getMonitoringRsh(); 283 delFiles[1] = "-x"; 284 delFiles[2] = node.trim(); 285 delFiles[3] = "rm -f "+outputFileName; 286 System.out.println("    Command is: "+delFiles[0]+" "+delFiles[1]+" "+delFiles[2]+" "+delFiles[3]+"<br>\n"); 287 delProcess = Runtime.getRuntime().exec(delFiles); 288 delProcess.waitFor(); 289 } 290 catch (IOException ioe) 291 { 292 System.out.println( 293 "An error occured while deleting old log files (" 294 + ioe.getMessage() 295 + ")"); 296 return null; 297 } 298 catch (InterruptedException ie) 299 { 300 System.out.println( 301 "An error occured while deleting old log files (" 302 + ie.getMessage() 303 + ")"); 304 return null; 305 } 306 307 try 308 { 309 String [] cmd = new String [6]; 310 cmd[0] = rubis.getMonitoringRsh(); 311 cmd[1] = "-x"; 312 cmd[2] = node.trim(); 313 cmd[3] = "/bin/bash"; 314 cmd[4] = "-c"; 315 cmd[5] = "'LANG=en_GB.UTF-8 " 316 + rubis.getMonitoringProgram() 317 + " " 318 + rubis.getMonitoringOptions() 319 + " " 320 + rubis.getMonitoringSampling() 321 + " " 322 + fullTimeInSec 323 + " -o " 324 + outputFileName 325 + "'"; 326 System.out.println( 327 "    Command is: " 328 + cmd[0] 329 + " " 330 + cmd[1] 331 + " " 332 + cmd[2] 333 + " " 334 + cmd[3] 335 + " " 336 + cmd[4] 337 + " " 338 + cmd[5] 339 + "<br>\n"); 340 return Runtime.getRuntime().exec(cmd); 341 } 342 catch (IOException ioe) 343 { 344 System.out.println( 345 "An error occured while executing monitoring program (" 346 + ioe.getMessage() 347 + ")"); 348 return null; 349 } 350 } 351 352 358 private void printNodeInformation(String node) 359 { 360 try 361 { 362 File dir = new File ("."); 363 364 String nodeInfoProgram = "/bin/echo \"Host : \"`/bin/hostname` ; " + 365 "/bin/echo \"Kernel: \"`/bin/cat /proc/version` ; " + 366 "/bin/grep net /proc/pci ; " + 367 "/bin/grep processor /proc/cpuinfo ; " + 368 "/bin/grep vendor_id /proc/cpuinfo ; " + 369 "/bin/grep model /proc/cpuinfo ; " + 370 "/bin/grep MHz /proc/cpuinfo ; " + 371 "/bin/grep cache /proc/cpuinfo ; " + 372 "/bin/grep MemTotal /proc/meminfo ; " + 373 "/bin/grep SwapTotal /proc/meminfo "; 374 375 String [] cmd = new String [4]; 376 cmd[0] = rubis.getMonitoringRsh(); 377 cmd[1] = "-x"; 378 cmd[2] = node; 379 cmd[3] = nodeInfoProgram; 380 Process p = Runtime.getRuntime().exec(cmd); 381 BufferedReader read = 382 new BufferedReader (new InputStreamReader (p.getInputStream())); 383 String msg; 384 while ((msg = read.readLine()) != null) { 385 System.out.println(msg + "<br>"); 386 } 387 read.close(); 388 } 389 catch (Exception ioe) 390 { 391 System.out.println( 392 "An error occured while getting node information (" 393 + ioe.getMessage() 394 + ")"); 395 } 396 } 397 398 404 public static void main(String [] args) 405 { 406 GregorianCalendar startDate; 407 GregorianCalendar endDate; 408 GregorianCalendar upRampDate; 409 GregorianCalendar runSessionDate; 410 GregorianCalendar downRampDate; 411 GregorianCalendar endDownRampDate; 412 Process webServerMonitor = null; 413 Process cjdbcServerMonitor = null; 414 Process [] dbServerMonitor = null; 415 Process [] ejbServerMonitor = null; 416 Process [] servletsServerMonitor = null; 417 Process clientMonitor; 418 Process [] remoteClientMonitor = null; 419 Process [] remoteClient = null; 420 String reportDir = ""; 421 String tmpDir = "/tmp/"; 422 boolean isMainClient = (args.length <= 2); String propertiesFileName; 424 425 if (isMainClient) 426 { 427 System.out.println( 429 "RUBiS client emulator - (C) Rice University/INRIA 2001\n"); 430 431 if (args.length <= 1) 432 { 433 reportDir = "bench/"+TimeManagement.currentDateToString()+"/"; 434 reportDir = reportDir.replace(' ', '@'); 435 } 436 else 437 { 438 reportDir = "bench/"+args[1]; 439 } 440 try 441 { 442 System.out.println("Creating report directory " + reportDir); 443 File dir = new File (reportDir); 444 dir.mkdirs(); 445 if (!dir.isDirectory()) 446 { 447 System.out.println( 448 "Unable to create " 449 + reportDir 450 + " using current directory instead"); 451 reportDir = "./"; 452 } 453 else 454 reportDir = dir.getCanonicalPath() + "/"; 455 System.out.println( 456 "Redirecting output to '" + reportDir + "index.html'"); 457 PrintStream outputStream = 458 new PrintStream (new FileOutputStream (reportDir + "index.html")); 459 System.out.println("Please wait while experiment is running ..."); 460 System.setOut(outputStream); 461 System.setErr(outputStream); 462 } 463 catch (Exception e) 464 { 465 System.out.println( 466 "Output redirection failed, displaying results on standard output (" 467 + e.getMessage() 468 + ")"); 469 } 470 System.out.println( 471 "<h2>RUBiS client emulator - (C) Rice University/INRIA 2001</h2><p>\n"); 472 startDate = new GregorianCalendar (); 473 System.out.println( 474 "<h3>Test date: " 475 + TimeManagement.dateToString(startDate) 476 + "</h3><br>\n"); 477 478 System.out.println("<A HREF=\"#config\">Test configuration</A><br>"); 479 System.out.println("<A HREF=\"trace_client0.html\">Test trace</A><br>"); 480 System.out.println( 481 "<A HREF=\"perf.html\">Test performance report</A><br><p>"); 482 System.out.println("<p><hr><p>"); 483 484 System.out.println( 485 "<CENTER><A NAME=\"config\"></A><h2>*** Test configuration ***</h2></CENTER>"); 486 if (args.length == 0) 487 propertiesFileName = "rubis"; 488 else 489 propertiesFileName = args[0]; 490 } 491 else 492 { 493 System.out.println( 494 "RUBiS remote client emulator - (C) Rice University/INRIA 2001\n"); 495 startDate = new GregorianCalendar (); 496 propertiesFileName = args[2]; 497 } 498 499 ClientEmulator client = new ClientEmulator(propertiesFileName); 500 502 Stats stats = new Stats(client.rubis.getNbOfRows()); 503 Stats upRampStats = new Stats(client.rubis.getNbOfRows()); 504 Stats runSessionStats = new Stats(client.rubis.getNbOfRows()); 505 Stats downRampStats = new Stats(client.rubis.getNbOfRows()); 506 Stats allStats = new Stats(client.rubis.getNbOfRows()); 507 UserSession[] sessions = new UserSession[client.rubis.getNbOfClients()]; 508 boolean cjdbcFlag = client.rubis.getCJDBCServerName() != null 509 && !client.rubis.getCJDBCServerName().equals(""); 510 System.out.println("<p><hr><p>"); 511 512 if (isMainClient) 513 { 514 System.out.println( 516 "Total number of clients for this experiment: " 517 + (client.rubis.getNbOfClients() 518 * (client.rubis.getRemoteClients().size() + 1)) 519 + "<br>"); 520 remoteClient = new Process [client.rubis.getRemoteClients().size()]; 521 for (int i = 0; i < client.rubis.getRemoteClients().size(); i++) 522 { 523 try 524 { 525 System.out.println( 526 "ClientEmulator: Starting remote client on " 527 + client.rubis.getRemoteClients().get(i) 528 + "<br>\n"); 529 String [] rcmdClient = new String [3]; 530 rcmdClient[0] = client.rubis.getMonitoringRsh(); 531 rcmdClient[1] = (String ) client.rubis.getRemoteClients().get(i); 532 rcmdClient[2] = 533 client.rubis.getClientsRemoteCommand() 534 + " " 535 + tmpDir 536 + "trace_client" 537 + (i + 1) 538 + ".html " 539 + tmpDir 540 + "stat_client" 541 + (i + 1) 542 + ".html" 543 + " " 544 + propertiesFileName; 545 remoteClient[i] = Runtime.getRuntime().exec(rcmdClient); 546 System.out.println( 547 "    Command is: " 548 + rcmdClient[0] 549 + " " 550 + rcmdClient[1] 551 + " " 552 + rcmdClient[2] 553 + "<br>\n"); 554 } 555 catch (IOException ioe) 556 { 557 System.out.println( 558 "An error occured while executing remote client (" 559 + ioe.getMessage() 560 + ")"); 561 } 562 } 563 564 System.out.println( 566 "<CENTER></A><A NAME=\"trace\"><h2>*** Monitoring ***</h2></CENTER>"); 567 568 System.out.println( 570 "ClientEmulator: Starting monitoring program on Web server " 571 + client.rubis.getWebServerName() 572 + "<br>\n"); 573 webServerMonitor = 574 client.startMonitoringProgram( 575 client.rubis.getWebServerName(), 576 tmpDir + "web_server"); 577 578 if (cjdbcFlag) 580 { 581 System.out.println( 582 "ClientEmulator: Starting monitoring program on CJDBC server " 583 + client.rubis.getCJDBCServerName() 584 + "<br>\n"); 585 cjdbcServerMonitor = 586 client.startMonitoringProgram( 587 client.rubis.getCJDBCServerName(), 588 tmpDir + "cjdbc_server"); 589 } 590 591 if (client.rubis.getDBServerNames().size() > 0) 592 dbServerMonitor = new Process [client.rubis.getDBServerNames().size()]; 593 for (int i = 0; i < client.rubis.getDBServerNames().size(); i++) 595 { 596 System.out.println("ClientEmulator: Starting monitoring program on Database server "+client.rubis.getDBServerNames().get(i)+"<br>\n"); 597 dbServerMonitor[i] = client.startMonitoringProgram((String )client.rubis.getDBServerNames().get(i), tmpDir+"db_server"+i); 598 } 599 600 if (client.rubis.getServletsServerNames().size() > 0) 601 servletsServerMonitor = new Process [client.rubis.getServletsServerNames().size()]; 602 for (int i = 0; i < client.rubis.getServletsServerNames().size(); i++) 604 { 605 System.out.println("ClientEmulator: Starting monitoring program on Servlets server "+client.rubis.getServletsServerNames().get(i)+"<br>\n"); 606 servletsServerMonitor[i] = client.startMonitoringProgram((String )client.rubis.getServletsServerNames().get(i), tmpDir+"servlets_server"+i); 607 } 608 609 if (client.rubis.getEJBServerNames().size() > 0) 610 ejbServerMonitor = new Process [client.rubis.getEJBServerNames().size()]; 611 for (int i = 0; i < client.rubis.getEJBServerNames().size(); i++) 613 { 614 System.out.println("ClientEmulator: Starting monitoring program on EJB server "+client.rubis.getEJBServerNames().get(i)+"<br>\n"); 615 ejbServerMonitor[i] = client.startMonitoringProgram((String )client.rubis.getEJBServerNames().get(i), tmpDir+"ejb_server"+i); 616 } 617 618 System.out.println( 620 "ClientEmulator: Starting monitoring program locally on client<br>\n"); 621 clientMonitor = 622 client.startMonitoringProgram("localhost", tmpDir + "client0"); 623 624 remoteClientMonitor = new Process [client.rubis.getRemoteClients().size()]; 625 for (int i = 0; i < client.rubis.getRemoteClients().size(); i++) 627 { 628 System.out.println( 629 "ClientEmulator: Starting monitoring program locally on client<br>\n"); 630 remoteClientMonitor[i] = 631 client.startMonitoringProgram( 632 (String ) client.rubis.getRemoteClients().get(i), 633 tmpDir + "client" + (i + 1)); 634 } 635 636 try 638 { 639 PrintStream outputStream = 640 new PrintStream ( 641 new FileOutputStream (reportDir + "trace_client0.html")); 642 System.setOut(outputStream); 643 System.setErr(outputStream); 644 } 645 catch (FileNotFoundException fnf) 646 { 647 System.err.println( 648 "Unable to redirect main client output, got error (" 649 + fnf.getMessage() 650 + ")<br>"); 651 } 652 } 653 else 654 { System.out.println("Redirecting output to '" + args[0] + "'"); 656 try 657 { 658 PrintStream outputStream = 659 new PrintStream (new FileOutputStream (args[0])); 660 System.out.println("Please wait while experiment is running ..."); 661 System.setOut(outputStream); 662 System.setErr(outputStream); 663 } 664 catch (Exception e) 665 { 666 System.out.println( 667 "Output redirection failed, displaying results on standard output (" 668 + e.getMessage() 669 + ")"); 670 } 671 startDate = new GregorianCalendar (); 672 } 673 674 678 System.out.println( 679 "<CENTER></A><A NAME=\"trace\"><h2>*** Test trace ***</h2></CENTER><p>"); 680 System.out.println( 681 "<A HREF=\"trace_client0.html\">Main client traces</A><br>"); 682 for (int i = 0; i < client.rubis.getRemoteClients().size(); i++) 683 System.out.println( 684 "<A HREF=\"trace_client" 685 + (i + 1) 686 + ".html\">client1 (" 687 + client.rubis.getRemoteClients().get(i) 688 + ") traces</A><br>"); 689 System.out.println("<br><p>"); 690 System.out.println("   <A HREF=\"#up\">Up ramp trace</A><br>"); 691 System.out.println( 692 "   <A HREF=\"#run\">Runtime session trace</A><br>"); 693 System.out.println( 694 "   <A HREF=\"#down\">Down ramp trace</A><br><p><p>"); 695 696 System.out.println( 698 "ClientEmulator: Starting " 699 + client.rubis.getNbOfClients() 700 + " session threads<br>"); 701 for (int i = 0; i < client.rubis.getNbOfClients(); i++) 702 { 703 sessions[i] = 704 new UserSession("UserSession" + i, client.urlGen, client.rubis, stats); 705 sessions[i].start(); 706 } 707 708 System.out.println("<br><A NAME=\"up\"></A>"); 710 System.out.println( 711 "<h3>ClientEmulator: Switching to ** UP RAMP **</h3><br><p>"); 712 client.setSlowDownFactor(client.rubis.getUpRampSlowdown()); 713 upRampDate = new GregorianCalendar (); 714 try 715 { 716 Thread.currentThread().sleep(client.rubis.getUpRampTime()); 717 } 718 catch (java.lang.InterruptedException ie) 719 { 720 System.err.println("ClientEmulator has been interrupted."); 721 } 722 upRampStats.merge(stats); 723 stats.reset(); 724 726 System.out.println("<br><A NAME=\"run\"></A>"); 728 System.out.println( 729 "<h3>ClientEmulator: Switching to ** RUNTIME SESSION **</h3><br><p>"); 730 client.setSlowDownFactor(1); 731 runSessionDate = new GregorianCalendar (); 732 try 733 { 734 Thread.currentThread().sleep(client.rubis.getSessionTime()); 735 } 736 catch (java.lang.InterruptedException ie) 737 { 738 System.err.println("ClientEmulator has been interrupted."); 739 } 740 runSessionStats.merge(stats); 741 stats.reset(); 742 744 System.out.println("<br><A NAME=\"down\"></A>"); 746 System.out.println( 747 "<h3>ClientEmulator: Switching to ** DOWN RAMP **</h3><br><p>"); 748 client.setSlowDownFactor(client.rubis.getDownRampSlowdown()); 749 downRampDate = new GregorianCalendar (); 750 try 751 { 752 Thread.currentThread().sleep(client.rubis.getDownRampTime()); 753 } 754 catch (java.lang.InterruptedException ie) 755 { 756 System.err.println("ClientEmulator has been interrupted."); 757 } 758 downRampStats.merge(stats); 759 endDownRampDate = new GregorianCalendar (); 760 761 client.setEndOfSimulation(); 763 System.out.println("ClientEmulator: Shutting down threads ...<br>"); 764 for (int i = 0; i < client.rubis.getNbOfClients(); i++) 765 { 766 try 767 { 768 sessions[i].join(2000); 769 } 770 catch (java.lang.InterruptedException ie) 771 { 772 System.err.println( 773 "ClientEmulator: Thread " + i + " has been interrupted."); 774 } 775 } 776 System.out.println("Done\n"); 777 endDate = new GregorianCalendar (); 778 allStats.merge(stats); 779 allStats.merge(runSessionStats); 780 allStats.merge(upRampStats); 781 System.out.println("<p><hr><p>"); 782 783 787 try 790 { 791 PrintStream outputStream; 792 if (isMainClient) 793 outputStream = 794 new PrintStream (new FileOutputStream (reportDir + "perf.html")); 795 else 796 outputStream = new PrintStream (new FileOutputStream (args[1])); 797 System.setOut(outputStream); 798 System.setErr(outputStream); 799 } 800 catch (Exception e) 801 { 802 System.out.println( 803 "Output redirection failed, displaying results on standard output (" 804 + e.getMessage() 805 + ")"); 806 } 807 808 System.out.println( 809 "<center><h2>*** Performance Report ***</h2></center><br>"); 810 System.out.println( 811 "<A HREF=\"perf.html\">Overall performance report</A><br>"); 812 System.out.println( 813 "<A HREF=\"stat_client0.html\">Main client (localhost) statistics</A><br>"); 814 for (int i = 0; i < client.rubis.getRemoteClients().size(); i++) 815 System.out.println( 816 "<A HREF=\"stat_client" 817 + (i + 1) 818 + ".html\">client1 (" 819 + client.rubis.getRemoteClients().get(i) 820 + ") statistics</A><br>"); 821 System.out.println("<A HREF=\"db_graphs.html\">Database graphs</A><br>"); 822 if (client.rubis.getServletsServerNames().size() > 0) 823 System.out.println("<A HREF=\"servlets_graphs.html\">Servlets graphs</A><br>"); 824 if (client.rubis.getEJBServerNames().size() > 0) 825 System.out.println("<A HREF=\"ejb_graphs.html\">EJB graphs</A><br>"); 826 827 System.out.println( 828 "<p><br>   <A HREF=\"perf.html#node\">Node information</A><br>"); 829 System.out.println( 830 "   <A HREF=\"#time\">Test timing information</A><br>"); 831 System.out.println( 832 "   <A HREF=\"#up_stat\">Up ramp statistics</A><br>"); 833 System.out.println( 834 "   <A HREF=\"#run_stat\">Runtime session statistics</A><br>"); 835 System.out.println( 836 "   <A HREF=\"#down_stat\">Down ramp statistics</A><br>"); 837 System.out.println( 838 "   <A HREF=\"#all_stat\">Overall statistics</A><br>"); 839 System.out.println( 840 "   <A HREF=\"#cpu_graph\">CPU usage graphs</A><br>"); 841 System.out.println( 842 "   <A HREF=\"#procs_graph\">Processes usage graphs</A><br>"); 843 System.out.println( 844 "   <A HREF=\"#mem_graph\">Memory usage graph</A><br>"); 845 System.out.println( 846 "   <A HREF=\"#disk_graph\">Disk usage graphs</A><br>"); 847 System.out.println( 848 "   <A HREF=\"#net_graph\">Network usage graphs</A><br>"); 849 850 if (isMainClient) 851 { 852 System.out.println( 854 "<br><A NAME=\"node\"></A><h3>Node Information</h3><br>"); 855 856 System.out.println("<B>Web server</B><br>"); 858 client.printNodeInformation(client.rubis.getWebServerName()); 859 860 if (cjdbcFlag) 862 { 863 System.out.println("<br><B>C-JDBC server</B><br>"); 864 client.printNodeInformation((String )client.rubis.getCJDBCServerName()); 865 } 866 867 System.out.println("<br><B>Database server</B><br>"); 869 client.printNodeInformation((String )client.rubis.getDBServerNames().get(0)); 870 871 if (client.rubis.getServletsServerNames().size() > 0) 873 { 874 System.out.println("<br><B>Servlets server</B><br>"); 875 client.printNodeInformation((String )client.rubis.getServletsServerNames().get(0)); 876 } 877 878 if (client.rubis.getEJBServerNames().size() > 0) 880 { 881 System.out.println("<br><B>EJB server</B><br>"); 882 client.printNodeInformation((String )client.rubis.getEJBServerNames().get(0)); 883 } 884 885 System.out.println("<br><B>Local client</B><br>"); 887 client.printNodeInformation("localhost"); 888 889 for (int i = 0; i < client.rubis.getRemoteClients().size(); i++) 891 { 892 System.out.println("<br><B>Remote client " + i + "</B><br>"); 893 client.printNodeInformation( 894 (String ) client.rubis.getRemoteClients().get(i)); 895 } 896 897 try 898 { 899 PrintStream outputStream = new PrintStream (new FileOutputStream (reportDir+"db_graphs.html")); 900 System.setOut(outputStream); 901 System.setErr(outputStream); 902 } 903 catch (Exception ioe) 904 { 905 System.out.println("An error occured while creating file ("+ioe.getMessage()+")"); 906 } 907 908 System.out.println("<center><h2>*** Database servers graphs ***</h2></center><br>"); 909 System.out.println("<A HREF=\"perf.html\">Overall performance report</A><br>"); 910 System.out.println("<A HREF=\"stat_client0.html\">Main client (localhost) statistics</A><br>"); 911 for (int i = 0 ; i < client.rubis.getRemoteClients().size() ; i++) 912 System.out.println("<A HREF=\"stat_client"+(i+1)+".html\">client1 ("+client.rubis.getRemoteClients().get(i)+") statistics</A><br>"); 913 System.out.println("<A HREF=\"db_graphs.html\">Database graphs</A><br>"); 914 if (client.rubis.getServletsServerNames().size() > 0) 915 System.out.println("<A HREF=\"servlets_graphs.html\">Servlets graphs</A><br>"); 916 if (client.rubis.getEJBServerNames().size() > 0) 917 System.out.println("<A HREF=\"ejb_graphs.html\">EJB graphs</A><br>"); 918 919 System.out.println("<p><br>   <A HREF=\"#node\">Node information</A><br>"); 920 System.out.println("   <A HREF=\"#cpu_graph\">CPU usage graphs</A><br>"); 921 System.out.println("   <A HREF=\"#procs_graph\">Processes usage graphs</A><br>"); 922 System.out.println("   <A HREF=\"#mem_graph\">Memory usage graph</A><br>"); 923 System.out.println("   <A HREF=\"#disk_graph\">Disk usage graphs</A><br>"); 924 System.out.println("   <A HREF=\"#net_graph\">Network usage graphs</A><br>"); 925 926 System.out.println("<br><A NAME=\"node\"></A><h3>Node Information</h3><br>"); 927 for (int i = 0; i < client.rubis.getDBServerNames().size(); i++) 928 { 929 System.out.println("<br><B>Database server "+i+"</B><br>"); 930 client.printNodeInformation((String )client.rubis.getDBServerNames().get(i)); 931 } 932 933 System.out.println("<br><A NAME=\"cpu_graph\"></A>"); 934 System.out.println("<br><h3>CPU Usage graphs</h3><p>"); 935 System.out.println("<IMG SRC=\"db_cpu_busy."+client.rubis.getGnuPlotTerminal()+"\">"); 936 System.out.println("<IMG SRC=\"db_cpu_idle."+client.rubis.getGnuPlotTerminal()+"\">"); 937 System.out.println("<IMG SRC=\"db_cpu_user_kernel."+client.rubis.getGnuPlotTerminal()+"\">"); 938 939 System.out.println("<br><A NAME=\"procs_graph\"></A>"); 940 System.out.println("<br><h3>Processes Usage graphs</h3><p>"); 941 System.out.println("<IMG SRC=\"db_procs."+client.rubis.getGnuPlotTerminal()+"\">"); 942 System.out.println("<IMG SRC=\"db_ctxtsw."+client.rubis.getGnuPlotTerminal()+"\">"); 943 944 System.out.println("<br><A NAME=\"mem_graph\"></A>"); 945 System.out.println("<br><h3>Memory Usage graphs</h3><p>"); 946 System.out.println("<IMG SRC=\"db_mem_usage."+client.rubis.getGnuPlotTerminal()+"\">"); 947 System.out.println("<IMG SRC=\"db_mem_cache."+client.rubis.getGnuPlotTerminal()+"\">"); 948 949 System.out.println("<br><A NAME=\"disk_graph\"></A>"); 950 System.out.println("<br><h3>Disk Usage graphs</h3><p>"); 951 System.out.println("<IMG SRC=\"db_disk_rw_req."+client.rubis.getGnuPlotTerminal()+"\">"); 952 System.out.println("<IMG SRC=\"db_disk_tps."+client.rubis.getGnuPlotTerminal()+"\">"); 953 954 System.out.println("<br><A NAME=\"net_graph\"></A>"); 955 System.out.println("<br><h3>Network Usage graphs</h3><p>"); 956 System.out.println("<IMG SRC=\"db_net_rt_byt."+client.rubis.getGnuPlotTerminal()+"\">"); 957 System.out.println("<IMG SRC=\"db_net_rt_pack."+client.rubis.getGnuPlotTerminal()+"\">"); 958 System.out.println("<IMG SRC=\"db_socks."+client.rubis.getGnuPlotTerminal()+"\">"); 959 960 if (client.rubis.getServletsServerNames().size() > 0) 961 { 962 try 963 { 964 PrintStream outputStream = new PrintStream (new FileOutputStream (reportDir+"servlets_graphs.html")); 965 System.setOut(outputStream); 966 System.setErr(outputStream); 967 } 968 catch (Exception ioe) 969 { 970 System.out.println("An error occured while creating file ("+ioe.getMessage()+")"); 971 } 972 973 System.out.println("<center><h2>*** Servlets servers graphs ***</h2></center><br>"); 974 System.out.println("<A HREF=\"perf.html\">Overall performance report</A><br>"); 975 System.out.println("<A HREF=\"stat_client0.html\">Main client (localhost) statistics</A><br>"); 976 for (int i = 0 ; i < client.rubis.getRemoteClients().size() ; i++) 977 System.out.println("<A HREF=\"stat_client"+(i+1)+".html\">client1 ("+client.rubis.getRemoteClients().get(i)+") statistics</A><br>"); 978 System.out.println("<A HREF=\"db_graphs.html\">Database graphs</A><br>"); 979 if (client.rubis.getServletsServerNames().size() > 0) 980 System.out.println("<A HREF=\"servlets_graphs.html\">Servlets graphs</A><br>"); 981 if (client.rubis.getEJBServerNames().size() > 0) 982 System.out.println("<A HREF=\"ejb_graphs.html\">EJB graphs</A><br>"); 983 984 System.out.println("<p><br>   <A HREF=\"#node\">Node information</A><br>"); 985 System.out.println("   <A HREF=\"#cpu_graph\">CPU usage graphs</A><br>"); 986 System.out.println("   <A HREF=\"#procs_graph\">Processes usage graphs</A><br>"); 987 System.out.println("   <A HREF=\"#mem_graph\">Memory usage graph</A><br>"); 988 System.out.println("   <A HREF=\"#disk_graph\">Disk usage graphs</A><br>"); 989 System.out.println("   <A HREF=\"#net_graph\">Network usage graphs</A><br>"); 990 991 System.out.println("<br><A NAME=\"node\"></A><h3>Node Information</h3><br>"); 992 for (int i = 0; i < client.rubis.getServletsServerNames().size(); i++) 993 { 994 System.out.println("<br><B>Servlets server "+i+"</B><br>"); 995 client.printNodeInformation((String )client.rubis.getServletsServerNames().get(i)); 996 } 997 998 System.out.println("<br><A NAME=\"cpu_graph\"></A>"); 999 System.out.println("<br><h3>CPU Usage graphs</h3><p>"); 1000 System.out.println("<IMG SRC=\"servlets_cpu_busy."+client.rubis.getGnuPlotTerminal()+"\">"); 1001 System.out.println("<IMG SRC=\"servlets_cpu_idle."+client.rubis.getGnuPlotTerminal()+"\">"); 1002 System.out.println("<IMG SRC=\"servlets_cpu_user_kernel."+client.rubis.getGnuPlotTerminal()+"\">"); 1003 1004 System.out.println("<br><A NAME=\"procs_graph\"></A>"); 1005 System.out.println("<br><h3>Processes Usage graphs</h3><p>"); 1006 System.out.println("<IMG SRC=\"servlets_procs."+client.rubis.getGnuPlotTerminal()+"\">"); 1007 System.out.println("<IMG SRC=\"servlets_ctxtsw."+client.rubis.getGnuPlotTerminal()+"\">"); 1008 1009 System.out.println("<br><A NAME=\"mem_graph\"></A>"); 1010 System.out.println("<br><h3>Memory Usage graphs</h3><p>"); 1011 System.out.println("<IMG SRC=\"servlets_mem_usage."+client.rubis.getGnuPlotTerminal()+"\">"); 1012 System.out.println("<IMG SRC=\"servlets_mem_cache."+client.rubis.getGnuPlotTerminal()+"\">"); 1013 1014 System.out.println("<br><A NAME=\"disk_graph\"></A>"); 1015 System.out.println("<br><h3>Disk Usage graphs</h3><p>"); 1016 System.out.println("<IMG SRC=\"servlets_disk_rw_req."+client.rubis.getGnuPlotTerminal()+"\">"); 1017 System.out.println("<IMG SRC=\"servlets_disk_tps."+client.rubis.getGnuPlotTerminal()+"\">"); 1018 1019 System.out.println("<br><A NAME=\"net_graph\"></A>"); 1020 System.out.println("<br><h3>Network Usage graphs</h3><p>"); 1021 System.out.println("<IMG SRC=\"servlets_net_rt_byt."+client.rubis.getGnuPlotTerminal()+"\">"); 1022 System.out.println("<IMG SRC=\"servlets_net_rt_pack."+client.rubis.getGnuPlotTerminal()+"\">"); 1023 System.out.println("<IMG SRC=\"servlets_socks."+client.rubis.getGnuPlotTerminal()+"\">"); 1024 } 1025 1026 if (client.rubis.getEJBServerNames().size() > 0) 1027 { 1028 try 1029 { 1030 PrintStream outputStream = new PrintStream (new FileOutputStream (reportDir+"ejb_graphs.html")); 1031 System.setOut(outputStream); 1032 System.setErr(outputStream); 1033 } 1034 catch (Exception ioe) 1035 { 1036 System.out.println("An error occured while creating file ("+ioe.getMessage()+")"); 1037 } 1038 1039 System.out.println("<center><h2>*** EJB servers graphs ***</h2></center><br>"); 1040 System.out.println("<A HREF=\"perf.html\">Overall performance report</A><br>"); 1041 System.out.println("<A HREF=\"stat_client0.html\">Main client (localhost) statistics</A><br>"); 1042 for (int i = 0 ; i < client.rubis.getRemoteClients().size() ; i++) 1043 System.out.println("<A HREF=\"stat_client"+(i+1)+".html\">client1 ("+client.rubis.getRemoteClients().get(i)+") statistics</A><br>"); 1044 System.out.println("<A HREF=\"db_graphs.html\">Database graphs</A><br>"); 1045 if (client.rubis.getServletsServerNames().size() > 0) 1046 System.out.println("<A HREF=\"servlets_graphs.html\">Servlets graphs</A><br>"); 1047 if (client.rubis.getEJBServerNames().size() > 0) 1048 System.out.println("<A HREF=\"ejb_graphs.html\">EJB graphs</A><br>"); 1049 1050 System.out.println("<p><br>   <A HREF=\"#node\">Node information</A><br>"); 1051 System.out.println("   <A HREF=\"#cpu_graph\">CPU usage graphs</A><br>"); 1052 System.out.println("   <A HREF=\"#procs_graph\">Processes usage graphs</A><br>"); 1053 System.out.println("   <A HREF=\"#mem_graph\">Memory usage graph</A><br>"); 1054 System.out.println("   <A HREF=\"#disk_graph\">Disk usage graphs</A><br>"); 1055 System.out.println("   <A HREF=\"#net_graph\">Network usage graphs</A><br>"); 1056 1057 System.out.println("<br><A NAME=\"node\"></A><h3>Node Information</h3><br>"); 1058 for (int i = 0; i < client.rubis.getEJBServerNames().size(); i++) 1059 { 1060 System.out.println("<br><B>EJB server "+i+"</B><br>"); 1061 client.printNodeInformation((String )client.rubis.getEJBServerNames().get(i)); 1062 } 1063 1064 System.out.println("<br><A NAME=\"cpu_graph\"></A>"); 1065 System.out.println("<br><h3>CPU Usage graphs</h3><p>"); 1066 System.out.println("<IMG SRC=\"ejb_cpu_busy."+client.rubis.getGnuPlotTerminal()+"\">"); 1067 System.out.println("<IMG SRC=\"ejb_cpu_idle."+client.rubis.getGnuPlotTerminal()+"\">"); 1068 System.out.println("<IMG SRC=\"ejb_cpu_user_kernel."+client.rubis.getGnuPlotTerminal()+"\">"); 1069 1070 System.out.println("<br><A NAME=\"procs_graph\"></A>"); 1071 System.out.println("<br><h3>Processes Usage graphs</h3><p>"); 1072 System.out.println("<IMG SRC=\"ejb_procs."+client.rubis.getGnuPlotTerminal()+"\">"); 1073 System.out.println("<IMG SRC=\"ejb_ctxtsw."+client.rubis.getGnuPlotTerminal()+"\">"); 1074 1075 System.out.println("<br><A NAME=\"mem_graph\"></A>"); 1076 System.out.println("<br><h3>Memory Usage graphs</h3><p>"); 1077 System.out.println("<IMG SRC=\"ejb_mem_usage."+client.rubis.getGnuPlotTerminal()+"\">"); 1078 System.out.println("<IMG SRC=\"ejb_mem_cache."+client.rubis.getGnuPlotTerminal()+"\">"); 1079 1080 System.out.println("<br><A NAME=\"disk_graph\"></A>"); 1081 System.out.println("<br><h3>Disk Usage graphs</h3><p>"); 1082 System.out.println("<IMG SRC=\"ejb_disk_rw_req."+client.rubis.getGnuPlotTerminal()+"\">"); 1083 System.out.println("<IMG SRC=\"ejb_disk_tps."+client.rubis.getGnuPlotTerminal()+"\">"); 1084 1085 System.out.println("<br><A NAME=\"net_graph\"></A>"); 1086 System.out.println("<br><h3>Network Usage graphs</h3><p>"); 1087 System.out.println("<IMG SRC=\"ejb_net_rt_byt."+client.rubis.getGnuPlotTerminal()+"\">"); 1088 System.out.println("<IMG SRC=\"ejb_net_rt_pack."+client.rubis.getGnuPlotTerminal()+"\">"); 1089 System.out.println("<IMG SRC=\"ejb_socks."+client.rubis.getGnuPlotTerminal()+"\">"); 1090 } 1091 1092 try 1093 { 1094 PrintStream outputStream = 1095 new PrintStream ( 1096 new FileOutputStream (reportDir + "stat_client0.html")); 1097 System.setOut(outputStream); 1098 System.setErr(outputStream); 1099 System.out.println( 1100 "<center><h2>*** Performance Report ***</h2></center><br>"); 1101 System.out.println( 1102 "<A HREF=\"perf.html\">Overall performance report</A><br>"); 1103 System.out.println( 1104 "<A HREF=\"stat_client0.html\">Main client (localhost) statistics</A><br>"); 1105 for (int i = 0; i < client.rubis.getRemoteClients().size(); i++) 1106 System.out.println( 1107 "<A HREF=\"stat_client" 1108 + (i + 1) 1109 + ".html\">client1 (" 1110 + client.rubis.getRemoteClients().get(i) 1111 + ") statistics</A><br>"); 1112 1113 System.out.println("<A HREF=\"db_graphs.html\">Database graphs</A><br>"); 1114 if (client.rubis.getServletsServerNames().size() > 0) 1115 System.out.println("<A HREF=\"servlets_graphs.html\">Servlets graphs</A><br>"); 1116 if (client.rubis.getEJBServerNames().size() > 0) 1117 System.out.println("<A HREF=\"ejb_graphs.html\">EJB graphs</A><br>"); 1118 1119 System.out.println( 1120 "<p><br>   <A HREF=\"perf.html#node\">Node information</A><br>"); 1121 System.out.println( 1122 "   <A HREF=\"#time\">Test timing information</A><br>"); 1123 System.out.println( 1124 "   <A HREF=\"#up_stat\">Up ramp statistics</A><br>"); 1125 System.out.println( 1126 "   <A HREF=\"#run_stat\">Runtime session statistics</A><br>"); 1127 System.out.println( 1128 "   <A HREF=\"#down_stat\">Down ramp statistics</A><br>"); 1129 System.out.println( 1130 "   <A HREF=\"#all_stat\">Overall statistics</A><br>"); 1131 System.out.println( 1132 "   <A HREF=\"#cpu_graph\">CPU usage graphs</A><br>"); 1133 System.out.println( 1134 "   <A HREF=\"#procs_graph\">Processes usage graphs</A><br>"); 1135 System.out.println( 1136 "   <A HREF=\"#mem_graph\">Memory usage graph</A><br>"); 1137 System.out.println( 1138 "   <A HREF=\"#disk_graph\">Disk usage graphs</A><br>"); 1139 System.out.println( 1140 "   <A HREF=\"#net_graph\">Network usage graphs</A><br>"); 1141 } 1142 catch (Exception ioe) 1143 { 1144 System.out.println( 1145 "An error occured while getting node information (" 1146 + ioe.getMessage() 1147 + ")"); 1148 } 1149 } 1150 1151 System.out.println( 1153 "<br><p><A NAME=\"time\"></A><h3>Test timing information</h3><p>"); 1154 System.out.println("<TABLE BORDER=1>"); 1155 System.out.println( 1156 "<TR><TD><B>Test start</B><TD>" + TimeManagement.dateToString(startDate)); 1157 System.out.println( 1158 "<TR><TD><B>Up ramp start</B><TD>" 1159 + TimeManagement.dateToString(upRampDate)); 1160 System.out.println( 1161 "<TR><TD><B>Runtime session start</B><TD>" 1162 + TimeManagement.dateToString(runSessionDate)); 1163 System.out.println( 1164 "<TR><TD><B>Down ramp start</B><TD>" 1165 + TimeManagement.dateToString(downRampDate)); 1166 System.out.println( 1167 "<TR><TD><B>Test end</B><TD>" + TimeManagement.dateToString(endDate)); 1168 System.out.println( 1169 "<TR><TD><B>Up ramp length</B><TD>" 1170 + TimeManagement.diffTime(upRampDate, runSessionDate) 1171 + " (requested " 1172 + client.rubis.getUpRampTime() 1173 + " ms)"); 1174 System.out.println( 1175 "<TR><TD><B>Runtime session length</B><TD>" 1176 + TimeManagement.diffTime(runSessionDate, downRampDate) 1177 + " (requested " 1178 + client.rubis.getSessionTime() 1179 + " ms)"); 1180 System.out.println( 1181 "<TR><TD><B>Down ramp length</B><TD>" 1182 + TimeManagement.diffTime(downRampDate, endDownRampDate) 1183 + " (requested " 1184 + client.rubis.getDownRampTime() 1185 + " ms)"); 1186 System.out.println( 1187 "<TR><TD><B>Total test length</B><TD>" 1188 + TimeManagement.diffTime(startDate, endDate)); 1189 System.out.println("</TABLE><p>"); 1190 1191 System.out.println("<br><A NAME=\"up_stat\"></A>"); 1193 upRampStats.display_stats( 1194 "Up ramp", 1195 TimeManagement.diffTimeInMs(upRampDate, runSessionDate), 1196 false); 1197 System.out.println("<br><A NAME=\"run_stat\"></A>"); 1198 runSessionStats.display_stats( 1199 "Runtime session", 1200 TimeManagement.diffTimeInMs(runSessionDate, downRampDate), 1201 false); 1202 System.out.println("<br><A NAME=\"down_stat\"></A>"); 1203 downRampStats.display_stats( 1204 "Down ramp", 1205 TimeManagement.diffTimeInMs(downRampDate, endDownRampDate), 1206 false); 1207 System.out.println("<br><A NAME=\"all_stat\"></A>"); 1208 allStats.display_stats( 1209 "Overall", 1210 TimeManagement.diffTimeInMs(upRampDate, endDownRampDate), 1211 false); 1212 1213 if (isMainClient) 1214 { 1215 1216 try 1217 { 1218 for (int i = 0; i < client.rubis.getRemoteClients().size(); i++) 1220 { 1221 if (remoteClientMonitor[i].exitValue() != 0) 1223 { 1224 remoteClientMonitor[i].waitFor(); 1225 } 1226 if (remoteClient[i].exitValue() != 0) 1227 { 1228 remoteClient[i].waitFor(); 1229 } 1230 } 1233 if (webServerMonitor.exitValue() != 0) 1234 { 1235 webServerMonitor.waitFor(); 1236 } 1237 if (cjdbcServerMonitor.exitValue() != 0) 1238 { 1239 cjdbcServerMonitor.waitFor(); 1240 } 1241 for (int i = 0; i < dbServerMonitor.length; i++) 1242 dbServerMonitor[i].waitFor(); 1243 if (servletsServerMonitor != null) 1244 { 1245 for (int i = 0; i < servletsServerMonitor.length; i++) 1246 servletsServerMonitor[i].waitFor(); 1247 } 1248 if (ejbServerMonitor != null) 1249 { 1250 for (int i = 0; i < ejbServerMonitor.length; i++) 1251 ejbServerMonitor[i].waitFor(); 1252 } 1253 } 1254 catch (Exception e) 1255 { 1256 System.out.println( 1257 "An error occured while waiting for remote processes termination (" 1258 + e.getMessage() 1259 + ")"); 1260 } 1261 1262 try 1264 { 1265 for (int i = 0; i < client.rubis.getRemoteClients().size(); i++) 1266 { 1267 client.getMonitoredData( 1268 (String ) client.rubis.getRemoteClients().get(i), 1269 tmpDir + "client" + (i + 1), 1270 reportDir); 1271 } 1272 1273 for (int i = 0; i < dbServerMonitor.length; i++) 1274 { 1275 client.getMonitoredData((String )client.rubis.getDBServerNames().get(i), 1276 tmpDir+"db_server"+i, 1277 reportDir); 1278 } 1279 1280 client.getMonitoredData(client.rubis.getWebServerName(), 1282 tmpDir + "web_server", 1283 reportDir); 1284 1285 client.getMonitoredData("localhost", 1287 tmpDir + "client0", 1288 reportDir); 1289 1290 if (cjdbcFlag) 1292 { 1293 client.getMonitoredData(client.rubis.getCJDBCServerName(), 1294 tmpDir + "cjdbc_server", 1295 reportDir); 1296 } 1297 1298 if (servletsServerMonitor != null) 1299 { 1300 for (int i = 0; i < servletsServerMonitor.length; i++) 1301 client.getMonitoredData((String )client.rubis.getServletsServerNames().get(i), 1302 tmpDir+"servlets_server"+i, 1303 reportDir); 1304 } 1305 if (ejbServerMonitor != null) 1306 { 1307 for (int i = 0; i < ejbServerMonitor.length; i++) 1308 client.getMonitoredData((String )client.rubis.getEJBServerNames().get(i), 1309 tmpDir+"ejb_server"+i, 1310 reportDir); 1311 } 1312 for (int i = 0; i < client.rubis.getRemoteClients().size(); i++) 1314 { 1315 client.getHTMLData((String ) client.rubis.getRemoteClients().get(i), 1316 tmpDir + "trace_client" + (i + 1) + ".html ", 1317 reportDir); 1318 client.getHTMLData((String ) client.rubis.getRemoteClients().get(i), 1319 tmpDir + "stat_client" + (i + 1) + ".html ", 1320 reportDir); 1321 } 1322 } 1323 catch (Exception e) 1324 { 1325 System.out.println( 1326 "An error occured while transferring log files (" 1327 + e.getMessage() 1328 + ")"); 1329 } 1330 1331 try 1333 { 1334 String [] cmd = null; 1335 if (client.rubis.getEJBServerNames().size() > 0) 1336 { 1337 cmd = new String [7]; 1338 cmd[0] = "bench/ejb_generate_graphs.sh"; 1339 } 1340 else if (client.rubis.getServletsServerNames().size() > 0) 1341 { 1342 cmd = new String [6]; 1343 cmd[0] = "bench/servlets_generate_graphs.sh"; 1344 } 1345 else 1346 { 1347 cmd = new String [5]; 1348 cmd[0] = "bench/generate_graphs.sh"; 1349 } 1350 cmd[1] = reportDir; 1351 cmd[2] = client.rubis.getGnuPlotTerminal(); 1352 cmd[3] = Integer.toString(client.rubis.getRemoteClients().size() + 1); 1353 cmd[4] = Integer.toString(client.rubis.getDBServerNames().size()); 1354 if (client.rubis.getServletsServerNames().size() > 0) 1355 cmd[5] = Integer.toString(client.rubis.getServletsServerNames().size()); 1356 if (client.rubis.getEJBServerNames().size() > 0) 1357 cmd[6] = Integer.toString(client.rubis.getEJBServerNames().size()); 1358 Process graph = Runtime.getRuntime().exec(cmd); 1359 BufferedReader read = new BufferedReader (new InputStreamReader (graph.getInputStream())); 1361 String msg; 1362 while ((msg = read.readLine()) != null) { 1363 } 1365 read.close(); 1366 graph.waitFor(); 1367 } 1368 catch (Exception e) 1369 { 1370 System.out.println( 1371 "An error occured while generating the graphs (" 1372 + e.getMessage() 1373 + ")"); 1374 } 1375 } 1376 1377 System.out.println("<br><A NAME=\"cpu_graph\"></A>"); 1378 System.out.println("<br><h3>CPU Usage graphs</h3><p>"); 1379 System.out.println("<TABLE>"); 1380 System.out.println( 1381 "<TR><TD><IMG SRC=\"cpu_busy." 1382 + client.rubis.getGnuPlotTerminal() 1383 + "\"><TD><IMG SRC=\"client_cpu_busy." 1384 + client.rubis.getGnuPlotTerminal() 1385 + "\">"); 1386 if (cjdbcFlag) 1387 { 1388 System.out.println( 1389 "<TR><TD><IMG SRC=\"cjdbc_server_cpu_busy." 1390 + client.rubis.getGnuPlotTerminal() 1391 + "\">"); 1392 } 1393 System.out.println( 1394 "<TR><TD><IMG SRC=\"cpu_idle." 1395 + client.rubis.getGnuPlotTerminal() 1396 + "\"><TD><IMG SRC=\"client_cpu_idle." 1397 + client.rubis.getGnuPlotTerminal() 1398 + "\">"); 1399 if (cjdbcFlag) 1400 { 1401 System.out.println( 1402 "<TR><TD><IMG SRC=\"cjdbc_server_cpu_idle." 1403 + client.rubis.getGnuPlotTerminal() 1404 + "\">"); 1405 } 1406 System.out.println( 1407 "<TR><TD><IMG SRC=\"cpu_user_kernel." 1408 + client.rubis.getGnuPlotTerminal() 1409 + "\"><TD><IMG SRC=\"client_cpu_user_kernel." 1410 + client.rubis.getGnuPlotTerminal() 1411 + "\">"); 1412 if (cjdbcFlag) 1413 { 1414 System.out.println( 1415 "<TR><TD><IMG SRC=\"cjdbc_server_cpu_user_kernel." 1416 + client.rubis.getGnuPlotTerminal() 1417 + "\">"); 1418 } 1419 System.out.println("</TABLE><p>"); 1420 1421 System.out.println("<br><A NAME=\"procs_graph\"></A>"); 1422 System.out.println("<TABLE>"); 1423 System.out.println("<br><h3>Processes Usage graphs</h3><p>"); 1424 System.out.println( 1425 "<TR><TD><IMG SRC=\"procs." 1426 + client.rubis.getGnuPlotTerminal() 1427 + "\"><TD><IMG SRC=\"client_procs." 1428 + client.rubis.getGnuPlotTerminal() 1429 + "\">"); 1430 if (cjdbcFlag) 1431 { 1432 System.out.println( 1433 "<TR><TD><IMG SRC=\"cjdbc_server_procs." 1434 + client.rubis.getGnuPlotTerminal() 1435 + "\">"); 1436 } 1437 System.out.println( 1438 "<TR><TD><IMG SRC=\"ctxtsw." 1439 + client.rubis.getGnuPlotTerminal() 1440 + "\"><TD><IMG SRC=\"client_ctxtsw." 1441 + client.rubis.getGnuPlotTerminal() 1442 + "\">"); 1443 if (cjdbcFlag) 1444 { 1445 System.out.println( 1446 "<TR><TD><IMG SRC=\"cjdbc_server_ctxtsw." 1447 + client.rubis.getGnuPlotTerminal() 1448 + "\">"); 1449 } 1450 System.out.println("</TABLE><p>"); 1451 1452 System.out.println("<br><A NAME=\"mem_graph\"></A>"); 1453 System.out.println("<br><h3>Memory Usage graph</h3><p>"); 1454 System.out.println("<TABLE>"); 1455 System.out.println( 1456 "<TR><TD><IMG SRC=\"mem_usage." 1457 + client.rubis.getGnuPlotTerminal() 1458 + "\"><TD><IMG SRC=\"client_mem_usage." 1459 + client.rubis.getGnuPlotTerminal() 1460 + "\">"); 1461 if (cjdbcFlag) 1462 { 1463 System.out.println( 1464 "<TR><TD><IMG SRC=\"cjdbc_server_mem_usage." 1465 + client.rubis.getGnuPlotTerminal() 1466 + "\">"); 1467 } 1468 System.out.println( 1469 "<TR><TD><IMG SRC=\"mem_cache." 1470 + client.rubis.getGnuPlotTerminal() 1471 + "\"><TD><IMG SRC=\"client_mem_cache." 1472 + client.rubis.getGnuPlotTerminal() 1473 + "\">"); 1474 if (cjdbcFlag) 1475 { 1476 System.out.println( 1477 "<TR><TD><IMG SRC=\"cjdbc_server_mem_cache." 1478 + client.rubis.getGnuPlotTerminal() 1479 + "\">"); 1480 } 1481 System.out.println("</TABLE><p>"); 1482 1483 System.out.println("<br><A NAME=\"disk_graph\"></A>"); 1484 System.out.println("<br><h3>Disk Usage graphs</h3><p>"); 1485 System.out.println("<TABLE>"); 1486 System.out.println( 1487 "<TR><TD><IMG SRC=\"disk_rw_req." 1488 + client.rubis.getGnuPlotTerminal() 1489 + "\"><TD><IMG SRC=\"client_disk_rw_req." 1490 + client.rubis.getGnuPlotTerminal() 1491 + "\">"); 1492 if (cjdbcFlag) 1493 { 1494 System.out.println( 1495 "<TR><TD><IMG SRC=\"cjdbc_server_disk_rw_req." 1496 + client.rubis.getGnuPlotTerminal() 1497 + "\">"); 1498 } 1499 System.out.println( 1500 "<TR><TD><IMG SRC=\"disk_tps." 1501 + client.rubis.getGnuPlotTerminal() 1502 + "\"><TD><IMG SRC=\"client_disk_tps." 1503 + client.rubis.getGnuPlotTerminal() 1504 + "\">"); 1505 if (cjdbcFlag) 1506 { 1507 System.out.println( 1508 "<TR><TD><IMG SRC=\"cjdbc_server_disk_tps." 1509 + client.rubis.getGnuPlotTerminal() 1510 + "\">"); 1511 } 1512 System.out.println("</TABLE><p>"); 1513 1514 System.out.println("<br><A NAME=\"net_graph\"></A>"); 1515 System.out.println("<br><h3>Network Usage graphs</h3><p>"); 1516 System.out.println("<TABLE>"); 1517 System.out.println( 1518 "<TR><TD><IMG SRC=\"net_rt_byt." 1519 + client.rubis.getGnuPlotTerminal() 1520 + "\"><TD><IMG SRC=\"client_net_rt_byt." 1521 + client.rubis.getGnuPlotTerminal() 1522 + "\">"); 1523 if (cjdbcFlag) 1524 { 1525 System.out.println( 1526 "<TR><TD><IMG SRC=\"cjdbc_server_net_rt_byt." 1527 + client.rubis.getGnuPlotTerminal() 1528 + "\">"); 1529 } 1530 System.out.println( 1531 "<TR><TD><IMG SRC=\"net_rt_pack." 1532 + client.rubis.getGnuPlotTerminal() 1533 + "\"><TD><IMG SRC=\"client_net_rt_pack." 1534 + client.rubis.getGnuPlotTerminal() 1535 + "\">"); 1536 if (cjdbcFlag) 1537 { 1538 System.out.println( 1539 "<TR><TD><IMG SRC=\"cjdbc_server_net_rt_pack." 1540 + client.rubis.getGnuPlotTerminal() 1541 + "\">"); 1542 } 1543 System.out.println( 1544 "<TR><TD><IMG SRC=\"socks." 1545 + client.rubis.getGnuPlotTerminal() 1546 + "\"><TD><IMG SRC=\"client_socks." 1547 + client.rubis.getGnuPlotTerminal() 1548 + "\">"); 1549 if (cjdbcFlag) 1550 { 1551 System.out.println( 1552 "<TR><TD><IMG SRC=\"cjdbc_server_socks." 1553 + client.rubis.getGnuPlotTerminal() 1554 + "\">"); 1555 } 1556 System.out.println("</TABLE><p>"); 1557 1558 if (isMainClient) 1559 { 1560 try 1562 { 1563 String [] cmd = new String [6]; 1564 cmd[0] = "bench/compute_global_stats.awk"; 1565 cmd[1] = "-v"; 1566 cmd[2] = "path=" + reportDir; 1567 cmd[3] = "-v"; 1568 cmd[4] = 1569 "nbscript=" 1570 + Integer.toString(client.rubis.getRemoteClients().size() + 1); 1571 cmd[5] = reportDir + "stat_client0.html"; 1572 Process computeStats = Runtime.getRuntime().exec(cmd); 1573 computeStats.waitFor(); 1574 } 1575 catch (Exception e) 1576 { 1577 System.out.println( 1578 "An error occured while generating the graphs (" 1579 + e.getMessage() 1580 + ")"); 1581 } 1582 } 1583 1584 Runtime.getRuntime().exit(0); 1585 } 1586 1587} 1588 | Popular Tags |