chinese string can be correctly transfered to C++

This commit is contained in:
Zhen Tang 2013-07-08 02:00:34 +08:00
parent 853ad0db23
commit bbbf500be8
9 changed files with 110 additions and 77 deletions

View File

@ -0,0 +1,17 @@
#include "stdafx.h"
#include <jni.h>
char * GetJString(JNIEnv * environment, jstring jstr)
{
jsize length = environment->GetStringLength(jstr);
const jchar * jcstr = environment->GetStringChars( jstr, NULL );
int size=0;
char *str=(char *)malloc(length*2+1);
if((size=WideCharToMultiByte(CP_ACP,0,LPCWSTR(jcstr),length,str,length*2+1,NULL,NULL))==0)
{
return NULL;
}
environment->ReleaseStringChars(jstr,jcstr);
str[size] = 0;
return str;
}

View File

@ -0,0 +1,5 @@
#pragma once
#include <jni.h>
char * GetJString(JNIEnv * environment, jstring jstr);

View File

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "LogicalDiskMonitor.h"
#include "Common.h"
JNIEXPORT jobjectArray JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDiskMonitor_getInstances
(JNIEnv * environment, jobject object)
@ -41,28 +42,28 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName)
{
return LogicalDisk::GetFreeSpacePercent(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDiskMonitor_getFreeMegabytes
(JNIEnv * environment, jobject object, jstring instanceName)
{
return LogicalDisk::GetFreeMegabytes(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDiskMonitor_getCurrentDiskQueueLength
(JNIEnv * environment, jobject object, jstring instanceName)
{
return LogicalDisk::GetCurrentDiskQueueLength(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDiskMonitor_getDiskTimePercent
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetDiskTimePercent(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -70,7 +71,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetAverageDiskQueueLength(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -78,7 +79,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetDiskReadTimePercent(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -86,7 +87,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetAverageDiskReadQueueLength(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -94,7 +95,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetDiskWriteTimePercent(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -102,7 +103,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetAverageDiskWriteQueueLength(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -110,7 +111,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetAverageDiskTransferTimeInSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -118,7 +119,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetAverageDiskReadTimeInSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -126,7 +127,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetAverageDiskWriteTimeInSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -134,7 +135,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetDiskTransfersPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -142,7 +143,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetDiskReadsPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -150,7 +151,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetDiskWritesPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -158,7 +159,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetDiskBytesPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -166,7 +167,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetDiskReadBytesPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -174,7 +175,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetDiskWriteBytesPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -182,7 +183,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetAverageDiskBytesPerTransfer(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -190,7 +191,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetAverageDiskBytesPerRead(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -198,7 +199,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetAverageDiskBytesPerWrite(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -206,7 +207,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetIdleTimePercent(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -214,6 +215,6 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_LogicalDi
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return LogicalDisk::GetSplitIOPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}

View File

@ -146,6 +146,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Common.h" />
<ClInclude Include="LogicalDiskMonitor.h" />
<ClInclude Include="MemoryMonitor.h" />
<ClInclude Include="MonitorApi.h" />
@ -154,6 +155,7 @@
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Common.cpp" />
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>

View File

@ -33,6 +33,9 @@
<ClInclude Include="NetworkInterfaceMonitor.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Common.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
@ -50,5 +53,8 @@
<ClCompile Include="NetworkInterfaceMonitor.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Common.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "NetworkInterfaceMonitor.h"
#include "Common.h"
JNIEXPORT jobjectArray JNICALL Java_org_bench4q_monitor_performance_windows_NetworkInterfaceMonitor_getInstances
(JNIEnv * environment, jobject object)
@ -41,7 +42,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetBytesTotalPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -49,7 +50,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetPacketsPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -57,7 +58,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetPacketsReceivedPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -65,7 +66,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetPacketsSentPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -73,14 +74,14 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName)
{
return NetworkInterface::GetCurrentBandwidth(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkInterfaceMonitor_getBytesReceivedPerSecond
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetBytesReceivedPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -88,7 +89,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetPacketsReceivedUnicastPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -96,7 +97,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetPacketsReceivedNonUnicastPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -104,28 +105,28 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName)
{
return NetworkInterface::GetPacketsReceivedDiscarded(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkInterfaceMonitor_getPacketsReceivedErrors
(JNIEnv * environment, jobject object, jstring instanceName)
{
return NetworkInterface::GetPacketsReceivedErrors(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkInterfaceMonitor_getPacketsReceivedUnknown
(JNIEnv * environment, jobject object, jstring instanceName)
{
return NetworkInterface::GetPacketsReceivedUnknown(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkInterfaceMonitor_getBytesSentPerSecond
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetBytesSentPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -133,7 +134,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetPacketsSentUnicastPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -141,7 +142,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetPacketsSentNonUnicastPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -149,42 +150,42 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName)
{
return NetworkInterface::GetPacketsOutboundDiscarded(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkInterfaceMonitor_getPacketsOutboundErrors
(JNIEnv * environment, jobject object, jstring instanceName)
{
return NetworkInterface::GetPacketsOutboundErrors(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkInterfaceMonitor_getOutputQueueLength
(JNIEnv * environment, jobject object, jstring instanceName)
{
return NetworkInterface::GetOutputQueueLength(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkInterfaceMonitor_getOffloadedConnections
(JNIEnv * environment, jobject object, jstring instanceName)
{
return NetworkInterface::GetOffloadedConnections(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkInterfaceMonitor_getTcpActiveRscConnections
(JNIEnv * environment, jobject object, jstring instanceName)
{
return NetworkInterface::GetTcpActiveRscConnections(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkInterfaceMonitor_getTcpRscCoalescedPacketsPerSecond
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetTcpRscCoalescedPacketsPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -192,7 +193,7 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return NetworkInterface::GetTcpRscExceptionsPerSecond(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str()
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
@ -200,5 +201,5 @@ JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_NetworkIn
(JNIEnv * environment, jobject object, jstring instanceName)
{
return NetworkInterface::GetTcpRscAveragePacketSize(
Common::StringToWideString(string(environment->GetStringUTFChars(instanceName,false))).c_str());
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}

View File

@ -8,12 +8,13 @@
#endif
#else
#ifdef _WIN64
#pragma comment(lib,"../x64/Debug/Monitor.lib")
#pragma comment(lib,"../x64/Release/Monitor.lib")
#else
#pragma comment(lib,"../Debug/Monitor.lib")
#pragma comment(lib,"../Release/Monitor.lib")
#endif
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

View File

@ -8,9 +8,9 @@
#endif
#else
#ifdef _WIN64
#pragma comment(lib,"../x64/Debug/Monitor.lib")
#pragma comment(lib,"../x64/Release/Monitor.lib")
#else
#pragma comment(lib,"../Debug/Monitor.lib")
#pragma comment(lib,"../Release/Monitor.lib")
#endif
#endif

View File

@ -1,7 +1,6 @@
package org.bench4q.monitor;
import java.io.File;
import java.net.NetworkInterface;
import org.bench4q.monitor.performance.windows.LogicalDiskMonitor;
import org.bench4q.monitor.performance.windows.MemoryMonitor;
@ -51,25 +50,25 @@ public class Main {
}
public static void main(String[] args) {
LogicalDiskMonitor logicalDiskMonitor = new LogicalDiskMonitor();
String[] logicalDiskInstances = logicalDiskMonitor.getInstances();
for (String elem : logicalDiskInstances) {
System.out.println(elem);
}
String[] logicalDiskCounter = logicalDiskMonitor.getCounterList();
for (String elem : logicalDiskCounter) {
System.out.println(elem);
}
System.out.println(logicalDiskMonitor.getFreeMegabytes("_Total"));
MemoryMonitor memoryMonitor = new MemoryMonitor();
String[] memoryCounter = memoryMonitor.getCounterList();
for (String elem : memoryCounter) {
System.out.println(elem);
}
System.out.println(memoryMonitor.getAvailableBytes());
System.out.println(memoryMonitor.getAvailableKiloBytes());
System.out.println(memoryMonitor.getAvailableMegaBytes());
// LogicalDiskMonitor logicalDiskMonitor = new LogicalDiskMonitor();
// String[] logicalDiskInstances = logicalDiskMonitor.getInstances();
// for (String elem : logicalDiskInstances) {
// System.out.println(elem);
// }
// String[] logicalDiskCounter = logicalDiskMonitor.getCounterList();
// for (String elem : logicalDiskCounter) {
// System.out.println(elem);
// }
// System.out.println(logicalDiskMonitor.getFreeMegabytes("_Total"));
//
// MemoryMonitor memoryMonitor = new MemoryMonitor();
// String[] memoryCounter = memoryMonitor.getCounterList();
// for (String elem : memoryCounter) {
// System.out.println(elem);
// }
// System.out.println(memoryMonitor.getAvailableBytes());
// System.out.println(memoryMonitor.getAvailableKiloBytes());
// System.out.println(memoryMonitor.getAvailableMegaBytes());
NetworkInterfaceMonitor networkInterfaceMonitor = new NetworkInterfaceMonitor();
String[] networkInterfaceInstances = networkInterfaceMonitor
@ -77,16 +76,17 @@ public class Main {
for (String elem : networkInterfaceInstances) {
System.out.println(elem);
System.out.println("bandwidth:"
+ networkInterfaceMonitor.getCurrentBandwidth(elem));
}
String[] networkInterfaceCounter = networkInterfaceMonitor
.getCounterList();
for (String elem : networkInterfaceCounter) {
System.out.println(elem);
+ networkInterfaceMonitor.getCurrentBandwidth("Broadcom 802.11n ÍøÂçÊÊÅäÆ÷"));
}
MonitorServer monitorServer = new MonitorServer(5555);
monitorServer.start();
// String[] networkInterfaceCounter = networkInterfaceMonitor
// .getCounterList();
// for (String elem : networkInterfaceCounter) {
// System.out.println(elem);
// }
// MonitorServer monitorServer = new MonitorServer(5555);
// monitorServer.start();
}
}