windows monitor completed.

This commit is contained in:
Zhen Tang 2013-07-15 15:06:56 +08:00
parent d78faaa0a4
commit 853aa65cc4
6 changed files with 333 additions and 4 deletions

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
.settings
.project
.classpath
/.settings
/target
/WindowsMonitor/Debug
/WindowsMonitor/Release

View File

@ -155,6 +155,7 @@
<ClInclude Include="PhysicalDiskMonitor.h" />
<ClInclude Include="ProcessMonitor.h" />
<ClInclude Include="ProcessorInformationMonitor.h" />
<ClInclude Include="ProcessorMonitor.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="TCPv4Monitor.h" />
<ClInclude Include="TCPv6Monitor.h" />
@ -183,6 +184,7 @@
<ClCompile Include="PhysicalDiskMonitor.cpp" />
<ClCompile Include="ProcessMonitor.cpp" />
<ClCompile Include="ProcessorInformationMonitor.cpp" />
<ClCompile Include="ProcessorMonitor.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>

View File

@ -57,6 +57,9 @@
<ClInclude Include="ProcessorInformationMonitor.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="ProcessorMonitor.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
@ -98,5 +101,8 @@
<ClCompile Include="ProcessorInformationMonitor.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="ProcessorMonitor.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,158 @@
#include "stdafx.h"
#include "ProcessorMonitor.h"
#include "Common.h"
JNIEXPORT jobjectArray JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getInstances
(JNIEnv * environment, jobject object)
{
list<wstring> instances=Processor::GetInstances();
list<wstring>::iterator iter;
long count=(long)instances.size();
jobjectArray array=environment->NewObjectArray(
count,environment->FindClass("java/lang/String"),environment->NewStringUTF(""));
int i=0;
for(iter=instances.begin();iter!=instances.end();iter++)
{
environment->SetObjectArrayElement(array,i
,environment->NewStringUTF(GetUTF8String((*iter).c_str())));
i++;
}
return array;
}
JNIEXPORT jobjectArray JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getCounterList
(JNIEnv * environment, jobject object)
{
list<wstring> counterList=Processor::GetCounterList();
list<wstring>::iterator iter;
long count=(long)counterList.size();
jobjectArray array=environment->NewObjectArray(
count,environment->FindClass("java/lang/String"),environment->NewStringUTF(""));
int i=0;
for(iter=counterList.begin();iter!=counterList.end();iter++)
{
environment->SetObjectArrayElement(array,i
,environment->NewStringUTF(GetUTF8String((*iter).c_str())));
i++;
}
return array;
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getProcessorTimePercent
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetProcessorTimePercent(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getUserTimePercent
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetUserTimePercent(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getPrivilegedTimePercent
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetPrivilegedTimePercent(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getInterruptsPerSecond
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetInterruptsPerSecond(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getDpcTimePercent
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetDpcTimePercent(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getInterruptTimePercent
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetInterruptTimePercent(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getDpcsQueuedPerSecond
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetDpcsQueuedPerSecond(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getDpcRate
(JNIEnv * environment, jobject object, jstring instanceName)
{
return Processor::GetDpcRate(
Common::StringToWideString(GetJString(environment,instanceName)).c_str());
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getIdleTimePercent
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetIdleTimePercent(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC1TimePercent
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetC1TimePercent(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC2TimePercent
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetC2TimePercent(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC3TimePercent
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetC3TimePercent(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC1TransitionsPerSecond
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetC1TransitionsPerSecond(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC2TransitionsPerSecond
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetC2TransitionsPerSecond(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC3TransitionsPerSecond
(JNIEnv * environment, jobject object, jstring instanceName, jint idleTime)
{
return Processor::GetC3TransitionsPerSecond(
Common::StringToWideString(GetJString(environment,instanceName)).c_str()
,idleTime);
}

View File

@ -0,0 +1,149 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_bench4q_monitor_performance_windows_ProcessorMonitor */
#ifndef _Included_org_bench4q_monitor_performance_windows_ProcessorMonitor
#define _Included_org_bench4q_monitor_performance_windows_ProcessorMonitor
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getInstances
* Signature: ()[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getInstances
(JNIEnv *, jobject);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getCounterList
* Signature: ()[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getCounterList
(JNIEnv *, jobject);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getProcessorTimePercent
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getProcessorTimePercent
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getUserTimePercent
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getUserTimePercent
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getPrivilegedTimePercent
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getPrivilegedTimePercent
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getInterruptsPerSecond
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getInterruptsPerSecond
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getDpcTimePercent
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getDpcTimePercent
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getInterruptTimePercent
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getInterruptTimePercent
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getDpcsQueuedPerSecond
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getDpcsQueuedPerSecond
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getDpcRate
* Signature: (Ljava/lang/String;)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getDpcRate
(JNIEnv *, jobject, jstring);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getIdleTimePercent
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getIdleTimePercent
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getC1TimePercent
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC1TimePercent
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getC2TimePercent
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC2TimePercent
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getC3TimePercent
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC3TimePercent
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getC1TransitionsPerSecond
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC1TransitionsPerSecond
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getC2TransitionsPerSecond
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC2TransitionsPerSecond
(JNIEnv *, jobject, jstring, jint);
/*
* Class: org_bench4q_monitor_performance_windows_ProcessorMonitor
* Method: getC3TransitionsPerSecond
* Signature: (Ljava/lang/String;I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_ProcessorMonitor_getC3TransitionsPerSecond
(JNIEnv *, jobject, jstring, jint);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -8,6 +8,7 @@ import org.bench4q.monitor.performance.windows.NetworkInterfaceMonitor;
import org.bench4q.monitor.performance.windows.PhysicalDiskMonitor;
import org.bench4q.monitor.performance.windows.ProcessMonitor;
import org.bench4q.monitor.performance.windows.ProcessorInformationMonitor;
import org.bench4q.monitor.performance.windows.ProcessorMonitor;
import org.bench4q.monitor.performance.windows.TCPv4Monitor;
import org.bench4q.monitor.performance.windows.TCPv6Monitor;
import org.bench4q.monitor.performance.windows.UDPv4Monitor;
@ -113,18 +114,31 @@ public class Main {
for (String elem : processCounter) {
System.out.println(elem);
}
ProcessorInformationMonitor processorInformationMonitor = new ProcessorInformationMonitor();
String[] processorInformationInstances = processorInformationMonitor.getInstances();
String[] processorInformationInstances = processorInformationMonitor
.getInstances();
for (String elem : processorInformationInstances) {
System.out.println(elem);
}
String[] processorInformationCounter = processorInformationMonitor.getCounterList();
String[] processorInformationCounter = processorInformationMonitor
.getCounterList();
for (String elem : processorInformationCounter) {
System.out.println(elem);
}
ProcessorMonitor processorMonitor = new ProcessorMonitor();
String[] processorInstances = processorMonitor.getInstances();
for (String elem : processorInstances) {
System.out.println(elem);
}
String[] processorCounter = processorMonitor.getCounterList();
for (String elem : processorCounter) {
System.out.println(elem);
}
TCPv4Monitor tcpv4Monitor = new TCPv4Monitor();
String[] tcpv4Counter = tcpv4Monitor.getCounterList();
for (String elem : tcpv4Counter) {