Christian-Josef Schrattenthaler said:
Hi!
I am a Java-Newbie, and I am playing around with my first program.
I want to get some hardware information, and in the newsgroups I was
reprimand to Hyperic Sigar.
Now I tried some hours to get the needed information, but I didn't
understand how Sigar works.
I tried:
---
import java.util.Map;
import org.hyperic.sigar.CpuInfo;
import org.hyperic.sigar.FileSystem;
import org.hyperic.sigar.Sigar;
public class SystemInfo {
public static void main(String[] args) {
System.out.println(Sigar.VERSION_STRING);
System.out.println("**********");
Map ci = new CpuInfo().toMap();
System.out.println(ci.toString());
System.out.println("**********");
Map fs = new FileSystem().toMap();
System.out.println(fs.toString());
System.out.println("**********");
}
}
---
But I get no Information:
---
1.2.0.0
**********
{Model=null, CacheSize=0, Mhz=0, Vendor=null}
**********
{Type=0, DirName=null, TypeName=null, DevName=null, SysTypeName=null,
Flags=0}
**********
---
Please can anyone tell me how to use Sigar in my Java project?
Thanks & greetings,
Christian.
I do not want to install this product. It is to big. I am running on
windoze XP SP 2. I can run the dos cmd line program sigar:
java -jar sigar.jar
This required the few other jar files and a DLL to be in the classpath
and path:
sigar.jar
bcel-5.1.jar
junit.jar
log4j.jar
sigar-x86-winnt.dll
I suspect that you will have to have the sigar-x86-winnt.dll in
java.library.path to get the actual information to be passed back to
your program ala the sigar Class. This is naturally for windows. Not
sure about the other platforms. The doc says that there are examples
under java\examples. I did not find then but may not have the correct
download.
Sample cmd line output:
==> sigar help
Available commands:
alias - Create alias command
cpuinfo - Display cpu information
df - Report filesystem disk space usage
du - Display usage for a directory recursively
free - Display information about free and used memory
get - Get system properties
help - Gives help on shell commands
ifconfig - Network interface information
iostat - Report filesystem disk i/o
kill - Send signal to a process
mps - Show multi process status
netinfo - Display network info
netstat - Display network connections
pargs - Show process command line arguments
penv - Show process environment
pfile - Display process file info
pinfo - Display all process info
pmodules - Display process module info
ps - Show process status
ptql - Run process table query
quit - Terminate the shell
route - Kernel IP routing table
service - Windows service commands
set - Set system properties
sleep - Delay execution for the a number of seconds
source - Read a file, executing the contents
sysinfo - Display system information
test - Run sigar tests
time - Time command
ulimit - Display system resource limits
uptime - Display how long the system has been running
version - Display sigar and system version info
who - Show who is logged on
==> sigar cpuinfo
1 total CPUs..
Vendor........Intel
Model.........x86 Family 6 Model 8 Stepping 6
Mhz...........848
CPU 0.........
User Time.....100.0%
Sys Time......0.0%
Idle Time.....0.0%
Wait Time.....0.0%
Nice Time.....0.0%
Combined......100.0%
Totals........
User Time.....N%
Sys Time......N%
Idle Time.....N%
Wait Time.....N%
Nice Time.....N%
==> sigar free
total used free
Mem: 654880 520484 134396
Swap: 1104428 883924 220504
RAM: 640MB
sigar df
Filesystem Size Used Avail Use% Mounted on Type
A:\ 0 0 0 - A:\ none/none
C:\ 28G 24G 4.2G 86% C:\ NTFS/local
D:\ 695M 695M 0 100% D:\ CDFS/cdrom
E:\ 0 0 0 - E:\ cdrom/cdrom
==> sigar sysinfo
Sigar version.......java=1.2.0.0, native=1.2.0.0
Build date..........java=07/15/2006 05:22 PM, native=07/15/2006 05:22 PM
Archlib.............sigar-x86-winnt.dll
Current fqdn........WEConsultants.cmts.mtp.ptd.net
Hostname............WEConsultants
Current user........Ed Taylor
OS description......Microsoft Windows XP
OS name.............Win32
OS arch.............x86
OS version..........5.1
OS patch level......Service Pack 2
OS vendor...........Microsoft
OS vendor version...XP
OS code name........Whistler
OS data model.......32
OS cpu endian.......little
Java vm version.....1.5.0_07-b03
Java vm vendor......Sun Microsystems Inc.
Java home...........C:\Program Files\Java\jre1.5.0_07
4:51 PM up 21:39, (load average unknown)
File Systems.........[A:\, C:\, D:\, E:\]
Network Interfaces...[eth0, lo0]
System resource limits:
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.phpnet.us
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.phpnet.us
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)