Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: To get graph of System performance in java

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post To get graph of System performance in java

    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.InputStreamReader;
    import java.util.*;
     
    public class psk {
      private psk() {  }
     
      public static List<String> listRunningProcesses() {
        List<String> processList = new ArrayList<String>();
        try {
     
            File file = File.createTempFile("realhowto",".vbs");
            file.deleteOnExit();
            FileWriter fw = new java.io.FileWriter(file);
     
            String vbs = "Set WshShell = WScript.CreateObject(\"WScript.Shell\")\n"
                       + "Set locator = CreateObject(\"WbemScripting.SWbemLocator\")\n"
                       + "Set service = locator.ConnectServer()\n"
                       + "Set processes = service.ExecQuery _\n"
                       + " (\"select name from Win32_Process\")\n"
                       + "For Each process in processes\n"
                       + "wscript.echo process.Name \n"
                       + "Next\n"
                       + "Set WSHShell = Nothing\n";
     
            fw.write(vbs);
            fw.close();
            Process p = Runtime.getRuntime().exec("cscript //NoLogo " + file.getPath());
            BufferedReader input =
                new BufferedReader
                  (new InputStreamReader(p.getInputStream()));
            String line;
            while ((line = input.readLine()) != null) {
                processList.add(line);
            }
            input.close();
        }
        catch(Exception e){
            e.printStackTrace();
        }
        return processList;
      }
     
      public static void main(String[] args){
        List<String> processes = VBSUtils.listRunningProcesses();
        String result = "";
     
        Iterator<String> it = processes.iterator();
        int i = 0;
        while (it.hasNext()) {
           result += it.next() +"";
           i++;
           if (i==10) {
               result += "\n";
               i = 0;
           }
        }
        msgBox("Running processes :  \n\n"+ result);
      }
     
      public static void msgBox(String msg) {
        javax.swing.JOptionPane.showConfirmDialog((java.awt.Component)
           null, msg, "VBSUtils", javax.swing.JOptionPane.DEFAULT_OPTION);
      }
    }
    I can get Process list,but i need cpu,memory & disk usage in graph format pls help
    Last edited by pbrockway2; March 2nd, 2013 at 12:41 AM. Reason: code tags added


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: To get graph of System performance in java

    Also at javaforums.org.

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: To get graph of System performance in java

    no i couldnt find

Similar Threads

  1. Mysql query performance issue in java batch
    By siva.wins in forum JDBC & Databases
    Replies: 3
    Last Post: January 9th, 2013, 12:32 PM
  2. How to speed up the performance of the java application
    By Sathiyan in forum Java Theory & Questions
    Replies: 4
    Last Post: December 2nd, 2011, 02:09 AM
  3. Java Bar graph takes user input to create graph?
    By kenjiro310 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 31st, 2011, 07:37 AM
  4. Java Network performance analyser program help
    By Tark221 in forum Java Theory & Questions
    Replies: 4
    Last Post: March 22nd, 2011, 01:02 PM
  5. Replies: 1
    Last Post: October 7th, 2008, 07:35 AM