11 changed files with 151 additions and 13 deletions

No files matched your search

+4 -4
View File
@@ -824,22 +824,22 @@ use vars qw(%classes %cmds);
FileSystemUsage => [
{
name => 'total', type => 'Long',
desc => 'Total bytes of filesystem',
desc => 'Total Kbytes of filesystem',
plat => '*'
},
{
name => 'free', type => 'Long',
desc => 'Total free bytes on filesystem',
desc => 'Total free Kbytes on filesystem',
plat => '*'
},
{
name => 'used', type => 'Long',
desc => 'Total used bytes on filesystem',
desc => 'Total used Kbytes on filesystem',
plat => '*'
},
{
name => 'avail', type => 'Long',
desc => 'Total free bytes on filesystem available to caller',
desc => 'Total free Kbytes on filesystem available to caller',
plat => '*'
},
{
+6 -3
View File
@@ -281,6 +281,8 @@
<include name="sigar.h"/>
<include name="sigar_fileinfo.h"/>
<include name="sigar_format.h"/>
<include name="sigar_ptql.h"/>
<include name="sigar_log.h"/>
</fileset>
</copy>
</target>
@@ -445,7 +447,8 @@
<include name="lib/*.lib"/>
</fileset>
<fileset dir=".">
<include name="lib/*.jar"/>
<include name="lib/junit.jar"/>
<include name="lib/log4j.jar"/>
</fileset>
</copy>
@@ -549,8 +552,8 @@
<include name="bindings/java/.classpath"/>
<include name="bindings/java/.project"/>
<include name="bindings/java/.sigar_shellrc"/>
<include name="bindings/java/lib/*.jar"/>
<include name="bindings/java/lib/*.dll"/>
<include name="bindings/java/lib/log4j.jar"/>
<include name="bindings/java/lib/junit.jar"/>
<exclude name="**/.svn/**"/>
<exclude name="bindings/java/build/**"/>
</fileset>
+26 -1
View File
@@ -106,6 +106,19 @@ JNIEXPORT jint SIGAR_JNI(win32_RegistryKey_RegLoadKey)
return lResult;
}
/* http://msdn.microsoft.com/en-us/library/aa384129(VS.85).aspx */
#ifndef KEY_WOW64_64KEY
#define KEY_WOW64_64KEY 0x0100
#endif
#ifndef KEY_WOW64_32KEY
#define KEY_WOW64_32KEY 0x0200
#endif
static DWORD RegOpenOpts[] = {
KEY_WOW64_32KEY,
KEY_WOW64_64KEY
};
JNIEXPORT jlong SIGAR_JNI(win32_RegistryKey_RegOpenKey)
(JNIEnv *env, jclass, jlong hkey, jstring subkey)
{
@@ -113,6 +126,7 @@ JNIEXPORT jlong SIGAR_JNI(win32_RegistryKey_RegOpenKey)
jsize len = env->GetStringLength(subkey);
LPTSTR lpSubkey = (LPTSTR)env->GetStringChars(subkey, NULL);
LPTSTR copy;
int i;
/* required under IBM/WebSphere 4.0 for certain keys */
if (lpSubkey[len] != '\0') {
@@ -122,7 +136,18 @@ JNIEXPORT jlong SIGAR_JNI(win32_RegistryKey_RegOpenKey)
else {
copy = lpSubkey;
}
RegOpenKey((HKEY)hkey, copy, &hkeyResult);
/* try both flags so 32-bit apps can access registry entries
of 64-bit apps and vice-versa */
for (i=0; i<sizeof(RegOpenOpts)/sizeof(RegOpenOpts[0]); i++) {
DWORD status =
RegOpenKeyEx((HKEY)hkey, copy,
0, KEY_READ|RegOpenOpts[i],
&hkeyResult);
if (status == ERROR_SUCCESS) {
break;
}
}
env->ReleaseStringChars(subkey, (const jchar *)lpSubkey);
if (copy != lpSubkey) {
@@ -18,6 +18,7 @@
package org.hyperic.sigar.test;
import java.util.Date;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.Uptime;
@@ -32,6 +33,9 @@ public class TestUptime extends SigarTestCase {
Uptime uptime = sigar.getUptime();
long now = System.currentTimeMillis();
traceln("\nboottime=" +
new Date(now - (long)uptime.getUptime()*1000));
assertTrue(uptime.getUptime() > 0);
}
}
@@ -102,6 +102,10 @@ public class TestEventLog extends SigarTestCase {
EventLog log = new EventLog();
log.open(logname);
if (log.getNumberOfRecords() == 0) {
log.close();
return 0; //else log.getOldestRecord() throws Exception
}
int oldestRecord = log.getOldestRecord();
int numRecords = log.getNumberOfRecords();
traceln("oldest=" + oldestRecord +
@@ -18,10 +18,12 @@
package org.hyperic.sigar.win32.test;
import junit.framework.TestCase;
import java.util.ArrayList;
import org.hyperic.sigar.test.SigarTestCase;
import org.hyperic.sigar.win32.RegistryKey;
public class TestRegistryKey extends TestCase {
public class TestRegistryKey extends SigarTestCase {
private static final boolean TEST_WRITE = false;
@@ -37,6 +39,71 @@ public class TestRegistryKey extends TestCase {
software.close();
}
public void testHardwareValues() throws Exception {
RegistryKey hw =
RegistryKey.LocalMachine.openSubKey("HARDWARE\\DESCRIPTION\\System");
try {
ArrayList values = new ArrayList();
hw.getMultiStringValue("SystemBiosVersion", values);
assertGtZeroTrace("SystemBiosVersion.size()", values.size());
traceln("SystemBiosVersion=" + values);
} catch (Exception e) {}
RegistryKey cpu0 = hw.openSubKey("CentralProcessor\\0");
String cpu = cpu0.getStringValue("ProcessorNameString");
assertLengthTrace("cpu0", cpu);
cpu0.close();
hw.close();
}
public void testSoftwareValues() throws Exception {
RegistryKey ms =
RegistryKey.LocalMachine.openSubKey("SOFTWARE\\Microsoft");
RegistryKey msmq = null;
try {
msmq = ms.openSubKey("MSMQ\\Parameters");
} catch (Exception e) { /*not installed - ok*/ }
if (msmq != null) {
traceln("MSMQ...");
if (msmq.getSubKeyNames().length > 0) {
try {
String build = msmq.getStringValue("CurrentBuild");
assertLengthTrace("CurrentBuild", build);
int id = msmq.getIntValue("SeqID");
assertGtZeroTrace("SeqID", id);
} catch (Exception e) {}
}
msmq.close();
}
RegistryKey sql = null;
try {
sql = ms.openSubKey("Microsoft SQL Server\\MSSQL.1\\Setup");
} catch (Exception e) { /*not installed - ok*/ }
if (sql != null) {
traceln("MsSQL...");
try {
String edition = sql.getStringValue("Edition");
assertLengthTrace("Edition", edition);
} catch (Exception e) {}
sql.close();
}
ms.close();
final String TC =
"SOFTWARE\\Apache Software Foundation\\Procrun 2.0\\Tomcat6\\Parameters\\Java";
try {
RegistryKey tc =
RegistryKey.LocalMachine.openSubKey(TC);
traceln("Tomcat6...");
ArrayList values = new ArrayList();
tc.getMultiStringValue("Options", values);
assertGtZeroTrace("Options.size()", values.size());
traceln("Options=" + values);
tc.close();
} catch (Exception e) {}
}
//dont want to be writing to the registry
public void testRegistryWrite() throws Exception {
if (!TEST_WRITE) {
+1 -1
View File
@@ -1,6 +1,6 @@
copyright.year=2004-2008
version.major=1
version.minor=6
version.maint=0
version.maint=1
version.build=0
+1
View File
@@ -37,6 +37,7 @@ typedef sigar_proc_cred_name_t * Sigar__ProcCredName;
typedef sigar_file_attrs_t * Sigar__FileAttrs;
typedef sigar_cpu_t * Sigar__Cpu;
typedef sigar_cpu_info_t * Sigar__CpuInfo;
typedef sigar_cpu_perc_t * Sigar__CpuPerc;
typedef sigar_net_interface_config_t * Sigar__NetInterfaceConfig;
typedef sigar_swap_t * Sigar__Swap;
typedef sigar_proc_state_t * Sigar__ProcState;
+1
View File
@@ -14,6 +14,7 @@ Sigar::ProcCredName T_PTROBJ
Sigar::FileAttrs T_PTROBJ
Sigar::Cpu T_PTROBJ
Sigar::CpuInfo T_PTROBJ
Sigar::CpuPerc T_PTROBJ
Sigar::NetInterfaceConfig T_PTROBJ
Sigar::Swap T_PTROBJ
Sigar::ProcState T_PTROBJ
+2
View File
@@ -270,6 +270,8 @@ static VALUE rb_sigar_cpu_info_list(VALUE obj)
return RETVAL;
}
static VALUE rb_cSigarCpuPerc;
static VALUE rb_cSigarFileSystem;
static VALUE rb_sigar_file_system_list(VALUE obj)
+33 -2
View File
@@ -29,6 +29,7 @@
#define PERFBUF_SIZE 8192
#define PERF_TITLE_PROC 230
#define PERF_TITLE_SYS_KEY "2"
#define PERF_TITLE_MEM_KEY "4"
#define PERF_TITLE_PROC_KEY "230"
#define PERF_TITLE_CPU_KEY "238"
@@ -975,11 +976,41 @@ SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar,
}
}
#define PERF_TITLE_UPTIME_KEY 674 /* System Up Time */
SIGAR_DECLARE(int) sigar_uptime_get(sigar_t *sigar,
sigar_uptime_t *uptime)
{
uptime->uptime = GetTickCount() / 1000;
return SIGAR_OK;
int status;
PERF_OBJECT_TYPE *object =
get_perf_object_inst(sigar, PERF_TITLE_SYS_KEY, 0, &status);
PERF_INSTANCE_DEFINITION *inst;
PERF_COUNTER_DEFINITION *counter;
BYTE *data;
DWORD i;
if (!object) {
return status;
}
data = (BYTE *)((BYTE *)object + object->DefinitionLength);
for (i=0, counter = PdhFirstCounter(object);
i<object->NumCounters;
i++, counter = PdhNextCounter(counter))
{
if (counter->CounterNameTitleIndex == PERF_TITLE_UPTIME_KEY) {
DWORD offset = counter->CounterOffset;
LONGLONG time = object->PerfTime.QuadPart;
LONGLONG freq = object->PerfFreq.QuadPart;
LONGLONG counter = *((LONGLONG *)(data + offset));
uptime->uptime = (time - counter) / freq;
return SIGAR_OK;
}
}
/* http://msdn.microsoft.com/en-us/library/ms724408.aspx */
return GetTickCount() / 1000;
}
/*