diff --git a/WindowsMonitor/Monitor/System.cpp b/WindowsMonitor/Monitor/System.cpp index 6268b8df..930a9a32 100644 --- a/WindowsMonitor/Monitor/System.cpp +++ b/WindowsMonitor/Monitor/System.cpp @@ -9,154 +9,154 @@ list System::GetCounterList() } // File Read Operations/sec -double System::GetFileReadOperationsPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\File Read Operations/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetFileReadOperationsPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\File Read Operations/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // File Write Operations/sec -double System::GetFileWriteOperationsPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\File Write Operations/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetFileWriteOperationsPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\File Write Operations/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // File Control Operations/sec -double System::GetFileControlOperationsPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\File Control Operations/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetFileControlOperationsPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\File Control Operations/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // File Read Bytes/sec -double System::GetFileReadBytesPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\File Read Bytes/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetFileReadBytesPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\File Read Bytes/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // File Write Bytes/sec -double System::GetFileWriteBytesPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\File Write Bytes/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetFileWriteBytesPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\File Write Bytes/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // File Control Bytes/sec -double System::GetFileControlBytesPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\File Control Bytes/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetFileControlBytesPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\File Control Bytes/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // Context Switches/sec -double System::GetContextSwitchesPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\Context Switches/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetContextSwitchesPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\Context Switches/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // System Calls/sec -double System::GetSystemCallsPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\System Calls/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetSystemCallsPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\System Calls/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // File Data Operations/sec -double System::GetFileDataOperationsPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\File Data Operations/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetFileDataOperationsPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\File Data Operations/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // System Up Time -double System::GetSystemUpTime() -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\System Up Time"; - double ret=Common::GetCounterValue(fullCounterPath.c_str()); - return ret; +double System::GetSystemUpTime() +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\System Up Time"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + return ret; } // Processor Queue Length -double System::GetProcessorQueueLength() -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\Processor Queue Length"; - double ret=Common::GetCounterValue(fullCounterPath.c_str()); - return ret; +double System::GetProcessorQueueLength() +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\Processor Queue Length"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + return ret; } // Processes -double System::GetProcessesCount() -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\Processes"; - double ret=Common::GetCounterValue(fullCounterPath.c_str()); - return ret; +double System::GetProcessesCount() +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\Processes"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + return ret; } // Threads -double System::GetThreadsCount() -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\Threads"; - double ret=Common::GetCounterValue(fullCounterPath.c_str()); - return ret; +double System::GetThreadsCount() +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\Threads"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + return ret; } // Alignment Fixups/sec -double System::GetAlignmentFixupsPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\Alignment Fixups/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetAlignmentFixupsPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\Alignment Fixups/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // Exception Dispatches/sec -double System::GetExceptionDispatchesPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\Exception Dispatches/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetExceptionDispatchesPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\Exception Dispatches/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // Floating Emulations/sec -double System::GetFloatingEmulationsPerSecond(int idleTime) -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\Floating Emulations/sec"; - double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); - return ret; +double System::GetFloatingEmulationsPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\Floating Emulations/sec"; + double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; } // % Registry Quota In Use -double System::GetRegistryQuotaInUsePercent() -{ - wstring fullCounterPath(L""); - fullCounterPath+=L"\\System\\% Registry Quota In Use"; - double ret=Common::GetCounterValue(fullCounterPath.c_str()); - return ret; +double System::GetRegistryQuotaInUsePercent() +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\System\\% Registry Quota In Use"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + return ret; } diff --git a/WindowsMonitor/Monitor/TCPv6.cpp b/WindowsMonitor/Monitor/TCPv6.cpp index b4f3e886..862cbf3d 100644 --- a/WindowsMonitor/Monitor/TCPv6.cpp +++ b/WindowsMonitor/Monitor/TCPv6.cpp @@ -9,11 +9,86 @@ list TCPv6::GetCounterList() } // Segments/sec +double TCPv6::GetSegmentsPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\TCPv6\\Segments/sec"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + //double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; +} + // Connections Established +double TCPv6::GetConnectionsEstablished() +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\TCPv6\\Connections Established"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + return ret; +} + // Connections Active +double TCPv6::GetConnectionsActive() +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\TCPv6\\Connections Active"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + return ret; +} + // Connections Passive +double TCPv6::GetConnectionsPassive() +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\TCPv6\\Connections Passive"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + return ret; +} + // Connection Failures +double TCPv6::GetConnectionFailures() +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\TCPv6\\Connection Failures"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + return ret; +} + // Connections Reset +double TCPv6::GetConnectionsReset() +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\TCPv6\\Connections Reset"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + return ret; +} + // Segments Received/sec +double TCPv6::GetSegmentsReceivedPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\TCPv6\\Segments Received/sec"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + //double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; +} + // Segments Sent/sec -// Segments Retransmitted/sec \ No newline at end of file +double TCPv6::GetSegmentsSentPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\TCPv6\\Segments Sent/sec"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + //double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; +} + +// Segments Retransmitted/sec +double TCPv6::GetSegmentsRetransmittedPerSecond(int idleTime) +{ + wstring fullCounterPath(L""); + fullCounterPath+=L"\\TCPv6\\Segments Retransmitted/sec"; + double ret=Common::GetCounterValue(fullCounterPath.c_str()); + //double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime); + return ret; +} \ No newline at end of file diff --git a/WindowsMonitor/Monitor/TCPv6.h b/WindowsMonitor/Monitor/TCPv6.h index ed2e5ec2..258fe6c2 100644 --- a/WindowsMonitor/Monitor/TCPv6.h +++ b/WindowsMonitor/Monitor/TCPv6.h @@ -8,4 +8,13 @@ class MONITOR_API TCPv6 { public: static list GetCounterList(); + double TCPv6::GetSegmentsPerSecond(int idleTime); + double TCPv6::GetConnectionsEstablished(); + double TCPv6::GetConnectionsActive(); + double TCPv6::GetConnectionsPassive(); + double TCPv6::GetConnectionFailures(); + double TCPv6::GetConnectionsReset(); + double TCPv6::GetSegmentsReceivedPerSecond(int idleTime); + double TCPv6::GetSegmentsSentPerSecond(int idleTime); + double TCPv6::GetSegmentsRetransmittedPerSecond(int idleTime); }; \ No newline at end of file diff --git a/WindowsMonitor/Native/Common.cpp b/WindowsMonitor/Native/Common.cpp index b913c7f0..df06cd50 100644 --- a/WindowsMonitor/Native/Common.cpp +++ b/WindowsMonitor/Native/Common.cpp @@ -7,7 +7,11 @@ char * GetJString(JNIEnv * environment, jstring str) const jchar * jcstr=environment->GetStringChars(str,NULL); int size=0; char * ret=(char *)malloc(length*2+1); - if((size=WideCharToMultiByte(CP_ACP,0,LPCWSTR(jcstr),length,ret,length*2+1,NULL,NULL))==0) + if(ret==NULL) + { + return NULL; + } + if((size=WideCharToMultiByte(CP_ACP,0,(wchar_t *)jcstr,length,ret,length*2+1,NULL,NULL))==0) { return NULL; }