Who could help me with Hyperic Sigar?

  • Thread starter Christian-Josef Schrattenthaler
  • Start date
C

Christian-Josef Schrattenthaler

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

IchBin

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 DLL in your 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 oputput:

==> 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-)
 
I

IchBin

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-)
 
C

Christian-Josef Schrattenthaler

Hello together!

I did it by myself:

1. True Homepage of Hyperic Sigar: http://sigar.hyperic.com

2. True download under:
https://sourceforge.net/project/showfiles.php?group_id=172552

3. I downloaded the file hyperic-sigar-1.2.0.0.zip. I unzipped the file,
and copied all files from the folder "hyperic-sigar-1.2.0.0\sigar-bin\lib"
(excepted: .sigar_shellrc, bcel-5.1.jar, junit.jar, log4j.jar und pdh.dll).

4. After that I created a little Test-Program (I know it is not beatiful
and good, but I only needed a Test for how to use Hyperic Sigar). And it
worked!

***
import java.util.Map;

import org.hyperic.sigar.CpuInfo;
import org.hyperic.sigar.FileSystem;
import org.hyperic.sigar.Mem;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;

public class CJSSystemInformations {

private static Sigar sigar = new Sigar();

public static void main(String[] args) {
getInformationsAboutCPU();
getInformationsAboutMemory();
getInformationsAboutFileSystem();
}

/* Method to get Informations about the CPU(s): */
public static void getInformationsAboutCPU() {
System.out.println("************************************");
System.out.println("*** Informations about the CPUs: ***");
System.out.println("************************************\n");

CpuInfo[] cpuinfo = null;
try {
cpuinfo = sigar.getCpuInfoList();
} catch (SigarException se) {
se.printStackTrace();
}

System.out.println("---------------------");
System.out.println("Sigar found " + cpuinfo.length + " CPU(s)!");
System.out.println("---------------------");

for (int i = 0; i < cpuinfo.length; i++) {
Map map = cpuinfo.toMap();
System.out.println("CPU " + i + ": " + map);
}

System.out.println("\n************************************\n");
}

/* Method to get Informations about the Memory: */
public static void getInformationsAboutMemory() {
System.out.println("**************************************");
System.out.println("*** Informations about the Memory: ***");
System.out.println("**************************************\n");

Mem mem = null;
try {
mem = sigar.getMem();
} catch (SigarException se) {
se.printStackTrace();
}

Map map = mem.toMap();
System.out.println(map);

System.out.println("\nPretty printed:");
System.out.println("---------------");
System.out.println("Actual total free system memory: "
+ mem.getActualFree() / 1024 + " KB");
System.out.println("Actual total used system memory: "
+ mem.getActualUsed() / 1024 + " KB");
System.out.println("Total free system memory ......: " + mem.getFree()
/ 1024 + " KB");
System.out.println("System Random Access Memory....: " + mem.getRam()
+ " MB");
System.out.println("Total system memory............: " + mem.getTotal()
/ 1024 + " KB");
System.out.println("Total used system memory.......: " + mem.getUsed()
/ 1024 + " KB");

System.out.println("\n**************************************\n");
}

/* Method to get Informations about the FileSystem: */
public static void getInformationsAboutFileSystem() {
System.out.println("******************************************");
System.out.println("*** Informations about the FileSystem: ***");
System.out.println("******************************************\n");

FileSystem[] filesystem = null;
try {
filesystem = sigar.getFileSystemList();
} catch (SigarException se) {
se.printStackTrace();
}

System.out.println("---------------------");
System.out.println("Sigar found " + filesystem.length + " drives!");
System.out.println("---------------------");

for (int i = 0; i < filesystem.length; i++) {
Map map = filesystem.toMap();
System.out.println("drive " + i + ": " + map);
}

System.out.println("\n******************************************");
}

}
***

I din't find anything about using Hyperic Sigar. And I didn't get any
useful information about their forum, so I thougt, I post my result hoping
it could help anyone...

Greetings,
Christian.
 
I

IchBin

Christian-Josef Schrattenthaler said:
Hello together!

I did it by myself:

1. True Homepage of Hyperic Sigar: http://sigar.hyperic.com

2. True download under:
https://sourceforge.net/project/showfiles.php?group_id=172552

3. I downloaded the file hyperic-sigar-1.2.0.0.zip. I unzipped the file,
and copied all files from the folder "hyperic-sigar-1.2.0.0\sigar-bin\lib"
(excepted: .sigar_shellrc, bcel-5.1.jar, junit.jar, log4j.jar und pdh.dll).

4. After that I created a little Test-Program (I know it is not beatiful
and good, but I only needed a Test for how to use Hyperic Sigar). And it
worked!
[snip code]

I din't find anything about using Hyperic Sigar. And I didn't get any
useful information about their forum, so I thougt, I post my result hoping
it could help anyone...

Greetings,
Christian.

Thanks Christian for finding that download. It all makes sense now. I
like their examples and information. Much more information than the Java
Properties Class. You are right, to run all need the Java sigar.jar.

Also the sigar-x86-winnt.dll is required to run the product on windows.
If the DLL is not available you see an error:

"org.hyperic.sigar.SigarException: no sigar-x86-winnt.dll in
java.library.path"

The other jar files (log4j.jar, bcel-5.1.jar, junit.jar) are used for
Shell.java program. This is the cmdline program.

Not sure what the pdh.DLL is used for. My guess is for perl.

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-)
 
C

Christian-Josef Schrattenthaler

Not sure what the pdh.DLL is used for. My guess is for perl.

No, look to the properties of pdh.dll, it is from Microsoft. I searched for
this file on my Windows XP ServicePack2 System, and I found it in the
C:\WINDOWS\system32 directory. So I think, it should be on every modern
Windows system, and I don't need to ship it with my program.

Greetings,
Christian.
 
I

IchBin

Christian-Josef Schrattenthaler said:
No, look to the properties of pdh.dll, it is from Microsoft. I searched for
this file on my Windows XP ServicePack2 System, and I found it in the
C:\WINDOWS\system32 directory. So I think, it should be on every modern
Windows system, and I don't need to ship it with my program.

Greetings,
Christian.

You are right. I should have tracked it down and not say anything
because I would be guessing.

Well the PDH stands for 'Performance Data Helper'. Windows requires it
and is used when monitoring your machine's performance. The file
pdh.dll, contains program code used for the creation of log files and
other measurement methods. I only saw reference for Windows NT 4.0 and
Windows 2000. Naturally it must have some use for XP since it is on the
system I guess. But then I am guessing again.. lol

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-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top