Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26f2977533 | ||
|
|
b3b194e97b | ||
|
|
f2c9cc9d61 | ||
|
|
b1890e438d | ||
|
|
4424c48981 | ||
|
|
a6b5f3f30b | ||
|
|
61327b9034 | ||
|
|
7ac30e778a | ||
|
|
9b4dd7b263 | ||
|
|
29d57da8a9 | ||
|
|
898e933070 | ||
|
|
19a76d5fa1 | ||
|
|
4f4805ffd1 | ||
|
|
5c905c8e64 |
No files matched your search
@@ -824,22 +824,22 @@ use vars qw(%classes %cmds);
|
|||||||
FileSystemUsage => [
|
FileSystemUsage => [
|
||||||
{
|
{
|
||||||
name => 'total', type => 'Long',
|
name => 'total', type => 'Long',
|
||||||
desc => 'Total bytes of filesystem',
|
desc => 'Total Kbytes of filesystem',
|
||||||
plat => '*'
|
plat => '*'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name => 'free', type => 'Long',
|
name => 'free', type => 'Long',
|
||||||
desc => 'Total free bytes on filesystem',
|
desc => 'Total free Kbytes on filesystem',
|
||||||
plat => '*'
|
plat => '*'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name => 'used', type => 'Long',
|
name => 'used', type => 'Long',
|
||||||
desc => 'Total used bytes on filesystem',
|
desc => 'Total used Kbytes on filesystem',
|
||||||
plat => '*'
|
plat => '*'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name => 'avail', type => 'Long',
|
name => 'avail', type => 'Long',
|
||||||
desc => 'Total free bytes on filesystem available to caller',
|
desc => 'Total free Kbytes on filesystem available to caller',
|
||||||
plat => '*'
|
plat => '*'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -281,6 +281,8 @@
|
|||||||
<include name="sigar.h"/>
|
<include name="sigar.h"/>
|
||||||
<include name="sigar_fileinfo.h"/>
|
<include name="sigar_fileinfo.h"/>
|
||||||
<include name="sigar_format.h"/>
|
<include name="sigar_format.h"/>
|
||||||
|
<include name="sigar_ptql.h"/>
|
||||||
|
<include name="sigar_log.h"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
</target>
|
</target>
|
||||||
@@ -445,7 +447,8 @@
|
|||||||
<include name="lib/*.lib"/>
|
<include name="lib/*.lib"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
<fileset dir=".">
|
<fileset dir=".">
|
||||||
<include name="lib/*.jar"/>
|
<include name="lib/junit.jar"/>
|
||||||
|
<include name="lib/log4j.jar"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
@@ -549,8 +552,8 @@
|
|||||||
<include name="bindings/java/.classpath"/>
|
<include name="bindings/java/.classpath"/>
|
||||||
<include name="bindings/java/.project"/>
|
<include name="bindings/java/.project"/>
|
||||||
<include name="bindings/java/.sigar_shellrc"/>
|
<include name="bindings/java/.sigar_shellrc"/>
|
||||||
<include name="bindings/java/lib/*.jar"/>
|
<include name="bindings/java/lib/log4j.jar"/>
|
||||||
<include name="bindings/java/lib/*.dll"/>
|
<include name="bindings/java/lib/junit.jar"/>
|
||||||
<exclude name="**/.svn/**"/>
|
<exclude name="**/.svn/**"/>
|
||||||
<exclude name="bindings/java/build/**"/>
|
<exclude name="bindings/java/build/**"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
|
|||||||
@@ -106,6 +106,19 @@ JNIEXPORT jint SIGAR_JNI(win32_RegistryKey_RegLoadKey)
|
|||||||
return lResult;
|
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)
|
JNIEXPORT jlong SIGAR_JNI(win32_RegistryKey_RegOpenKey)
|
||||||
(JNIEnv *env, jclass, jlong hkey, jstring subkey)
|
(JNIEnv *env, jclass, jlong hkey, jstring subkey)
|
||||||
{
|
{
|
||||||
@@ -113,6 +126,7 @@ JNIEXPORT jlong SIGAR_JNI(win32_RegistryKey_RegOpenKey)
|
|||||||
jsize len = env->GetStringLength(subkey);
|
jsize len = env->GetStringLength(subkey);
|
||||||
LPTSTR lpSubkey = (LPTSTR)env->GetStringChars(subkey, NULL);
|
LPTSTR lpSubkey = (LPTSTR)env->GetStringChars(subkey, NULL);
|
||||||
LPTSTR copy;
|
LPTSTR copy;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* required under IBM/WebSphere 4.0 for certain keys */
|
/* required under IBM/WebSphere 4.0 for certain keys */
|
||||||
if (lpSubkey[len] != '\0') {
|
if (lpSubkey[len] != '\0') {
|
||||||
@@ -122,7 +136,18 @@ JNIEXPORT jlong SIGAR_JNI(win32_RegistryKey_RegOpenKey)
|
|||||||
else {
|
else {
|
||||||
copy = lpSubkey;
|
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);
|
env->ReleaseStringChars(subkey, (const jchar *)lpSubkey);
|
||||||
if (copy != lpSubkey) {
|
if (copy != lpSubkey) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package org.hyperic.sigar.test;
|
package org.hyperic.sigar.test;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import org.hyperic.sigar.Sigar;
|
import org.hyperic.sigar.Sigar;
|
||||||
import org.hyperic.sigar.Uptime;
|
import org.hyperic.sigar.Uptime;
|
||||||
|
|
||||||
@@ -32,6 +33,9 @@ public class TestUptime extends SigarTestCase {
|
|||||||
|
|
||||||
Uptime uptime = sigar.getUptime();
|
Uptime uptime = sigar.getUptime();
|
||||||
|
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
traceln("\nboottime=" +
|
||||||
|
new Date(now - (long)uptime.getUptime()*1000));
|
||||||
assertTrue(uptime.getUptime() > 0);
|
assertTrue(uptime.getUptime() > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,6 +102,10 @@ public class TestEventLog extends SigarTestCase {
|
|||||||
EventLog log = new EventLog();
|
EventLog log = new EventLog();
|
||||||
|
|
||||||
log.open(logname);
|
log.open(logname);
|
||||||
|
if (log.getNumberOfRecords() == 0) {
|
||||||
|
log.close();
|
||||||
|
return 0; //else log.getOldestRecord() throws Exception
|
||||||
|
}
|
||||||
int oldestRecord = log.getOldestRecord();
|
int oldestRecord = log.getOldestRecord();
|
||||||
int numRecords = log.getNumberOfRecords();
|
int numRecords = log.getNumberOfRecords();
|
||||||
traceln("oldest=" + oldestRecord +
|
traceln("oldest=" + oldestRecord +
|
||||||
|
|||||||
@@ -18,10 +18,12 @@
|
|||||||
|
|
||||||
package org.hyperic.sigar.win32.test;
|
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;
|
import org.hyperic.sigar.win32.RegistryKey;
|
||||||
|
|
||||||
public class TestRegistryKey extends TestCase {
|
public class TestRegistryKey extends SigarTestCase {
|
||||||
|
|
||||||
private static final boolean TEST_WRITE = false;
|
private static final boolean TEST_WRITE = false;
|
||||||
|
|
||||||
@@ -37,6 +39,71 @@ public class TestRegistryKey extends TestCase {
|
|||||||
software.close();
|
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
|
//dont want to be writing to the registry
|
||||||
public void testRegistryWrite() throws Exception {
|
public void testRegistryWrite() throws Exception {
|
||||||
if (!TEST_WRITE) {
|
if (!TEST_WRITE) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
copyright.year=2004-2008
|
copyright.year=2004-2008
|
||||||
version.major=1
|
version.major=1
|
||||||
version.minor=6
|
version.minor=6
|
||||||
version.maint=0
|
version.maint=1
|
||||||
version.build=0
|
version.build=0
|
||||||
|
|
||||||
@@ -37,6 +37,7 @@ typedef sigar_proc_cred_name_t * Sigar__ProcCredName;
|
|||||||
typedef sigar_file_attrs_t * Sigar__FileAttrs;
|
typedef sigar_file_attrs_t * Sigar__FileAttrs;
|
||||||
typedef sigar_cpu_t * Sigar__Cpu;
|
typedef sigar_cpu_t * Sigar__Cpu;
|
||||||
typedef sigar_cpu_info_t * Sigar__CpuInfo;
|
typedef sigar_cpu_info_t * Sigar__CpuInfo;
|
||||||
|
typedef sigar_cpu_perc_t * Sigar__CpuPerc;
|
||||||
typedef sigar_net_interface_config_t * Sigar__NetInterfaceConfig;
|
typedef sigar_net_interface_config_t * Sigar__NetInterfaceConfig;
|
||||||
typedef sigar_swap_t * Sigar__Swap;
|
typedef sigar_swap_t * Sigar__Swap;
|
||||||
typedef sigar_proc_state_t * Sigar__ProcState;
|
typedef sigar_proc_state_t * Sigar__ProcState;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ Sigar::ProcCredName T_PTROBJ
|
|||||||
Sigar::FileAttrs T_PTROBJ
|
Sigar::FileAttrs T_PTROBJ
|
||||||
Sigar::Cpu T_PTROBJ
|
Sigar::Cpu T_PTROBJ
|
||||||
Sigar::CpuInfo T_PTROBJ
|
Sigar::CpuInfo T_PTROBJ
|
||||||
|
Sigar::CpuPerc T_PTROBJ
|
||||||
Sigar::NetInterfaceConfig T_PTROBJ
|
Sigar::NetInterfaceConfig T_PTROBJ
|
||||||
Sigar::Swap T_PTROBJ
|
Sigar::Swap T_PTROBJ
|
||||||
Sigar::ProcState T_PTROBJ
|
Sigar::ProcState T_PTROBJ
|
||||||
|
|||||||
@@ -270,6 +270,8 @@ static VALUE rb_sigar_cpu_info_list(VALUE obj)
|
|||||||
return RETVAL;
|
return RETVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE rb_cSigarCpuPerc;
|
||||||
|
|
||||||
static VALUE rb_cSigarFileSystem;
|
static VALUE rb_cSigarFileSystem;
|
||||||
|
|
||||||
static VALUE rb_sigar_file_system_list(VALUE obj)
|
static VALUE rb_sigar_file_system_list(VALUE obj)
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#define PERFBUF_SIZE 8192
|
#define PERFBUF_SIZE 8192
|
||||||
|
|
||||||
#define PERF_TITLE_PROC 230
|
#define PERF_TITLE_PROC 230
|
||||||
|
#define PERF_TITLE_SYS_KEY "2"
|
||||||
#define PERF_TITLE_MEM_KEY "4"
|
#define PERF_TITLE_MEM_KEY "4"
|
||||||
#define PERF_TITLE_PROC_KEY "230"
|
#define PERF_TITLE_PROC_KEY "230"
|
||||||
#define PERF_TITLE_CPU_KEY "238"
|
#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_DECLARE(int) sigar_uptime_get(sigar_t *sigar,
|
||||||
sigar_uptime_t *uptime)
|
sigar_uptime_t *uptime)
|
||||||
{
|
{
|
||||||
uptime->uptime = GetTickCount() / 1000;
|
int status;
|
||||||
return SIGAR_OK;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in new issue
Block a user