add native version/build date
This commit is contained in:
parent
e014912280
commit
97a31a24f5
@ -197,6 +197,20 @@ JNIEXPORT jstring SIGAR_JNI(Sigar_formatSize)
|
||||
return JENV->NewStringUTF(env, buf);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring SIGAR_JNI(Sigar_getNativeVersion)
|
||||
(JNIEnv *env, jclass cls)
|
||||
{
|
||||
sigar_version_t *version = sigar_version_get();
|
||||
return JENV->NewStringUTF(env, version->version);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring SIGAR_JNI(Sigar_getNativeBuildDate)
|
||||
(JNIEnv *env, jclass cls)
|
||||
{
|
||||
sigar_version_t *version = sigar_version_get();
|
||||
return JENV->NewStringUTF(env, version->build_date);
|
||||
}
|
||||
|
||||
JNIEXPORT void SIGAR_JNI(Sigar_open)
|
||||
(JNIEnv *env, jobject obj)
|
||||
{
|
||||
|
@ -24,17 +24,27 @@ public class Sigar implements SigarProxy {
|
||||
public static final long FIELD_NOTIMPL = -1;
|
||||
|
||||
/**
|
||||
* The Sigar version in String form.
|
||||
* The Sigar java version.
|
||||
*/
|
||||
public static final String VERSION_STRING =
|
||||
SigarVersion.VERSION_STRING;
|
||||
|
||||
/**
|
||||
* The date on which the Sigar binaries were built.
|
||||
* The Sigar native version.
|
||||
*/
|
||||
public static final String NATIVE_VERSION_STRING;
|
||||
|
||||
/**
|
||||
* The date on which sigar.jar was built.
|
||||
*/
|
||||
public static final String BUILD_DATE =
|
||||
SigarVersion.BUILD_DATE;
|
||||
|
||||
/**
|
||||
* The date on which the sigar native binary was built.
|
||||
*/
|
||||
public static final String NATIVE_BUILD_DATE;
|
||||
|
||||
private static boolean enableLogging =
|
||||
"true".equals(System.getProperty("sigar.nativeLogging"));
|
||||
|
||||
@ -50,10 +60,11 @@ public class Sigar implements SigarProxy {
|
||||
private static SigarProxy instance = null;
|
||||
|
||||
static {
|
||||
boolean loaded = false;
|
||||
try {
|
||||
loadLibrary();
|
||||
loaded = true;
|
||||
} catch (SigarException e) {
|
||||
loadError = "Sigar.load: " + e.getMessage();
|
||||
try {
|
||||
SigarLog.debug(loadError, e);
|
||||
} catch (NoClassDefFoundError ne) {
|
||||
@ -62,6 +73,13 @@ public class Sigar implements SigarProxy {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (loaded) {
|
||||
NATIVE_VERSION_STRING = getNativeVersion();
|
||||
NATIVE_BUILD_DATE = getNativeBuildDate();
|
||||
}
|
||||
else {
|
||||
NATIVE_VERSION_STRING = NATIVE_BUILD_DATE = "N/A";
|
||||
}
|
||||
}
|
||||
|
||||
public static void load() throws SigarException {
|
||||
@ -98,6 +116,9 @@ public class Sigar implements SigarProxy {
|
||||
*/
|
||||
public static native String formatSize(long size);
|
||||
|
||||
private static native String getNativeVersion();
|
||||
private static native String getNativeBuildDate();
|
||||
|
||||
/**
|
||||
* Allocate and initialize the native Sigar object.
|
||||
*/
|
||||
|
@ -48,8 +48,16 @@ public class Version extends SigarCommandBase {
|
||||
public static void printInfo(PrintStream os) {
|
||||
String fqdn = getFQDN();
|
||||
String host = getHostName();
|
||||
os.println("Sigar version......." + Sigar.VERSION_STRING);
|
||||
os.println("Build date.........." + Sigar.BUILD_DATE);
|
||||
|
||||
String version =
|
||||
"java=" + Sigar.VERSION_STRING +
|
||||
", native=" + Sigar.NATIVE_VERSION_STRING;
|
||||
String build =
|
||||
"java=" + Sigar.BUILD_DATE +
|
||||
", native=" + Sigar.NATIVE_BUILD_DATE;
|
||||
|
||||
os.println("Sigar version......." + version);
|
||||
os.println("Build date.........." + build);
|
||||
os.println("Archlib............." +
|
||||
SigarLoader.getNativeLibraryName());
|
||||
os.println("Current fqdn........" + fqdn);
|
||||
|
Loading…
Reference in New Issue
Block a user