Solved

Getting System Information of server machine.... disk info. etc.

Posted on 2002-03-19
4
168 Views
Last Modified: 2010-03-31
Hi

I have a JSP utility which runs on tomcat and also has a backend Java process which utilises a MySQL DB. Now I am building some pretty large tables of data. And I want to be able to check via the web server the space available on disk, I'd also like to check other things like memory usage and system start time etc.

Now the memory usage one I can get from the system class (along with OS etc. ) however I cannot find a way to get disk info.

Any help would be grrreeaaattt

cheers

LK--<

[ I have looked at jconfig and a few others but they are not what I want/need :(  ]
0
Comment
Question by:LizardKing
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 6879782
There is no standard way to get it. On windows you can use something like this:
Process p = Runtime.getRuntime().exec("cmd /c dir c:");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
String freeSpace = "";
while ((line = br.readLine()) != null) {
  if (line.indexOf("bytes free") > -1) {
    int start = line.indexOf("dir(s)") + 7;
    int end = line.indexOf("bytes free", start);
    freeSpace = line.substring(start, end).trim();
    break;
  }
}
System.out.println("Free space: " + freeSpace);
0
 

Author Comment

by:LizardKing
ID: 6882249
That is a nice way of getting the info. however theres a few flaws in that this will only work on windows and what if there are multiple hard disks or the disk is not c: it is g: etc.

Cheers

LK--<
0
 
LVL 9

Accepted Solution

by:
Venci75 earned 25 total points
ID: 6882259
You can check the value of the system property "os.name" in order to determine the operating system:
System.getProperty("os.name");      

For unix you can use
Process p = Runtime.getRuntime().exec("df -k");
and process the command output in a different way.

I know - it is very incovenient - but unfortunately - there is no standard way to do this :(
0
 

Author Comment

by:LizardKing
ID: 6883089
I'm having a look at JConfig which I believe lets u do what I want its only $99 so its not too expensive , only thing is I cannot get it to work in my JSP :( , oh well I'll keep plugging at it

Oh you can have the points for your helpful comments

Cheers

LK--<
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
null output 3 59
printf performancy 11 104
Using jdbcTemplate.batchUpdate to improve INSERT performance 6 33
Java Inheritance super keyword use 8 72
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question