From 02bd1f5b896a05df60fb6b5aaa296e3bb8531d0e Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Thu, 20 Mar 2014 11:27:12 +0800 Subject: [PATCH] Merge Bench4Q-Monitor --- .../master/report/MonitorReportService.java | 246 ++++++ .../bench4q/master/report/ReportService.java | 175 ++++ .../master/report/ScriptReportService.java | 140 ++++ .../master/test/report/ReportFontTest.java | 54 ++ .../WindowsMonitor}/Monitor/Common.cpp | 0 .../WindowsMonitor}/Monitor/Common.h | 0 .../WindowsMonitor}/Monitor/LogicalDisk.cpp | 0 .../WindowsMonitor}/Monitor/LogicalDisk.h | 0 .../WindowsMonitor}/Monitor/Memory.cpp | 0 .../WindowsMonitor}/Monitor/Memory.h | 0 .../WindowsMonitor}/Monitor/Monitor.h | 0 .../WindowsMonitor}/Monitor/Monitor.vcxproj | 0 .../Monitor/Monitor.vcxproj.filters | 226 +++--- .../Monitor/Monitor.vcxproj.user | 0 .../WindowsMonitor}/Monitor/MonitorApi.h | 0 .../Monitor/NetworkInterface.cpp | 0 .../Monitor/NetworkInterface.h | 0 .../WindowsMonitor}/Monitor/PhysicalDisk.cpp | 0 .../WindowsMonitor}/Monitor/PhysicalDisk.h | 0 .../WindowsMonitor}/Monitor/Process.cpp | 0 .../WindowsMonitor}/Monitor/Process.h | 0 .../WindowsMonitor}/Monitor/Processor.cpp | 0 .../WindowsMonitor}/Monitor/Processor.h | 0 .../Monitor/ProcessorInformation.cpp | 0 .../Monitor/ProcessorInformation.h | 0 .../WindowsMonitor}/Monitor/System.cpp | 326 ++++---- .../WindowsMonitor}/Monitor/System.h | 0 .../WindowsMonitor}/Monitor/TCPv4.cpp | 0 .../WindowsMonitor}/Monitor/TCPv4.h | 0 .../WindowsMonitor}/Monitor/TCPv6.cpp | 0 .../WindowsMonitor}/Monitor/TCPv6.h | 0 .../WindowsMonitor}/Monitor/UDPv4.cpp | 0 .../WindowsMonitor}/Monitor/UDPv4.h | 0 .../WindowsMonitor}/Monitor/UDPv6.cpp | 0 .../WindowsMonitor}/Monitor/UDPv6.h | 0 .../WindowsMonitor}/Monitor/dllmain.cpp | 0 .../WindowsMonitor}/Monitor/stdafx.cpp | 0 .../WindowsMonitor}/Monitor/stdafx.h | 0 .../WindowsMonitor}/Native/Common.cpp | 0 .../WindowsMonitor}/Native/Common.h | 0 .../Native/LogicalDiskMonitor.cpp | 0 .../Native/LogicalDiskMonitor.h | 0 .../WindowsMonitor}/Native/MemoryMonitor.cpp | 0 .../WindowsMonitor}/Native/MemoryMonitor.h | 0 .../WindowsMonitor}/Native/MonitorApi.h | 0 .../WindowsMonitor}/Native/Native.h | 0 .../WindowsMonitor}/Native/Native.vcxproj | 408 +++++----- .../Native/Native.vcxproj.filters | 232 +++--- .../Native/Native.vcxproj.user | 0 .../Native/NetworkInterfaceMonitor.cpp | 0 .../Native/NetworkInterfaceMonitor.h | 0 .../Native/PhysicalDiskMonitor.cpp | 0 .../Native/PhysicalDiskMonitor.h | 0 .../WindowsMonitor}/Native/ProcessMonitor.cpp | 0 .../WindowsMonitor}/Native/ProcessMonitor.h | 0 .../Native/ProcessorInformationMonitor.cpp | 0 .../Native/ProcessorInformationMonitor.h | 0 .../Native/ProcessorMonitor.cpp | 0 .../WindowsMonitor}/Native/ProcessorMonitor.h | 0 .../WindowsMonitor}/Native/SystemMonitor.cpp | 0 .../WindowsMonitor}/Native/SystemMonitor.h | 0 .../WindowsMonitor}/Native/TCPv4Monitor.cpp | 0 .../WindowsMonitor}/Native/TCPv4Monitor.h | 0 .../WindowsMonitor}/Native/TCPv6Monitor.cpp | 0 .../WindowsMonitor}/Native/TCPv6Monitor.h | 0 .../WindowsMonitor}/Native/UDPv4Monitor.cpp | 0 .../WindowsMonitor}/Native/UDPv4Monitor.h | 0 .../WindowsMonitor}/Native/UDPv6Monitor.cpp | 0 .../WindowsMonitor}/Native/UDPv6Monitor.h | 0 .../WindowsMonitor}/Native/dllmain.cpp | 0 .../WindowsMonitor}/Native/stdafx.cpp | 0 .../WindowsMonitor}/Native/stdafx.h | 0 .../WindowsMonitor}/WindowsMonitor.sln | 0 .../descriptor.xml | 80 +- pom.xml => Bench4Q-Monitor/pom.xml | 172 ++-- .../main/java/org/bench4q/monitor/Main.java | 112 +-- .../org/bench4q/monitor/MonitorServer.java | 140 ++-- .../java/org/bench4q/monitor/OSUtils.java | 0 .../monitor/api/LogicalDiskController.java | 70 +- .../bench4q/monitor/api/MemoryController.java | 66 +- .../org/bench4q/monitor/api/MnitorStart.java | 0 .../api/NetworkInterfaceController.java | 66 +- .../monitor/api/PhysicalDiskController.java | 66 +- .../monitor/api/ProcessController.java | 72 +- .../monitor/api/ProcessorController.java | 70 +- .../bench4q/monitor/api/SystemController.java | 56 +- .../bench4q/monitor/entiry/LinuxFileRead.java | 0 .../monitor/entiry/MonitorContorlEntity.java | 50 +- .../file/Linux/WriteLogicalDiskLinux.java | 0 .../monitor/file/Linux/WriteMemoryLinux.java | 0 .../Linux/WriteNetworkInterfaceLinux.java | 74 +- .../file/Linux/WritePhysicalDiskLinux.java | 76 +- .../monitor/file/Linux/WriteProcessLinux.java | 66 +- .../file/Linux/WriteProcessorLinux.java | 72 +- .../monitor/file/Linux/WriteSystemLinux.java | 0 .../file/windows/WriteLogicalDiskWindows.java | 0 .../file/windows/WriteMemoryWindows.java | 0 .../windows/WriteNetworkInterfaceWindows.java | 70 +- .../windows/WritePhysicalDiskWindows.java | 72 +- .../file/windows/WriteProcessWindows.java | 68 +- .../file/windows/WriteProcessorWindows.java | 68 +- .../file/windows/WriteSystemWindows.java | 68 +- .../bench4q/monitor/files/CreatFileName.java | 42 +- .../org/bench4q/monitor/files/ReadFile.java | 56 +- .../java/org/bench4q/monitor/files/Write.java | 0 .../org/bench4q/monitor/files/WriteFiles.java | 474 +++++------ .../monitor/model/LogicalDiskModel.java | 62 +- .../monitor/model/LogicalDiskModelChild.java | 258 +++--- .../bench4q/monitor/model/MemoryModel.java | 112 +-- .../monitor/model/NetworkInterfaceModel.java | 52 +- .../model/NetworkInterfaceModelChild.java | 88 +- .../monitor/model/PhysicalDiskModel.java | 54 +- .../monitor/model/PhysicalDiskModelChild.java | 184 ++--- .../bench4q/monitor/model/ProcessModel.java | 58 +- .../monitor/model/ProcessModelChild.java | 86 +- .../bench4q/monitor/model/ProcessorModel.java | 46 +- .../monitor/model/ProcessorModelChild.java | 74 +- .../bench4q/monitor/model/SystemModel.java | 78 +- .../performance/linux/CpuInfoMonitor.java | 66 +- .../performance/linux/CpuStatusMonitor.java | 0 .../performance/linux/DiskStatusMonitor.java | 0 .../performance/linux/LogicalDiskMonitor.java | 760 +++++++++--------- .../performance/linux/MemoryInfoMonitor.java | 0 .../performance/linux/MemoryMonitor.java | 0 .../linux/NetworkInterfaceMonitor.java | 260 +++--- .../linux/PhysicalDiskMonitor.java | 408 +++++----- .../performance/linux/ProcessMonitor.java | 296 +++---- .../performance/linux/ProcessorMonitor.java | 358 ++++----- .../performance/linux/SystemMonitor.java | 250 +++--- .../windows/LogicalDiskMonitor.java | 0 .../performance/windows/MemoryMonitor.java | 0 .../windows/NetworkInterfaceMonitor.java | 0 .../windows/PhysicalDiskMonitor.java | 134 +-- .../performance/windows/ProcessMonitor.java | 154 ++-- .../windows/ProcessorInformationMonitor.java | 158 ++-- .../performance/windows/ProcessorMonitor.java | 96 +-- .../performance/windows/SystemMonitor.java | 90 +-- .../performance/windows/TCPv4Monitor.java | 0 .../performance/windows/TCPv6Monitor.java | 0 .../performance/windows/UDPv4Monitor.java | 0 .../performance/windows/UDPv6Monitor.java | 0 .../linux/LogicalDiskServiceLinux.java | 0 .../service/linux/MemoryServiceLinux.java | 0 .../linux/NetworkInterfaceServiceLinux.java | 58 +- .../linux/PhysicalDiskServiceLinux.java | 58 +- .../service/linux/ProcessServiceLinux.java | 0 .../service/linux/ProcessorServiceLinux.java | 60 +- .../service/linux/SystemServiceLinux.java | 0 .../windows/LogicalDiskServiceWindows.java | 158 ++-- .../service/windows/MemoryServiceWindows.java | 90 +-- .../NetworkInterfaceServiceWindows.java | 86 +- .../windows/PhysicalDiskServiceWindows.java | 100 +-- .../windows/ProcessServiceWindows.java | 82 +- .../windows/ProcessorServiceWindows.java | 90 +-- .../service/windows/SystemServiceWindows.java | 74 +- .../monitor/config/application-context.xml | 20 +- .../bench4q/monitor/test/LogicalDiskTest.java | 168 ++-- .../org/bench4q/monitor/test/MemoryTest.java | 156 ++-- .../bench4q/monitor/test/ProcessorTest.java | 174 ++-- .../test/communication/HttpRequester.java | 550 ++++++------- license.txt | 339 -------- 161 files changed, 5377 insertions(+), 5101 deletions(-) create mode 100644 Bench4Q-Master/src/main/java/org/bench4q/master/report/MonitorReportService.java create mode 100644 Bench4Q-Master/src/main/java/org/bench4q/master/report/ReportService.java create mode 100644 Bench4Q-Master/src/main/java/org/bench4q/master/report/ScriptReportService.java create mode 100644 Bench4Q-Master/src/test/java/org/bench4q/master/test/report/ReportFontTest.java rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Common.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Common.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/LogicalDisk.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/LogicalDisk.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Memory.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Memory.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Monitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Monitor.vcxproj (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Monitor.vcxproj.filters (96%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Monitor.vcxproj.user (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/MonitorApi.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/NetworkInterface.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/NetworkInterface.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/PhysicalDisk.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/PhysicalDisk.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Process.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Process.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Processor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/Processor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/ProcessorInformation.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/ProcessorInformation.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/System.cpp (96%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/System.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/TCPv4.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/TCPv4.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/TCPv6.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/TCPv6.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/UDPv4.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/UDPv4.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/UDPv6.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/UDPv6.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/dllmain.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/stdafx.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Monitor/stdafx.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/Common.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/Common.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/LogicalDiskMonitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/LogicalDiskMonitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/MemoryMonitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/MemoryMonitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/MonitorApi.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/Native.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/Native.vcxproj (98%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/Native.vcxproj.filters (96%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/Native.vcxproj.user (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/NetworkInterfaceMonitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/NetworkInterfaceMonitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/PhysicalDiskMonitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/PhysicalDiskMonitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/ProcessMonitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/ProcessMonitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/ProcessorInformationMonitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/ProcessorInformationMonitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/ProcessorMonitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/ProcessorMonitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/SystemMonitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/SystemMonitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/TCPv4Monitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/TCPv4Monitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/TCPv6Monitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/TCPv6Monitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/UDPv4Monitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/UDPv4Monitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/UDPv6Monitor.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/UDPv6Monitor.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/dllmain.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/stdafx.cpp (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/Native/stdafx.h (100%) rename {WindowsMonitor => Bench4Q-Monitor/WindowsMonitor}/WindowsMonitor.sln (100%) rename descriptor.xml => Bench4Q-Monitor/descriptor.xml (96%) rename pom.xml => Bench4Q-Monitor/pom.xml (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/Main.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/MonitorServer.java (95%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/OSUtils.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/api/LogicalDiskController.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/api/MemoryController.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/api/MnitorStart.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/api/NetworkInterfaceController.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/api/PhysicalDiskController.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/api/ProcessController.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/api/ProcessorController.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/api/SystemController.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/entiry/LinuxFileRead.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/entiry/MonitorContorlEntity.java (95%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/Linux/WriteLogicalDiskLinux.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/Linux/WriteMemoryLinux.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/Linux/WriteNetworkInterfaceLinux.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/Linux/WritePhysicalDiskLinux.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/Linux/WriteProcessLinux.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/Linux/WriteProcessorLinux.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/Linux/WriteSystemLinux.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/windows/WriteLogicalDiskWindows.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/windows/WriteMemoryWindows.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/windows/WriteNetworkInterfaceWindows.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/windows/WritePhysicalDiskWindows.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/windows/WriteProcessWindows.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/windows/WriteProcessorWindows.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/file/windows/WriteSystemWindows.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/files/CreatFileName.java (95%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/files/ReadFile.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/files/Write.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/files/WriteFiles.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/LogicalDiskModel.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/LogicalDiskModelChild.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/MemoryModel.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/NetworkInterfaceModel.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/NetworkInterfaceModelChild.java (95%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/PhysicalDiskModelChild.java (95%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/ProcessModel.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/ProcessModelChild.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/ProcessorModel.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/ProcessorModelChild.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/model/SystemModel.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/linux/CpuInfoMonitor.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/linux/CpuStatusMonitor.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/linux/DiskStatusMonitor.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/linux/LogicalDiskMonitor.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/linux/MemoryInfoMonitor.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/linux/MemoryMonitor.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/linux/NetworkInterfaceMonitor.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/linux/PhysicalDiskMonitor.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/linux/ProcessMonitor.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/linux/ProcessorMonitor.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/linux/SystemMonitor.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/LogicalDiskMonitor.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/MemoryMonitor.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/NetworkInterfaceMonitor.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/PhysicalDiskMonitor.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/ProcessMonitor.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/ProcessorInformationMonitor.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/ProcessorMonitor.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/SystemMonitor.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/TCPv4Monitor.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/TCPv6Monitor.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/UDPv4Monitor.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/performance/windows/UDPv6Monitor.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/linux/LogicalDiskServiceLinux.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/linux/MemoryServiceLinux.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/linux/NetworkInterfaceServiceLinux.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/linux/PhysicalDiskServiceLinux.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/linux/ProcessServiceLinux.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/linux/ProcessorServiceLinux.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/linux/SystemServiceLinux.java (100%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/windows/LogicalDiskServiceWindows.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/windows/MemoryServiceWindows.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/windows/NetworkInterfaceServiceWindows.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/windows/PhysicalDiskServiceWindows.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/windows/ProcessServiceWindows.java (96%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java (97%) rename {src => Bench4Q-Monitor/src}/main/java/org/bench4q/monitor/service/windows/SystemServiceWindows.java (97%) rename {src => Bench4Q-Monitor/src}/main/resources/org/bench4q/monitor/config/application-context.xml (98%) rename {src => Bench4Q-Monitor/src}/test/java/org/bench4q/monitor/test/LogicalDiskTest.java (96%) rename {src => Bench4Q-Monitor/src}/test/java/org/bench4q/monitor/test/MemoryTest.java (96%) rename {src => Bench4Q-Monitor/src}/test/java/org/bench4q/monitor/test/ProcessorTest.java (96%) rename {src => Bench4Q-Monitor/src}/test/java/org/bench4q/monitor/test/communication/HttpRequester.java (96%) delete mode 100644 license.txt diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/report/MonitorReportService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/report/MonitorReportService.java new file mode 100644 index 00000000..a24a1daa --- /dev/null +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/report/MonitorReportService.java @@ -0,0 +1,246 @@ +package org.bench4q.master.report; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.bench4q.master.domain.entity.MonitorResult; +import org.bench4q.master.domain.service.MonitorResultService; +import org.bench4q.master.domain.service.TestPlanScriptService; +import org.bench4q.master.domain.service.TestPlanService; +import org.bench4q.master.exception.Bench4QException; +import org.bench4q.share.helper.MarshalHelper; +import org.bench4q.share.models.master.MonitorResultContainerModel; +import org.bench4q.share.models.monitor.MemoryModel; +import org.bench4q.share.models.monitor.NetworkInterfaceModel; +import org.bench4q.share.models.monitor.PhysicalDiskModel; +import org.bench4q.share.models.monitor.ProcessorModel; +import org.jfree.data.time.Second; +import org.jfree.data.time.TimeSeries; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.lowagie.text.Document; + +@Component +public class MonitorReportService { + public static String Processor = "ProcessorTimePercent (unit: %)"; + public static String Memory = "Memory Available Memory(unit: KiloByte)"; + public static String logical_Disk = "logicalDisk IO (unit: Byte)"; + public static String network_Interface = "networkInterface IO (unit: Byte/second)"; + private TestPlanScriptService testPlanScriptService; + private TestPlanService testPlanService; + private MonitorResultService monitorResultService; + + public TestPlanScriptService getTestPlanScriptService() { + return testPlanScriptService; + } + + @Autowired + public void setTestPlanScriptService( + TestPlanScriptService testPlanScriptService) { + this.testPlanScriptService = testPlanScriptService; + } + + public TestPlanService getTestPlanService() { + return testPlanService; + } + + @Autowired + public void setTestPlanService(TestPlanService testPlanService) { + this.testPlanService = testPlanService; + } + + public MonitorResultService getMonitorResultService() { + return monitorResultService; + } + + @Autowired + public void setMonitorResultService( + MonitorResultService monitorResultService) { + this.monitorResultService = monitorResultService; + } + + void createMonitorResultImages(UUID testPlanRunID, Document document) throws Bench4QException { + Map SUTResultMap = new HashMap(); + List results = this.getMonitorResultService() + .queryMonitorResults(testPlanRunID); + if (results == null) { + return; + } + + for (MonitorResult result : results) { + if (result == null) { + continue; + } + buildSUTResultMap(SUTResultMap, result); + } + + for (String hostName : SUTResultMap.keySet()) { + createSUTImage(hostName, SUTResultMap.get(hostName), document); + } + } + + private void buildSUTResultMap( + Map sUTResultMap, + MonitorResult result) { + String hostName = result.getHostNameUnderMonitor(); + if (!sUTResultMap.containsKey(hostName)) { + sUTResultMap.put(result.getHostNameUnderMonitor(), + new MonitorResultContainerModel()); + } + sortResultToList(result, sUTResultMap.get(hostName)); + } + + private void sortResultToList(final MonitorResult result, + MonitorResultContainerModel container) { + try { + if (Class.forName(result.getType()).equals(PhysicalDiskModel.class)) { + container.getLogicalDiskModels().add( + (PhysicalDiskModel) MarshalHelper.unmarshal( + PhysicalDiskModel.class, result.getContent())); + } else if (Class.forName(result.getType()) + .equals(MemoryModel.class)) { + container.getMemoryModels().add( + (MemoryModel) MarshalHelper.unmarshal( + MemoryModel.class, result.getContent())); + } else if (Class.forName(result.getType()).equals( + NetworkInterfaceModel.class)) { + container.getNetWorkModels().add( + (NetworkInterfaceModel) MarshalHelper.unmarshal( + NetworkInterfaceModel.class, + result.getContent())); + } else if (Class.forName(result.getType()).equals( + ProcessorModel.class)) { + container.getProcessorModels().add( + (ProcessorModel) MarshalHelper.unmarshal( + ProcessorModel.class, result.getContent())); + } + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + + private void createSUTImage(String hostName, + MonitorResultContainerModel container, Document document) { + try { + ReportService.addParagraph(logical_Disk, document); + createLogicalDiskImage(container.getLogicalDiskModels(), document); + ReportService.addParagraph(Memory, document); + createMemoryImage(container.getMemoryModels(), document); + ReportService.addParagraph(network_Interface, document); +// createNetworkImage(container.getNetWorkModels(), document); + ReportService.addParagraph(Processor, document); + createProcessorImage(container.getProcessorModels(), document); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + private void createProcessorImage(List list, + Document document) throws Exception { + if (list == null || list.size() == 0) { + return; + } + int seriesCount = list.get(0).getProcessorModelList().size(); + + List timeSeriesArray = ReportService.buildSeries( + seriesCount, Processor); + + for (ProcessorModel model : list) { + if (model == null) + continue; + for (int i = 0; i < timeSeriesArray.size(); i++) { + timeSeriesArray.get(i).addOrUpdate( + new Second(model.getSamplingTime()), + model.getProcessorModelList().get(i) + .getProcessorTimePercent()); + } + } + ReportService.writeImageIntoPdf( + ReportService.buildChartStream(document, seriesCount, + timeSeriesArray, Processor).toByteArray(), document); + + } + + private void createMemoryImage(List list, Document document) + throws Exception { + if (list == null || list.size() == 0) { + return; + } + int seriesCount = 1; + List timeSeriesArray = ReportService.buildSeries( + seriesCount, Memory); + for (MemoryModel model : list) { + if (model == null) + continue; + for (int i = 0; i < timeSeriesArray.size(); i++) { + timeSeriesArray.get(i).addOrUpdate( + new Second(model.getSamplingTime()), + model.getAvailableKiloBytes()); + } + } + ReportService.writeImageIntoPdf( + ReportService.buildChartStream(document, seriesCount, + timeSeriesArray, Memory).toByteArray(), document); + } + + private void createLogicalDiskImage(List list, + Document document) throws Exception { + if (list == null || list.size() == 0) { + return; + } + int seriesCount = list.get(0).getFieFileSystemModels().size(); + List timeSeriesArray = ReportService.buildSeries( + seriesCount, logical_Disk); + + for (PhysicalDiskModel model : list) { + if (model == null) + continue; + for (int i = 0; i < timeSeriesArray.size(); i++) { + timeSeriesArray.get(i).addOrUpdate( + new Second(model.getSamplingTime()), + model.getFieFileSystemModels().get(i) + .getDiskTotalKBytesRate()); + } + } + + ReportService.writeImageIntoPdf( + ReportService.buildChartStream(document, seriesCount, + timeSeriesArray, logical_Disk).toByteArray(), document); + } + + + /** + * refactor this kind of use + * + * @param list + * @param document + * @throws Exception + */ + +// private void createNetworkImage(List list, +// Document document) throws Exception { +// if (list == null || list.size() == 0) { +// return; +// } +// int seriesCount = list.get(0).getNetworkList().size(); +// List timeSeriesArray = ReportService.buildSeries( +// seriesCount, network_Interface); +// for (NetworkInterfaceModel model : list) { +// for (int i = 0; i < timeSeriesArray.size(); i++) { +// timeSeriesArray.get(i).addOrUpdate( +// new Second(model.getSamplingTime()), +// model.getNetworkList().get(i).getBytesTotalPerSecond()); +// } +// } +// ReportService.writeImageIntoPdf( +// ReportService.buildChartStream(document, seriesCount, +// timeSeriesArray, network_Interface).toByteArray(), +// document); +// } +//} +} diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/report/ReportService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/report/ReportService.java new file mode 100644 index 00000000..38d750bb --- /dev/null +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/report/ReportService.java @@ -0,0 +1,175 @@ +package org.bench4q.master.report; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import org.apache.commons.io.FileUtils; +import org.apache.log4j.Logger; +import org.bench4q.master.exception.ExceptionLog; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartUtilities; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.title.TextTitle; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.lowagie.text.Document; +import com.lowagie.text.DocumentException; +import com.lowagie.text.Element; +import com.lowagie.text.Image; +import com.lowagie.text.Paragraph; +import com.lowagie.text.pdf.PdfWriter; + +@Component +public class ReportService { + public static String Time = "time"; + public static String PDF_FOLDER = "report"; + private ScriptReportService scriptReportService; + private MonitorReportService monitorReportService; + private Logger logger = Logger.getLogger(ReportService.class); + private static int PICTURE_WIDTH = 500; + private static int PICTURE_HIGHT = 450; + + public ScriptReportService getScriptReportService() { + return scriptReportService; + } + + @Autowired + public void setScriptReportService(ScriptReportService scriptReportService) { + this.scriptReportService = scriptReportService; + } + + public MonitorReportService getMonitorReportService() { + return monitorReportService; + } + + @Autowired + public void setMonitorReportService( + MonitorReportService monitorReportService) { + this.monitorReportService = monitorReportService; + } + + public byte[] createReport(UUID testPlanRunID) { + try { + if (isReportCreated(testPlanRunID)) { + return FileUtils.readFileToByteArray(new File(ReportService + .buildFilePath(testPlanRunID))); + } + isFolderExist(); + Document document = new Document(); + PdfWriter.getInstance(document, new FileOutputStream( + buildFilePath(testPlanRunID))); + document.open(); + this.getScriptReportService().createScriptsResultsImage( + testPlanRunID, document); + this.getMonitorReportService().createMonitorResultImages( + testPlanRunID, document); + document.close(); + return FileUtils.readFileToByteArray(new File( + buildFilePath(testPlanRunID))); + } catch (Exception e) { + logger.error(ExceptionLog.getStackTrace(e)); + return null; + } + } + + public boolean isReportCreated(UUID testPlanRunID) { + return new File(buildFilePath(testPlanRunID)).exists(); + } + + public static String buildFilePath(UUID testPlanRunID) { + return PDF_FOLDER + System.getProperty("file.separator") + + testPlanRunID + ".pdf"; + } + + private void isFolderExist() { + try { + if (!new File(PDF_FOLDER).isDirectory()) { + new File(PDF_FOLDER).mkdir(); + } + } catch (SecurityException e) { + e.printStackTrace(); + } + } + + static void addParagraph(String content, Document document) + throws DocumentException { + Paragraph paragraph = new Paragraph(content); + paragraph.setAlignment(Element.ALIGN_CENTER); + document.add(paragraph); + } + + public static ByteArrayOutputStream buildChartStream(Document document, + int seriesCount, List timeSeriesArray, String value) + throws IOException { + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + JFreeChart chart = ChartFactory.createTimeSeriesChart(value, + ReportService.Time, value, buildDataSet(timeSeriesArray), true, + true, true); + adjustChartFont(value, chart); + + ChartUtilities.writeChartAsPNG(outputStream, chart, PICTURE_WIDTH, + PICTURE_HIGHT); + return outputStream; + } + + private static void adjustChartFont(String value, JFreeChart chart) { + Font xfont = new Font("����", Font.CENTER_BASELINE, 14);// X + Font yfont = new Font("����", Font.CENTER_BASELINE, 14);// Y + Font kfont = new Font("����", Font.CENTER_BASELINE, 12);// + Font titleFont = new Font("΢���ź�", Font.CENTER_BASELINE, 16); // title + + chart.setBorderStroke(new BasicStroke(1)); + chart.setBorderVisible(true); + chart.setBorderPaint(Color.cyan); + + chart.setTitle(new TextTitle(value, titleFont)); + XYPlot plot = chart.getXYPlot(); + plot.getRangeAxis().setLabelFont(yfont); + plot.getRangeAxis().setTickLabelFont(kfont); + plot.getDomainAxis().setLabelFont(xfont); + plot.getDomainAxis().setTickLabelFont(kfont); + chart.setBackgroundPaint(java.awt.Color.white); + } + + public static List buildSeries(int seriesCount, String mainTitle) { + List timeSeriesArray = new ArrayList( + seriesCount); + for (int i = 0; i < seriesCount; i++) { + timeSeriesArray.add(new TimeSeries(mainTitle + "-" + i)); + } + return timeSeriesArray; + } + + static TimeSeriesCollection buildDataSet( + final List timeSeriesArray) { + TimeSeriesCollection lineDataset = new TimeSeriesCollection(); + if (timeSeriesArray == null) { + return null; + } + for (TimeSeries timeSeries : timeSeriesArray) { + lineDataset.addSeries(timeSeries); + } + return lineDataset; + } + + public static void writeImageIntoPdf(byte[] buffer, Document document) + throws Exception { + Image image = Image.getInstance(buffer); + image.setAlignment(Element.ALIGN_CENTER); + document.add(image); + } + +} diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/report/ScriptReportService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/report/ScriptReportService.java new file mode 100644 index 00000000..3c58f80d --- /dev/null +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/report/ScriptReportService.java @@ -0,0 +1,140 @@ +package org.bench4q.master.report; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import org.apache.log4j.Logger; +import org.bench4q.master.domain.entity.TestPlanScript; +import org.bench4q.master.domain.entity.TestPlanScriptResult; +import org.bench4q.master.domain.repository.TestPlanRepository; +import org.bench4q.master.domain.service.MonitorResultService; +import org.bench4q.master.domain.service.TestPlanScriptService; +import org.bench4q.master.domain.service.TestPlanService; +import org.bench4q.share.models.master.statistics.ScriptBriefResultModel; +import org.jfree.data.time.Second; +import org.jfree.data.time.TimeSeries; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.lowagie.text.Document; + +@Component +public class ScriptReportService { + public static String SCRIPT_TITLE = "Script result"; + public static String Average_Response_Time = "averageResponseTime(unit: ms)"; + public static String MAX_RESPONSE_TIME = "maxResponseTime(unit : time)"; + private TestPlanScriptService testPlanScriptService; + private TestPlanService testPlanService; + private TestPlanRepository testPlanRepository; + private MonitorResultService monitorResultService; + private Logger logger = Logger.getLogger(ScriptReportService.class); + + public TestPlanScriptService getTestPlanScriptService() { + return testPlanScriptService; + } + + @Autowired + public void setTestPlanScriptService( + TestPlanScriptService testPlanScriptService) { + this.testPlanScriptService = testPlanScriptService; + } + + public TestPlanService getTestPlanService() { + return testPlanService; + } + + @Autowired + public void setTestPlanService(TestPlanService testPlanService) { + this.testPlanService = testPlanService; + } + + public MonitorResultService getMonitorResultService() { + return monitorResultService; + } + + @Autowired + public void setMonitorResultService( + MonitorResultService monitorResultService) { + this.monitorResultService = monitorResultService; + } + + private TestPlanRepository getTestPlanRepository() { + return testPlanRepository; + } + + @Autowired + private void setTestPlanRepository(TestPlanRepository testPlanRepository) { + this.testPlanRepository = testPlanRepository; + } + + void createScriptsResultsImage(UUID testPlanRunId, Document document) { + + Set scripts = this.getTestPlanRepository() + .getTestPlanBy(testPlanRunId).getTestPlanScripts(); + if (scripts == null) { + return; + } + for (TestPlanScript testPlanScript : scripts) { + createScriptImage(this.getTestPlanScriptService() + .queryScriptBriefResults(testPlanScript), document); + } + + } + + private void createScriptImage(List results, + Document document) { + + if (results == null) { + return; + } + createAverageReponseTimeImage(results, document); + } + + private void createAverageReponseTimeImage( + List results, Document document) { + List timeSeriesList = new ArrayList(); + if (results == null) { + return; + } + addScriptSeries(results, timeSeriesList, "averageResponseTime"); + addScriptSeries(results, timeSeriesList, "maxResponseTime"); + try { + ReportService.writeImageIntoPdf( + ReportService.buildChartStream(document, + timeSeriesList.size(), timeSeriesList, + Average_Response_Time + "&" + MAX_RESPONSE_TIME) + .toByteArray(), document); + } catch (Exception e) { + e.printStackTrace(); + } + } + + // TODO: refactor this to a kind of command mode + private void addScriptSeries(List results, + List timeSeriesList, String fieldName) { + try { + TimeSeries timeSeries = new TimeSeries(fieldName); + for (TestPlanScriptResult result : results) { + if (!result.getResultType().equals( + ScriptBriefResultModel.class.getName())) { + continue; + } + ScriptBriefResultModel scriptBriefResultModel = result + .extractScriptBriefResultModel(); + Field field = scriptBriefResultModel.getClass() + .getDeclaredField(fieldName); + field.setAccessible(true); + timeSeries.addOrUpdate(new Second(result.getCreateDatetime()), + field.getLong(scriptBriefResultModel)); + } + timeSeriesList.add(timeSeries); + } catch (Exception e) { + logger.error(e.toString() + + " in addScriptSeries where fieldName is : " + fieldName); + } + + } +} diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/test/report/ReportFontTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/report/ReportFontTest.java new file mode 100644 index 00000000..d74c7d8f --- /dev/null +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/report/ReportFontTest.java @@ -0,0 +1,54 @@ +package org.bench4q.master.test.report; + +import static org.junit.Assert.*; + +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import org.bench4q.master.report.ReportService; +import org.jfree.data.time.Second; +import org.jfree.data.time.TimeSeries; +import org.junit.Test; + +import com.lowagie.text.Document; +import com.lowagie.text.DocumentException; +import com.lowagie.text.pdf.PdfWriter; + +public class ReportFontTest { + + @Test + public void test() { + fail("Not yet implemented"); + } + + public void createReportTest() throws FileNotFoundException, + DocumentException { + + Document document = new Document(); + PdfWriter.getInstance( + document, + new FileOutputStream(ReportService.buildFilePath(UUID + .randomUUID()))); + document.open(); + + } + + public void createTestImage(UUID id, Document document) throws IOException, + Exception { + List timeSeriesList = new ArrayList(); + TimeSeries timeSeries = new TimeSeries("test"); + long now = System.currentTimeMillis(); + timeSeries.add(new Second(new Date(now)), 3000); + timeSeries.add(new Second(new Date(now + 100)), 4000); + timeSeriesList.add(timeSeries); + ReportService.buildSeries(1, "test"); + ReportService.writeImageIntoPdf( + ReportService.buildChartStream(document, 1, timeSeriesList, + "test").toByteArray(), document); + } +} diff --git a/WindowsMonitor/Monitor/Common.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/Common.cpp similarity index 100% rename from WindowsMonitor/Monitor/Common.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Common.cpp diff --git a/WindowsMonitor/Monitor/Common.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/Common.h similarity index 100% rename from WindowsMonitor/Monitor/Common.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Common.h diff --git a/WindowsMonitor/Monitor/LogicalDisk.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/LogicalDisk.cpp similarity index 100% rename from WindowsMonitor/Monitor/LogicalDisk.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/LogicalDisk.cpp diff --git a/WindowsMonitor/Monitor/LogicalDisk.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/LogicalDisk.h similarity index 100% rename from WindowsMonitor/Monitor/LogicalDisk.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/LogicalDisk.h diff --git a/WindowsMonitor/Monitor/Memory.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/Memory.cpp similarity index 100% rename from WindowsMonitor/Monitor/Memory.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Memory.cpp diff --git a/WindowsMonitor/Monitor/Memory.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/Memory.h similarity index 100% rename from WindowsMonitor/Monitor/Memory.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Memory.h diff --git a/WindowsMonitor/Monitor/Monitor.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/Monitor.h similarity index 100% rename from WindowsMonitor/Monitor/Monitor.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Monitor.h diff --git a/WindowsMonitor/Monitor/Monitor.vcxproj b/Bench4Q-Monitor/WindowsMonitor/Monitor/Monitor.vcxproj similarity index 100% rename from WindowsMonitor/Monitor/Monitor.vcxproj rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Monitor.vcxproj diff --git a/WindowsMonitor/Monitor/Monitor.vcxproj.filters b/Bench4Q-Monitor/WindowsMonitor/Monitor/Monitor.vcxproj.filters similarity index 96% rename from WindowsMonitor/Monitor/Monitor.vcxproj.filters rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Monitor.vcxproj.filters index 2cc5b993..1ee57345 100644 --- a/WindowsMonitor/Monitor/Monitor.vcxproj.filters +++ b/Bench4Q-Monitor/WindowsMonitor/Monitor/Monitor.vcxproj.filters @@ -1,114 +1,114 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + \ No newline at end of file diff --git a/WindowsMonitor/Monitor/Monitor.vcxproj.user b/Bench4Q-Monitor/WindowsMonitor/Monitor/Monitor.vcxproj.user similarity index 100% rename from WindowsMonitor/Monitor/Monitor.vcxproj.user rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Monitor.vcxproj.user diff --git a/WindowsMonitor/Monitor/MonitorApi.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/MonitorApi.h similarity index 100% rename from WindowsMonitor/Monitor/MonitorApi.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/MonitorApi.h diff --git a/WindowsMonitor/Monitor/NetworkInterface.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/NetworkInterface.cpp similarity index 100% rename from WindowsMonitor/Monitor/NetworkInterface.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/NetworkInterface.cpp diff --git a/WindowsMonitor/Monitor/NetworkInterface.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/NetworkInterface.h similarity index 100% rename from WindowsMonitor/Monitor/NetworkInterface.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/NetworkInterface.h diff --git a/WindowsMonitor/Monitor/PhysicalDisk.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/PhysicalDisk.cpp similarity index 100% rename from WindowsMonitor/Monitor/PhysicalDisk.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/PhysicalDisk.cpp diff --git a/WindowsMonitor/Monitor/PhysicalDisk.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/PhysicalDisk.h similarity index 100% rename from WindowsMonitor/Monitor/PhysicalDisk.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/PhysicalDisk.h diff --git a/WindowsMonitor/Monitor/Process.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/Process.cpp similarity index 100% rename from WindowsMonitor/Monitor/Process.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Process.cpp diff --git a/WindowsMonitor/Monitor/Process.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/Process.h similarity index 100% rename from WindowsMonitor/Monitor/Process.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Process.h diff --git a/WindowsMonitor/Monitor/Processor.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/Processor.cpp similarity index 100% rename from WindowsMonitor/Monitor/Processor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Processor.cpp diff --git a/WindowsMonitor/Monitor/Processor.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/Processor.h similarity index 100% rename from WindowsMonitor/Monitor/Processor.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/Processor.h diff --git a/WindowsMonitor/Monitor/ProcessorInformation.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/ProcessorInformation.cpp similarity index 100% rename from WindowsMonitor/Monitor/ProcessorInformation.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/ProcessorInformation.cpp diff --git a/WindowsMonitor/Monitor/ProcessorInformation.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/ProcessorInformation.h similarity index 100% rename from WindowsMonitor/Monitor/ProcessorInformation.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/ProcessorInformation.h diff --git a/WindowsMonitor/Monitor/System.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/System.cpp similarity index 96% rename from WindowsMonitor/Monitor/System.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/System.cpp index 7fee5d8d..8318829c 100644 --- a/WindowsMonitor/Monitor/System.cpp +++ b/Bench4Q-Monitor/WindowsMonitor/Monitor/System.cpp @@ -1,163 +1,163 @@ -#include "stdafx.h" -#include "Monitor.h" -#include "Common.h" -#include "System.h" - -list System::GetCounterList() -{ - return Common::GetCounterList(L"System"); -} - -// 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; -} - -// 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; -} - -// 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; -} - -// 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; -} - -// 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; -} - -// 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; -} - -// 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; -} - -// 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; -} - -// 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; -} - -// System Up Time -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; -} - -// Processes -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; -} - -// 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; -} - -// 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; -} - -// 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; -} - -// % 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; -} +#include "stdafx.h" +#include "Monitor.h" +#include "Common.h" +#include "System.h" + +list System::GetCounterList() +{ + return Common::GetCounterList(L"System"); +} + +// 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; +} + +// 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; +} + +// 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; +} + +// 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; +} + +// 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; +} + +// 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; +} + +// 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; +} + +// 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; +} + +// 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; +} + +// System Up Time +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; +} + +// Processes +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; +} + +// 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; +} + +// 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; +} + +// 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; +} + +// % 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; +} diff --git a/WindowsMonitor/Monitor/System.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/System.h similarity index 100% rename from WindowsMonitor/Monitor/System.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/System.h diff --git a/WindowsMonitor/Monitor/TCPv4.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/TCPv4.cpp similarity index 100% rename from WindowsMonitor/Monitor/TCPv4.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/TCPv4.cpp diff --git a/WindowsMonitor/Monitor/TCPv4.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/TCPv4.h similarity index 100% rename from WindowsMonitor/Monitor/TCPv4.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/TCPv4.h diff --git a/WindowsMonitor/Monitor/TCPv6.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/TCPv6.cpp similarity index 100% rename from WindowsMonitor/Monitor/TCPv6.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/TCPv6.cpp diff --git a/WindowsMonitor/Monitor/TCPv6.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/TCPv6.h similarity index 100% rename from WindowsMonitor/Monitor/TCPv6.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/TCPv6.h diff --git a/WindowsMonitor/Monitor/UDPv4.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/UDPv4.cpp similarity index 100% rename from WindowsMonitor/Monitor/UDPv4.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/UDPv4.cpp diff --git a/WindowsMonitor/Monitor/UDPv4.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/UDPv4.h similarity index 100% rename from WindowsMonitor/Monitor/UDPv4.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/UDPv4.h diff --git a/WindowsMonitor/Monitor/UDPv6.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/UDPv6.cpp similarity index 100% rename from WindowsMonitor/Monitor/UDPv6.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/UDPv6.cpp diff --git a/WindowsMonitor/Monitor/UDPv6.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/UDPv6.h similarity index 100% rename from WindowsMonitor/Monitor/UDPv6.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/UDPv6.h diff --git a/WindowsMonitor/Monitor/dllmain.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/dllmain.cpp similarity index 100% rename from WindowsMonitor/Monitor/dllmain.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/dllmain.cpp diff --git a/WindowsMonitor/Monitor/stdafx.cpp b/Bench4Q-Monitor/WindowsMonitor/Monitor/stdafx.cpp similarity index 100% rename from WindowsMonitor/Monitor/stdafx.cpp rename to Bench4Q-Monitor/WindowsMonitor/Monitor/stdafx.cpp diff --git a/WindowsMonitor/Monitor/stdafx.h b/Bench4Q-Monitor/WindowsMonitor/Monitor/stdafx.h similarity index 100% rename from WindowsMonitor/Monitor/stdafx.h rename to Bench4Q-Monitor/WindowsMonitor/Monitor/stdafx.h diff --git a/WindowsMonitor/Native/Common.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/Common.cpp similarity index 100% rename from WindowsMonitor/Native/Common.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/Common.cpp diff --git a/WindowsMonitor/Native/Common.h b/Bench4Q-Monitor/WindowsMonitor/Native/Common.h similarity index 100% rename from WindowsMonitor/Native/Common.h rename to Bench4Q-Monitor/WindowsMonitor/Native/Common.h diff --git a/WindowsMonitor/Native/LogicalDiskMonitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/LogicalDiskMonitor.cpp similarity index 100% rename from WindowsMonitor/Native/LogicalDiskMonitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/LogicalDiskMonitor.cpp diff --git a/WindowsMonitor/Native/LogicalDiskMonitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/LogicalDiskMonitor.h similarity index 100% rename from WindowsMonitor/Native/LogicalDiskMonitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/LogicalDiskMonitor.h diff --git a/WindowsMonitor/Native/MemoryMonitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/MemoryMonitor.cpp similarity index 100% rename from WindowsMonitor/Native/MemoryMonitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/MemoryMonitor.cpp diff --git a/WindowsMonitor/Native/MemoryMonitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/MemoryMonitor.h similarity index 100% rename from WindowsMonitor/Native/MemoryMonitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/MemoryMonitor.h diff --git a/WindowsMonitor/Native/MonitorApi.h b/Bench4Q-Monitor/WindowsMonitor/Native/MonitorApi.h similarity index 100% rename from WindowsMonitor/Native/MonitorApi.h rename to Bench4Q-Monitor/WindowsMonitor/Native/MonitorApi.h diff --git a/WindowsMonitor/Native/Native.h b/Bench4Q-Monitor/WindowsMonitor/Native/Native.h similarity index 100% rename from WindowsMonitor/Native/Native.h rename to Bench4Q-Monitor/WindowsMonitor/Native/Native.h diff --git a/WindowsMonitor/Native/Native.vcxproj b/Bench4Q-Monitor/WindowsMonitor/Native/Native.vcxproj similarity index 98% rename from WindowsMonitor/Native/Native.vcxproj rename to Bench4Q-Monitor/WindowsMonitor/Native/Native.vcxproj index b95b45ad..e09fe5e8 100644 --- a/WindowsMonitor/Native/Native.vcxproj +++ b/Bench4Q-Monitor/WindowsMonitor/Native/Native.vcxproj @@ -1,205 +1,205 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {286E6C20-9603-4870-BD34-FF54406AE1DC} - Win32Proj - Native - - - - DynamicLibrary - true - v110 - Unicode - - - DynamicLibrary - true - v110 - Unicode - - - DynamicLibrary - false - v110 - true - Unicode - - - DynamicLibrary - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - - - true - AllRules.ruleset - true - - - false - - - false - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;NATIVE_EXPORTS;%(PreprocessorDefinitions) - true - $(JAVA_HOME)/include/win32;$(JAVA_HOME)/include;%(AdditionalIncludeDirectories) - - - Windows - true - - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;NATIVE_EXPORTS;%(PreprocessorDefinitions) - true - $(JAVA_HOME)/include/win32;$(JAVA_HOME)/include;%(AdditionalIncludeDirectories) - true - - - Windows - true - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;NATIVE_EXPORTS;%(PreprocessorDefinitions) - true - $(JAVA_HOME)/include/win32;$(JAVA_HOME)/include;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;NATIVE_EXPORTS;%(PreprocessorDefinitions) - true - $(JAVA_HOME)/include/win32;$(JAVA_HOME)/include;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - false - false - - - - - false - false - - - - - - - - - - - - - - Create - Create - Create - Create - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {286E6C20-9603-4870-BD34-FF54406AE1DC} + Win32Proj + Native + + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + + + true + AllRules.ruleset + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;NATIVE_EXPORTS;%(PreprocessorDefinitions) + true + $(JAVA_HOME)/include/win32;$(JAVA_HOME)/include;%(AdditionalIncludeDirectories) + + + Windows + true + + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;NATIVE_EXPORTS;%(PreprocessorDefinitions) + true + $(JAVA_HOME)/include/win32;$(JAVA_HOME)/include;%(AdditionalIncludeDirectories) + true + + + Windows + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;NATIVE_EXPORTS;%(PreprocessorDefinitions) + true + $(JAVA_HOME)/include/win32;$(JAVA_HOME)/include;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;NATIVE_EXPORTS;%(PreprocessorDefinitions) + true + $(JAVA_HOME)/include/win32;$(JAVA_HOME)/include;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + false + false + + + + + false + false + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + \ No newline at end of file diff --git a/WindowsMonitor/Native/Native.vcxproj.filters b/Bench4Q-Monitor/WindowsMonitor/Native/Native.vcxproj.filters similarity index 96% rename from WindowsMonitor/Native/Native.vcxproj.filters rename to Bench4Q-Monitor/WindowsMonitor/Native/Native.vcxproj.filters index 9e5cf821..451fc4e5 100644 --- a/WindowsMonitor/Native/Native.vcxproj.filters +++ b/Bench4Q-Monitor/WindowsMonitor/Native/Native.vcxproj.filters @@ -1,117 +1,117 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + \ No newline at end of file diff --git a/WindowsMonitor/Native/Native.vcxproj.user b/Bench4Q-Monitor/WindowsMonitor/Native/Native.vcxproj.user similarity index 100% rename from WindowsMonitor/Native/Native.vcxproj.user rename to Bench4Q-Monitor/WindowsMonitor/Native/Native.vcxproj.user diff --git a/WindowsMonitor/Native/NetworkInterfaceMonitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/NetworkInterfaceMonitor.cpp similarity index 100% rename from WindowsMonitor/Native/NetworkInterfaceMonitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/NetworkInterfaceMonitor.cpp diff --git a/WindowsMonitor/Native/NetworkInterfaceMonitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/NetworkInterfaceMonitor.h similarity index 100% rename from WindowsMonitor/Native/NetworkInterfaceMonitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/NetworkInterfaceMonitor.h diff --git a/WindowsMonitor/Native/PhysicalDiskMonitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/PhysicalDiskMonitor.cpp similarity index 100% rename from WindowsMonitor/Native/PhysicalDiskMonitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/PhysicalDiskMonitor.cpp diff --git a/WindowsMonitor/Native/PhysicalDiskMonitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/PhysicalDiskMonitor.h similarity index 100% rename from WindowsMonitor/Native/PhysicalDiskMonitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/PhysicalDiskMonitor.h diff --git a/WindowsMonitor/Native/ProcessMonitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/ProcessMonitor.cpp similarity index 100% rename from WindowsMonitor/Native/ProcessMonitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/ProcessMonitor.cpp diff --git a/WindowsMonitor/Native/ProcessMonitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/ProcessMonitor.h similarity index 100% rename from WindowsMonitor/Native/ProcessMonitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/ProcessMonitor.h diff --git a/WindowsMonitor/Native/ProcessorInformationMonitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/ProcessorInformationMonitor.cpp similarity index 100% rename from WindowsMonitor/Native/ProcessorInformationMonitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/ProcessorInformationMonitor.cpp diff --git a/WindowsMonitor/Native/ProcessorInformationMonitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/ProcessorInformationMonitor.h similarity index 100% rename from WindowsMonitor/Native/ProcessorInformationMonitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/ProcessorInformationMonitor.h diff --git a/WindowsMonitor/Native/ProcessorMonitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/ProcessorMonitor.cpp similarity index 100% rename from WindowsMonitor/Native/ProcessorMonitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/ProcessorMonitor.cpp diff --git a/WindowsMonitor/Native/ProcessorMonitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/ProcessorMonitor.h similarity index 100% rename from WindowsMonitor/Native/ProcessorMonitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/ProcessorMonitor.h diff --git a/WindowsMonitor/Native/SystemMonitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/SystemMonitor.cpp similarity index 100% rename from WindowsMonitor/Native/SystemMonitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/SystemMonitor.cpp diff --git a/WindowsMonitor/Native/SystemMonitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/SystemMonitor.h similarity index 100% rename from WindowsMonitor/Native/SystemMonitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/SystemMonitor.h diff --git a/WindowsMonitor/Native/TCPv4Monitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/TCPv4Monitor.cpp similarity index 100% rename from WindowsMonitor/Native/TCPv4Monitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/TCPv4Monitor.cpp diff --git a/WindowsMonitor/Native/TCPv4Monitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/TCPv4Monitor.h similarity index 100% rename from WindowsMonitor/Native/TCPv4Monitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/TCPv4Monitor.h diff --git a/WindowsMonitor/Native/TCPv6Monitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/TCPv6Monitor.cpp similarity index 100% rename from WindowsMonitor/Native/TCPv6Monitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/TCPv6Monitor.cpp diff --git a/WindowsMonitor/Native/TCPv6Monitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/TCPv6Monitor.h similarity index 100% rename from WindowsMonitor/Native/TCPv6Monitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/TCPv6Monitor.h diff --git a/WindowsMonitor/Native/UDPv4Monitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/UDPv4Monitor.cpp similarity index 100% rename from WindowsMonitor/Native/UDPv4Monitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/UDPv4Monitor.cpp diff --git a/WindowsMonitor/Native/UDPv4Monitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/UDPv4Monitor.h similarity index 100% rename from WindowsMonitor/Native/UDPv4Monitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/UDPv4Monitor.h diff --git a/WindowsMonitor/Native/UDPv6Monitor.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/UDPv6Monitor.cpp similarity index 100% rename from WindowsMonitor/Native/UDPv6Monitor.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/UDPv6Monitor.cpp diff --git a/WindowsMonitor/Native/UDPv6Monitor.h b/Bench4Q-Monitor/WindowsMonitor/Native/UDPv6Monitor.h similarity index 100% rename from WindowsMonitor/Native/UDPv6Monitor.h rename to Bench4Q-Monitor/WindowsMonitor/Native/UDPv6Monitor.h diff --git a/WindowsMonitor/Native/dllmain.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/dllmain.cpp similarity index 100% rename from WindowsMonitor/Native/dllmain.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/dllmain.cpp diff --git a/WindowsMonitor/Native/stdafx.cpp b/Bench4Q-Monitor/WindowsMonitor/Native/stdafx.cpp similarity index 100% rename from WindowsMonitor/Native/stdafx.cpp rename to Bench4Q-Monitor/WindowsMonitor/Native/stdafx.cpp diff --git a/WindowsMonitor/Native/stdafx.h b/Bench4Q-Monitor/WindowsMonitor/Native/stdafx.h similarity index 100% rename from WindowsMonitor/Native/stdafx.h rename to Bench4Q-Monitor/WindowsMonitor/Native/stdafx.h diff --git a/WindowsMonitor/WindowsMonitor.sln b/Bench4Q-Monitor/WindowsMonitor/WindowsMonitor.sln similarity index 100% rename from WindowsMonitor/WindowsMonitor.sln rename to Bench4Q-Monitor/WindowsMonitor/WindowsMonitor.sln diff --git a/descriptor.xml b/Bench4Q-Monitor/descriptor.xml similarity index 96% rename from descriptor.xml rename to Bench4Q-Monitor/descriptor.xml index e53b7ff1..c62ee5da 100644 --- a/descriptor.xml +++ b/Bench4Q-Monitor/descriptor.xml @@ -1,41 +1,41 @@ - - - publish - - tar.gz - - false - - - lib - false - false - runtime - - - - - target/bench4q-monitor.jar - / - - - WindowsMonitor/Release/Monitor.dll - /lib/x86 - - - WindowsMonitor/Release/Native.dll - /lib/x86 - - - WindowsMonitor/x64/Release/Monitor.dll - /lib/x64 - - - WindowsMonitor/x64/Release/Native.dll - /lib/x64 - - + + + publish + + tar.gz + + false + + + lib + false + false + runtime + + + + + target/bench4q-monitor.jar + / + + + WindowsMonitor/Release/Monitor.dll + /lib/x86 + + + WindowsMonitor/Release/Native.dll + /lib/x86 + + + WindowsMonitor/x64/Release/Monitor.dll + /lib/x64 + + + WindowsMonitor/x64/Release/Native.dll + /lib/x64 + + \ No newline at end of file diff --git a/pom.xml b/Bench4Q-Monitor/pom.xml similarity index 96% rename from pom.xml rename to Bench4Q-Monitor/pom.xml index a2318d14..c6e2cb7c 100644 --- a/pom.xml +++ b/Bench4Q-Monitor/pom.xml @@ -1,87 +1,87 @@ - - 4.0.0 - org.bench4q - bench4q-monitor - jar - 0.0.1-SNAPSHOT - Bench4Q Monitor - Bench4Q Monitor - - TCSE, ISCAS - - - - junit - junit - 4.11 - test - - - org.eclipse.jetty - jetty-server - 8.1.11.v20130520 - - - org.eclipse.jetty - jetty-servlet - 8.1.11.v20130520 - - - org.springframework - spring-webmvc - 3.2.4.RELEASE - - - org.codehaus.jackson - jackson-mapper-asl - 1.9.12 - - - org.apache.directory.studio - org.apache.commons.io - 2.4 - - - - - - maven-jar-plugin - - - - org.bench4q.monitor.Main - true - lib/ - - - - - - maven-assembly-plugin - - - make-zip - package - - single - - - - descriptor.xml - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - bench4q-monitor - + + 4.0.0 + org.bench4q + bench4q-monitor + jar + 0.0.1-SNAPSHOT + Bench4Q Monitor + Bench4Q Monitor + + TCSE, ISCAS + + + + junit + junit + 4.11 + test + + + org.eclipse.jetty + jetty-server + 8.1.11.v20130520 + + + org.eclipse.jetty + jetty-servlet + 8.1.11.v20130520 + + + org.springframework + spring-webmvc + 3.2.4.RELEASE + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.12 + + + org.apache.directory.studio + org.apache.commons.io + 2.4 + + + + + + maven-jar-plugin + + + + org.bench4q.monitor.Main + true + lib/ + + + + + + maven-assembly-plugin + + + make-zip + package + + single + + + + descriptor.xml + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + bench4q-monitor + \ No newline at end of file diff --git a/src/main/java/org/bench4q/monitor/Main.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/Main.java similarity index 96% rename from src/main/java/org/bench4q/monitor/Main.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/Main.java index cf068dbc..755d08bc 100644 --- a/src/main/java/org/bench4q/monitor/Main.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/Main.java @@ -1,56 +1,56 @@ -package org.bench4q.monitor; - -import java.io.File; - -public class Main { - static { - loadLibraries(); - } - - private static void loadLibraries() { - String osName = System.getProperty("os.name").toLowerCase(); - if (osName.contains("windows")) { - String directory = Main.class.getProtectionDomain().getCodeSource() - .getLocation().getFile().replace("\\", "/"); - File file = new File(directory); - if (!file.isDirectory()) { - directory = directory.substring(0, directory.lastIndexOf("/")); - if (!directory.endsWith("/")) { - directory += "/"; - } - int arch = Integer.parseInt(System - .getProperty("sun.arch.data.model")); - if (arch == 64) { - System.load(directory + "lib/x64/Monitor.dll"); - System.load(directory + "lib/x64/Native.dll"); - } else { - System.load(directory + "lib/x86/Monitor.dll"); - System.load(directory + "lib/x86/Native.dll"); - } - } else { - // In IDE - String userDir = System.getProperty("user.dir").replace("\\", - "/"); - userDir += "/WindowsMonitor"; - int arch = Integer.parseInt(System - .getProperty("sun.arch.data.model")); - if (arch == 64) { - System.load(userDir + "/x64/Release/Monitor.dll"); - System.load(userDir + "/x64/Release/Native.dll"); - } else { - System.load(userDir + "/Release/Monitor.dll"); - System.load(userDir + "/Release/Native.dll"); - } - } - } - } - - public static void main(String[] args) { - - if (System.getProperty("os.name").toLowerCase().contains("windows")) - loadLibraries(); - MonitorServer monitorServer = new MonitorServer(5556); - monitorServer.start(); - } - -} +package org.bench4q.monitor; + +import java.io.File; + +public class Main { + static { + loadLibraries(); + } + + private static void loadLibraries() { + String osName = System.getProperty("os.name").toLowerCase(); + if (osName.contains("windows")) { + String directory = Main.class.getProtectionDomain().getCodeSource() + .getLocation().getFile().replace("\\", "/"); + File file = new File(directory); + if (!file.isDirectory()) { + directory = directory.substring(0, directory.lastIndexOf("/")); + if (!directory.endsWith("/")) { + directory += "/"; + } + int arch = Integer.parseInt(System + .getProperty("sun.arch.data.model")); + if (arch == 64) { + System.load(directory + "lib/x64/Monitor.dll"); + System.load(directory + "lib/x64/Native.dll"); + } else { + System.load(directory + "lib/x86/Monitor.dll"); + System.load(directory + "lib/x86/Native.dll"); + } + } else { + // In IDE + String userDir = System.getProperty("user.dir").replace("\\", + "/"); + userDir += "/WindowsMonitor"; + int arch = Integer.parseInt(System + .getProperty("sun.arch.data.model")); + if (arch == 64) { + System.load(userDir + "/x64/Release/Monitor.dll"); + System.load(userDir + "/x64/Release/Native.dll"); + } else { + System.load(userDir + "/Release/Monitor.dll"); + System.load(userDir + "/Release/Native.dll"); + } + } + } + } + + public static void main(String[] args) { + + if (System.getProperty("os.name").toLowerCase().contains("windows")) + loadLibraries(); + MonitorServer monitorServer = new MonitorServer(5556); + monitorServer.start(); + } + +} diff --git a/src/main/java/org/bench4q/monitor/MonitorServer.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/MonitorServer.java similarity index 95% rename from src/main/java/org/bench4q/monitor/MonitorServer.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/MonitorServer.java index a742e19e..3d098c5f 100644 --- a/src/main/java/org/bench4q/monitor/MonitorServer.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/MonitorServer.java @@ -1,70 +1,70 @@ -package org.bench4q.monitor; - -import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.bio.SocketConnector; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; -import org.springframework.web.servlet.DispatcherServlet; - -public class MonitorServer { - private Server server; - private int port; - - private Server getServer() { - return server; - } - - private void setServer(Server server) { - this.server = server; - } - - private int getPort() { - return port; - } - - private void setPort(int port) { - this.port = port; - } - - public MonitorServer(int port) { - this.setPort(port); - } - - public boolean start() { - try { - - System.out.println(this.getPort()); - this.setServer(new Server()); - Connector connector = new SocketConnector(); - connector.setPort(this.getPort()); - this.getServer().addConnector(connector); - ServletContextHandler servletContextHandler = new ServletContextHandler(); - ServletHolder servletHolder = servletContextHandler.addServlet( - DispatcherServlet.class, "/"); - servletHolder - .setInitParameter("contextConfigLocation", - "classpath*:org/bench4q/monitor/config/application-context.xml"); - this.getServer().setHandler(servletContextHandler); - this.getServer().start(); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean stop() { - try { - if (this.getServer() != null) { - this.getServer().stop(); - } - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } finally { - this.setServer(null); - } - } -} +package org.bench4q.monitor; + +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.bio.SocketConnector; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.springframework.web.servlet.DispatcherServlet; + +public class MonitorServer { + private Server server; + private int port; + + private Server getServer() { + return server; + } + + private void setServer(Server server) { + this.server = server; + } + + private int getPort() { + return port; + } + + private void setPort(int port) { + this.port = port; + } + + public MonitorServer(int port) { + this.setPort(port); + } + + public boolean start() { + try { + + System.out.println(this.getPort()); + this.setServer(new Server()); + Connector connector = new SocketConnector(); + connector.setPort(this.getPort()); + this.getServer().addConnector(connector); + ServletContextHandler servletContextHandler = new ServletContextHandler(); + ServletHolder servletHolder = servletContextHandler.addServlet( + DispatcherServlet.class, "/"); + servletHolder + .setInitParameter("contextConfigLocation", + "classpath*:org/bench4q/monitor/config/application-context.xml"); + this.getServer().setHandler(servletContextHandler); + this.getServer().start(); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public boolean stop() { + try { + if (this.getServer() != null) { + this.getServer().stop(); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } finally { + this.setServer(null); + } + } +} diff --git a/src/main/java/org/bench4q/monitor/OSUtils.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/OSUtils.java similarity index 100% rename from src/main/java/org/bench4q/monitor/OSUtils.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/OSUtils.java diff --git a/src/main/java/org/bench4q/monitor/api/LogicalDiskController.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/LogicalDiskController.java similarity index 97% rename from src/main/java/org/bench4q/monitor/api/LogicalDiskController.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/LogicalDiskController.java index 05af1303..16d9d56b 100644 --- a/src/main/java/org/bench4q/monitor/api/LogicalDiskController.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/LogicalDiskController.java @@ -1,35 +1,35 @@ -package org.bench4q.monitor.api; - -import java.io.IOException; - -import org.bench4q.monitor.entiry.MonitorContorlEntity; -import org.bench4q.monitor.model.LogicalDiskModel; -import org.bench4q.monitor.service.linux.LogicalDiskServiceLinux; -import org.bench4q.monitor.service.windows.LogicalDiskServiceWindows; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -@RequestMapping(value = "/Monitor", method = { RequestMethod.GET, - RequestMethod.POST }) -public class LogicalDiskController extends MonitorContorlEntity {// �Ժ�ʵ��linux��Ҫ����linux��dervice - @RequestMapping("/LogicalDisk") - @ResponseBody - public LogicalDiskModel getLogicalDiskInfo() throws IOException, - InterruptedException { - - if (this.getOsNameString().contains("windows")) { - LogicalDiskServiceWindows logicalDiskServiceWindows = new LogicalDiskServiceWindows(); - return logicalDiskServiceWindows.getLogicalDiskInfo(this - .getIdleTime()); - } else if (this.getOsNameString().contains("linux")) { - LogicalDiskServiceLinux logicalDiskServiceLinux = new LogicalDiskServiceLinux(); - return logicalDiskServiceLinux.getLogicalDiskInfo(this - .getIdleTime()); - } else - return null; - } - -} +package org.bench4q.monitor.api; + +import java.io.IOException; + +import org.bench4q.monitor.entiry.MonitorContorlEntity; +import org.bench4q.monitor.model.LogicalDiskModel; +import org.bench4q.monitor.service.linux.LogicalDiskServiceLinux; +import org.bench4q.monitor.service.windows.LogicalDiskServiceWindows; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping(value = "/Monitor", method = { RequestMethod.GET, + RequestMethod.POST }) +public class LogicalDiskController extends MonitorContorlEntity {// �Ժ�ʵ��linux��Ҫ����linux��dervice + @RequestMapping("/LogicalDisk") + @ResponseBody + public LogicalDiskModel getLogicalDiskInfo() throws IOException, + InterruptedException { + + if (this.getOsNameString().contains("windows")) { + LogicalDiskServiceWindows logicalDiskServiceWindows = new LogicalDiskServiceWindows(); + return logicalDiskServiceWindows.getLogicalDiskInfo(this + .getIdleTime()); + } else if (this.getOsNameString().contains("linux")) { + LogicalDiskServiceLinux logicalDiskServiceLinux = new LogicalDiskServiceLinux(); + return logicalDiskServiceLinux.getLogicalDiskInfo(this + .getIdleTime()); + } else + return null; + } + +} diff --git a/src/main/java/org/bench4q/monitor/api/MemoryController.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/MemoryController.java similarity index 97% rename from src/main/java/org/bench4q/monitor/api/MemoryController.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/MemoryController.java index 643c75eb..41949543 100644 --- a/src/main/java/org/bench4q/monitor/api/MemoryController.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/MemoryController.java @@ -1,33 +1,33 @@ -package org.bench4q.monitor.api; - -import java.io.IOException; - -import org.bench4q.monitor.entiry.MonitorContorlEntity; -import org.bench4q.monitor.model.MemoryModel; -import org.bench4q.monitor.service.linux.MemoryServiceLinux; -import org.bench4q.monitor.service.windows.MemoryServiceWindows; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -@RequestMapping("/Monitor") -public class MemoryController extends MonitorContorlEntity { - - @RequestMapping(value = "/Memory", method = { RequestMethod.GET, - RequestMethod.POST }) - @ResponseBody - public MemoryModel getMemoryInfo() throws NumberFormatException, - IOException { - if (this.getOsNameString().contains("windows")) { - MemoryServiceWindows memoryServiceWindows = new MemoryServiceWindows(); - - return memoryServiceWindows.getMemoryInfo(this.getIdleTime()); - } else if (this.getOsNameString().contains("linux")) { - MemoryServiceLinux memoryServiceLinux = new MemoryServiceLinux(); - return memoryServiceLinux.getMemoryInfo(this.getIdleTime()); - } else - return null; - } -} +package org.bench4q.monitor.api; + +import java.io.IOException; + +import org.bench4q.monitor.entiry.MonitorContorlEntity; +import org.bench4q.monitor.model.MemoryModel; +import org.bench4q.monitor.service.linux.MemoryServiceLinux; +import org.bench4q.monitor.service.windows.MemoryServiceWindows; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/Monitor") +public class MemoryController extends MonitorContorlEntity { + + @RequestMapping(value = "/Memory", method = { RequestMethod.GET, + RequestMethod.POST }) + @ResponseBody + public MemoryModel getMemoryInfo() throws NumberFormatException, + IOException { + if (this.getOsNameString().contains("windows")) { + MemoryServiceWindows memoryServiceWindows = new MemoryServiceWindows(); + + return memoryServiceWindows.getMemoryInfo(this.getIdleTime()); + } else if (this.getOsNameString().contains("linux")) { + MemoryServiceLinux memoryServiceLinux = new MemoryServiceLinux(); + return memoryServiceLinux.getMemoryInfo(this.getIdleTime()); + } else + return null; + } +} diff --git a/src/main/java/org/bench4q/monitor/api/MnitorStart.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/MnitorStart.java similarity index 100% rename from src/main/java/org/bench4q/monitor/api/MnitorStart.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/MnitorStart.java diff --git a/src/main/java/org/bench4q/monitor/api/NetworkInterfaceController.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/NetworkInterfaceController.java similarity index 97% rename from src/main/java/org/bench4q/monitor/api/NetworkInterfaceController.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/NetworkInterfaceController.java index b1bfc88a..ed4a7798 100644 --- a/src/main/java/org/bench4q/monitor/api/NetworkInterfaceController.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/NetworkInterfaceController.java @@ -1,33 +1,33 @@ -package org.bench4q.monitor.api; - -import java.io.IOException; - -import org.bench4q.monitor.entiry.MonitorContorlEntity; -import org.bench4q.monitor.model.NetworkInterfaceModel; -import org.bench4q.monitor.service.linux.NetworkInterfaceServiceLinux; -import org.bench4q.monitor.service.windows.NetworkInterfaceServiceWindows; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -@RequestMapping("/Monitor") -public class NetworkInterfaceController extends MonitorContorlEntity { - - @RequestMapping("/NetworkInterface") - @ResponseBody - public NetworkInterfaceModel getNetworkInterfaceInfo() throws IOException, - InterruptedException { - if (this.getOsNameString().contains("windows")) { - NetworkInterfaceServiceWindows networkInterfaceServiceWindows = new NetworkInterfaceServiceWindows(); - return networkInterfaceServiceWindows.getNetworkInterfaceInfo(this - .getIdleTime()); - } else if (this.getOsNameString().contains("linux")) { - NetworkInterfaceServiceLinux networkInterfaceServiceLinux = new NetworkInterfaceServiceLinux(); - return networkInterfaceServiceLinux.getNetworkInterfaceInfo(this - .getIdleTime()); - } else - return null; - } - -} +package org.bench4q.monitor.api; + +import java.io.IOException; + +import org.bench4q.monitor.entiry.MonitorContorlEntity; +import org.bench4q.monitor.model.NetworkInterfaceModel; +import org.bench4q.monitor.service.linux.NetworkInterfaceServiceLinux; +import org.bench4q.monitor.service.windows.NetworkInterfaceServiceWindows; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/Monitor") +public class NetworkInterfaceController extends MonitorContorlEntity { + + @RequestMapping("/NetworkInterface") + @ResponseBody + public NetworkInterfaceModel getNetworkInterfaceInfo() throws IOException, + InterruptedException { + if (this.getOsNameString().contains("windows")) { + NetworkInterfaceServiceWindows networkInterfaceServiceWindows = new NetworkInterfaceServiceWindows(); + return networkInterfaceServiceWindows.getNetworkInterfaceInfo(this + .getIdleTime()); + } else if (this.getOsNameString().contains("linux")) { + NetworkInterfaceServiceLinux networkInterfaceServiceLinux = new NetworkInterfaceServiceLinux(); + return networkInterfaceServiceLinux.getNetworkInterfaceInfo(this + .getIdleTime()); + } else + return null; + } + +} diff --git a/src/main/java/org/bench4q/monitor/api/PhysicalDiskController.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/PhysicalDiskController.java similarity index 97% rename from src/main/java/org/bench4q/monitor/api/PhysicalDiskController.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/PhysicalDiskController.java index 971477a1..20fcddb1 100644 --- a/src/main/java/org/bench4q/monitor/api/PhysicalDiskController.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/PhysicalDiskController.java @@ -1,33 +1,33 @@ -package org.bench4q.monitor.api; - -import java.io.IOException; - -import org.bench4q.monitor.entiry.MonitorContorlEntity; -import org.bench4q.monitor.model.PhysicalDiskModel; -import org.bench4q.monitor.service.linux.PhysicalDiskServiceLinux; -import org.bench4q.monitor.service.windows.PhysicalDiskServiceWindows; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -@RequestMapping("/Monitor") -public class PhysicalDiskController extends MonitorContorlEntity { - - @RequestMapping("/PhysicalDisk") - @ResponseBody - public PhysicalDiskModel getPhysicalDislInfo() throws IOException, - InterruptedException { - if (this.getOsNameString().contains("windows")) { - PhysicalDiskServiceWindows physicalDiskServiceWindows = new PhysicalDiskServiceWindows(); - return physicalDiskServiceWindows.getPhysicalDiskInfo(this - .getIdleTime()); - } else if (this.getOsNameString().contains("linux")) { - PhysicalDiskServiceLinux physicalDiskServiceLinux = new PhysicalDiskServiceLinux(); - return physicalDiskServiceLinux.getPhysicalFDiskInfo(this - .getIdleTime()); - } else - return null; - - } -} +package org.bench4q.monitor.api; + +import java.io.IOException; + +import org.bench4q.monitor.entiry.MonitorContorlEntity; +import org.bench4q.monitor.model.PhysicalDiskModel; +import org.bench4q.monitor.service.linux.PhysicalDiskServiceLinux; +import org.bench4q.monitor.service.windows.PhysicalDiskServiceWindows; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/Monitor") +public class PhysicalDiskController extends MonitorContorlEntity { + + @RequestMapping("/PhysicalDisk") + @ResponseBody + public PhysicalDiskModel getPhysicalDislInfo() throws IOException, + InterruptedException { + if (this.getOsNameString().contains("windows")) { + PhysicalDiskServiceWindows physicalDiskServiceWindows = new PhysicalDiskServiceWindows(); + return physicalDiskServiceWindows.getPhysicalDiskInfo(this + .getIdleTime()); + } else if (this.getOsNameString().contains("linux")) { + PhysicalDiskServiceLinux physicalDiskServiceLinux = new PhysicalDiskServiceLinux(); + return physicalDiskServiceLinux.getPhysicalFDiskInfo(this + .getIdleTime()); + } else + return null; + + } +} diff --git a/src/main/java/org/bench4q/monitor/api/ProcessController.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/ProcessController.java similarity index 97% rename from src/main/java/org/bench4q/monitor/api/ProcessController.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/ProcessController.java index b6a5906a..b11a1edc 100644 --- a/src/main/java/org/bench4q/monitor/api/ProcessController.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/ProcessController.java @@ -1,36 +1,36 @@ -package org.bench4q.monitor.api; - -import java.io.IOException; - -import org.bench4q.monitor.entiry.MonitorContorlEntity; -import org.bench4q.monitor.model.ProcessModel; -import org.bench4q.monitor.service.linux.ProcessServiceLinux; -import org.bench4q.monitor.service.windows.ProcessServiceWindows; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -@RequestMapping("/Monitor") -public class ProcessController extends MonitorContorlEntity { - - @RequestMapping("/Process") - @ResponseBody - public ProcessModel getProcessInfo() throws IOException, - InterruptedException { - - if (this.getOsNameString().contains("windows")) { - ProcessServiceWindows processServiceWindows = new ProcessServiceWindows(); - return processServiceWindows.getProcessInfo(this.getIdleTime()); - } else if (this.getOsNameString().contains("linux")) { - ProcessServiceLinux processServiceLinux = new ProcessServiceLinux(); - // ProcessModel processModel = - // processServiceLinux.getProcessInfo(this - // .getIdleTime()); - - return processServiceLinux.getProcessInfo(this.getIdleTime()); - } else - return null; - } - -} +package org.bench4q.monitor.api; + +import java.io.IOException; + +import org.bench4q.monitor.entiry.MonitorContorlEntity; +import org.bench4q.monitor.model.ProcessModel; +import org.bench4q.monitor.service.linux.ProcessServiceLinux; +import org.bench4q.monitor.service.windows.ProcessServiceWindows; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/Monitor") +public class ProcessController extends MonitorContorlEntity { + + @RequestMapping("/Process") + @ResponseBody + public ProcessModel getProcessInfo() throws IOException, + InterruptedException { + + if (this.getOsNameString().contains("windows")) { + ProcessServiceWindows processServiceWindows = new ProcessServiceWindows(); + return processServiceWindows.getProcessInfo(this.getIdleTime()); + } else if (this.getOsNameString().contains("linux")) { + ProcessServiceLinux processServiceLinux = new ProcessServiceLinux(); + // ProcessModel processModel = + // processServiceLinux.getProcessInfo(this + // .getIdleTime()); + + return processServiceLinux.getProcessInfo(this.getIdleTime()); + } else + return null; + } + +} diff --git a/src/main/java/org/bench4q/monitor/api/ProcessorController.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/ProcessorController.java similarity index 97% rename from src/main/java/org/bench4q/monitor/api/ProcessorController.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/ProcessorController.java index c43e0dcf..360fb9bd 100644 --- a/src/main/java/org/bench4q/monitor/api/ProcessorController.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/ProcessorController.java @@ -1,35 +1,35 @@ -package org.bench4q.monitor.api; - -import java.io.IOException; - -import org.bench4q.monitor.entiry.MonitorContorlEntity; -import org.bench4q.monitor.model.ProcessorModel; -import org.bench4q.monitor.service.linux.ProcessorServiceLinux; -import org.bench4q.monitor.service.windows.ProcessorServiceWindows; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -@RequestMapping("/Monitor") -public class ProcessorController extends MonitorContorlEntity { - - @RequestMapping("/Processor") - @ResponseBody - public ProcessorModel getProcessorInfo() throws IOException, InterruptedException { - - if (this.getOsNameString().contains("windows")) { - ProcessorServiceWindows processorServiceWindows=new ProcessorServiceWindows(); - return processorServiceWindows.getProcessorInfo( - this.getIdleTime()); - } - else if (this.getOsNameString().contains("linux")){ - - ProcessorServiceLinux processorServiceLinux=new ProcessorServiceLinux(); - return processorServiceLinux.getProcessorInfo( - this.getIdleTime()); - } - else - return null; - } -} +package org.bench4q.monitor.api; + +import java.io.IOException; + +import org.bench4q.monitor.entiry.MonitorContorlEntity; +import org.bench4q.monitor.model.ProcessorModel; +import org.bench4q.monitor.service.linux.ProcessorServiceLinux; +import org.bench4q.monitor.service.windows.ProcessorServiceWindows; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/Monitor") +public class ProcessorController extends MonitorContorlEntity { + + @RequestMapping("/Processor") + @ResponseBody + public ProcessorModel getProcessorInfo() throws IOException, InterruptedException { + + if (this.getOsNameString().contains("windows")) { + ProcessorServiceWindows processorServiceWindows=new ProcessorServiceWindows(); + return processorServiceWindows.getProcessorInfo( + this.getIdleTime()); + } + else if (this.getOsNameString().contains("linux")){ + + ProcessorServiceLinux processorServiceLinux=new ProcessorServiceLinux(); + return processorServiceLinux.getProcessorInfo( + this.getIdleTime()); + } + else + return null; + } +} diff --git a/src/main/java/org/bench4q/monitor/api/SystemController.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/SystemController.java similarity index 97% rename from src/main/java/org/bench4q/monitor/api/SystemController.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/SystemController.java index 4022cabb..679acc8e 100644 --- a/src/main/java/org/bench4q/monitor/api/SystemController.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/api/SystemController.java @@ -1,28 +1,28 @@ -package org.bench4q.monitor.api; - -import java.io.IOException; - -import org.bench4q.monitor.entiry.MonitorContorlEntity; -import org.bench4q.monitor.model.SystemModel; -import org.bench4q.monitor.service.linux.SystemServiceLinux; -import org.bench4q.monitor.service.windows.SystemServiceWindows; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -@RequestMapping("/Monitor") -public class SystemController extends MonitorContorlEntity { - @ResponseBody - @RequestMapping("/System") - public SystemModel getSystemInfo() throws IOException, InterruptedException { - if (this.getOsNameString().contains("windows")) { - SystemServiceWindows systemServiceWindows = new SystemServiceWindows(); - return systemServiceWindows.getSystemInfo(this.getIdleTime()); - } else if (this.getOsNameString().contains("linux")) { - SystemServiceLinux systemServiceLinux = new SystemServiceLinux(); - return systemServiceLinux.getSystemInfo(this.getIdleTime()); - } else - return null; - } -} +package org.bench4q.monitor.api; + +import java.io.IOException; + +import org.bench4q.monitor.entiry.MonitorContorlEntity; +import org.bench4q.monitor.model.SystemModel; +import org.bench4q.monitor.service.linux.SystemServiceLinux; +import org.bench4q.monitor.service.windows.SystemServiceWindows; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/Monitor") +public class SystemController extends MonitorContorlEntity { + @ResponseBody + @RequestMapping("/System") + public SystemModel getSystemInfo() throws IOException, InterruptedException { + if (this.getOsNameString().contains("windows")) { + SystemServiceWindows systemServiceWindows = new SystemServiceWindows(); + return systemServiceWindows.getSystemInfo(this.getIdleTime()); + } else if (this.getOsNameString().contains("linux")) { + SystemServiceLinux systemServiceLinux = new SystemServiceLinux(); + return systemServiceLinux.getSystemInfo(this.getIdleTime()); + } else + return null; + } +} diff --git a/src/main/java/org/bench4q/monitor/entiry/LinuxFileRead.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/entiry/LinuxFileRead.java similarity index 100% rename from src/main/java/org/bench4q/monitor/entiry/LinuxFileRead.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/entiry/LinuxFileRead.java diff --git a/src/main/java/org/bench4q/monitor/entiry/MonitorContorlEntity.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/entiry/MonitorContorlEntity.java similarity index 95% rename from src/main/java/org/bench4q/monitor/entiry/MonitorContorlEntity.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/entiry/MonitorContorlEntity.java index 97438ad3..ab2563ac 100644 --- a/src/main/java/org/bench4q/monitor/entiry/MonitorContorlEntity.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/entiry/MonitorContorlEntity.java @@ -1,25 +1,25 @@ -package org.bench4q.monitor.entiry; - - -public class MonitorContorlEntity { - private String osNameString; - private int idleTime; - public MonitorContorlEntity(){ - this.osNameString=System.getProperty("os.name").toLowerCase(); - this.idleTime=3000; - } - public String getOsNameString() { - return osNameString; - } - public void setOsNameString(String osNameString) { - this.osNameString = osNameString; - } - public int getIdleTime() { - return idleTime; - } - public void setIdleTime(int idleTime) { - this.idleTime = idleTime; - } - } - - +package org.bench4q.monitor.entiry; + + +public class MonitorContorlEntity { + private String osNameString; + private int idleTime; + public MonitorContorlEntity(){ + this.osNameString=System.getProperty("os.name").toLowerCase(); + this.idleTime=3000; + } + public String getOsNameString() { + return osNameString; + } + public void setOsNameString(String osNameString) { + this.osNameString = osNameString; + } + public int getIdleTime() { + return idleTime; + } + public void setIdleTime(int idleTime) { + this.idleTime = idleTime; + } + } + + diff --git a/src/main/java/org/bench4q/monitor/file/Linux/WriteLogicalDiskLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteLogicalDiskLinux.java similarity index 100% rename from src/main/java/org/bench4q/monitor/file/Linux/WriteLogicalDiskLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteLogicalDiskLinux.java diff --git a/src/main/java/org/bench4q/monitor/file/Linux/WriteMemoryLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteMemoryLinux.java similarity index 100% rename from src/main/java/org/bench4q/monitor/file/Linux/WriteMemoryLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteMemoryLinux.java diff --git a/src/main/java/org/bench4q/monitor/file/Linux/WriteNetworkInterfaceLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteNetworkInterfaceLinux.java similarity index 96% rename from src/main/java/org/bench4q/monitor/file/Linux/WriteNetworkInterfaceLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteNetworkInterfaceLinux.java index a8969f8d..9cc7fd50 100644 --- a/src/main/java/org/bench4q/monitor/file/Linux/WriteNetworkInterfaceLinux.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteNetworkInterfaceLinux.java @@ -1,37 +1,37 @@ -package org.bench4q.monitor.file.Linux; - -import java.io.FileNotFoundException; -import java.io.PrintWriter; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import org.bench4q.monitor.model.NetworkInterfaceModel; -import org.bench4q.monitor.performance.linux.NetworkInterfaceMonitor; -import org.bench4q.monitor.files.Write; - -public class WriteNetworkInterfaceLinux extends Write { - private NetworkInterfaceMonitor networkInterfaceMonitor; - - public WriteNetworkInterfaceLinux(PrintWriter out, int idleTime) - throws FileNotFoundException { - this.out = out; - this.networkInterfaceMonitor = new NetworkInterfaceMonitor(); - this.idleTime = idleTime; - } - - public void run() { - try { - JAXBContext context = JAXBContext - .newInstance(NetworkInterfaceModel.class); - Marshaller marshaller = context.createMarshaller(); - NetworkInterfaceModel networkInterfaceModel = networkInterfaceMonitor - .getNetworkInterfaceInfo(idleTime); - marshaller.marshal(networkInterfaceModel, out); - } catch (Exception e) { - System.out.println(e); - } - - } - -} +package org.bench4q.monitor.file.Linux; + +import java.io.FileNotFoundException; +import java.io.PrintWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.bench4q.monitor.model.NetworkInterfaceModel; +import org.bench4q.monitor.performance.linux.NetworkInterfaceMonitor; +import org.bench4q.monitor.files.Write; + +public class WriteNetworkInterfaceLinux extends Write { + private NetworkInterfaceMonitor networkInterfaceMonitor; + + public WriteNetworkInterfaceLinux(PrintWriter out, int idleTime) + throws FileNotFoundException { + this.out = out; + this.networkInterfaceMonitor = new NetworkInterfaceMonitor(); + this.idleTime = idleTime; + } + + public void run() { + try { + JAXBContext context = JAXBContext + .newInstance(NetworkInterfaceModel.class); + Marshaller marshaller = context.createMarshaller(); + NetworkInterfaceModel networkInterfaceModel = networkInterfaceMonitor + .getNetworkInterfaceInfo(idleTime); + marshaller.marshal(networkInterfaceModel, out); + } catch (Exception e) { + System.out.println(e); + } + + } + +} diff --git a/src/main/java/org/bench4q/monitor/file/Linux/WritePhysicalDiskLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WritePhysicalDiskLinux.java similarity index 96% rename from src/main/java/org/bench4q/monitor/file/Linux/WritePhysicalDiskLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WritePhysicalDiskLinux.java index 90bf38ab..c00d0fd1 100644 --- a/src/main/java/org/bench4q/monitor/file/Linux/WritePhysicalDiskLinux.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WritePhysicalDiskLinux.java @@ -1,38 +1,38 @@ -package org.bench4q.monitor.file.Linux; - -import java.io.FileNotFoundException; -import java.io.PrintWriter; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import org.bench4q.monitor.model.PhysicalDiskModel; -import org.bench4q.monitor.performance.linux.PhysicalDiskMonitor; -import org.bench4q.monitor.files.Write; - -public class WritePhysicalDiskLinux extends Write { - - private PhysicalDiskMonitor physicalDiskMonitor; - - public WritePhysicalDiskLinux(PrintWriter out, int idleTime) - throws FileNotFoundException { - this.out = out; - this.physicalDiskMonitor = new PhysicalDiskMonitor(); - this.idleTime = idleTime; - } - - public void run() { - try { - JAXBContext context = JAXBContext - .newInstance(PhysicalDiskModel.class); - Marshaller marshaller = context.createMarshaller(); - PhysicalDiskModel physicalDiskModel = physicalDiskMonitor - .getPhysicalDiskInfo(idleTime); - marshaller.marshal(physicalDiskModel, out); - } catch (Exception e) { - System.out.println(e); - } - - } - -} +package org.bench4q.monitor.file.Linux; + +import java.io.FileNotFoundException; +import java.io.PrintWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.bench4q.monitor.model.PhysicalDiskModel; +import org.bench4q.monitor.performance.linux.PhysicalDiskMonitor; +import org.bench4q.monitor.files.Write; + +public class WritePhysicalDiskLinux extends Write { + + private PhysicalDiskMonitor physicalDiskMonitor; + + public WritePhysicalDiskLinux(PrintWriter out, int idleTime) + throws FileNotFoundException { + this.out = out; + this.physicalDiskMonitor = new PhysicalDiskMonitor(); + this.idleTime = idleTime; + } + + public void run() { + try { + JAXBContext context = JAXBContext + .newInstance(PhysicalDiskModel.class); + Marshaller marshaller = context.createMarshaller(); + PhysicalDiskModel physicalDiskModel = physicalDiskMonitor + .getPhysicalDiskInfo(idleTime); + marshaller.marshal(physicalDiskModel, out); + } catch (Exception e) { + System.out.println(e); + } + + } + +} diff --git a/src/main/java/org/bench4q/monitor/file/Linux/WriteProcessLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteProcessLinux.java similarity index 96% rename from src/main/java/org/bench4q/monitor/file/Linux/WriteProcessLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteProcessLinux.java index 4b3df699..229a04b1 100644 --- a/src/main/java/org/bench4q/monitor/file/Linux/WriteProcessLinux.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteProcessLinux.java @@ -1,33 +1,33 @@ -package org.bench4q.monitor.file.Linux; - -import java.io.PrintWriter; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import org.bench4q.monitor.model.ProcessModel; -import org.bench4q.monitor.performance.linux.ProcessMonitor; -import org.bench4q.monitor.files.Write; - -public class WriteProcessLinux extends Write { - private ProcessMonitor processMonitor; - - public WriteProcessLinux(PrintWriter out, int idleTime) { - this.out = out; - this.processMonitor = new ProcessMonitor(); - this.idleTime = idleTime; - } - - public void run() { - try { - JAXBContext context = JAXBContext.newInstance(ProcessModel.class); - Marshaller marshaller = context.createMarshaller(); - ProcessModel processModel = processMonitor.getProcessInfo(idleTime); - marshaller.marshal(processModel, out); - } catch (Exception e) { - System.out.println(e); - } - - } - -} +package org.bench4q.monitor.file.Linux; + +import java.io.PrintWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.bench4q.monitor.model.ProcessModel; +import org.bench4q.monitor.performance.linux.ProcessMonitor; +import org.bench4q.monitor.files.Write; + +public class WriteProcessLinux extends Write { + private ProcessMonitor processMonitor; + + public WriteProcessLinux(PrintWriter out, int idleTime) { + this.out = out; + this.processMonitor = new ProcessMonitor(); + this.idleTime = idleTime; + } + + public void run() { + try { + JAXBContext context = JAXBContext.newInstance(ProcessModel.class); + Marshaller marshaller = context.createMarshaller(); + ProcessModel processModel = processMonitor.getProcessInfo(idleTime); + marshaller.marshal(processModel, out); + } catch (Exception e) { + System.out.println(e); + } + + } + +} diff --git a/src/main/java/org/bench4q/monitor/file/Linux/WriteProcessorLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteProcessorLinux.java similarity index 96% rename from src/main/java/org/bench4q/monitor/file/Linux/WriteProcessorLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteProcessorLinux.java index db1a4ac0..d67db1d1 100644 --- a/src/main/java/org/bench4q/monitor/file/Linux/WriteProcessorLinux.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteProcessorLinux.java @@ -1,36 +1,36 @@ -package org.bench4q.monitor.file.Linux; - -import java.io.FileNotFoundException; -import java.io.PrintWriter; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import org.bench4q.monitor.model.ProcessorModel; -import org.bench4q.monitor.performance.linux.ProcessorMonitor; -import org.bench4q.monitor.files.Write; - -public class WriteProcessorLinux extends Write { - private ProcessorMonitor processorMonitor; - - public WriteProcessorLinux(PrintWriter out, int idleTime) - throws FileNotFoundException { - this.out = out; - this.processorMonitor = new ProcessorMonitor(); - this.idleTime = idleTime; - } - - public void run() { - try { - JAXBContext context = JAXBContext.newInstance(ProcessorModel.class); - Marshaller marshaller = context.createMarshaller(); - ProcessorModel processorModel = processorMonitor - .getProcessorInfo(idleTime); - marshaller.marshal(processorModel, out); - } catch (Exception e) { - System.out.println(e); - } - - } - -} +package org.bench4q.monitor.file.Linux; + +import java.io.FileNotFoundException; +import java.io.PrintWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.bench4q.monitor.model.ProcessorModel; +import org.bench4q.monitor.performance.linux.ProcessorMonitor; +import org.bench4q.monitor.files.Write; + +public class WriteProcessorLinux extends Write { + private ProcessorMonitor processorMonitor; + + public WriteProcessorLinux(PrintWriter out, int idleTime) + throws FileNotFoundException { + this.out = out; + this.processorMonitor = new ProcessorMonitor(); + this.idleTime = idleTime; + } + + public void run() { + try { + JAXBContext context = JAXBContext.newInstance(ProcessorModel.class); + Marshaller marshaller = context.createMarshaller(); + ProcessorModel processorModel = processorMonitor + .getProcessorInfo(idleTime); + marshaller.marshal(processorModel, out); + } catch (Exception e) { + System.out.println(e); + } + + } + +} diff --git a/src/main/java/org/bench4q/monitor/file/Linux/WriteSystemLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteSystemLinux.java similarity index 100% rename from src/main/java/org/bench4q/monitor/file/Linux/WriteSystemLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/Linux/WriteSystemLinux.java diff --git a/src/main/java/org/bench4q/monitor/file/windows/WriteLogicalDiskWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteLogicalDiskWindows.java similarity index 100% rename from src/main/java/org/bench4q/monitor/file/windows/WriteLogicalDiskWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteLogicalDiskWindows.java diff --git a/src/main/java/org/bench4q/monitor/file/windows/WriteMemoryWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteMemoryWindows.java similarity index 100% rename from src/main/java/org/bench4q/monitor/file/windows/WriteMemoryWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteMemoryWindows.java diff --git a/src/main/java/org/bench4q/monitor/file/windows/WriteNetworkInterfaceWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteNetworkInterfaceWindows.java similarity index 96% rename from src/main/java/org/bench4q/monitor/file/windows/WriteNetworkInterfaceWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteNetworkInterfaceWindows.java index 6efad297..dee8edda 100644 --- a/src/main/java/org/bench4q/monitor/file/windows/WriteNetworkInterfaceWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteNetworkInterfaceWindows.java @@ -1,35 +1,35 @@ -package org.bench4q.monitor.file.windows; - -import java.io.PrintWriter; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import org.bench4q.monitor.model.NetworkInterfaceModel; -import org.bench4q.monitor.service.windows.NetworkInterfaceServiceWindows; -import org.bench4q.monitor.files.Write; - -public class WriteNetworkInterfaceWindows extends Write { - private NetworkInterfaceServiceWindows networkInterfaceServiceWindows; - - public WriteNetworkInterfaceWindows(PrintWriter out, int idleTime) { - this.out = out; - this.networkInterfaceServiceWindows = new NetworkInterfaceServiceWindows(); - this.idleTime = idleTime; - } - - public void run() { - try { - JAXBContext context = JAXBContext - .newInstance(NetworkInterfaceModel.class); - Marshaller marshaller = context.createMarshaller(); - NetworkInterfaceModel networkInterfaceModel = networkInterfaceServiceWindows - .getNetworkInterfaceInfo(idleTime); - marshaller.marshal(networkInterfaceModel, out); - } catch (Exception e) { - System.out.println(e); - } - - } - -} +package org.bench4q.monitor.file.windows; + +import java.io.PrintWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.bench4q.monitor.model.NetworkInterfaceModel; +import org.bench4q.monitor.service.windows.NetworkInterfaceServiceWindows; +import org.bench4q.monitor.files.Write; + +public class WriteNetworkInterfaceWindows extends Write { + private NetworkInterfaceServiceWindows networkInterfaceServiceWindows; + + public WriteNetworkInterfaceWindows(PrintWriter out, int idleTime) { + this.out = out; + this.networkInterfaceServiceWindows = new NetworkInterfaceServiceWindows(); + this.idleTime = idleTime; + } + + public void run() { + try { + JAXBContext context = JAXBContext + .newInstance(NetworkInterfaceModel.class); + Marshaller marshaller = context.createMarshaller(); + NetworkInterfaceModel networkInterfaceModel = networkInterfaceServiceWindows + .getNetworkInterfaceInfo(idleTime); + marshaller.marshal(networkInterfaceModel, out); + } catch (Exception e) { + System.out.println(e); + } + + } + +} diff --git a/src/main/java/org/bench4q/monitor/file/windows/WritePhysicalDiskWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WritePhysicalDiskWindows.java similarity index 96% rename from src/main/java/org/bench4q/monitor/file/windows/WritePhysicalDiskWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WritePhysicalDiskWindows.java index 6e135835..a18634ed 100644 --- a/src/main/java/org/bench4q/monitor/file/windows/WritePhysicalDiskWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WritePhysicalDiskWindows.java @@ -1,36 +1,36 @@ -package org.bench4q.monitor.file.windows; - -import java.io.PrintWriter; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import org.bench4q.monitor.model.PhysicalDiskModel; -import org.bench4q.monitor.service.windows.PhysicalDiskServiceWindows; -import org.bench4q.monitor.files.Write; - -public class WritePhysicalDiskWindows extends Write { - - private PhysicalDiskServiceWindows physicalDiskServiceWindows; - - public WritePhysicalDiskWindows(PrintWriter out, int idleTime) { - this.out = out; - this.physicalDiskServiceWindows = new PhysicalDiskServiceWindows(); - this.idleTime = idleTime; - } - - public void run() { - try { - JAXBContext context = JAXBContext - .newInstance(PhysicalDiskModel.class); - Marshaller marshaller = context.createMarshaller(); - PhysicalDiskModel physicalDiskModel = physicalDiskServiceWindows - .getPhysicalDiskInfo(idleTime); - marshaller.marshal(physicalDiskModel, out); - } catch (Exception e) { - System.out.println(e); - } - - } - -} +package org.bench4q.monitor.file.windows; + +import java.io.PrintWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.bench4q.monitor.model.PhysicalDiskModel; +import org.bench4q.monitor.service.windows.PhysicalDiskServiceWindows; +import org.bench4q.monitor.files.Write; + +public class WritePhysicalDiskWindows extends Write { + + private PhysicalDiskServiceWindows physicalDiskServiceWindows; + + public WritePhysicalDiskWindows(PrintWriter out, int idleTime) { + this.out = out; + this.physicalDiskServiceWindows = new PhysicalDiskServiceWindows(); + this.idleTime = idleTime; + } + + public void run() { + try { + JAXBContext context = JAXBContext + .newInstance(PhysicalDiskModel.class); + Marshaller marshaller = context.createMarshaller(); + PhysicalDiskModel physicalDiskModel = physicalDiskServiceWindows + .getPhysicalDiskInfo(idleTime); + marshaller.marshal(physicalDiskModel, out); + } catch (Exception e) { + System.out.println(e); + } + + } + +} diff --git a/src/main/java/org/bench4q/monitor/file/windows/WriteProcessWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteProcessWindows.java similarity index 96% rename from src/main/java/org/bench4q/monitor/file/windows/WriteProcessWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteProcessWindows.java index f619e0db..dbcb5f41 100644 --- a/src/main/java/org/bench4q/monitor/file/windows/WriteProcessWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteProcessWindows.java @@ -1,34 +1,34 @@ -package org.bench4q.monitor.file.windows; - -import java.io.PrintWriter; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import org.bench4q.monitor.model.ProcessModel; -import org.bench4q.monitor.service.windows.ProcessServiceWindows; -import org.bench4q.monitor.files.Write; - -public class WriteProcessWindows extends Write { - private ProcessServiceWindows processServiceWindows; - - public WriteProcessWindows(PrintWriter out, int idleTime) { - this.out = out; - this.processServiceWindows = new ProcessServiceWindows(); - this.idleTime = idleTime; - } - - public void run() { - try { - JAXBContext context = JAXBContext.newInstance(ProcessModel.class); - Marshaller marshaller = context.createMarshaller(); - ProcessModel processModel = processServiceWindows - .getProcessInfo(idleTime); - marshaller.marshal(processModel, out); - } catch (Exception e) { - System.out.println(e); - } - - } - -} +package org.bench4q.monitor.file.windows; + +import java.io.PrintWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.bench4q.monitor.model.ProcessModel; +import org.bench4q.monitor.service.windows.ProcessServiceWindows; +import org.bench4q.monitor.files.Write; + +public class WriteProcessWindows extends Write { + private ProcessServiceWindows processServiceWindows; + + public WriteProcessWindows(PrintWriter out, int idleTime) { + this.out = out; + this.processServiceWindows = new ProcessServiceWindows(); + this.idleTime = idleTime; + } + + public void run() { + try { + JAXBContext context = JAXBContext.newInstance(ProcessModel.class); + Marshaller marshaller = context.createMarshaller(); + ProcessModel processModel = processServiceWindows + .getProcessInfo(idleTime); + marshaller.marshal(processModel, out); + } catch (Exception e) { + System.out.println(e); + } + + } + +} diff --git a/src/main/java/org/bench4q/monitor/file/windows/WriteProcessorWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteProcessorWindows.java similarity index 96% rename from src/main/java/org/bench4q/monitor/file/windows/WriteProcessorWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteProcessorWindows.java index 095632a6..a1151014 100644 --- a/src/main/java/org/bench4q/monitor/file/windows/WriteProcessorWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteProcessorWindows.java @@ -1,34 +1,34 @@ -package org.bench4q.monitor.file.windows; - -import java.io.PrintWriter; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import org.bench4q.monitor.model.ProcessorModel; -import org.bench4q.monitor.service.windows.ProcessorServiceWindows; -import org.bench4q.monitor.files.Write; - -public class WriteProcessorWindows extends Write { - private ProcessorServiceWindows processorServiceWindows; - - public WriteProcessorWindows(PrintWriter out, int idleTime) { - this.out = out; - this.processorServiceWindows = new ProcessorServiceWindows(); - this.idleTime = idleTime; - } - - public void run() { - try { - JAXBContext context = JAXBContext.newInstance(ProcessorModel.class); - Marshaller marshaller = context.createMarshaller(); - ProcessorModel processorModel = processorServiceWindows - .getProcessorInfo(idleTime); - marshaller.marshal(processorModel, out); - } catch (Exception e) { - System.out.println(e); - } - - } - -} +package org.bench4q.monitor.file.windows; + +import java.io.PrintWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.bench4q.monitor.model.ProcessorModel; +import org.bench4q.monitor.service.windows.ProcessorServiceWindows; +import org.bench4q.monitor.files.Write; + +public class WriteProcessorWindows extends Write { + private ProcessorServiceWindows processorServiceWindows; + + public WriteProcessorWindows(PrintWriter out, int idleTime) { + this.out = out; + this.processorServiceWindows = new ProcessorServiceWindows(); + this.idleTime = idleTime; + } + + public void run() { + try { + JAXBContext context = JAXBContext.newInstance(ProcessorModel.class); + Marshaller marshaller = context.createMarshaller(); + ProcessorModel processorModel = processorServiceWindows + .getProcessorInfo(idleTime); + marshaller.marshal(processorModel, out); + } catch (Exception e) { + System.out.println(e); + } + + } + +} diff --git a/src/main/java/org/bench4q/monitor/file/windows/WriteSystemWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteSystemWindows.java similarity index 96% rename from src/main/java/org/bench4q/monitor/file/windows/WriteSystemWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteSystemWindows.java index 1d0015d3..331a271e 100644 --- a/src/main/java/org/bench4q/monitor/file/windows/WriteSystemWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/file/windows/WriteSystemWindows.java @@ -1,34 +1,34 @@ -package org.bench4q.monitor.file.windows; - -import java.io.PrintWriter; -import org.bench4q.monitor.service.windows.SystemServiceWindows; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import org.bench4q.monitor.model.SystemModel; -import org.bench4q.monitor.files.Write; - -public class WriteSystemWindows extends Write { - private SystemServiceWindows SystemServiceWindows; - - public WriteSystemWindows(PrintWriter out, int idleTime) { - this.out = out; - this.SystemServiceWindows = new SystemServiceWindows(); - this.idleTime = idleTime; - } - - public void run() { - try { - JAXBContext context = JAXBContext.newInstance(SystemModel.class); - Marshaller marshaller = context.createMarshaller(); - SystemModel SystemModel = SystemServiceWindows - .getSystemInfo(idleTime); - marshaller.marshal(SystemModel, out); - } catch (Exception e) { - System.out.println(e); - } - - } - -} +package org.bench4q.monitor.file.windows; + +import java.io.PrintWriter; +import org.bench4q.monitor.service.windows.SystemServiceWindows; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.bench4q.monitor.model.SystemModel; +import org.bench4q.monitor.files.Write; + +public class WriteSystemWindows extends Write { + private SystemServiceWindows SystemServiceWindows; + + public WriteSystemWindows(PrintWriter out, int idleTime) { + this.out = out; + this.SystemServiceWindows = new SystemServiceWindows(); + this.idleTime = idleTime; + } + + public void run() { + try { + JAXBContext context = JAXBContext.newInstance(SystemModel.class); + Marshaller marshaller = context.createMarshaller(); + SystemModel SystemModel = SystemServiceWindows + .getSystemInfo(idleTime); + marshaller.marshal(SystemModel, out); + } catch (Exception e) { + System.out.println(e); + } + + } + +} diff --git a/src/main/java/org/bench4q/monitor/files/CreatFileName.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/files/CreatFileName.java similarity index 95% rename from src/main/java/org/bench4q/monitor/files/CreatFileName.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/files/CreatFileName.java index e4c81ea8..438b057f 100644 --- a/src/main/java/org/bench4q/monitor/files/CreatFileName.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/files/CreatFileName.java @@ -1,21 +1,21 @@ -package org.bench4q.monitor.files; - -import java.util.UUID; - -public class CreatFileName { - - public CreatFileName(String part, String time) { - this.part = part; - this.time = time; - } - - private String part; - private String time; - - public String getFileName() { - String fileName; - UUID uuid = UUID.randomUUID(); - fileName = uuid.toString() + "_" + part + "_" + time + ".xml"; - return fileName; - } -} +package org.bench4q.monitor.files; + +import java.util.UUID; + +public class CreatFileName { + + public CreatFileName(String part, String time) { + this.part = part; + this.time = time; + } + + private String part; + private String time; + + public String getFileName() { + String fileName; + UUID uuid = UUID.randomUUID(); + fileName = uuid.toString() + "_" + part + "_" + time + ".xml"; + return fileName; + } +} diff --git a/src/main/java/org/bench4q/monitor/files/ReadFile.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/files/ReadFile.java similarity index 96% rename from src/main/java/org/bench4q/monitor/files/ReadFile.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/files/ReadFile.java index d0272a53..5ccf7979 100644 --- a/src/main/java/org/bench4q/monitor/files/ReadFile.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/files/ReadFile.java @@ -1,28 +1,28 @@ -package org.bench4q.monitor.files; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.OutputStream; - -import org.springframework.stereotype.Component; -import org.springframework.util.FileCopyUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Component -@RequestMapping("/Mon") -public class ReadFile { - private String fileNameFile = "E:/wxr.xml"; - - @RequestMapping("/File") - @ResponseBody - public void getFile(OutputStream os) throws IOException { - FileInputStream fileInputStream = new FileInputStream(new File( - fileNameFile)); - // File file = new File(fileNameFile); - // Resource resource=new ClassPathResource(fileNameFile);//; - FileCopyUtils.copy(fileInputStream, os);// - - } -} +package org.bench4q.monitor.files; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.OutputStream; + +import org.springframework.stereotype.Component; +import org.springframework.util.FileCopyUtils; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Component +@RequestMapping("/Mon") +public class ReadFile { + private String fileNameFile = "E:/wxr.xml"; + + @RequestMapping("/File") + @ResponseBody + public void getFile(OutputStream os) throws IOException { + FileInputStream fileInputStream = new FileInputStream(new File( + fileNameFile)); + // File file = new File(fileNameFile); + // Resource resource=new ClassPathResource(fileNameFile);//; + FileCopyUtils.copy(fileInputStream, os);// + + } +} diff --git a/src/main/java/org/bench4q/monitor/files/Write.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/files/Write.java similarity index 100% rename from src/main/java/org/bench4q/monitor/files/Write.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/files/Write.java diff --git a/src/main/java/org/bench4q/monitor/files/WriteFiles.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/files/WriteFiles.java similarity index 97% rename from src/main/java/org/bench4q/monitor/files/WriteFiles.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/files/WriteFiles.java index 8e28e4ce..befa0b4b 100644 --- a/src/main/java/org/bench4q/monitor/files/WriteFiles.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/files/WriteFiles.java @@ -1,237 +1,237 @@ -package org.bench4q.monitor.files; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.bench4q.monitor.entiry.MonitorContorlEntity; -import org.bench4q.monitor.file.Linux.WriteLogicalDiskLinux; -import org.bench4q.monitor.file.Linux.WriteMemoryLinux; -import org.bench4q.monitor.file.Linux.WriteNetworkInterfaceLinux; -import org.bench4q.monitor.file.Linux.WritePhysicalDiskLinux; -import org.bench4q.monitor.file.Linux.WriteProcessLinux; -import org.bench4q.monitor.file.Linux.WriteProcessorLinux; -import org.bench4q.monitor.file.Linux.WriteSystemLinux; -import org.bench4q.monitor.file.windows.WriteLogicalDiskWindows; -import org.bench4q.monitor.file.windows.WriteMemoryWindows; -import org.bench4q.monitor.file.windows.WriteNetworkInterfaceWindows; -import org.bench4q.monitor.file.windows.WritePhysicalDiskWindows; -import org.bench4q.monitor.file.windows.WriteProcessWindows; -import org.bench4q.monitor.file.windows.WriteProcessorWindows; -import org.bench4q.monitor.file.windows.WriteSystemWindows; - -public class WriteFiles extends MonitorContorlEntity { - public static boolean flag = true; - private int threadCount; - private int saveCount; - private ExecutorService service; - WriteLogicalDiskWindows logicalDiskWindows; - WriteMemoryWindows memoryWindows; - WriteNetworkInterfaceWindows networkInterfaceWindows; - WritePhysicalDiskWindows physicalDiskWindows; - WriteProcessorWindows processorWindows; - WriteSystemWindows systemWindows; - WriteProcessWindows processWindows; - - WriteLogicalDiskLinux logicalDiskLinux; - WriteMemoryLinux memoryLinux; - WriteNetworkInterfaceLinux networkInterfaceLinux; - WritePhysicalDiskLinux physicalDiskLinux; - WriteProcessorLinux processorLinux; - WriteSystemLinux systemLinux; - WriteProcessLinux processLinux; - - public WriteFiles() throws FileNotFoundException { - this.threadCount = 7; - this.saveCount = 150; - service = null; - PrintWriter out = null; - if (this.getOsNameString().contains("windows")) { - - logicalDiskWindows = new WriteLogicalDiskWindows(out, - this.getIdleTime()); - memoryWindows = new WriteMemoryWindows(out, this.getIdleTime()); - networkInterfaceWindows = new WriteNetworkInterfaceWindows(out, - this.getIdleTime()); - physicalDiskWindows = new WritePhysicalDiskWindows(out, - this.getIdleTime()); - processorWindows = new WriteProcessorWindows(out, - this.getIdleTime()); - systemWindows = new WriteSystemWindows(out, this.getIdleTime()); - processWindows = new WriteProcessWindows(out, this.getIdleTime()); - - } else { - logicalDiskLinux = new WriteLogicalDiskLinux(out, - this.getIdleTime()); - memoryLinux = new WriteMemoryLinux(out, this.getIdleTime()); - networkInterfaceLinux = new WriteNetworkInterfaceLinux(out, - this.getIdleTime()); - physicalDiskLinux = new WritePhysicalDiskLinux(out, - this.getIdleTime()); - processorLinux = new WriteProcessorLinux(out, this.getIdleTime()); - systemLinux = new WriteSystemLinux(out, this.getIdleTime()); - processLinux = new WriteProcessLinux(out, this.getIdleTime()); - - } - - } - - public void start() throws FileNotFoundException { - - Executors.newFixedThreadPool(threadCount); - int time_count = 0; - SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHH:mm:ss"); - String filePath; - PrintWriter netPt = null, logicalPt = null, /* processPt = null, */processorPt = null, physicalPt = null, memoryPt = null, systemPt = null; - - if (this.getOsNameString().contains("windows")) { - while (flag) { - - if ((time_count % saveCount) == 0) { - time_count = 0; - df.format(new Date()); - filePath = new CreatFileName("NetworkInterface", - df.toString()).getFileName(); - netPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - networkInterfaceWindows.setOut(netPt); - - filePath = new CreatFileName("LogicalDisk", df.toString()) - .getFileName(); - logicalPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - logicalDiskWindows.setOut(logicalPt); - - filePath = new CreatFileName("Process", df.toString()) - .getFileName(); - // processPt = new PrintWriter(new BufferedWriter( - // new OutputStreamWriter(new FileOutputStream( - // new File(filePath))))); - physicalDiskWindows.setOut(physicalPt); - - filePath = new CreatFileName("Processor", df.toString()) - .getFileName(); - processorPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - processorWindows.setOut(processorPt); - - filePath = new CreatFileName("PhysicalDisk", df.toString()) - .getFileName(); - physicalPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - physicalDiskWindows.setOut(physicalPt); - - filePath = new CreatFileName("Memory", df.toString()) - .getFileName(); - memoryPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - memoryWindows.setOut(memoryPt); - - filePath = new CreatFileName("System", df.toString()) - .getFileName(); - systemPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - systemWindows.setOut(systemPt); - } - service.execute(systemWindows); - service.execute(physicalDiskWindows); - service.execute(processorLinux); - service.execute(memoryWindows); - service.execute(logicalDiskWindows); - service.execute(processWindows); - service.execute(networkInterfaceWindows); - time_count++; - } - - } else { - while (flag) { - - if ((time_count % saveCount) == 0) { - time_count = 0; - df.format(new Date()); - filePath = new CreatFileName("NetworkInterface", - df.toString()).getFileName(); - netPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - networkInterfaceLinux.setOut(netPt); - - filePath = new CreatFileName("LogicalDisk", df.toString()) - .getFileName(); - logicalPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - logicalDiskLinux.setOut(logicalPt); - - filePath = new CreatFileName("Process", df.toString()) - .getFileName(); - // processPt = new PrintWriter(new BufferedWriter( - // new OutputStreamWriter(new FileOutputStream( - // new File(filePath))))); - physicalDiskLinux.setOut(physicalPt); - - filePath = new CreatFileName("Processor", df.toString()) - .getFileName(); - processorPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - processorLinux.setOut(processorPt); - - filePath = new CreatFileName("PhysicalDisk", df.toString()) - .getFileName(); - physicalPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - physicalDiskLinux.setOut(physicalPt); - - filePath = new CreatFileName("Memory", df.toString()) - .getFileName(); - memoryPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - memoryLinux.setOut(memoryPt); - - filePath = new CreatFileName("System", df.toString()) - .getFileName(); - systemPt = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(new FileOutputStream( - new File(filePath))))); - systemLinux.setOut(systemPt); - } - service.execute(systemLinux); - service.execute(physicalDiskLinux); - service.execute(processorLinux); - service.execute(memoryLinux); - service.execute(logicalDiskLinux); - service.execute(processLinux); - service.execute(networkInterfaceLinux); - time_count++; - } - - } - - } - - public void stop() throws InterruptedException { - flag = false; - service.shutdown(); - service.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); - flag = false; - - } - -} +package org.bench4q.monitor.files; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.bench4q.monitor.entiry.MonitorContorlEntity; +import org.bench4q.monitor.file.Linux.WriteLogicalDiskLinux; +import org.bench4q.monitor.file.Linux.WriteMemoryLinux; +import org.bench4q.monitor.file.Linux.WriteNetworkInterfaceLinux; +import org.bench4q.monitor.file.Linux.WritePhysicalDiskLinux; +import org.bench4q.monitor.file.Linux.WriteProcessLinux; +import org.bench4q.monitor.file.Linux.WriteProcessorLinux; +import org.bench4q.monitor.file.Linux.WriteSystemLinux; +import org.bench4q.monitor.file.windows.WriteLogicalDiskWindows; +import org.bench4q.monitor.file.windows.WriteMemoryWindows; +import org.bench4q.monitor.file.windows.WriteNetworkInterfaceWindows; +import org.bench4q.monitor.file.windows.WritePhysicalDiskWindows; +import org.bench4q.monitor.file.windows.WriteProcessWindows; +import org.bench4q.monitor.file.windows.WriteProcessorWindows; +import org.bench4q.monitor.file.windows.WriteSystemWindows; + +public class WriteFiles extends MonitorContorlEntity { + public static boolean flag = true; + private int threadCount; + private int saveCount; + private ExecutorService service; + WriteLogicalDiskWindows logicalDiskWindows; + WriteMemoryWindows memoryWindows; + WriteNetworkInterfaceWindows networkInterfaceWindows; + WritePhysicalDiskWindows physicalDiskWindows; + WriteProcessorWindows processorWindows; + WriteSystemWindows systemWindows; + WriteProcessWindows processWindows; + + WriteLogicalDiskLinux logicalDiskLinux; + WriteMemoryLinux memoryLinux; + WriteNetworkInterfaceLinux networkInterfaceLinux; + WritePhysicalDiskLinux physicalDiskLinux; + WriteProcessorLinux processorLinux; + WriteSystemLinux systemLinux; + WriteProcessLinux processLinux; + + public WriteFiles() throws FileNotFoundException { + this.threadCount = 7; + this.saveCount = 150; + service = null; + PrintWriter out = null; + if (this.getOsNameString().contains("windows")) { + + logicalDiskWindows = new WriteLogicalDiskWindows(out, + this.getIdleTime()); + memoryWindows = new WriteMemoryWindows(out, this.getIdleTime()); + networkInterfaceWindows = new WriteNetworkInterfaceWindows(out, + this.getIdleTime()); + physicalDiskWindows = new WritePhysicalDiskWindows(out, + this.getIdleTime()); + processorWindows = new WriteProcessorWindows(out, + this.getIdleTime()); + systemWindows = new WriteSystemWindows(out, this.getIdleTime()); + processWindows = new WriteProcessWindows(out, this.getIdleTime()); + + } else { + logicalDiskLinux = new WriteLogicalDiskLinux(out, + this.getIdleTime()); + memoryLinux = new WriteMemoryLinux(out, this.getIdleTime()); + networkInterfaceLinux = new WriteNetworkInterfaceLinux(out, + this.getIdleTime()); + physicalDiskLinux = new WritePhysicalDiskLinux(out, + this.getIdleTime()); + processorLinux = new WriteProcessorLinux(out, this.getIdleTime()); + systemLinux = new WriteSystemLinux(out, this.getIdleTime()); + processLinux = new WriteProcessLinux(out, this.getIdleTime()); + + } + + } + + public void start() throws FileNotFoundException { + + Executors.newFixedThreadPool(threadCount); + int time_count = 0; + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHH:mm:ss"); + String filePath; + PrintWriter netPt = null, logicalPt = null, /* processPt = null, */processorPt = null, physicalPt = null, memoryPt = null, systemPt = null; + + if (this.getOsNameString().contains("windows")) { + while (flag) { + + if ((time_count % saveCount) == 0) { + time_count = 0; + df.format(new Date()); + filePath = new CreatFileName("NetworkInterface", + df.toString()).getFileName(); + netPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + networkInterfaceWindows.setOut(netPt); + + filePath = new CreatFileName("LogicalDisk", df.toString()) + .getFileName(); + logicalPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + logicalDiskWindows.setOut(logicalPt); + + filePath = new CreatFileName("Process", df.toString()) + .getFileName(); + // processPt = new PrintWriter(new BufferedWriter( + // new OutputStreamWriter(new FileOutputStream( + // new File(filePath))))); + physicalDiskWindows.setOut(physicalPt); + + filePath = new CreatFileName("Processor", df.toString()) + .getFileName(); + processorPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + processorWindows.setOut(processorPt); + + filePath = new CreatFileName("PhysicalDisk", df.toString()) + .getFileName(); + physicalPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + physicalDiskWindows.setOut(physicalPt); + + filePath = new CreatFileName("Memory", df.toString()) + .getFileName(); + memoryPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + memoryWindows.setOut(memoryPt); + + filePath = new CreatFileName("System", df.toString()) + .getFileName(); + systemPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + systemWindows.setOut(systemPt); + } + service.execute(systemWindows); + service.execute(physicalDiskWindows); + service.execute(processorLinux); + service.execute(memoryWindows); + service.execute(logicalDiskWindows); + service.execute(processWindows); + service.execute(networkInterfaceWindows); + time_count++; + } + + } else { + while (flag) { + + if ((time_count % saveCount) == 0) { + time_count = 0; + df.format(new Date()); + filePath = new CreatFileName("NetworkInterface", + df.toString()).getFileName(); + netPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + networkInterfaceLinux.setOut(netPt); + + filePath = new CreatFileName("LogicalDisk", df.toString()) + .getFileName(); + logicalPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + logicalDiskLinux.setOut(logicalPt); + + filePath = new CreatFileName("Process", df.toString()) + .getFileName(); + // processPt = new PrintWriter(new BufferedWriter( + // new OutputStreamWriter(new FileOutputStream( + // new File(filePath))))); + physicalDiskLinux.setOut(physicalPt); + + filePath = new CreatFileName("Processor", df.toString()) + .getFileName(); + processorPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + processorLinux.setOut(processorPt); + + filePath = new CreatFileName("PhysicalDisk", df.toString()) + .getFileName(); + physicalPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + physicalDiskLinux.setOut(physicalPt); + + filePath = new CreatFileName("Memory", df.toString()) + .getFileName(); + memoryPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + memoryLinux.setOut(memoryPt); + + filePath = new CreatFileName("System", df.toString()) + .getFileName(); + systemPt = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(new FileOutputStream( + new File(filePath))))); + systemLinux.setOut(systemPt); + } + service.execute(systemLinux); + service.execute(physicalDiskLinux); + service.execute(processorLinux); + service.execute(memoryLinux); + service.execute(logicalDiskLinux); + service.execute(processLinux); + service.execute(networkInterfaceLinux); + time_count++; + } + + } + + } + + public void stop() throws InterruptedException { + flag = false; + service.shutdown(); + service.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); + flag = false; + + } + +} diff --git a/src/main/java/org/bench4q/monitor/model/LogicalDiskModel.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/LogicalDiskModel.java similarity index 96% rename from src/main/java/org/bench4q/monitor/model/LogicalDiskModel.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/LogicalDiskModel.java index 1729c553..f8a2135c 100644 --- a/src/main/java/org/bench4q/monitor/model/LogicalDiskModel.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/LogicalDiskModel.java @@ -1,32 +1,32 @@ -package org.bench4q.monitor.model; - - - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - - -@XmlRootElement(name = "LogicalDisk") -public class LogicalDiskModel { - - - - private List logicalDiskList; - public LogicalDiskModel(){ - this.logicalDiskList=new ArrayList(); - } - - @XmlElementWrapper - @XmlElement(name="Instance",type=LogicalDiskModelChild.class) - - public List getLogicalDiskList() { - return logicalDiskList; - } - public void setLogicalDiskList ( ArrayList logicalDiskList) { - this.logicalDiskList = logicalDiskList; - } +package org.bench4q.monitor.model; + + + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + + +@XmlRootElement(name = "LogicalDisk") +public class LogicalDiskModel { + + + + private List logicalDiskList; + public LogicalDiskModel(){ + this.logicalDiskList=new ArrayList(); + } + + @XmlElementWrapper + @XmlElement(name="Instance",type=LogicalDiskModelChild.class) + + public List getLogicalDiskList() { + return logicalDiskList; + } + public void setLogicalDiskList ( ArrayList logicalDiskList) { + this.logicalDiskList = logicalDiskList; + } } \ No newline at end of file diff --git a/src/main/java/org/bench4q/monitor/model/LogicalDiskModelChild.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/LogicalDiskModelChild.java similarity index 96% rename from src/main/java/org/bench4q/monitor/model/LogicalDiskModelChild.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/LogicalDiskModelChild.java index 9c556df8..2d05ae00 100644 --- a/src/main/java/org/bench4q/monitor/model/LogicalDiskModelChild.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/LogicalDiskModelChild.java @@ -1,129 +1,129 @@ -package org.bench4q.monitor.model; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class LogicalDiskModelChild{ - private String instance; - private double freeSpacePercent; - private double freeMegabytes; - - // ���̻�ٷֱ� - private double diskTimePercent; - private double diskReadTimePercent; - private double diskWriteTimePercent; - - // ����ƽ��ʱ�� - private double averageDiskTransferTimeInSecond; - private double averageDiskReadTimeInSecond; - private double averageDiskWriteTimeInSecond; - // ����ƽ������ֽ� - - - private double diskBytesPerSecond; - - private double diskReadBytesPerSecond; - private double diskWriteBytesPerSecond; - - // ���аٷֱ� - private double idleTimePercent; - // ƽ����г��� - private double averageDiskQueueLength; - // ��ǰ���г��� - private double currentDiskQueueLength; - public String getInstance() { - return instance; - } - public void setInstance(String instance) { - this.instance = instance; - } - public double getFreeSpacePercent() { - return freeSpacePercent; - } - public void setFreeSpacePercent(double freeSpacePercent) { - this.freeSpacePercent = freeSpacePercent; - } - public double getFreeMegabytes() { - return freeMegabytes; - } - public void setFreeMegabytes(double freeMegabytes) { - this.freeMegabytes = freeMegabytes; - } - public double getDiskTimePercent() { - return diskTimePercent; - } - public void setDiskTimePercent(double diskTimePercent) { - this.diskTimePercent = diskTimePercent; - } - public double getDiskReadTimePercent() { - return diskReadTimePercent; - } - public void setDiskReadTimePercent(double diskReadTimePercent) { - this.diskReadTimePercent = diskReadTimePercent; - } - public double getDiskWriteTimePercent() { - return diskWriteTimePercent; - } - public void setDiskWriteTimePercent(double diskWriteTimePercent) { - this.diskWriteTimePercent = diskWriteTimePercent; - } - public double getAverageDiskTransferTimeInSecond() { - return averageDiskTransferTimeInSecond; - } - public void setAverageDiskTransferTimeInSecond( - double averageDiskTransferTimeInSecond) { - this.averageDiskTransferTimeInSecond = averageDiskTransferTimeInSecond; - } - public double getAverageDiskReadTimeInSecond() { - return averageDiskReadTimeInSecond; - } - public void setAverageDiskReadTimeInSecond(double averageDiskReadTimeInSecond) { - this.averageDiskReadTimeInSecond = averageDiskReadTimeInSecond; - } - public double getAverageDiskWriteTimeInSecond() { - return averageDiskWriteTimeInSecond; - } - public void setAverageDiskWriteTimeInSecond(double averageDiskWriteTimeInSecond) { - this.averageDiskWriteTimeInSecond = averageDiskWriteTimeInSecond; - } - - public double getDiskBytesPerSecond() { - return diskBytesPerSecond; - } - public void setDiskBytesPerSecond(double diskBytesPerSecond) { - this.diskBytesPerSecond = diskBytesPerSecond; - } - public double getDiskReadBytesPerSecond() { - return diskReadBytesPerSecond; - } - public void setDiskReadBytesPerSecond(double diskReadBytesPerSecond) { - this.diskReadBytesPerSecond = diskReadBytesPerSecond; - } - public double getDiskWriteBytesPerSecond() { - return diskWriteBytesPerSecond; - } - public void setDiskWriteBytesPerSecond(double diskkWriteBytesPerSecond) { - this.diskWriteBytesPerSecond = diskkWriteBytesPerSecond; - } - public double getIdleTimePercent() { - return idleTimePercent; - } - public void setIdleTimePercent(double idleTimePercent) { - this.idleTimePercent = idleTimePercent; - } - public double getAverageDiskQueueLength() { - return averageDiskQueueLength; - } - public void setAverageDiskQueueLength(double averageDiskQueueLength) { - this.averageDiskQueueLength = averageDiskQueueLength; - } - public double getCurrentDiskQueueLength() { - return currentDiskQueueLength; - } - public void setCurrentDiskQueueLength(double currentDiskQueueLength) { - this.currentDiskQueueLength = currentDiskQueueLength; - } - - - -} +package org.bench4q.monitor.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class LogicalDiskModelChild{ + private String instance; + private double freeSpacePercent; + private double freeMegabytes; + + // ���̻�ٷֱ� + private double diskTimePercent; + private double diskReadTimePercent; + private double diskWriteTimePercent; + + // ����ƽ��ʱ�� + private double averageDiskTransferTimeInSecond; + private double averageDiskReadTimeInSecond; + private double averageDiskWriteTimeInSecond; + // ����ƽ������ֽ� + + + private double diskBytesPerSecond; + + private double diskReadBytesPerSecond; + private double diskWriteBytesPerSecond; + + // ���аٷֱ� + private double idleTimePercent; + // ƽ����г��� + private double averageDiskQueueLength; + // ��ǰ���г��� + private double currentDiskQueueLength; + public String getInstance() { + return instance; + } + public void setInstance(String instance) { + this.instance = instance; + } + public double getFreeSpacePercent() { + return freeSpacePercent; + } + public void setFreeSpacePercent(double freeSpacePercent) { + this.freeSpacePercent = freeSpacePercent; + } + public double getFreeMegabytes() { + return freeMegabytes; + } + public void setFreeMegabytes(double freeMegabytes) { + this.freeMegabytes = freeMegabytes; + } + public double getDiskTimePercent() { + return diskTimePercent; + } + public void setDiskTimePercent(double diskTimePercent) { + this.diskTimePercent = diskTimePercent; + } + public double getDiskReadTimePercent() { + return diskReadTimePercent; + } + public void setDiskReadTimePercent(double diskReadTimePercent) { + this.diskReadTimePercent = diskReadTimePercent; + } + public double getDiskWriteTimePercent() { + return diskWriteTimePercent; + } + public void setDiskWriteTimePercent(double diskWriteTimePercent) { + this.diskWriteTimePercent = diskWriteTimePercent; + } + public double getAverageDiskTransferTimeInSecond() { + return averageDiskTransferTimeInSecond; + } + public void setAverageDiskTransferTimeInSecond( + double averageDiskTransferTimeInSecond) { + this.averageDiskTransferTimeInSecond = averageDiskTransferTimeInSecond; + } + public double getAverageDiskReadTimeInSecond() { + return averageDiskReadTimeInSecond; + } + public void setAverageDiskReadTimeInSecond(double averageDiskReadTimeInSecond) { + this.averageDiskReadTimeInSecond = averageDiskReadTimeInSecond; + } + public double getAverageDiskWriteTimeInSecond() { + return averageDiskWriteTimeInSecond; + } + public void setAverageDiskWriteTimeInSecond(double averageDiskWriteTimeInSecond) { + this.averageDiskWriteTimeInSecond = averageDiskWriteTimeInSecond; + } + + public double getDiskBytesPerSecond() { + return diskBytesPerSecond; + } + public void setDiskBytesPerSecond(double diskBytesPerSecond) { + this.diskBytesPerSecond = diskBytesPerSecond; + } + public double getDiskReadBytesPerSecond() { + return diskReadBytesPerSecond; + } + public void setDiskReadBytesPerSecond(double diskReadBytesPerSecond) { + this.diskReadBytesPerSecond = diskReadBytesPerSecond; + } + public double getDiskWriteBytesPerSecond() { + return diskWriteBytesPerSecond; + } + public void setDiskWriteBytesPerSecond(double diskkWriteBytesPerSecond) { + this.diskWriteBytesPerSecond = diskkWriteBytesPerSecond; + } + public double getIdleTimePercent() { + return idleTimePercent; + } + public void setIdleTimePercent(double idleTimePercent) { + this.idleTimePercent = idleTimePercent; + } + public double getAverageDiskQueueLength() { + return averageDiskQueueLength; + } + public void setAverageDiskQueueLength(double averageDiskQueueLength) { + this.averageDiskQueueLength = averageDiskQueueLength; + } + public double getCurrentDiskQueueLength() { + return currentDiskQueueLength; + } + public void setCurrentDiskQueueLength(double currentDiskQueueLength) { + this.currentDiskQueueLength = currentDiskQueueLength; + } + + + +} diff --git a/src/main/java/org/bench4q/monitor/model/MemoryModel.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/MemoryModel.java similarity index 96% rename from src/main/java/org/bench4q/monitor/model/MemoryModel.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/MemoryModel.java index 8932d736..8c5ed6e9 100644 --- a/src/main/java/org/bench4q/monitor/model/MemoryModel.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/MemoryModel.java @@ -1,56 +1,56 @@ -package org.bench4q.monitor.model; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name="Memory") -public class MemoryModel { - -// private double pageFaultsPerSecond;//������Ӳȱҳ - private double pagesPerSecond; - private double pagesInputPerSecond; - private double pagesOutputPerSecond; - private double cacheBytes; - private double committedBytes;//ռ�õ������ڴ���ֽ� - private double availableKiloBytes; - - - public double getPagesPerSecond() { - return pagesPerSecond; - } - public void setPagesPerSecond(double pagesPerSecond) { - this.pagesPerSecond = pagesPerSecond; - } - public double getPagesInputPerSecond() { - return pagesInputPerSecond; - } - public void setPagesInputPerSecond(double pagesInputPerSecond) { - this.pagesInputPerSecond = pagesInputPerSecond; - } - - public double getCacheBytes() { - return cacheBytes; - } - public void setCacheBytes(double cacheBytes) { - this.cacheBytes = cacheBytes; - } - - - public double getCommittedBytes() { - return committedBytes; - } - public void setCommittedBytes(double committedBytes) { - this.committedBytes = committedBytes; - } - public double getPagesOutputPerSecond() { - return pagesOutputPerSecond; - } - public void setPagesOutputPerSecond(double pagesOutputPerSecond) { - this.pagesOutputPerSecond = pagesOutputPerSecond; - } - public double getAvailableKiloBytes() { - return availableKiloBytes; - } - public void setAvailableKiloBytes(double availableKiloBytes) { - this.availableKiloBytes = availableKiloBytes; - } -} +package org.bench4q.monitor.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name="Memory") +public class MemoryModel { + +// private double pageFaultsPerSecond;//������Ӳȱҳ + private double pagesPerSecond; + private double pagesInputPerSecond; + private double pagesOutputPerSecond; + private double cacheBytes; + private double committedBytes;//ռ�õ������ڴ���ֽ� + private double availableKiloBytes; + + + public double getPagesPerSecond() { + return pagesPerSecond; + } + public void setPagesPerSecond(double pagesPerSecond) { + this.pagesPerSecond = pagesPerSecond; + } + public double getPagesInputPerSecond() { + return pagesInputPerSecond; + } + public void setPagesInputPerSecond(double pagesInputPerSecond) { + this.pagesInputPerSecond = pagesInputPerSecond; + } + + public double getCacheBytes() { + return cacheBytes; + } + public void setCacheBytes(double cacheBytes) { + this.cacheBytes = cacheBytes; + } + + + public double getCommittedBytes() { + return committedBytes; + } + public void setCommittedBytes(double committedBytes) { + this.committedBytes = committedBytes; + } + public double getPagesOutputPerSecond() { + return pagesOutputPerSecond; + } + public void setPagesOutputPerSecond(double pagesOutputPerSecond) { + this.pagesOutputPerSecond = pagesOutputPerSecond; + } + public double getAvailableKiloBytes() { + return availableKiloBytes; + } + public void setAvailableKiloBytes(double availableKiloBytes) { + this.availableKiloBytes = availableKiloBytes; + } +} diff --git a/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModel.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModel.java similarity index 96% rename from src/main/java/org/bench4q/monitor/model/NetworkInterfaceModel.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModel.java index 067888b6..6d8036c4 100644 --- a/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModel.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModel.java @@ -1,26 +1,26 @@ -package org.bench4q.monitor.model; - - - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name = "NetworkInterface") -public class NetworkInterfaceModel { - private List networkList; - @XmlElementWrapper - @XmlElement(name="Instance",type=NetworkInterfaceModelChild.class) - public List getNetworkList() { - return networkList; - } - - public void setNetworkList(List networkList) { - this.networkList = networkList; - } - public NetworkInterfaceModel(){ - this.networkList=new ArrayList(); - } -} +package org.bench4q.monitor.model; + + + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +@XmlRootElement(name = "NetworkInterface") +public class NetworkInterfaceModel { + private List networkList; + @XmlElementWrapper + @XmlElement(name="Instance",type=NetworkInterfaceModelChild.class) + public List getNetworkList() { + return networkList; + } + + public void setNetworkList(List networkList) { + this.networkList = networkList; + } + public NetworkInterfaceModel(){ + this.networkList=new ArrayList(); + } +} diff --git a/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModelChild.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModelChild.java similarity index 95% rename from src/main/java/org/bench4q/monitor/model/NetworkInterfaceModelChild.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModelChild.java index a4bce062..af6eb39a 100644 --- a/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModelChild.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModelChild.java @@ -1,44 +1,44 @@ -package org.bench4q.monitor.model; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class NetworkInterfaceModelChild { -private double bytesTotalPerSecond; -private double bytesReceivedPerSecond; -private double bytesSentPerSecond; -private String instance; -public double getBytesReceivedPerSecond() { - return bytesReceivedPerSecond; -} - -public void setBytesReceivedPerSecond(double bytesReceivedPerSecond) { - this.bytesReceivedPerSecond = bytesReceivedPerSecond; -} - -public double getBytesSentPerSecond() { - return bytesSentPerSecond; -} - -public void setBytesSentPerSecond(double bytesSentPerSecond) { - this.bytesSentPerSecond = bytesSentPerSecond; -} - - -public String getInstance() { - return instance; -} - -public void setInstance(String instance) { - this.instance = instance; -} - -public double getBytesTotalPerSecond() { - return bytesTotalPerSecond; -} - -public void setBytesTotalPerSecond(double bytesTotalPerSecond) { - this.bytesTotalPerSecond = bytesTotalPerSecond; -} - -} +package org.bench4q.monitor.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class NetworkInterfaceModelChild { +private double bytesTotalPerSecond; +private double bytesReceivedPerSecond; +private double bytesSentPerSecond; +private String instance; +public double getBytesReceivedPerSecond() { + return bytesReceivedPerSecond; +} + +public void setBytesReceivedPerSecond(double bytesReceivedPerSecond) { + this.bytesReceivedPerSecond = bytesReceivedPerSecond; +} + +public double getBytesSentPerSecond() { + return bytesSentPerSecond; +} + +public void setBytesSentPerSecond(double bytesSentPerSecond) { + this.bytesSentPerSecond = bytesSentPerSecond; +} + + +public String getInstance() { + return instance; +} + +public void setInstance(String instance) { + this.instance = instance; +} + +public double getBytesTotalPerSecond() { + return bytesTotalPerSecond; +} + +public void setBytesTotalPerSecond(double bytesTotalPerSecond) { + this.bytesTotalPerSecond = bytesTotalPerSecond; +} + +} diff --git a/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java similarity index 96% rename from src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java index e5dca772..6f2520a5 100644 --- a/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java @@ -1,27 +1,27 @@ -package org.bench4q.monitor.model; - - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name="PhisicalDisk") -public class PhysicalDiskModel { - private List physicalDiskModelList; - @XmlElementWrapper - @XmlElement(name="Instances",type=PhysicalDiskModelChild.class) - public List getPhysicalDiskModelList() { - return physicalDiskModelList; - } - public void setPhysicalDiskModelList( - List physicalDiskModelList) { - this.physicalDiskModelList = physicalDiskModelList; - } - public PhysicalDiskModel() { - // TODO Auto-generated constructor stub - this .physicalDiskModelList=new ArrayList(); - } - -} +package org.bench4q.monitor.model; + + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +@XmlRootElement(name="PhisicalDisk") +public class PhysicalDiskModel { + private List physicalDiskModelList; + @XmlElementWrapper + @XmlElement(name="Instances",type=PhysicalDiskModelChild.class) + public List getPhysicalDiskModelList() { + return physicalDiskModelList; + } + public void setPhysicalDiskModelList( + List physicalDiskModelList) { + this.physicalDiskModelList = physicalDiskModelList; + } + public PhysicalDiskModel() { + // TODO Auto-generated constructor stub + this .physicalDiskModelList=new ArrayList(); + } + +} diff --git a/src/main/java/org/bench4q/monitor/model/PhysicalDiskModelChild.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/PhysicalDiskModelChild.java similarity index 95% rename from src/main/java/org/bench4q/monitor/model/PhysicalDiskModelChild.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/PhysicalDiskModelChild.java index 5c4f4259..20d0c4bf 100644 --- a/src/main/java/org/bench4q/monitor/model/PhysicalDiskModelChild.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/PhysicalDiskModelChild.java @@ -1,92 +1,92 @@ -package org.bench4q.monitor.model; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class PhysicalDiskModelChild { - - private String instance; - - public String getInstance() { - return instance; - } - - - public void setInstance(String instance) { - this.instance = instance; - } - - - public double getDiskTimePercent() { - return diskTimePercent; - } - - - public void setDiskTimePercent(double diskTimePercent) { - this.diskTimePercent = diskTimePercent; - } - - - public double getAverageDiskQueueLength() { - return averageDiskQueueLength; - } - - - public void setAverageDiskQueueLength(double averageDiskQueueLength) { - this.averageDiskQueueLength = averageDiskQueueLength; - } - - - public double getCurrentDiskQueueLength() { - return currentDiskQueueLength; - } - - - public void setCurrentDiskQueueLength(double currentDiskQueueLength) { - this.currentDiskQueueLength = currentDiskQueueLength; - } - - - public double getDiskReadBytesPerSecond() { - return diskReadBytesPerSecond; - } - - - public void setDiskReadBytesPerSecond(double diskReadBytesPerSecond) { - this.diskReadBytesPerSecond = diskReadBytesPerSecond; - } - - - public double getDiskWriteBytesPerSecond() { - return diskWriteBytesPerSecond; - } - - - public void setDiskWriteBytesPerSecond(double diskWriteBytesPerSecond) { - this.diskWriteBytesPerSecond = diskWriteBytesPerSecond; - } - - - public double getDiskBytesPerSecond() { - return diskBytesPerSecond; - } - - - public void setDiskBytesPerSecond(double diskBytesPerSecond) { - this.diskBytesPerSecond = diskBytesPerSecond; - } - - - private double diskTimePercent; - - private double averageDiskQueueLength; - private double currentDiskQueueLength; - private double diskReadBytesPerSecond; - - private double diskWriteBytesPerSecond; - - - private double diskBytesPerSecond; - - -} +package org.bench4q.monitor.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class PhysicalDiskModelChild { + + private String instance; + + public String getInstance() { + return instance; + } + + + public void setInstance(String instance) { + this.instance = instance; + } + + + public double getDiskTimePercent() { + return diskTimePercent; + } + + + public void setDiskTimePercent(double diskTimePercent) { + this.diskTimePercent = diskTimePercent; + } + + + public double getAverageDiskQueueLength() { + return averageDiskQueueLength; + } + + + public void setAverageDiskQueueLength(double averageDiskQueueLength) { + this.averageDiskQueueLength = averageDiskQueueLength; + } + + + public double getCurrentDiskQueueLength() { + return currentDiskQueueLength; + } + + + public void setCurrentDiskQueueLength(double currentDiskQueueLength) { + this.currentDiskQueueLength = currentDiskQueueLength; + } + + + public double getDiskReadBytesPerSecond() { + return diskReadBytesPerSecond; + } + + + public void setDiskReadBytesPerSecond(double diskReadBytesPerSecond) { + this.diskReadBytesPerSecond = diskReadBytesPerSecond; + } + + + public double getDiskWriteBytesPerSecond() { + return diskWriteBytesPerSecond; + } + + + public void setDiskWriteBytesPerSecond(double diskWriteBytesPerSecond) { + this.diskWriteBytesPerSecond = diskWriteBytesPerSecond; + } + + + public double getDiskBytesPerSecond() { + return diskBytesPerSecond; + } + + + public void setDiskBytesPerSecond(double diskBytesPerSecond) { + this.diskBytesPerSecond = diskBytesPerSecond; + } + + + private double diskTimePercent; + + private double averageDiskQueueLength; + private double currentDiskQueueLength; + private double diskReadBytesPerSecond; + + private double diskWriteBytesPerSecond; + + + private double diskBytesPerSecond; + + +} diff --git a/src/main/java/org/bench4q/monitor/model/ProcessModel.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessModel.java similarity index 96% rename from src/main/java/org/bench4q/monitor/model/ProcessModel.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessModel.java index ce4354f7..091d9c76 100644 --- a/src/main/java/org/bench4q/monitor/model/ProcessModel.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessModel.java @@ -1,29 +1,29 @@ -package org.bench4q.monitor.model; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name="Process") -public class ProcessModel { - - private List procesModelList; - @XmlElementWrapper - @XmlElement(name="Instance",type=ProcessModelChild.class) - public List getProcesModelList() { - return procesModelList; - } - public void setProcesModelList(List procesModelList) { - this.procesModelList = procesModelList; - } - public ProcessModel(){ - this.procesModelList=new ArrayList(); - } - - - -} +package org.bench4q.monitor.model; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name="Process") +public class ProcessModel { + + private List procesModelList; + @XmlElementWrapper + @XmlElement(name="Instance",type=ProcessModelChild.class) + public List getProcesModelList() { + return procesModelList; + } + public void setProcesModelList(List procesModelList) { + this.procesModelList = procesModelList; + } + public ProcessModel(){ + this.procesModelList=new ArrayList(); + } + + + +} diff --git a/src/main/java/org/bench4q/monitor/model/ProcessModelChild.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessModelChild.java similarity index 96% rename from src/main/java/org/bench4q/monitor/model/ProcessModelChild.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessModelChild.java index 25ae5ab4..d97d5fbe 100644 --- a/src/main/java/org/bench4q/monitor/model/ProcessModelChild.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessModelChild.java @@ -1,43 +1,43 @@ -package org.bench4q.monitor.model; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class ProcessModelChild { - private String instanceString; - private double privateBytes; - private double processorTimePercent; -private double processId; -private double virtualBytes; - public double getProcessorTimePercent() { - return processorTimePercent; -} -public void setProcessorTimePercent(double processorTimePercent) { - this.processorTimePercent = processorTimePercent; -} -public double getProcessId() { - return processId; -} -public void setProcessId(double processId) { - this.processId = processId; -} -public double getVirtualBytes() { - return virtualBytes; -} -public void setVirtualBytes(double virtualBytes) { - this.virtualBytes = virtualBytes; -} - public String getInstanceString() { - return instanceString; - } - public void setInstanceString(String instanceString) { - this.instanceString = instanceString; - } - public double getPrivateBytes() { - return privateBytes; - } - public void setPrivateBytes(double privateBytes) { - this.privateBytes = privateBytes; - } - -} +package org.bench4q.monitor.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class ProcessModelChild { + private String instanceString; + private double privateBytes; + private double processorTimePercent; +private double processId; +private double virtualBytes; + public double getProcessorTimePercent() { + return processorTimePercent; +} +public void setProcessorTimePercent(double processorTimePercent) { + this.processorTimePercent = processorTimePercent; +} +public double getProcessId() { + return processId; +} +public void setProcessId(double processId) { + this.processId = processId; +} +public double getVirtualBytes() { + return virtualBytes; +} +public void setVirtualBytes(double virtualBytes) { + this.virtualBytes = virtualBytes; +} + public String getInstanceString() { + return instanceString; + } + public void setInstanceString(String instanceString) { + this.instanceString = instanceString; + } + public double getPrivateBytes() { + return privateBytes; + } + public void setPrivateBytes(double privateBytes) { + this.privateBytes = privateBytes; + } + +} diff --git a/src/main/java/org/bench4q/monitor/model/ProcessorModel.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessorModel.java similarity index 97% rename from src/main/java/org/bench4q/monitor/model/ProcessorModel.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessorModel.java index a9bb5807..2f4198ef 100644 --- a/src/main/java/org/bench4q/monitor/model/ProcessorModel.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessorModel.java @@ -1,23 +1,23 @@ -package org.bench4q.monitor.model; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name="Processor") -public class ProcessorModel { - private List processorModelList; - public ProcessorModel(){ - processorModelList=new ArrayList(); - } - @XmlElementWrapper - @XmlElement(name="processorModelChild",type=ProcessorModelChild.class) - public List getProcessorModelList() { - return processorModelList; - } - public void setProcessorModelList(List processorModelList) { - this.processorModelList = processorModelList; - } -} +package org.bench4q.monitor.model; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name="Processor") +public class ProcessorModel { + private List processorModelList; + public ProcessorModel(){ + processorModelList=new ArrayList(); + } + @XmlElementWrapper + @XmlElement(name="processorModelChild",type=ProcessorModelChild.class) + public List getProcessorModelList() { + return processorModelList; + } + public void setProcessorModelList(List processorModelList) { + this.processorModelList = processorModelList; + } +} diff --git a/src/main/java/org/bench4q/monitor/model/ProcessorModelChild.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessorModelChild.java similarity index 96% rename from src/main/java/org/bench4q/monitor/model/ProcessorModelChild.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessorModelChild.java index 63579388..bde59faa 100644 --- a/src/main/java/org/bench4q/monitor/model/ProcessorModelChild.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/ProcessorModelChild.java @@ -1,37 +1,37 @@ -package org.bench4q.monitor.model; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class ProcessorModelChild { - private String instance; - private Double processorTimePercent; - private Double userTimePercent; - private Double privilegedTimePercent; - - public String getInstance() { - return instance; - } - public void setInstance(String instance) { - this.instance = instance; - } - public Double getProcessorTimePercent() { - return processorTimePercent; - } - public void setProcessorTimePercent(Double processorTimePercent) { - this.processorTimePercent = processorTimePercent; - } - public Double getUserTimePercent() { - return userTimePercent; - } - public void setUserTimePercent(Double userTimePercent) { - this.userTimePercent = userTimePercent; - } - public Double getPrivilegedTimePercent() { - return privilegedTimePercent; - } - public void setPrivilegedTimePercent(Double privilegedTimePercent) { - this.privilegedTimePercent = privilegedTimePercent; - } - -} +package org.bench4q.monitor.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class ProcessorModelChild { + private String instance; + private Double processorTimePercent; + private Double userTimePercent; + private Double privilegedTimePercent; + + public String getInstance() { + return instance; + } + public void setInstance(String instance) { + this.instance = instance; + } + public Double getProcessorTimePercent() { + return processorTimePercent; + } + public void setProcessorTimePercent(Double processorTimePercent) { + this.processorTimePercent = processorTimePercent; + } + public Double getUserTimePercent() { + return userTimePercent; + } + public void setUserTimePercent(Double userTimePercent) { + this.userTimePercent = userTimePercent; + } + public Double getPrivilegedTimePercent() { + return privilegedTimePercent; + } + public void setPrivilegedTimePercent(Double privilegedTimePercent) { + this.privilegedTimePercent = privilegedTimePercent; + } + +} diff --git a/src/main/java/org/bench4q/monitor/model/SystemModel.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/SystemModel.java similarity index 96% rename from src/main/java/org/bench4q/monitor/model/SystemModel.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/SystemModel.java index f816ffc6..f4adb423 100644 --- a/src/main/java/org/bench4q/monitor/model/SystemModel.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/SystemModel.java @@ -1,39 +1,39 @@ -package org.bench4q.monitor.model; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class SystemModel { - - private double fileDataOperationsPerSecond; - - public double getFileDataOperationsPerSecond() { - return fileDataOperationsPerSecond; - } - - public void setFileDataOperationsPerSecond( - double fileDataOperationsPerSecond) { - this.fileDataOperationsPerSecond = fileDataOperationsPerSecond; - } - - public double getProcessorQueueLength() { - return processorQueueLength; - } - - public void setProcessorQueueLength(double processorQueueLength) { - this.processorQueueLength = processorQueueLength; - } - - private double processorQueueLength; - double totalProceesorTimePercent; - - public double getTotalProceesorTimePercent() { - return totalProceesorTimePercent; - } - - public void setTotalProceesorTimePercent(double totalProceesorTimePercent2) { - // TODO Auto-generated method stub - this.totalProceesorTimePercent = totalProceesorTimePercent2; - } - -} +package org.bench4q.monitor.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class SystemModel { + + private double fileDataOperationsPerSecond; + + public double getFileDataOperationsPerSecond() { + return fileDataOperationsPerSecond; + } + + public void setFileDataOperationsPerSecond( + double fileDataOperationsPerSecond) { + this.fileDataOperationsPerSecond = fileDataOperationsPerSecond; + } + + public double getProcessorQueueLength() { + return processorQueueLength; + } + + public void setProcessorQueueLength(double processorQueueLength) { + this.processorQueueLength = processorQueueLength; + } + + private double processorQueueLength; + double totalProceesorTimePercent; + + public double getTotalProceesorTimePercent() { + return totalProceesorTimePercent; + } + + public void setTotalProceesorTimePercent(double totalProceesorTimePercent2) { + // TODO Auto-generated method stub + this.totalProceesorTimePercent = totalProceesorTimePercent2; + } + +} diff --git a/src/main/java/org/bench4q/monitor/performance/linux/CpuInfoMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/CpuInfoMonitor.java similarity index 96% rename from src/main/java/org/bench4q/monitor/performance/linux/CpuInfoMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/CpuInfoMonitor.java index 1bf88f11..827b038c 100644 --- a/src/main/java/org/bench4q/monitor/performance/linux/CpuInfoMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/CpuInfoMonitor.java @@ -1,33 +1,33 @@ -package org.bench4q.monitor.performance.linux; - -public class CpuInfoMonitor { - // /proc/cpuinfo - // processor : 0 - // vendor_id : GenuineIntel - // cpu family : 6 - // model : 44 - // model name : Intel(R) Xeon(R) CPU E5620 @ 2.40GHz - // stepping : 2 - // microcode : 0xc - // cpu MHz : 2394.062 - // cache size : 12288 KB - // physical id : 0 - // siblings : 1 - // core id : 0 - // cpu cores : 1 - // apicid : 0 - // initial apicid : 3 - // fpu : yes - // fpu_exception : yes - // cpuid level : 11 - // wp : yes - // flags : fpu de tsc msr pae cx8 sep cmov pat clflush mmx fxsr sse sse2 ss - // ht syscall nx lm constant_tsc up rep_good nopl pni pclmulqdq ssse3 cx16 - // sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat epb dtherm - // bogomips : 4788.12 - // clflush size : 64 - // cache_alignment : 64 - // address sizes : 40 bits physical, 48 bits virtual - // power management: - -} +package org.bench4q.monitor.performance.linux; + +public class CpuInfoMonitor { + // /proc/cpuinfo + // processor : 0 + // vendor_id : GenuineIntel + // cpu family : 6 + // model : 44 + // model name : Intel(R) Xeon(R) CPU E5620 @ 2.40GHz + // stepping : 2 + // microcode : 0xc + // cpu MHz : 2394.062 + // cache size : 12288 KB + // physical id : 0 + // siblings : 1 + // core id : 0 + // cpu cores : 1 + // apicid : 0 + // initial apicid : 3 + // fpu : yes + // fpu_exception : yes + // cpuid level : 11 + // wp : yes + // flags : fpu de tsc msr pae cx8 sep cmov pat clflush mmx fxsr sse sse2 ss + // ht syscall nx lm constant_tsc up rep_good nopl pni pclmulqdq ssse3 cx16 + // sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat epb dtherm + // bogomips : 4788.12 + // clflush size : 64 + // cache_alignment : 64 + // address sizes : 40 bits physical, 48 bits virtual + // power management: + +} diff --git a/src/main/java/org/bench4q/monitor/performance/linux/CpuStatusMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/CpuStatusMonitor.java similarity index 100% rename from src/main/java/org/bench4q/monitor/performance/linux/CpuStatusMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/CpuStatusMonitor.java diff --git a/src/main/java/org/bench4q/monitor/performance/linux/DiskStatusMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/DiskStatusMonitor.java similarity index 100% rename from src/main/java/org/bench4q/monitor/performance/linux/DiskStatusMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/DiskStatusMonitor.java diff --git a/src/main/java/org/bench4q/monitor/performance/linux/LogicalDiskMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/LogicalDiskMonitor.java similarity index 97% rename from src/main/java/org/bench4q/monitor/performance/linux/LogicalDiskMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/LogicalDiskMonitor.java index 272c508f..0a567ba9 100644 --- a/src/main/java/org/bench4q/monitor/performance/linux/LogicalDiskMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/LogicalDiskMonitor.java @@ -1,380 +1,380 @@ -package org.bench4q.monitor.performance.linux; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; - -import org.bench4q.monitor.entiry.LinuxFileRead; -import org.bench4q.monitor.model.LogicalDiskModel; -import org.bench4q.monitor.model.LogicalDiskModelChild; - -public class LogicalDiskMonitor extends LinuxFileRead { - public LogicalDiskMonitor() throws FileNotFoundException { - super("/proc/diskstats"); - instances = new ArrayList(); - - freeSpacePercent = new HashMap(); - freeMegabytes = new HashMap(); - - diskTimePercent = new HashMap(); - diskReadTimePercent = new HashMap(); - diskWriteTimePercent = new HashMap(); - - averageDiskTransferTimeInSecond = new HashMap(); - averageDiskReadTimeInSecond = new HashMap(); - averageDiskWriteTimeInSecond = new HashMap(); - - diskBytesPerSecond = new HashMap(); - diskReadBytesPerSecond = new HashMap(); - diskWriteBytesPerSecond = new HashMap(); - idleTimePercent = new HashMap(); - - averageDiskQueueLength = new HashMap(); - - currentDiskQueueLength = new HashMap(); - - } - - private List instances; - - public List getInstances() throws IOException, InterruptedException { - getLogicalDiskInfo(1); - return instances; - } - - public double getFreeSpacePercent(String instance) throws IOException, - InterruptedException { - getLogicalDiskInfo(1); - return freeSpacePercent.get(instance); - } - - public double getFreeMegabytes(String instance) throws IOException, - InterruptedException { - getLogicalDiskInfo(1); - return freeMegabytes.get(instance); - } - - public double getDiskTimePercent(String instance, int idleTime) - throws IOException, InterruptedException { - getLogicalDiskInfo(idleTime); - return diskTimePercent.get(instance); - } - - public double getDiskReadTimePercent(String instance, int idleTime) - throws IOException, InterruptedException { - getLogicalDiskInfo(idleTime); - return diskReadTimePercent.get(instance); - } - - public double getDiskWriteTimePercent(String instance, int idleTime) - throws IOException, InterruptedException { - getLogicalDiskInfo(idleTime); - return diskWriteTimePercent.get(instance); - } - - public double getAverageDiskTransferTimeInSecond(String instance, - int idleTime) throws IOException, InterruptedException { - getLogicalDiskInfo(idleTime); - return averageDiskTransferTimeInSecond.get(instance); - } - - public double getAverageDiskReadTimeInSecond(String instance, int idleTime) - throws IOException, InterruptedException { - getLogicalDiskInfo(idleTime); - return averageDiskReadTimeInSecond.get(instance); - } - - public double getAverageDiskWriteTimeInSecond(String instacne, int idleTime) - throws IOException, InterruptedException { - getLogicalDiskInfo(idleTime); - return averageDiskWriteTimeInSecond.get(instacne); - - } - - public double getDiskBytesPerSecond(String instance, int idleTime) - throws IOException, InterruptedException { - getLogicalDiskInfo(idleTime); - return diskBytesPerSecond.get(instance); - } - - public double getDiskReadBytesPerSecond(String instance, int idleTime) - throws IOException, InterruptedException { - - getLogicalDiskInfo(idleTime); - return diskReadBytesPerSecond.get(instance); - } - - public double getDiskWriteBytesPerSecond(String instance, int idleTime) - throws IOException, InterruptedException { - getLogicalDiskInfo(idleTime); - return diskWriteBytesPerSecond.get(instance); - } - - public double getIdleTimePercent(String instance, int idleTime) - throws IOException, InterruptedException { - getLogicalDiskInfo(idleTime); - return idleTimePercent.get(instance); - } - - public double getAverageDiskQueueLength(String instacne, int idleTime) - throws IOException, InterruptedException { - getLogicalDiskInfo(idleTime); - return averageDiskQueueLength.get(instacne); - } - - public double getCurrentDiskQueueLength(String instacne, int idleTime) - throws IOException, InterruptedException { - getLogicalDiskInfo(idleTime); - return currentDiskQueueLength.get(instacne); - } - - private Map freeSpacePercent; - private Map freeMegabytes; - - private Map diskTimePercent; - private Map diskReadTimePercent; - private Map diskWriteTimePercent; - - private Map averageDiskTransferTimeInSecond; - private Map averageDiskReadTimeInSecond; - private Map averageDiskWriteTimeInSecond; - - Map diskBytesPerSecond; - private Map diskReadBytesPerSecond;; - private Map diskWriteBytesPerSecond; - - private Map idleTimePercent; - private Map averageDiskQueueLength; - private Map currentDiskQueueLength; - - public LogicalDiskModel getLogicalDiskInfo(int idleTime) - throws IOException, InterruptedException { - LogicalDiskModel logicalDiskModel = new LogicalDiskModel(); - - List instances_temp = new ArrayList(); - Map currentDiskQueueLength_p = new HashMap(); - Map currentDiskQueueLength_temp = new HashMap(); - BufferedReader br = this.getBufferedReader(); - String str; - StringTokenizer token; - Map readTmie = new HashMap(), writeTime = new HashMap(), readTimes = new HashMap(), writeTimes = new HashMap(), secRead = new HashMap(), secWrite = new HashMap(); - while ((str = br.readLine()) != null) { - // String s = str; - token = new StringTokenizer(str); - str = token.nextToken(); - - if (str.equals("8")) { - // System.out.println(str+":"+s); - str = token.nextToken(); - if (!(str.equals("0"))) { - - str = token.nextToken(); - String elem = str; - instances_temp.add(elem); - str = token.nextToken(); - readTimes.put(elem, (double) Integer.parseInt(str)); - - str = token.nextToken(); - str = token.nextToken(); - secRead.put(elem, (double) Integer.parseInt(str)); - // secRead.put(elem, (double) Integer.parseInt(str)); - str = token.nextToken(); - readTmie.put(elem, (double) Integer.parseInt(str));// ms - str = token.nextToken(); - str = token.nextToken(); - writeTimes.put(elem, (double) Integer.parseInt(str)); - str = token.nextToken(); - secWrite.put(elem, (double) Integer.parseInt(str)); - str = token.nextToken(); - writeTime.put(elem, (double) Integer.parseInt(str)); - str = token.nextToken(); - currentDiskQueueLength_p.put(elem, - (double) Integer.parseInt(str)); - str = token.nextToken(); - str = token.nextToken(); - - } - } - } - br.close(); - Thread.sleep(idleTime); - br = new BufferedReader(new InputStreamReader(new FileInputStream( - new File("/proc/diskstats")))); - while ((str = br.readLine()) != null) { - token = new StringTokenizer(str); - str = token.nextToken(); - if (str.equals("8")) { - str = token.nextToken(); - if (!(str.equals("0"))) { - str = token.nextToken(); - String elem = str; - str = token.nextToken(); - readTimes.put(elem, - (double) (Integer.parseInt(str) - readTimes - .get(elem))); - - str = token.nextToken(); - str = token.nextToken(); - secRead.put(elem, Integer.parseInt(str) - secRead.get(elem)); - str = token.nextToken(); - readTmie.put(elem, - Integer.parseInt(str) - readTmie.get(elem));// ms - str = token.nextToken(); - writeTimes.put(elem, - Integer.parseInt(str) - writeTimes.get(elem)); - str = token.nextToken(); - str = token.nextToken(); - secWrite.put(elem, - Integer.parseInt(str) - secWrite.get(elem)); - str = token.nextToken(); - writeTime.put(elem, - Integer.parseInt(str) - writeTime.get(elem)); - str = token.nextToken(); - currentDiskQueueLength_temp.put(elem, - (double) Integer.parseInt(str)); - str = token.nextToken(); - str = token.nextToken(); - } - } - } - - Runtime rt = Runtime.getRuntime(); - // Integer time = new Integer(idleTime); - Process p = rt.exec("df -hl "); - BufferedReader in = new BufferedReader(new InputStreamReader( - p.getInputStream())); - while ((str = in.readLine()) != null) { - token = new StringTokenizer(str); - str = token.nextToken(); - Iterator itr = instances_temp.iterator(); - while (itr.hasNext()) { - String instance = itr.next(); - // System.out.println("instance_temp"+instance); - if (str.contains(instance)) { - instances.add(instance); - - str = token.nextToken(); - str = token.nextToken(); - freeMegabytes.put(instance, Double.parseDouble(str - .substring(0, str.length() - 1)) * 1024); - freeSpacePercent.put( - instance, - 100 - Double.parseDouble(str.substring(0, - str.length() - 1))); - currentDiskQueueLength.put(instance, - currentDiskQueueLength_temp.get(instance)); - } - } - - } - in.close(); - Iterator itr = instances.iterator(); - while (itr.hasNext()) { - str = itr.next(); - averageDiskQueueLength.put(str, - (currentDiskQueueLength.get(str) + currentDiskQueueLength_p - .get(str)) / 2); - averageDiskTransferTimeInSecond.put(str, (double) idleTime / 1000 - / (readTimes.get(str) + writeTimes.get(str))); - if (readTimes.get(str) != 0) { - averageDiskReadTimeInSecond.put(str, (double) idleTime / 1000 - / readTimes.get(str)); - } else - averageDiskReadTimeInSecond.put(str, 0.0); - - if (writeTimes.get(str) != 0) { - averageDiskWriteTimeInSecond.put(str, (double) idleTime / 1000 - / writeTimes.get(str)); - } else - averageDiskWriteTimeInSecond.put(str, 0.0); - if (readTmie.get(str) != 0) { - diskReadBytesPerSecond.put(str, - (double) (secRead.get(str) * 512) - / (readTmie.get(str) / 1000)); - } else - diskReadBytesPerSecond.put(str, 0.0); - if (writeTime.get(str) != 0) { - diskWriteBytesPerSecond.put( - str, - (double) (secWrite.get(str) * 512) - / (writeTime.get(str) / 1000)); - } else - diskWriteBytesPerSecond.put(str, 0.0); - if (writeTime.get(str) == 0 && readTmie.get(str) == 0) { - diskBytesPerSecond.put(str, 0.0); - } else - diskBytesPerSecond - .put(str, - (double) (secRead.get(str) * 512 + secWrite - .get(str) * 512) - / (readTmie.get(str) / 1000 + writeTime - .get(str) / 1000)); - idleTimePercent.put(str, - (double) (100 - (readTmie.get(str) + writeTime.get(str)) - / idleTime * 100)); - diskTimePercent.put(str, 100 - idleTimePercent.get(str)); - diskReadTimePercent.put(str, (double) readTmie.get(str) / idleTime - * 100); - diskWriteTimePercent.put(str, (double) writeTime.get(str) - / idleTime * 100); - } - itr = instances.iterator(); - - while (itr.hasNext()) { - LogicalDiskModelChild logicalDiskModelChild = new LogicalDiskModelChild(); - String elem = itr.next(); - - logicalDiskModelChild.setInstance(elem); - logicalDiskModelChild.setDiskBytesPerSecond(diskBytesPerSecond - .get(elem)); - logicalDiskModelChild - .setDiskWriteBytesPerSecond(diskWriteBytesPerSecond - .get(elem)); - - logicalDiskModelChild - .setDiskReadBytesPerSecond(diskReadBytesPerSecond.get(elem)); - logicalDiskModelChild - .setAverageDiskQueueLength(averageDiskQueueLength.get(elem)); - logicalDiskModelChild - .setAverageDiskReadTimeInSecond(averageDiskReadTimeInSecond - .get(elem)); - - logicalDiskModelChild - .setAverageDiskTransferTimeInSecond(averageDiskTransferTimeInSecond - .get(elem)); - logicalDiskModelChild - .setCurrentDiskQueueLength(currentDiskQueueLength.get(elem)); - - logicalDiskModelChild - .setAverageDiskWriteTimeInSecond(averageDiskWriteTimeInSecond - .get(elem)); - - logicalDiskModelChild.setDiskReadTimePercent(diskReadTimePercent - .get(elem)); - logicalDiskModelChild.setDiskTimePercent(diskTimePercent.get(elem)); - logicalDiskModelChild.setDiskWriteTimePercent(diskWriteTimePercent - .get(elem)); - - logicalDiskModelChild.setFreeMegabytes(freeMegabytes.get(elem)); - logicalDiskModelChild.setFreeSpacePercent(freeSpacePercent - .get(elem)); - logicalDiskModelChild.setIdleTimePercent(idleTimePercent.get(elem)); - - logicalDiskModel.getLogicalDiskList().add(logicalDiskModelChild); - - } - br.close(); - - return logicalDiskModel; - } - -} +package org.bench4q.monitor.performance.linux; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; + +import org.bench4q.monitor.entiry.LinuxFileRead; +import org.bench4q.monitor.model.LogicalDiskModel; +import org.bench4q.monitor.model.LogicalDiskModelChild; + +public class LogicalDiskMonitor extends LinuxFileRead { + public LogicalDiskMonitor() throws FileNotFoundException { + super("/proc/diskstats"); + instances = new ArrayList(); + + freeSpacePercent = new HashMap(); + freeMegabytes = new HashMap(); + + diskTimePercent = new HashMap(); + diskReadTimePercent = new HashMap(); + diskWriteTimePercent = new HashMap(); + + averageDiskTransferTimeInSecond = new HashMap(); + averageDiskReadTimeInSecond = new HashMap(); + averageDiskWriteTimeInSecond = new HashMap(); + + diskBytesPerSecond = new HashMap(); + diskReadBytesPerSecond = new HashMap(); + diskWriteBytesPerSecond = new HashMap(); + idleTimePercent = new HashMap(); + + averageDiskQueueLength = new HashMap(); + + currentDiskQueueLength = new HashMap(); + + } + + private List instances; + + public List getInstances() throws IOException, InterruptedException { + getLogicalDiskInfo(1); + return instances; + } + + public double getFreeSpacePercent(String instance) throws IOException, + InterruptedException { + getLogicalDiskInfo(1); + return freeSpacePercent.get(instance); + } + + public double getFreeMegabytes(String instance) throws IOException, + InterruptedException { + getLogicalDiskInfo(1); + return freeMegabytes.get(instance); + } + + public double getDiskTimePercent(String instance, int idleTime) + throws IOException, InterruptedException { + getLogicalDiskInfo(idleTime); + return diskTimePercent.get(instance); + } + + public double getDiskReadTimePercent(String instance, int idleTime) + throws IOException, InterruptedException { + getLogicalDiskInfo(idleTime); + return diskReadTimePercent.get(instance); + } + + public double getDiskWriteTimePercent(String instance, int idleTime) + throws IOException, InterruptedException { + getLogicalDiskInfo(idleTime); + return diskWriteTimePercent.get(instance); + } + + public double getAverageDiskTransferTimeInSecond(String instance, + int idleTime) throws IOException, InterruptedException { + getLogicalDiskInfo(idleTime); + return averageDiskTransferTimeInSecond.get(instance); + } + + public double getAverageDiskReadTimeInSecond(String instance, int idleTime) + throws IOException, InterruptedException { + getLogicalDiskInfo(idleTime); + return averageDiskReadTimeInSecond.get(instance); + } + + public double getAverageDiskWriteTimeInSecond(String instacne, int idleTime) + throws IOException, InterruptedException { + getLogicalDiskInfo(idleTime); + return averageDiskWriteTimeInSecond.get(instacne); + + } + + public double getDiskBytesPerSecond(String instance, int idleTime) + throws IOException, InterruptedException { + getLogicalDiskInfo(idleTime); + return diskBytesPerSecond.get(instance); + } + + public double getDiskReadBytesPerSecond(String instance, int idleTime) + throws IOException, InterruptedException { + + getLogicalDiskInfo(idleTime); + return diskReadBytesPerSecond.get(instance); + } + + public double getDiskWriteBytesPerSecond(String instance, int idleTime) + throws IOException, InterruptedException { + getLogicalDiskInfo(idleTime); + return diskWriteBytesPerSecond.get(instance); + } + + public double getIdleTimePercent(String instance, int idleTime) + throws IOException, InterruptedException { + getLogicalDiskInfo(idleTime); + return idleTimePercent.get(instance); + } + + public double getAverageDiskQueueLength(String instacne, int idleTime) + throws IOException, InterruptedException { + getLogicalDiskInfo(idleTime); + return averageDiskQueueLength.get(instacne); + } + + public double getCurrentDiskQueueLength(String instacne, int idleTime) + throws IOException, InterruptedException { + getLogicalDiskInfo(idleTime); + return currentDiskQueueLength.get(instacne); + } + + private Map freeSpacePercent; + private Map freeMegabytes; + + private Map diskTimePercent; + private Map diskReadTimePercent; + private Map diskWriteTimePercent; + + private Map averageDiskTransferTimeInSecond; + private Map averageDiskReadTimeInSecond; + private Map averageDiskWriteTimeInSecond; + + Map diskBytesPerSecond; + private Map diskReadBytesPerSecond;; + private Map diskWriteBytesPerSecond; + + private Map idleTimePercent; + private Map averageDiskQueueLength; + private Map currentDiskQueueLength; + + public LogicalDiskModel getLogicalDiskInfo(int idleTime) + throws IOException, InterruptedException { + LogicalDiskModel logicalDiskModel = new LogicalDiskModel(); + + List instances_temp = new ArrayList(); + Map currentDiskQueueLength_p = new HashMap(); + Map currentDiskQueueLength_temp = new HashMap(); + BufferedReader br = this.getBufferedReader(); + String str; + StringTokenizer token; + Map readTmie = new HashMap(), writeTime = new HashMap(), readTimes = new HashMap(), writeTimes = new HashMap(), secRead = new HashMap(), secWrite = new HashMap(); + while ((str = br.readLine()) != null) { + // String s = str; + token = new StringTokenizer(str); + str = token.nextToken(); + + if (str.equals("8")) { + // System.out.println(str+":"+s); + str = token.nextToken(); + if (!(str.equals("0"))) { + + str = token.nextToken(); + String elem = str; + instances_temp.add(elem); + str = token.nextToken(); + readTimes.put(elem, (double) Integer.parseInt(str)); + + str = token.nextToken(); + str = token.nextToken(); + secRead.put(elem, (double) Integer.parseInt(str)); + // secRead.put(elem, (double) Integer.parseInt(str)); + str = token.nextToken(); + readTmie.put(elem, (double) Integer.parseInt(str));// ms + str = token.nextToken(); + str = token.nextToken(); + writeTimes.put(elem, (double) Integer.parseInt(str)); + str = token.nextToken(); + secWrite.put(elem, (double) Integer.parseInt(str)); + str = token.nextToken(); + writeTime.put(elem, (double) Integer.parseInt(str)); + str = token.nextToken(); + currentDiskQueueLength_p.put(elem, + (double) Integer.parseInt(str)); + str = token.nextToken(); + str = token.nextToken(); + + } + } + } + br.close(); + Thread.sleep(idleTime); + br = new BufferedReader(new InputStreamReader(new FileInputStream( + new File("/proc/diskstats")))); + while ((str = br.readLine()) != null) { + token = new StringTokenizer(str); + str = token.nextToken(); + if (str.equals("8")) { + str = token.nextToken(); + if (!(str.equals("0"))) { + str = token.nextToken(); + String elem = str; + str = token.nextToken(); + readTimes.put(elem, + (double) (Integer.parseInt(str) - readTimes + .get(elem))); + + str = token.nextToken(); + str = token.nextToken(); + secRead.put(elem, Integer.parseInt(str) - secRead.get(elem)); + str = token.nextToken(); + readTmie.put(elem, + Integer.parseInt(str) - readTmie.get(elem));// ms + str = token.nextToken(); + writeTimes.put(elem, + Integer.parseInt(str) - writeTimes.get(elem)); + str = token.nextToken(); + str = token.nextToken(); + secWrite.put(elem, + Integer.parseInt(str) - secWrite.get(elem)); + str = token.nextToken(); + writeTime.put(elem, + Integer.parseInt(str) - writeTime.get(elem)); + str = token.nextToken(); + currentDiskQueueLength_temp.put(elem, + (double) Integer.parseInt(str)); + str = token.nextToken(); + str = token.nextToken(); + } + } + } + + Runtime rt = Runtime.getRuntime(); + // Integer time = new Integer(idleTime); + Process p = rt.exec("df -hl "); + BufferedReader in = new BufferedReader(new InputStreamReader( + p.getInputStream())); + while ((str = in.readLine()) != null) { + token = new StringTokenizer(str); + str = token.nextToken(); + Iterator itr = instances_temp.iterator(); + while (itr.hasNext()) { + String instance = itr.next(); + // System.out.println("instance_temp"+instance); + if (str.contains(instance)) { + instances.add(instance); + + str = token.nextToken(); + str = token.nextToken(); + freeMegabytes.put(instance, Double.parseDouble(str + .substring(0, str.length() - 1)) * 1024); + freeSpacePercent.put( + instance, + 100 - Double.parseDouble(str.substring(0, + str.length() - 1))); + currentDiskQueueLength.put(instance, + currentDiskQueueLength_temp.get(instance)); + } + } + + } + in.close(); + Iterator itr = instances.iterator(); + while (itr.hasNext()) { + str = itr.next(); + averageDiskQueueLength.put(str, + (currentDiskQueueLength.get(str) + currentDiskQueueLength_p + .get(str)) / 2); + averageDiskTransferTimeInSecond.put(str, (double) idleTime / 1000 + / (readTimes.get(str) + writeTimes.get(str))); + if (readTimes.get(str) != 0) { + averageDiskReadTimeInSecond.put(str, (double) idleTime / 1000 + / readTimes.get(str)); + } else + averageDiskReadTimeInSecond.put(str, 0.0); + + if (writeTimes.get(str) != 0) { + averageDiskWriteTimeInSecond.put(str, (double) idleTime / 1000 + / writeTimes.get(str)); + } else + averageDiskWriteTimeInSecond.put(str, 0.0); + if (readTmie.get(str) != 0) { + diskReadBytesPerSecond.put(str, + (double) (secRead.get(str) * 512) + / (readTmie.get(str) / 1000)); + } else + diskReadBytesPerSecond.put(str, 0.0); + if (writeTime.get(str) != 0) { + diskWriteBytesPerSecond.put( + str, + (double) (secWrite.get(str) * 512) + / (writeTime.get(str) / 1000)); + } else + diskWriteBytesPerSecond.put(str, 0.0); + if (writeTime.get(str) == 0 && readTmie.get(str) == 0) { + diskBytesPerSecond.put(str, 0.0); + } else + diskBytesPerSecond + .put(str, + (double) (secRead.get(str) * 512 + secWrite + .get(str) * 512) + / (readTmie.get(str) / 1000 + writeTime + .get(str) / 1000)); + idleTimePercent.put(str, + (double) (100 - (readTmie.get(str) + writeTime.get(str)) + / idleTime * 100)); + diskTimePercent.put(str, 100 - idleTimePercent.get(str)); + diskReadTimePercent.put(str, (double) readTmie.get(str) / idleTime + * 100); + diskWriteTimePercent.put(str, (double) writeTime.get(str) + / idleTime * 100); + } + itr = instances.iterator(); + + while (itr.hasNext()) { + LogicalDiskModelChild logicalDiskModelChild = new LogicalDiskModelChild(); + String elem = itr.next(); + + logicalDiskModelChild.setInstance(elem); + logicalDiskModelChild.setDiskBytesPerSecond(diskBytesPerSecond + .get(elem)); + logicalDiskModelChild + .setDiskWriteBytesPerSecond(diskWriteBytesPerSecond + .get(elem)); + + logicalDiskModelChild + .setDiskReadBytesPerSecond(diskReadBytesPerSecond.get(elem)); + logicalDiskModelChild + .setAverageDiskQueueLength(averageDiskQueueLength.get(elem)); + logicalDiskModelChild + .setAverageDiskReadTimeInSecond(averageDiskReadTimeInSecond + .get(elem)); + + logicalDiskModelChild + .setAverageDiskTransferTimeInSecond(averageDiskTransferTimeInSecond + .get(elem)); + logicalDiskModelChild + .setCurrentDiskQueueLength(currentDiskQueueLength.get(elem)); + + logicalDiskModelChild + .setAverageDiskWriteTimeInSecond(averageDiskWriteTimeInSecond + .get(elem)); + + logicalDiskModelChild.setDiskReadTimePercent(diskReadTimePercent + .get(elem)); + logicalDiskModelChild.setDiskTimePercent(diskTimePercent.get(elem)); + logicalDiskModelChild.setDiskWriteTimePercent(diskWriteTimePercent + .get(elem)); + + logicalDiskModelChild.setFreeMegabytes(freeMegabytes.get(elem)); + logicalDiskModelChild.setFreeSpacePercent(freeSpacePercent + .get(elem)); + logicalDiskModelChild.setIdleTimePercent(idleTimePercent.get(elem)); + + logicalDiskModel.getLogicalDiskList().add(logicalDiskModelChild); + + } + br.close(); + + return logicalDiskModel; + } + +} diff --git a/src/main/java/org/bench4q/monitor/performance/linux/MemoryInfoMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/MemoryInfoMonitor.java similarity index 100% rename from src/main/java/org/bench4q/monitor/performance/linux/MemoryInfoMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/MemoryInfoMonitor.java diff --git a/src/main/java/org/bench4q/monitor/performance/linux/MemoryMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/MemoryMonitor.java similarity index 100% rename from src/main/java/org/bench4q/monitor/performance/linux/MemoryMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/MemoryMonitor.java diff --git a/src/main/java/org/bench4q/monitor/performance/linux/NetworkInterfaceMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/NetworkInterfaceMonitor.java similarity index 97% rename from src/main/java/org/bench4q/monitor/performance/linux/NetworkInterfaceMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/NetworkInterfaceMonitor.java index 6cf049b7..12f7de78 100644 --- a/src/main/java/org/bench4q/monitor/performance/linux/NetworkInterfaceMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/NetworkInterfaceMonitor.java @@ -1,130 +1,130 @@ -package org.bench4q.monitor.performance.linux; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.bench4q.monitor.entiry.LinuxFileRead; -import org.bench4q.monitor.model.NetworkInterfaceModel; -import org.bench4q.monitor.model.NetworkInterfaceModelChild; - -public class NetworkInterfaceMonitor extends LinuxFileRead { - // /proc/net/dev - public NetworkInterfaceMonitor() throws FileNotFoundException { - super("/proc/net/dev"); - // TODO Auto-generated constructor stub - bytesTotalPerSecond = new HashMap(); - bytesReceivedPerSecond = new HashMap(); - bytesSentPerSecond = new HashMap(); - instances = new ArrayList(); - } - - private Map bytesTotalPerSecond; - private Map bytesReceivedPerSecond; - private Map bytesSentPerSecond; - private List instances; - - public List getInstances() throws IOException, InterruptedException { - getNetworkInterfaceInfo(1000); - return instances; - } - - public double getBytesTotalPerSecond(String instance, int idleTime) - throws IOException, InterruptedException { - getNetworkInterfaceInfo(idleTime); - return bytesTotalPerSecond.get(instance); - } - - public double getBytesReceivedPerSecond(String instance, int idleTime) - throws IOException, InterruptedException { - getNetworkInterfaceInfo(idleTime); - return bytesReceivedPerSecond.get(instance); - } - - public double getBytesSentPerSecond(String instacne, int idleTime) - throws IOException, InterruptedException { - getNetworkInterfaceInfo(idleTime); - return bytesSentPerSecond.get(instacne); - } - - public NetworkInterfaceModel getNetworkInterfaceInfo(int idleTime) - throws IOException, InterruptedException { - NetworkInterfaceModel networkInterfaceModel = new NetworkInterfaceModel(); - int time = idleTime / 1000; - BufferedReader br = this.getBufferedReader(); - Map bytesReceived = new HashMap(); - Map bytesSent = new HashMap(); - String nextline; - br.readLine(); - br.readLine(); - StringTokenizer token; - while ((nextline = br.readLine()) != null) { - if (nextline.contains("eth")) { - token = new StringTokenizer(nextline); - String instance = token.nextToken().replace(":", "");// instance - instances.add(instance); - String str = token.nextToken();// received bytes - bytesReceived.put(instance, Double.parseDouble(str)); - for (int i = 0; i < 7; i++) - token.nextToken(); - str = token.nextToken(); - bytesSent.put(instance, Double.parseDouble(str)); - } - } - Thread.sleep(idleTime); - br = new BufferedReader(new InputStreamReader(new FileInputStream( - new File("/proc/net/dev")))); - br.readLine(); - br.readLine(); - while ((nextline = br.readLine()) != null) { - if (nextline.contains("eth")) { - token = new StringTokenizer(nextline); - String instance = token.nextToken().replace(":", "");// instance - String str = token.nextToken();// received bytes - - bytesReceived.put(instance, Double.parseDouble(str) - - bytesReceived.get(instance)); - for (int i = 0; i < 7; i++) - token.nextToken(); - str = token.nextToken(); - - bytesSent.put(instance, - Double.parseDouble(str) - bytesReceived.get(instance)); - bytesReceivedPerSecond.put(instance, - bytesReceived.get(instance) / time); - bytesSentPerSecond - .put(instance, bytesSent.get(instance) / time); - bytesTotalPerSecond.put(instance, - bytesReceivedPerSecond.get(instance) - + bytesSentPerSecond.get(instance)); - } - } - Iterator itr = instances.iterator(); - while (itr.hasNext()) { - String instance = itr.next(); - NetworkInterfaceModelChild networkInterfaceModelChild = new NetworkInterfaceModelChild(); - networkInterfaceModelChild - .setBytesReceivedPerSecond(bytesReceivedPerSecond - .get(instance)); - networkInterfaceModelChild.setBytesSentPerSecond(bytesSentPerSecond - .get(instance)); - networkInterfaceModelChild - .setBytesTotalPerSecond(bytesTotalPerSecond.get(instance)); - networkInterfaceModelChild.setInstance(instance); - networkInterfaceModel.getNetworkList().add( - networkInterfaceModelChild); - } - br.close(); - return networkInterfaceModel; - } - -} +package org.bench4q.monitor.performance.linux; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import org.bench4q.monitor.entiry.LinuxFileRead; +import org.bench4q.monitor.model.NetworkInterfaceModel; +import org.bench4q.monitor.model.NetworkInterfaceModelChild; + +public class NetworkInterfaceMonitor extends LinuxFileRead { + // /proc/net/dev + public NetworkInterfaceMonitor() throws FileNotFoundException { + super("/proc/net/dev"); + // TODO Auto-generated constructor stub + bytesTotalPerSecond = new HashMap(); + bytesReceivedPerSecond = new HashMap(); + bytesSentPerSecond = new HashMap(); + instances = new ArrayList(); + } + + private Map bytesTotalPerSecond; + private Map bytesReceivedPerSecond; + private Map bytesSentPerSecond; + private List instances; + + public List getInstances() throws IOException, InterruptedException { + getNetworkInterfaceInfo(1000); + return instances; + } + + public double getBytesTotalPerSecond(String instance, int idleTime) + throws IOException, InterruptedException { + getNetworkInterfaceInfo(idleTime); + return bytesTotalPerSecond.get(instance); + } + + public double getBytesReceivedPerSecond(String instance, int idleTime) + throws IOException, InterruptedException { + getNetworkInterfaceInfo(idleTime); + return bytesReceivedPerSecond.get(instance); + } + + public double getBytesSentPerSecond(String instacne, int idleTime) + throws IOException, InterruptedException { + getNetworkInterfaceInfo(idleTime); + return bytesSentPerSecond.get(instacne); + } + + public NetworkInterfaceModel getNetworkInterfaceInfo(int idleTime) + throws IOException, InterruptedException { + NetworkInterfaceModel networkInterfaceModel = new NetworkInterfaceModel(); + int time = idleTime / 1000; + BufferedReader br = this.getBufferedReader(); + Map bytesReceived = new HashMap(); + Map bytesSent = new HashMap(); + String nextline; + br.readLine(); + br.readLine(); + StringTokenizer token; + while ((nextline = br.readLine()) != null) { + if (nextline.contains("eth")) { + token = new StringTokenizer(nextline); + String instance = token.nextToken().replace(":", "");// instance + instances.add(instance); + String str = token.nextToken();// received bytes + bytesReceived.put(instance, Double.parseDouble(str)); + for (int i = 0; i < 7; i++) + token.nextToken(); + str = token.nextToken(); + bytesSent.put(instance, Double.parseDouble(str)); + } + } + Thread.sleep(idleTime); + br = new BufferedReader(new InputStreamReader(new FileInputStream( + new File("/proc/net/dev")))); + br.readLine(); + br.readLine(); + while ((nextline = br.readLine()) != null) { + if (nextline.contains("eth")) { + token = new StringTokenizer(nextline); + String instance = token.nextToken().replace(":", "");// instance + String str = token.nextToken();// received bytes + + bytesReceived.put(instance, Double.parseDouble(str) + - bytesReceived.get(instance)); + for (int i = 0; i < 7; i++) + token.nextToken(); + str = token.nextToken(); + + bytesSent.put(instance, + Double.parseDouble(str) - bytesReceived.get(instance)); + bytesReceivedPerSecond.put(instance, + bytesReceived.get(instance) / time); + bytesSentPerSecond + .put(instance, bytesSent.get(instance) / time); + bytesTotalPerSecond.put(instance, + bytesReceivedPerSecond.get(instance) + + bytesSentPerSecond.get(instance)); + } + } + Iterator itr = instances.iterator(); + while (itr.hasNext()) { + String instance = itr.next(); + NetworkInterfaceModelChild networkInterfaceModelChild = new NetworkInterfaceModelChild(); + networkInterfaceModelChild + .setBytesReceivedPerSecond(bytesReceivedPerSecond + .get(instance)); + networkInterfaceModelChild.setBytesSentPerSecond(bytesSentPerSecond + .get(instance)); + networkInterfaceModelChild + .setBytesTotalPerSecond(bytesTotalPerSecond.get(instance)); + networkInterfaceModelChild.setInstance(instance); + networkInterfaceModel.getNetworkList().add( + networkInterfaceModelChild); + } + br.close(); + return networkInterfaceModel; + } + +} diff --git a/src/main/java/org/bench4q/monitor/performance/linux/PhysicalDiskMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/PhysicalDiskMonitor.java similarity index 96% rename from src/main/java/org/bench4q/monitor/performance/linux/PhysicalDiskMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/PhysicalDiskMonitor.java index b5a67037..cb4162cd 100644 --- a/src/main/java/org/bench4q/monitor/performance/linux/PhysicalDiskMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/PhysicalDiskMonitor.java @@ -1,204 +1,204 @@ -package org.bench4q.monitor.performance.linux; - -import java.util.List; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.StringTokenizer; -import java.util.Iterator; - -import org.bench4q.monitor.entiry.LinuxFileRead; -import org.bench4q.monitor.model.PhysicalDiskModel; -import org.bench4q.monitor.model.PhysicalDiskModelChild; - -public class PhysicalDiskMonitor extends LinuxFileRead { - public PhysicalDiskMonitor() throws FileNotFoundException { - super("/proc/diskstats"); - instance = new ArrayList(); - diskTimePercent = new HashMap(); - averageDiskQueueLength = new HashMap(); - currentDiskQueueLength = new HashMap(); - diskReadBytesPerSecond = new HashMap(); - diskWriteBytesPerSecond = new HashMap(); - diskBytesPerSecond = new HashMap(); - } - - private List instance; - private Map diskTimePercent; - private Map averageDiskQueueLength; - private Map currentDiskQueueLength; - private Map diskReadBytesPerSecond; - private Map diskWriteBytesPerSecond; - private Map diskBytesPerSecond; - - public List getInstances() throws IOException, InterruptedException { - this.getPhysicalDiskInfo(1); - return this.instance; - } - - public double getDiskTimePercent(String instance, int idleTime) - throws IOException, InterruptedException { - - this.getPhysicalDiskInfo(idleTime); - return this.diskTimePercent.get(instance); - } - - public double getAverageDiskQueueLength(String instance, int idleTime) - throws IOException, InterruptedException { - this.getPhysicalDiskInfo(idleTime); - return this.averageDiskQueueLength.get(instance); - } - - public double getCurrentDiskQueueLength(String instance) - throws IOException, InterruptedException { - this.getPhysicalDiskInfo(1); - return this.currentDiskQueueLength.get(instance); - - } - - public double getReadBytesPerSecond(String instance, int idleTime) - throws IOException, InterruptedException { - this.getPhysicalDiskInfo(idleTime); - return this.diskReadBytesPerSecond.get(instance); - } - - public double getDiskWriteBytesPerSecond(String instance, int idleTime) - throws IOException, InterruptedException { - this.getPhysicalDiskInfo(idleTime); - return this.diskWriteBytesPerSecond.get(instance); - } - - public double getDiskBytesPerSecond(String instance, int idleTime) - throws IOException, InterruptedException { - this.getPhysicalDiskInfo(idleTime); - return this.diskBytesPerSecond.get(instance); - } - - public PhysicalDiskModel getPhysicalDiskInfo(int idleTime) - throws IOException, InterruptedException { - - Runtime rt = Runtime.getRuntime(); - Integer time = new Integer(idleTime); - Process p = rt.exec("iostat -x " + time.toString() + " 2");// df -hl - // 查看硬盘空间 - - BufferedReader in = new BufferedReader(new InputStreamReader( - p.getInputStream())); - String str = ""; - int j = 0; - while ((str = in.readLine()) != null) { - if (str.contains("Device")) - j++; - if (j == 2) - break; - } - int device = 0, rkb = 0, wkb = 0, avgqu = 0, util = 0; - StringTokenizer token = new StringTokenizer(str.toLowerCase()); - int i = 0; - while (token.hasMoreTokens()) { - - str = token.nextToken(); - - if (str.contains("device")) - device = i; - if (str.contains("rkb/s")) - rkb = i; - if (str.contains("wkb/s")) - wkb = i; - if (str.contains("avgqu-sz")) - avgqu = i; - if (str.contains("%util")) - util = i; - i++; - } - - while ((str = in.readLine()) != null) { - i = 0; - token = new StringTokenizer(str); - String elem = ""; - while (token.hasMoreTokens()) { - str = token.nextToken(); - - if (device == i) { - instance.add(str); - elem = str; - } - if (rkb == i) { - diskReadBytesPerSecond.put(elem, - (Double.parseDouble(str)) * 1024); - } - if (wkb == i) { - diskWriteBytesPerSecond.put(elem, - (Double.parseDouble(str)) * 1024); - System.out.println(str); - } - if (avgqu == i) { - averageDiskQueueLength.put(elem, (Double.parseDouble(str))); - } - - if (util == i) - diskTimePercent.put(elem, Double.parseDouble(str)); - i++; - } - - } - Set set = diskReadBytesPerSecond.keySet(); - Iterator itr = set.iterator(); - while (itr.hasNext()) { - String elem = itr.next(); - diskBytesPerSecond.put(elem, diskReadBytesPerSecond.get(elem) - + diskWriteBytesPerSecond.get(elem)); - } - in.close(); - BufferedReader br = this.getBufferedReader(); - while ((str = br.readLine()) != null) { - token = new StringTokenizer(str); - while (token.hasMoreTokens()) { - str = token.nextToken(); - if (str.equals("8")) { - str = token.nextToken(); - if (str.contains("0")) { - str = token.nextToken(); - String elem = str; - - for (i = 0; i <= 8; i++) { - str = token.nextToken(); - } - currentDiskQueueLength.put(elem, - (double) Integer.parseInt(str)); - } - } - } - } - br.close(); - itr = instance.iterator(); - PhysicalDiskModel physicalDiskModel = new PhysicalDiskModel(); - while (itr.hasNext()) { - String elem = itr.next(); - PhysicalDiskModelChild physicalDiskModelChild = new PhysicalDiskModelChild(); - physicalDiskModelChild.setInstance(elem); - physicalDiskModelChild - .setAverageDiskQueueLength(averageDiskQueueLength.get(elem)); - physicalDiskModelChild - .setCurrentDiskQueueLength(currentDiskQueueLength.get(elem)); - physicalDiskModelChild.setDiskBytesPerSecond(diskBytesPerSecond - .get(elem)); - physicalDiskModelChild - .setDiskReadBytesPerSecond(diskReadBytesPerSecond.get(elem)); - physicalDiskModelChild - .setDiskTimePercent(diskTimePercent.get(elem)); - physicalDiskModelChild - .setDiskWriteBytesPerSecond(diskWriteBytesPerSecond - .get(elem)); - physicalDiskModel.getPhysicalDiskModelList().add( - physicalDiskModelChild); - } - return physicalDiskModel; - } - -} +package org.bench4q.monitor.performance.linux; + +import java.util.List; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.Iterator; + +import org.bench4q.monitor.entiry.LinuxFileRead; +import org.bench4q.monitor.model.PhysicalDiskModel; +import org.bench4q.monitor.model.PhysicalDiskModelChild; + +public class PhysicalDiskMonitor extends LinuxFileRead { + public PhysicalDiskMonitor() throws FileNotFoundException { + super("/proc/diskstats"); + instance = new ArrayList(); + diskTimePercent = new HashMap(); + averageDiskQueueLength = new HashMap(); + currentDiskQueueLength = new HashMap(); + diskReadBytesPerSecond = new HashMap(); + diskWriteBytesPerSecond = new HashMap(); + diskBytesPerSecond = new HashMap(); + } + + private List instance; + private Map diskTimePercent; + private Map averageDiskQueueLength; + private Map currentDiskQueueLength; + private Map diskReadBytesPerSecond; + private Map diskWriteBytesPerSecond; + private Map diskBytesPerSecond; + + public List getInstances() throws IOException, InterruptedException { + this.getPhysicalDiskInfo(1); + return this.instance; + } + + public double getDiskTimePercent(String instance, int idleTime) + throws IOException, InterruptedException { + + this.getPhysicalDiskInfo(idleTime); + return this.diskTimePercent.get(instance); + } + + public double getAverageDiskQueueLength(String instance, int idleTime) + throws IOException, InterruptedException { + this.getPhysicalDiskInfo(idleTime); + return this.averageDiskQueueLength.get(instance); + } + + public double getCurrentDiskQueueLength(String instance) + throws IOException, InterruptedException { + this.getPhysicalDiskInfo(1); + return this.currentDiskQueueLength.get(instance); + + } + + public double getReadBytesPerSecond(String instance, int idleTime) + throws IOException, InterruptedException { + this.getPhysicalDiskInfo(idleTime); + return this.diskReadBytesPerSecond.get(instance); + } + + public double getDiskWriteBytesPerSecond(String instance, int idleTime) + throws IOException, InterruptedException { + this.getPhysicalDiskInfo(idleTime); + return this.diskWriteBytesPerSecond.get(instance); + } + + public double getDiskBytesPerSecond(String instance, int idleTime) + throws IOException, InterruptedException { + this.getPhysicalDiskInfo(idleTime); + return this.diskBytesPerSecond.get(instance); + } + + public PhysicalDiskModel getPhysicalDiskInfo(int idleTime) + throws IOException, InterruptedException { + + Runtime rt = Runtime.getRuntime(); + Integer time = new Integer(idleTime); + Process p = rt.exec("iostat -x " + time.toString() + " 2");// df -hl + // 查看硬盘空间 + + BufferedReader in = new BufferedReader(new InputStreamReader( + p.getInputStream())); + String str = ""; + int j = 0; + while ((str = in.readLine()) != null) { + if (str.contains("Device")) + j++; + if (j == 2) + break; + } + int device = 0, rkb = 0, wkb = 0, avgqu = 0, util = 0; + StringTokenizer token = new StringTokenizer(str.toLowerCase()); + int i = 0; + while (token.hasMoreTokens()) { + + str = token.nextToken(); + + if (str.contains("device")) + device = i; + if (str.contains("rkb/s")) + rkb = i; + if (str.contains("wkb/s")) + wkb = i; + if (str.contains("avgqu-sz")) + avgqu = i; + if (str.contains("%util")) + util = i; + i++; + } + + while ((str = in.readLine()) != null) { + i = 0; + token = new StringTokenizer(str); + String elem = ""; + while (token.hasMoreTokens()) { + str = token.nextToken(); + + if (device == i) { + instance.add(str); + elem = str; + } + if (rkb == i) { + diskReadBytesPerSecond.put(elem, + (Double.parseDouble(str)) * 1024); + } + if (wkb == i) { + diskWriteBytesPerSecond.put(elem, + (Double.parseDouble(str)) * 1024); + System.out.println(str); + } + if (avgqu == i) { + averageDiskQueueLength.put(elem, (Double.parseDouble(str))); + } + + if (util == i) + diskTimePercent.put(elem, Double.parseDouble(str)); + i++; + } + + } + Set set = diskReadBytesPerSecond.keySet(); + Iterator itr = set.iterator(); + while (itr.hasNext()) { + String elem = itr.next(); + diskBytesPerSecond.put(elem, diskReadBytesPerSecond.get(elem) + + diskWriteBytesPerSecond.get(elem)); + } + in.close(); + BufferedReader br = this.getBufferedReader(); + while ((str = br.readLine()) != null) { + token = new StringTokenizer(str); + while (token.hasMoreTokens()) { + str = token.nextToken(); + if (str.equals("8")) { + str = token.nextToken(); + if (str.contains("0")) { + str = token.nextToken(); + String elem = str; + + for (i = 0; i <= 8; i++) { + str = token.nextToken(); + } + currentDiskQueueLength.put(elem, + (double) Integer.parseInt(str)); + } + } + } + } + br.close(); + itr = instance.iterator(); + PhysicalDiskModel physicalDiskModel = new PhysicalDiskModel(); + while (itr.hasNext()) { + String elem = itr.next(); + PhysicalDiskModelChild physicalDiskModelChild = new PhysicalDiskModelChild(); + physicalDiskModelChild.setInstance(elem); + physicalDiskModelChild + .setAverageDiskQueueLength(averageDiskQueueLength.get(elem)); + physicalDiskModelChild + .setCurrentDiskQueueLength(currentDiskQueueLength.get(elem)); + physicalDiskModelChild.setDiskBytesPerSecond(diskBytesPerSecond + .get(elem)); + physicalDiskModelChild + .setDiskReadBytesPerSecond(diskReadBytesPerSecond.get(elem)); + physicalDiskModelChild + .setDiskTimePercent(diskTimePercent.get(elem)); + physicalDiskModelChild + .setDiskWriteBytesPerSecond(diskWriteBytesPerSecond + .get(elem)); + physicalDiskModel.getPhysicalDiskModelList().add( + physicalDiskModelChild); + } + return physicalDiskModel; + } + +} diff --git a/src/main/java/org/bench4q/monitor/performance/linux/ProcessMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/ProcessMonitor.java similarity index 96% rename from src/main/java/org/bench4q/monitor/performance/linux/ProcessMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/ProcessMonitor.java index d9ef8bd0..5d8854cc 100644 --- a/src/main/java/org/bench4q/monitor/performance/linux/ProcessMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/ProcessMonitor.java @@ -1,149 +1,149 @@ -package org.bench4q.monitor.performance.linux; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.bench4q.monitor.model.ProcessModel; -import org.bench4q.monitor.model.ProcessModelChild; - -public class ProcessMonitor { - - private List instances; - private Map privateBytes; - private Map processorTimePercent; - private Map processId; - private Map virtualBytes; - - public ProcessMonitor() { - instances = new ArrayList(); - privateBytes = new HashMap(); - processorTimePercent = new HashMap(); - processId = new HashMap(); - virtualBytes = new HashMap(); - - } - - public List getInstances() throws IOException, InterruptedException { - getProcessInfo(1000); - return instances; - } - - public double getPrivateBytes(String instance) throws IOException, - InterruptedException { - getProcessInfo(1000); - return privateBytes.get(instance); - - } - - public double getProcessorTimePercent(String instance, int idleTime) - throws IOException, InterruptedException { - getProcessInfo(idleTime); - return processorTimePercent.get(instance); - } - - public double getProcessId(String instance) throws IOException, - InterruptedException { - getProcessInfo(1000); - return processId.get(instance); - } - - public double getVirtualBytes(String instance) throws IOException, - InterruptedException { - getProcessInfo(1000); - return virtualBytes.get(instance); - } - - public ProcessModel getProcessInfo(int idleTime) throws IOException, - InterruptedException {// top鍛戒护鏄寜鐓鏉ヨ鏃剁殑 - - ProcessModel processModel = new ProcessModel(); - Integer time = new Integer(idleTime / 1000); - Runtime rt = Runtime.getRuntime(); - - Process p = rt.exec("top -b -d " + time.toString() + " -n 2"); - BufferedReader in = new BufferedReader(new InputStreamReader( - p.getInputStream())); - String nextline; - StringTokenizer token; - int count = 0; - int pid = 0, virt = 0, shr = 0, cpu = 0, command = 0; - // int length = 0; - while ((nextline = in.readLine()) != null) { - if (nextline.toLowerCase().contains("pid user")) - count++; - if (count == 2 && nextline.toLowerCase().contains("pid user")) { - token = new StringTokenizer(nextline); - int i = 0; - while (token.hasMoreTokens()) { - String str = token.nextToken(); - if (str.equals("PID")) - pid = i; - if (str.equals("VIRT")) - virt = i; - if (str.equals("SHR")) - shr = i; - if (str.equals("%CPU")) - cpu = i; - if (str.equals("COMMAND")) - command = i; - i++; - } - // length = i; - nextline = in.readLine(); - - } - - if (count == 2 && nextline.length() > 0) { - - String s[] = new String[20]; - token = new StringTokenizer(nextline); - for (int i = 0; token.hasMoreTokens(); i++) { - s[i] = token.nextToken(); - } - String instance = s[command]; - instances.add(s[command]); - double virtValue, shrValue; - if (s[virt].contains("m")) { - s[virt] = s[virt].substring(0, s[virt].length() - 1); - virtValue = Double.parseDouble(s[virt]) * 1024; - - } else - virtValue = Double.parseDouble(s[virt]); - if (s[shr].contains("m")) { - s[shr] = s[shr].substring(0, s[shr].length() - 1); - shrValue = Double.parseDouble(s[shr]) * 1024; - } else - shrValue = Double.parseDouble(s[shr]); - double pbytes = virtValue - shrValue; - privateBytes.put(instance, pbytes); - processorTimePercent.put(instance, Double.parseDouble(s[cpu])); - processId.put(instance, Double.parseDouble(s[pid])); - virtualBytes.put(instance, virtValue); - } - } - - in.close(); - // System.out.println(instances.size()); - Iterator itr = instances.iterator(); - while (itr.hasNext()) { - ProcessModelChild processModelChild = new ProcessModelChild(); - String instance = itr.next(); - processModelChild.setInstanceString(instance); - processModelChild.setPrivateBytes(privateBytes.get(instance)); - processModelChild.setProcessId(processId.get(instance)); - processModelChild.setProcessorTimePercent(processorTimePercent - .get(instance)); - processModelChild.setVirtualBytes(virtualBytes.get(instance)); - processModel.getProcesModelList().add(processModelChild); - } - return processModel; - } - +package org.bench4q.monitor.performance.linux; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import org.bench4q.monitor.model.ProcessModel; +import org.bench4q.monitor.model.ProcessModelChild; + +public class ProcessMonitor { + + private List instances; + private Map privateBytes; + private Map processorTimePercent; + private Map processId; + private Map virtualBytes; + + public ProcessMonitor() { + instances = new ArrayList(); + privateBytes = new HashMap(); + processorTimePercent = new HashMap(); + processId = new HashMap(); + virtualBytes = new HashMap(); + + } + + public List getInstances() throws IOException, InterruptedException { + getProcessInfo(1000); + return instances; + } + + public double getPrivateBytes(String instance) throws IOException, + InterruptedException { + getProcessInfo(1000); + return privateBytes.get(instance); + + } + + public double getProcessorTimePercent(String instance, int idleTime) + throws IOException, InterruptedException { + getProcessInfo(idleTime); + return processorTimePercent.get(instance); + } + + public double getProcessId(String instance) throws IOException, + InterruptedException { + getProcessInfo(1000); + return processId.get(instance); + } + + public double getVirtualBytes(String instance) throws IOException, + InterruptedException { + getProcessInfo(1000); + return virtualBytes.get(instance); + } + + public ProcessModel getProcessInfo(int idleTime) throws IOException, + InterruptedException {// top鍛戒护鏄寜鐓鏉ヨ鏃剁殑 + + ProcessModel processModel = new ProcessModel(); + Integer time = new Integer(idleTime / 1000); + Runtime rt = Runtime.getRuntime(); + + Process p = rt.exec("top -b -d " + time.toString() + " -n 2"); + BufferedReader in = new BufferedReader(new InputStreamReader( + p.getInputStream())); + String nextline; + StringTokenizer token; + int count = 0; + int pid = 0, virt = 0, shr = 0, cpu = 0, command = 0; + // int length = 0; + while ((nextline = in.readLine()) != null) { + if (nextline.toLowerCase().contains("pid user")) + count++; + if (count == 2 && nextline.toLowerCase().contains("pid user")) { + token = new StringTokenizer(nextline); + int i = 0; + while (token.hasMoreTokens()) { + String str = token.nextToken(); + if (str.equals("PID")) + pid = i; + if (str.equals("VIRT")) + virt = i; + if (str.equals("SHR")) + shr = i; + if (str.equals("%CPU")) + cpu = i; + if (str.equals("COMMAND")) + command = i; + i++; + } + // length = i; + nextline = in.readLine(); + + } + + if (count == 2 && nextline.length() > 0) { + + String s[] = new String[20]; + token = new StringTokenizer(nextline); + for (int i = 0; token.hasMoreTokens(); i++) { + s[i] = token.nextToken(); + } + String instance = s[command]; + instances.add(s[command]); + double virtValue, shrValue; + if (s[virt].contains("m")) { + s[virt] = s[virt].substring(0, s[virt].length() - 1); + virtValue = Double.parseDouble(s[virt]) * 1024; + + } else + virtValue = Double.parseDouble(s[virt]); + if (s[shr].contains("m")) { + s[shr] = s[shr].substring(0, s[shr].length() - 1); + shrValue = Double.parseDouble(s[shr]) * 1024; + } else + shrValue = Double.parseDouble(s[shr]); + double pbytes = virtValue - shrValue; + privateBytes.put(instance, pbytes); + processorTimePercent.put(instance, Double.parseDouble(s[cpu])); + processId.put(instance, Double.parseDouble(s[pid])); + virtualBytes.put(instance, virtValue); + } + } + + in.close(); + // System.out.println(instances.size()); + Iterator itr = instances.iterator(); + while (itr.hasNext()) { + ProcessModelChild processModelChild = new ProcessModelChild(); + String instance = itr.next(); + processModelChild.setInstanceString(instance); + processModelChild.setPrivateBytes(privateBytes.get(instance)); + processModelChild.setProcessId(processId.get(instance)); + processModelChild.setProcessorTimePercent(processorTimePercent + .get(instance)); + processModelChild.setVirtualBytes(virtualBytes.get(instance)); + processModel.getProcesModelList().add(processModelChild); + } + return processModel; + } + } \ No newline at end of file diff --git a/src/main/java/org/bench4q/monitor/performance/linux/ProcessorMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/ProcessorMonitor.java similarity index 97% rename from src/main/java/org/bench4q/monitor/performance/linux/ProcessorMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/ProcessorMonitor.java index cff79bef..b8419548 100644 --- a/src/main/java/org/bench4q/monitor/performance/linux/ProcessorMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/ProcessorMonitor.java @@ -1,179 +1,179 @@ -package org.bench4q.monitor.performance.linux; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.bench4q.monitor.entiry.LinuxFileRead; -import org.bench4q.monitor.model.ProcessorModel; -import org.bench4q.monitor.model.ProcessorModelChild; - -public class ProcessorMonitor extends LinuxFileRead { - - private List instances; - - private Map privilegedTimePercent; - private Map processorTimePercent; - private Map userTimePercent; - - public void setInstances(List instances) { - this.instances = instances; - } - - public Map getPrivilegedTimePercent() { - return privilegedTimePercent; - } - - public void setPrivilegedTimePercent( - Map privilegedTimePercent) { - this.privilegedTimePercent = privilegedTimePercent; - } - - public Map getProcessorTimePercent() { - return processorTimePercent; - } - - public void setProcessorTimePercent(Map processorTimePercent) { - this.processorTimePercent = processorTimePercent; - } - - public Map getUserTimePercent() { - return userTimePercent; - } - - public void setUserTimePercent(Map userTimePercent) { - this.userTimePercent = userTimePercent; - } - - public ProcessorMonitor() throws FileNotFoundException { - super("/proc/stat"); - this.instances = new ArrayList(); - this.privilegedTimePercent = new HashMap(); - this.processorTimePercent = new HashMap(); - this.userTimePercent = new HashMap(); - } - - public List getInstances() throws IOException, InterruptedException { - BufferedReader br = this.getBufferedReader(); - - StringTokenizer token = new StringTokenizer(br.readLine()); - - while (token != null) { - String instance; - instance = token.nextToken().toLowerCase(); - if (!instance.contains("cpu")) - break; - this.instances.add(instance); - - token = new StringTokenizer(br.readLine()); - } - br.close(); - return this.instances; - } - - public double getPrivilegedTimePercent(String instance, int idleTime) - throws IOException, InterruptedException { - - getProcessorInfo(idleTime); - return privilegedTimePercent.get(instance); - - } - - public double getProcessorTimePercent(String instance, int idleTime) - throws IOException, InterruptedException { - - getProcessorInfo(idleTime); - return processorTimePercent.get(instance); - } - - public double getUserTimePercent(String instance, int idleTime) - throws IOException, InterruptedException { - - getProcessorInfo(idleTime); - return userTimePercent.get(instance); - } - - public ProcessorModel getProcessorInfo(int idleTime) throws IOException, - InterruptedException { - ProcessorModel processorModel = new ProcessorModel(); - BufferedReader br = this.getBufferedReader(); - Map tokens = new HashMap(); - StringTokenizer token = new StringTokenizer(br.readLine()); - // int i = 0; - while (token != null) { - - String instance = token.nextToken().toLowerCase(); - if (instance.contains("cpu")) { - this.instances.add(instance); - tokens.put(instance, token); - // i++; - token = new StringTokenizer(br.readLine()); - } else - break; - } - br.close(); - Thread.sleep(idleTime); - File file = new File("/proc/stat"); - br = new BufferedReader( - new InputStreamReader(new FileInputStream(file))); - String str; - int user1, user2 = 0, nice1, nice2 = 0, sys1, sys2 = 0, idle1, idle2 = 0, iowait1, iowait2 = 0; - - while ((str = br.readLine()) != null) { - token = new StringTokenizer(str); - String instance = token.nextToken().toLowerCase(); - if (instance.contains("cpu")) { - user2 = Integer.parseInt(token.nextToken()); - nice2 = Integer.parseInt(token.nextToken()); - sys2 = Integer.parseInt(token.nextToken()); - idle2 = Integer.parseInt(token.nextToken()); - iowait2 = Integer.parseInt(token.nextToken()); - token = tokens.get(instance); - // token.nextToken(); - user1 = Integer.parseInt(token.nextToken()); - nice1 = Integer.parseInt(token.nextToken()); - sys1 = Integer.parseInt(token.nextToken()); - idle1 = Integer.parseInt(token.nextToken()); - iowait1 = Integer.parseInt(token.nextToken()); - Double processorTimePercent_temp = (double) ((user2 + sys2 + nice2) - (user1 - + sys1 + nice1)) - / (double) ((user2 + sys2 + idle2 + nice2 + iowait2) - (user1 - + sys1 + idle1 + nice1 + iowait1)) * 100; - if(processorTimePercent_temp.equals("NaN")) processorTimePercent_temp=0.0; - Double userTimePercent_temp = (double) ((user2) - (user1)) - / (double) ((user2 + sys2 + nice2 + idle2 + iowait2) - (user1 - + sys1 + iowait1 + nice1 + idle1)) * 100; - if(userTimePercent_temp.equals("NaN")) userTimePercent_temp=0.0; - Double privilegedTimePercent_temp = (double) ((sys2) - (sys1)) - / (double) ((user2 + sys2 + nice2 + idle2 + iowait2) - (user1 - + sys1 + iowait1 + nice1 + idle2)) * 100; - if(privilegedTimePercent_temp.equals("NaN")) privilegedTimePercent_temp=0.0; - privilegedTimePercent.put(instance, privilegedTimePercent_temp); - processorTimePercent.put(instance, processorTimePercent_temp); - userTimePercent.put(instance, userTimePercent_temp); - ProcessorModelChild processorModelChild = new ProcessorModelChild(); - processorModelChild.setInstance(instance); - processorModelChild - .setPrivilegedTimePercent(privilegedTimePercent_temp); - processorModelChild - .setProcessorTimePercent(processorTimePercent_temp); - processorModelChild.setUserTimePercent(userTimePercent_temp); - processorModel.getProcessorModelList().add(processorModelChild); - } else - break; - } - - br.close(); - return processorModel; - - } - -} +package org.bench4q.monitor.performance.linux; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import org.bench4q.monitor.entiry.LinuxFileRead; +import org.bench4q.monitor.model.ProcessorModel; +import org.bench4q.monitor.model.ProcessorModelChild; + +public class ProcessorMonitor extends LinuxFileRead { + + private List instances; + + private Map privilegedTimePercent; + private Map processorTimePercent; + private Map userTimePercent; + + public void setInstances(List instances) { + this.instances = instances; + } + + public Map getPrivilegedTimePercent() { + return privilegedTimePercent; + } + + public void setPrivilegedTimePercent( + Map privilegedTimePercent) { + this.privilegedTimePercent = privilegedTimePercent; + } + + public Map getProcessorTimePercent() { + return processorTimePercent; + } + + public void setProcessorTimePercent(Map processorTimePercent) { + this.processorTimePercent = processorTimePercent; + } + + public Map getUserTimePercent() { + return userTimePercent; + } + + public void setUserTimePercent(Map userTimePercent) { + this.userTimePercent = userTimePercent; + } + + public ProcessorMonitor() throws FileNotFoundException { + super("/proc/stat"); + this.instances = new ArrayList(); + this.privilegedTimePercent = new HashMap(); + this.processorTimePercent = new HashMap(); + this.userTimePercent = new HashMap(); + } + + public List getInstances() throws IOException, InterruptedException { + BufferedReader br = this.getBufferedReader(); + + StringTokenizer token = new StringTokenizer(br.readLine()); + + while (token != null) { + String instance; + instance = token.nextToken().toLowerCase(); + if (!instance.contains("cpu")) + break; + this.instances.add(instance); + + token = new StringTokenizer(br.readLine()); + } + br.close(); + return this.instances; + } + + public double getPrivilegedTimePercent(String instance, int idleTime) + throws IOException, InterruptedException { + + getProcessorInfo(idleTime); + return privilegedTimePercent.get(instance); + + } + + public double getProcessorTimePercent(String instance, int idleTime) + throws IOException, InterruptedException { + + getProcessorInfo(idleTime); + return processorTimePercent.get(instance); + } + + public double getUserTimePercent(String instance, int idleTime) + throws IOException, InterruptedException { + + getProcessorInfo(idleTime); + return userTimePercent.get(instance); + } + + public ProcessorModel getProcessorInfo(int idleTime) throws IOException, + InterruptedException { + ProcessorModel processorModel = new ProcessorModel(); + BufferedReader br = this.getBufferedReader(); + Map tokens = new HashMap(); + StringTokenizer token = new StringTokenizer(br.readLine()); + // int i = 0; + while (token != null) { + + String instance = token.nextToken().toLowerCase(); + if (instance.contains("cpu")) { + this.instances.add(instance); + tokens.put(instance, token); + // i++; + token = new StringTokenizer(br.readLine()); + } else + break; + } + br.close(); + Thread.sleep(idleTime); + File file = new File("/proc/stat"); + br = new BufferedReader( + new InputStreamReader(new FileInputStream(file))); + String str; + int user1, user2 = 0, nice1, nice2 = 0, sys1, sys2 = 0, idle1, idle2 = 0, iowait1, iowait2 = 0; + + while ((str = br.readLine()) != null) { + token = new StringTokenizer(str); + String instance = token.nextToken().toLowerCase(); + if (instance.contains("cpu")) { + user2 = Integer.parseInt(token.nextToken()); + nice2 = Integer.parseInt(token.nextToken()); + sys2 = Integer.parseInt(token.nextToken()); + idle2 = Integer.parseInt(token.nextToken()); + iowait2 = Integer.parseInt(token.nextToken()); + token = tokens.get(instance); + // token.nextToken(); + user1 = Integer.parseInt(token.nextToken()); + nice1 = Integer.parseInt(token.nextToken()); + sys1 = Integer.parseInt(token.nextToken()); + idle1 = Integer.parseInt(token.nextToken()); + iowait1 = Integer.parseInt(token.nextToken()); + Double processorTimePercent_temp = (double) ((user2 + sys2 + nice2) - (user1 + + sys1 + nice1)) + / (double) ((user2 + sys2 + idle2 + nice2 + iowait2) - (user1 + + sys1 + idle1 + nice1 + iowait1)) * 100; + if(processorTimePercent_temp.equals("NaN")) processorTimePercent_temp=0.0; + Double userTimePercent_temp = (double) ((user2) - (user1)) + / (double) ((user2 + sys2 + nice2 + idle2 + iowait2) - (user1 + + sys1 + iowait1 + nice1 + idle1)) * 100; + if(userTimePercent_temp.equals("NaN")) userTimePercent_temp=0.0; + Double privilegedTimePercent_temp = (double) ((sys2) - (sys1)) + / (double) ((user2 + sys2 + nice2 + idle2 + iowait2) - (user1 + + sys1 + iowait1 + nice1 + idle2)) * 100; + if(privilegedTimePercent_temp.equals("NaN")) privilegedTimePercent_temp=0.0; + privilegedTimePercent.put(instance, privilegedTimePercent_temp); + processorTimePercent.put(instance, processorTimePercent_temp); + userTimePercent.put(instance, userTimePercent_temp); + ProcessorModelChild processorModelChild = new ProcessorModelChild(); + processorModelChild.setInstance(instance); + processorModelChild + .setPrivilegedTimePercent(privilegedTimePercent_temp); + processorModelChild + .setProcessorTimePercent(processorTimePercent_temp); + processorModelChild.setUserTimePercent(userTimePercent_temp); + processorModel.getProcessorModelList().add(processorModelChild); + } else + break; + } + + br.close(); + return processorModel; + + } + +} diff --git a/src/main/java/org/bench4q/monitor/performance/linux/SystemMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/SystemMonitor.java similarity index 96% rename from src/main/java/org/bench4q/monitor/performance/linux/SystemMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/SystemMonitor.java index 55195eb4..333611b4 100644 --- a/src/main/java/org/bench4q/monitor/performance/linux/SystemMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/SystemMonitor.java @@ -1,125 +1,125 @@ -package org.bench4q.monitor.performance.linux; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Iterator; -import java.util.List; -import java.util.StringTokenizer; - -import org.bench4q.monitor.entiry.LinuxFileRead; -import org.bench4q.monitor.model.ProcessorModel; -import org.bench4q.monitor.model.ProcessorModelChild; -import org.bench4q.monitor.model.SystemModel; - -public class SystemMonitor extends LinuxFileRead { - - public SystemMonitor() throws FileNotFoundException { - super("/proc/stat"); - // TODO Auto-generated constructor stub - - } - - public double getTotalProceesorTimePercent(int idleTime) - throws IOException, InterruptedException { - getSystemInfo(idleTime); - return totalProceesorTimePercent; - } - - public double getProcessorQueueLength() throws IOException, - InterruptedException { - getSystemInfo(1000); - return processorQueueLength; - } - - public double getFileDataOperationsPerSecond(int idleTime) - throws IOException, InterruptedException { - getSystemInfo(idleTime); - return fileDataOperationsPerSecond; - } - - private double totalProceesorTimePercent; - private double processorQueueLength; - private double fileDataOperationsPerSecond; - - public SystemModel getSystemInfo(int idleTime) throws IOException, - InterruptedException { - SystemModel systemModel = new SystemModel(); - totalProceesorTimePercent = 0; - fileDataOperationsPerSecond = 0; - String nextline; - StringTokenizer token = null; - ProcessorMonitor pm = new ProcessorMonitor(); - // "in" is used for reading file "proc/diskstats" - BufferedReader in = new BufferedReader(new InputStreamReader( - new FileInputStream(new File("/proc/diskstats")))); - while ((nextline = in.readLine()) != null) { - if (nextline.contains("8 0 ")) { - token = new StringTokenizer(nextline); - token.nextToken(); - token.nextToken(); - token.nextToken(); - fileDataOperationsPerSecond -= Integer.parseInt(token - .nextToken()); - token.nextToken(); - token.nextToken(); - token.nextToken(); - fileDataOperationsPerSecond -= Integer.parseInt(token - .nextToken()); - } - } - in.close(); - ProcessorModel pModel = pm.getProcessorInfo(idleTime); - BufferedReader br = this.getBufferedReader(); - - while ((nextline = br.readLine()) != null) { - if (nextline.contains("procs_running")) { - token = new StringTokenizer(nextline); - token.nextToken(); - processorQueueLength += Integer.parseInt(token.nextToken()); - } - if (nextline.contains("procs_blocked")) { - token = new StringTokenizer(nextline); - token.nextToken(); - processorQueueLength += Integer.parseInt(token.nextToken()); - } - - } - br.close(); - in = new BufferedReader(new InputStreamReader(new FileInputStream( - new File("/proc/diskstats")))); - while ((nextline = in.readLine()) != null) { - if (nextline.contains("8 0 ")) { - token = new StringTokenizer(nextline); - token.nextToken(); - token.nextToken(); - token.nextToken(); - fileDataOperationsPerSecond += Integer.parseInt(token - .nextToken()); - token.nextToken(); - token.nextToken(); - token.nextToken(); - fileDataOperationsPerSecond += Integer.parseInt(token - .nextToken()); - } - } - in.close(); - fileDataOperationsPerSecond = fileDataOperationsPerSecond - / (idleTime / 1000); - - List list = pModel.getProcessorModelList(); - Iterator itr = list.iterator(); - while (itr.hasNext()) { - totalProceesorTimePercent += itr.next().getProcessorTimePercent(); - } - systemModel.setFileDataOperationsPerSecond(fileDataOperationsPerSecond); - systemModel.setProcessorQueueLength(processorQueueLength); - systemModel.setTotalProceesorTimePercent(totalProceesorTimePercent); - return systemModel; - - } - -} +package org.bench4q.monitor.performance.linux; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; + +import org.bench4q.monitor.entiry.LinuxFileRead; +import org.bench4q.monitor.model.ProcessorModel; +import org.bench4q.monitor.model.ProcessorModelChild; +import org.bench4q.monitor.model.SystemModel; + +public class SystemMonitor extends LinuxFileRead { + + public SystemMonitor() throws FileNotFoundException { + super("/proc/stat"); + // TODO Auto-generated constructor stub + + } + + public double getTotalProceesorTimePercent(int idleTime) + throws IOException, InterruptedException { + getSystemInfo(idleTime); + return totalProceesorTimePercent; + } + + public double getProcessorQueueLength() throws IOException, + InterruptedException { + getSystemInfo(1000); + return processorQueueLength; + } + + public double getFileDataOperationsPerSecond(int idleTime) + throws IOException, InterruptedException { + getSystemInfo(idleTime); + return fileDataOperationsPerSecond; + } + + private double totalProceesorTimePercent; + private double processorQueueLength; + private double fileDataOperationsPerSecond; + + public SystemModel getSystemInfo(int idleTime) throws IOException, + InterruptedException { + SystemModel systemModel = new SystemModel(); + totalProceesorTimePercent = 0; + fileDataOperationsPerSecond = 0; + String nextline; + StringTokenizer token = null; + ProcessorMonitor pm = new ProcessorMonitor(); + // "in" is used for reading file "proc/diskstats" + BufferedReader in = new BufferedReader(new InputStreamReader( + new FileInputStream(new File("/proc/diskstats")))); + while ((nextline = in.readLine()) != null) { + if (nextline.contains("8 0 ")) { + token = new StringTokenizer(nextline); + token.nextToken(); + token.nextToken(); + token.nextToken(); + fileDataOperationsPerSecond -= Integer.parseInt(token + .nextToken()); + token.nextToken(); + token.nextToken(); + token.nextToken(); + fileDataOperationsPerSecond -= Integer.parseInt(token + .nextToken()); + } + } + in.close(); + ProcessorModel pModel = pm.getProcessorInfo(idleTime); + BufferedReader br = this.getBufferedReader(); + + while ((nextline = br.readLine()) != null) { + if (nextline.contains("procs_running")) { + token = new StringTokenizer(nextline); + token.nextToken(); + processorQueueLength += Integer.parseInt(token.nextToken()); + } + if (nextline.contains("procs_blocked")) { + token = new StringTokenizer(nextline); + token.nextToken(); + processorQueueLength += Integer.parseInt(token.nextToken()); + } + + } + br.close(); + in = new BufferedReader(new InputStreamReader(new FileInputStream( + new File("/proc/diskstats")))); + while ((nextline = in.readLine()) != null) { + if (nextline.contains("8 0 ")) { + token = new StringTokenizer(nextline); + token.nextToken(); + token.nextToken(); + token.nextToken(); + fileDataOperationsPerSecond += Integer.parseInt(token + .nextToken()); + token.nextToken(); + token.nextToken(); + token.nextToken(); + fileDataOperationsPerSecond += Integer.parseInt(token + .nextToken()); + } + } + in.close(); + fileDataOperationsPerSecond = fileDataOperationsPerSecond + / (idleTime / 1000); + + List list = pModel.getProcessorModelList(); + Iterator itr = list.iterator(); + while (itr.hasNext()) { + totalProceesorTimePercent += itr.next().getProcessorTimePercent(); + } + systemModel.setFileDataOperationsPerSecond(fileDataOperationsPerSecond); + systemModel.setProcessorQueueLength(processorQueueLength); + systemModel.setTotalProceesorTimePercent(totalProceesorTimePercent); + return systemModel; + + } + +} diff --git a/src/main/java/org/bench4q/monitor/performance/windows/LogicalDiskMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/LogicalDiskMonitor.java similarity index 100% rename from src/main/java/org/bench4q/monitor/performance/windows/LogicalDiskMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/LogicalDiskMonitor.java diff --git a/src/main/java/org/bench4q/monitor/performance/windows/MemoryMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/MemoryMonitor.java similarity index 100% rename from src/main/java/org/bench4q/monitor/performance/windows/MemoryMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/MemoryMonitor.java diff --git a/src/main/java/org/bench4q/monitor/performance/windows/NetworkInterfaceMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/NetworkInterfaceMonitor.java similarity index 100% rename from src/main/java/org/bench4q/monitor/performance/windows/NetworkInterfaceMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/NetworkInterfaceMonitor.java diff --git a/src/main/java/org/bench4q/monitor/performance/windows/PhysicalDiskMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/PhysicalDiskMonitor.java similarity index 96% rename from src/main/java/org/bench4q/monitor/performance/windows/PhysicalDiskMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/PhysicalDiskMonitor.java index f4033c8e..9d0c51b3 100644 --- a/src/main/java/org/bench4q/monitor/performance/windows/PhysicalDiskMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/PhysicalDiskMonitor.java @@ -1,67 +1,67 @@ -package org.bench4q.monitor.performance.windows; - -import org.springframework.stereotype.Component; - -@Component -public class PhysicalDiskMonitor { - public native String[] getInstances(); - - public native String[] getCounterList(); - - public native double getCurrentDiskQueueLength(String instanceName); - - public native double getDiskTimePercent(String instanceName, int idleTime); - - public native double getAverageDiskQueueLength(String instanceName, - int idleTime); - - public native double getDiskReadTimePercent(String instanceName, - int idleTime); - - public native double getAverageDiskReadQueueLength(String instanceName, - int idleTime); - - public native double getDiskWriteTimePercent(String instanceName, - int idleTime); - - public native double getAverageDiskWriteQueueLength(String instanceName, - int idleTime); - - public native double getAverageDiskTransferTimeInSecond( - String instanceName, int idleTime); - - public native double getAverageDiskReadTimeInSecond(String instanceName, - int idleTime); - - public native double getAverageDiskWriteTimeInSecond(String instanceName, - int idleTime); - - public native double getDiskTransfersPerSecond(String instanceName, - int idleTime); - - public native double getDiskReadsPerSecond(String instanceName, int idleTime); - - public native double getDiskWritesPerSecond(String instanceName, - int idleTime); - - public native double getDiskBytesPerSecond(String instanceName, int idleTime); - - public native double getDiskReadBytesPerSecond(String instanceName, - int idleTime); - - public native double getDiskWriteBytesPerSecond(String instanceName, - int idleTime); - - public native double getAverageDiskBytesPerTransfer(String instanceName, - int idleTime); - - public native double getAverageDiskBytesPerRead(String instanceName, - int idleTime); - - public native double getAverageDiskBytesPerWrite(String instanceName, - int idleTime); - - public native double getIdleTimePercent(String instanceName, int idleTime); - - public native double getSplitIOPerSecond(String instanceName, int idleTime); -} +package org.bench4q.monitor.performance.windows; + +import org.springframework.stereotype.Component; + +@Component +public class PhysicalDiskMonitor { + public native String[] getInstances(); + + public native String[] getCounterList(); + + public native double getCurrentDiskQueueLength(String instanceName); + + public native double getDiskTimePercent(String instanceName, int idleTime); + + public native double getAverageDiskQueueLength(String instanceName, + int idleTime); + + public native double getDiskReadTimePercent(String instanceName, + int idleTime); + + public native double getAverageDiskReadQueueLength(String instanceName, + int idleTime); + + public native double getDiskWriteTimePercent(String instanceName, + int idleTime); + + public native double getAverageDiskWriteQueueLength(String instanceName, + int idleTime); + + public native double getAverageDiskTransferTimeInSecond( + String instanceName, int idleTime); + + public native double getAverageDiskReadTimeInSecond(String instanceName, + int idleTime); + + public native double getAverageDiskWriteTimeInSecond(String instanceName, + int idleTime); + + public native double getDiskTransfersPerSecond(String instanceName, + int idleTime); + + public native double getDiskReadsPerSecond(String instanceName, int idleTime); + + public native double getDiskWritesPerSecond(String instanceName, + int idleTime); + + public native double getDiskBytesPerSecond(String instanceName, int idleTime); + + public native double getDiskReadBytesPerSecond(String instanceName, + int idleTime); + + public native double getDiskWriteBytesPerSecond(String instanceName, + int idleTime); + + public native double getAverageDiskBytesPerTransfer(String instanceName, + int idleTime); + + public native double getAverageDiskBytesPerRead(String instanceName, + int idleTime); + + public native double getAverageDiskBytesPerWrite(String instanceName, + int idleTime); + + public native double getIdleTimePercent(String instanceName, int idleTime); + + public native double getSplitIOPerSecond(String instanceName, int idleTime); +} diff --git a/src/main/java/org/bench4q/monitor/performance/windows/ProcessMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/ProcessMonitor.java similarity index 96% rename from src/main/java/org/bench4q/monitor/performance/windows/ProcessMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/ProcessMonitor.java index 4b4b9287..b5b0d22c 100644 --- a/src/main/java/org/bench4q/monitor/performance/windows/ProcessMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/ProcessMonitor.java @@ -1,77 +1,77 @@ -package org.bench4q.monitor.performance.windows; - -import org.springframework.stereotype.Component; - -@Component -public class ProcessMonitor { - public native String[] getInstances(); - - public native String[] getCounterList(); - - public native double getProcessorTimePercent(String instanceName, - int idleTime); - - public native double getUserTimePercent(String instanceName, int idleTime); - - public native double getPrivilegedTimePercent(String instanceName, - int idleTime); - - public native double getVirtualBytesPeak(String instanceName); - - public native double getVirtualBytes(String instanceName); - - public native double getPageFaultsPerSecond(String instanceName, - int idleTime); - - public native double getWorkingSetPeak(String instanceName); - - public native double getWorkingSet(String instanceName); - - public native double getPageFileBytesPeak(String instanceName); - - public native double getPageFileBytes(String instanceName); - - public native double getPrivateBytes(String instanceName); - - public native double getThreadCount(String instanceName); - - public native double getPriorityBase(String instanceName); - - public native double getElapsedTime(String instanceName); - - public native double getProcessId(String instanceName); - - public native double getCreatingProcessId(String instanceName); - - public native double getPoolPagedBytes(String instanceName); - - public native double getPoolNonpagedBytes(String instanceName); - - public native double getHandleCount(String instanceName); - - public native double getIOReadOperationsPerSecond(String instanceName, - int idleTime); - - public native double getIOWriteOperationsPerSecond(String instanceName, - int idleTime); - - public native double getIODataOperationsPerSecond(String instanceName, - int idleTime); - - public native double getIOOtherOperationsPerSecond(String instanceName, - int idleTime); - - public native double getIOReadBytesPerSecond(String instanceName, - int idleTime); - - public native double getIOWriteBytesPerSecond(String instanceName, - int idleTime); - - public native double getIODataBytesPerSecond(String instanceName, - int idleTime); - - public native double getIOOtherBytesPerSecond(String instanceName, - int idleTime); - - public native double getPrivateWorkingSet(String instanceName); -} +package org.bench4q.monitor.performance.windows; + +import org.springframework.stereotype.Component; + +@Component +public class ProcessMonitor { + public native String[] getInstances(); + + public native String[] getCounterList(); + + public native double getProcessorTimePercent(String instanceName, + int idleTime); + + public native double getUserTimePercent(String instanceName, int idleTime); + + public native double getPrivilegedTimePercent(String instanceName, + int idleTime); + + public native double getVirtualBytesPeak(String instanceName); + + public native double getVirtualBytes(String instanceName); + + public native double getPageFaultsPerSecond(String instanceName, + int idleTime); + + public native double getWorkingSetPeak(String instanceName); + + public native double getWorkingSet(String instanceName); + + public native double getPageFileBytesPeak(String instanceName); + + public native double getPageFileBytes(String instanceName); + + public native double getPrivateBytes(String instanceName); + + public native double getThreadCount(String instanceName); + + public native double getPriorityBase(String instanceName); + + public native double getElapsedTime(String instanceName); + + public native double getProcessId(String instanceName); + + public native double getCreatingProcessId(String instanceName); + + public native double getPoolPagedBytes(String instanceName); + + public native double getPoolNonpagedBytes(String instanceName); + + public native double getHandleCount(String instanceName); + + public native double getIOReadOperationsPerSecond(String instanceName, + int idleTime); + + public native double getIOWriteOperationsPerSecond(String instanceName, + int idleTime); + + public native double getIODataOperationsPerSecond(String instanceName, + int idleTime); + + public native double getIOOtherOperationsPerSecond(String instanceName, + int idleTime); + + public native double getIOReadBytesPerSecond(String instanceName, + int idleTime); + + public native double getIOWriteBytesPerSecond(String instanceName, + int idleTime); + + public native double getIODataBytesPerSecond(String instanceName, + int idleTime); + + public native double getIOOtherBytesPerSecond(String instanceName, + int idleTime); + + public native double getPrivateWorkingSet(String instanceName); +} diff --git a/src/main/java/org/bench4q/monitor/performance/windows/ProcessorInformationMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/ProcessorInformationMonitor.java similarity index 96% rename from src/main/java/org/bench4q/monitor/performance/windows/ProcessorInformationMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/ProcessorInformationMonitor.java index 3ae181dd..fc308cde 100644 --- a/src/main/java/org/bench4q/monitor/performance/windows/ProcessorInformationMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/ProcessorInformationMonitor.java @@ -1,79 +1,79 @@ -package org.bench4q.monitor.performance.windows; - -public class ProcessorInformationMonitor { - public native String[] getInstances(); - - public native String[] getCounterList(); - - public native double getPerformanceLimitFlags(String instanceName); - - public native double getPerformanceLimitPercent(String instanceName); - - public native double getPrivilegedUtilityPercent(String instanceName, - int idleTime); - - public native double getProcessorUtilityPercent(String instanceName, - int idleTime); - - public native double getProcessorPerformancePercent(String instanceName, - int idleTime); - - public native double getIdleBreakEventsPerSecond(String instanceName, - int idleTime); - - public native double getAverageIdleTime(String instanceName, int idleTime); - - public native double getClockInterruptsPerSecond(String instanceName, - int idleTime); - - public native double getProcessorStateFlags(String instanceName); - - public native double getPercentageOfMaximumFrequency(String instanceName); - - public native double getProcessorFrequency(String instanceName); - - public native double getParkingStatus(String instanceName); - - public native double getPriorityTimePercent(String instanceName, - int idleTime); - - public native double getC3TransitionsPerSecond(String instanceName, - int idleTime); - - public native double getC2TransitionsPerSecond(String instanceName, - int idleTime); - - public native double getC1TransitionsPerSecond(String instanceName, - int idleTime); - - public native double getC3TimePercent(String instanceName, int idleTime); - - public native double getC2TimePercent(String instanceName, int idleTime); - - public native double getC1TimePercent(String instanceName, int idleTime); - - public native double getIdleTimePercent(String instanceName, int idleTime); - - public native double getDpcRate(String instanceName); - - public native double getDpcsQueuedPerSecond(String instanceName, - int idleTime); - - public native double getInterruptTimePercent(String instanceName, - int idleTime); - - public native double getDpcTimePercent(String instanceName, int idleTime); - - - - native double getInterruptsPerSecond(String instanceName, - int idleTime); - - public native double getPrivilegedTimePercent(String instanceName, - int idleTime); - - public native double getUserTimePercent(String instanceName, int idleTime); - - public native double getProcessorTimePercent(String instanceName, - int idleTime); -} +package org.bench4q.monitor.performance.windows; + +public class ProcessorInformationMonitor { + public native String[] getInstances(); + + public native String[] getCounterList(); + + public native double getPerformanceLimitFlags(String instanceName); + + public native double getPerformanceLimitPercent(String instanceName); + + public native double getPrivilegedUtilityPercent(String instanceName, + int idleTime); + + public native double getProcessorUtilityPercent(String instanceName, + int idleTime); + + public native double getProcessorPerformancePercent(String instanceName, + int idleTime); + + public native double getIdleBreakEventsPerSecond(String instanceName, + int idleTime); + + public native double getAverageIdleTime(String instanceName, int idleTime); + + public native double getClockInterruptsPerSecond(String instanceName, + int idleTime); + + public native double getProcessorStateFlags(String instanceName); + + public native double getPercentageOfMaximumFrequency(String instanceName); + + public native double getProcessorFrequency(String instanceName); + + public native double getParkingStatus(String instanceName); + + public native double getPriorityTimePercent(String instanceName, + int idleTime); + + public native double getC3TransitionsPerSecond(String instanceName, + int idleTime); + + public native double getC2TransitionsPerSecond(String instanceName, + int idleTime); + + public native double getC1TransitionsPerSecond(String instanceName, + int idleTime); + + public native double getC3TimePercent(String instanceName, int idleTime); + + public native double getC2TimePercent(String instanceName, int idleTime); + + public native double getC1TimePercent(String instanceName, int idleTime); + + public native double getIdleTimePercent(String instanceName, int idleTime); + + public native double getDpcRate(String instanceName); + + public native double getDpcsQueuedPerSecond(String instanceName, + int idleTime); + + public native double getInterruptTimePercent(String instanceName, + int idleTime); + + public native double getDpcTimePercent(String instanceName, int idleTime); + + + + native double getInterruptsPerSecond(String instanceName, + int idleTime); + + public native double getPrivilegedTimePercent(String instanceName, + int idleTime); + + public native double getUserTimePercent(String instanceName, int idleTime); + + public native double getProcessorTimePercent(String instanceName, + int idleTime); +} diff --git a/src/main/java/org/bench4q/monitor/performance/windows/ProcessorMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/ProcessorMonitor.java similarity index 96% rename from src/main/java/org/bench4q/monitor/performance/windows/ProcessorMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/ProcessorMonitor.java index 35db6c00..5fb621c7 100644 --- a/src/main/java/org/bench4q/monitor/performance/windows/ProcessorMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/ProcessorMonitor.java @@ -1,48 +1,48 @@ -package org.bench4q.monitor.performance.windows; - -import org.springframework.stereotype.Component; - -@Component -public class ProcessorMonitor { - public native String[] getInstances(); - - public native String[] getCounterList(); - - public native double getProcessorTimePercent(String instanceName, - int idleTime); - - public native double getUserTimePercent(String instanceName, int idleTime); - - public native double getPrivilegedTimePercent(String instanceName, - int idleTime); - - public native double getInterruptsPerSecond(String instanceName, - int idleTime); - - public native double getDpcTimePercent(String instanceName, int idleTime); - - public native double getInterruptTimePercent(String instanceName, - int idleTime); - - public native double getDpcsQueuedPerSecond(String instanceName, - int idleTime); - - public native double getDpcRate(String instanceName); - - public native double getIdleTimePercent(String instanceName, int idleTime); - - public native double getC1TimePercent(String instanceName, int idleTime); - - public native double getC2TimePercent(String instanceName, int idleTime); - - public native double getC3TimePercent(String instanceName, int idleTime); - - public native double getC1TransitionsPerSecond(String instanceName, - int idleTime); - - public native double getC2TransitionsPerSecond(String instanceName, - int idleTime); - - public native double getC3TransitionsPerSecond(String instanceName, - int idleTime); -} +package org.bench4q.monitor.performance.windows; + +import org.springframework.stereotype.Component; + +@Component +public class ProcessorMonitor { + public native String[] getInstances(); + + public native String[] getCounterList(); + + public native double getProcessorTimePercent(String instanceName, + int idleTime); + + public native double getUserTimePercent(String instanceName, int idleTime); + + public native double getPrivilegedTimePercent(String instanceName, + int idleTime); + + public native double getInterruptsPerSecond(String instanceName, + int idleTime); + + public native double getDpcTimePercent(String instanceName, int idleTime); + + public native double getInterruptTimePercent(String instanceName, + int idleTime); + + public native double getDpcsQueuedPerSecond(String instanceName, + int idleTime); + + public native double getDpcRate(String instanceName); + + public native double getIdleTimePercent(String instanceName, int idleTime); + + public native double getC1TimePercent(String instanceName, int idleTime); + + public native double getC2TimePercent(String instanceName, int idleTime); + + public native double getC3TimePercent(String instanceName, int idleTime); + + public native double getC1TransitionsPerSecond(String instanceName, + int idleTime); + + public native double getC2TransitionsPerSecond(String instanceName, + int idleTime); + + public native double getC3TransitionsPerSecond(String instanceName, + int idleTime); +} diff --git a/src/main/java/org/bench4q/monitor/performance/windows/SystemMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/SystemMonitor.java similarity index 96% rename from src/main/java/org/bench4q/monitor/performance/windows/SystemMonitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/SystemMonitor.java index 2440c6e4..87062eab 100644 --- a/src/main/java/org/bench4q/monitor/performance/windows/SystemMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/SystemMonitor.java @@ -1,45 +1,45 @@ -package org.bench4q.monitor.performance.windows; - - - -public class SystemMonitor { - - public native String[] getCounterList(); - - /*public native double getFileReadOperationsPerSecond(int idleTime); - - public native double getFileWriteOperationsPerSecond(int idleTime); - - public native double getFileControlOperationsPerSecond(int idleTime); - - public native double getFileReadBytesPerSecond(int idleTime); - - public native double getFileWriteBytesPerSecond(int idleTime); - - public native double getFileControlBytesPerSecond(int idleTime); - - public native double getContextSwitchesPerSecond(int idleTime); - - public native double getSystemCallsPerSecond(int idleTime);*/ - - public native double getFileDataOperationsPerSecond(int idleTime); - - public native double getProcessorQueueLength(); - - - - /*public native double getSystemUpTime(); - - - public native double getProcessesCount(); - - public native double getThreadsCount(); - - public native double getAlignmentFixupsPerSecond(int idleTime); - - public native double getExceptionDispatchesPerSecond(int idleTime); - - public native double getFloatingEmulationsPerSecond(int idleTime); - - public native double getRegistryQuotaInUsePercent();*/ -} +package org.bench4q.monitor.performance.windows; + + + +public class SystemMonitor { + + public native String[] getCounterList(); + + /*public native double getFileReadOperationsPerSecond(int idleTime); + + public native double getFileWriteOperationsPerSecond(int idleTime); + + public native double getFileControlOperationsPerSecond(int idleTime); + + public native double getFileReadBytesPerSecond(int idleTime); + + public native double getFileWriteBytesPerSecond(int idleTime); + + public native double getFileControlBytesPerSecond(int idleTime); + + public native double getContextSwitchesPerSecond(int idleTime); + + public native double getSystemCallsPerSecond(int idleTime);*/ + + public native double getFileDataOperationsPerSecond(int idleTime); + + public native double getProcessorQueueLength(); + + + + /*public native double getSystemUpTime(); + + + public native double getProcessesCount(); + + public native double getThreadsCount(); + + public native double getAlignmentFixupsPerSecond(int idleTime); + + public native double getExceptionDispatchesPerSecond(int idleTime); + + public native double getFloatingEmulationsPerSecond(int idleTime); + + public native double getRegistryQuotaInUsePercent();*/ +} diff --git a/src/main/java/org/bench4q/monitor/performance/windows/TCPv4Monitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/TCPv4Monitor.java similarity index 100% rename from src/main/java/org/bench4q/monitor/performance/windows/TCPv4Monitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/TCPv4Monitor.java diff --git a/src/main/java/org/bench4q/monitor/performance/windows/TCPv6Monitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/TCPv6Monitor.java similarity index 100% rename from src/main/java/org/bench4q/monitor/performance/windows/TCPv6Monitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/TCPv6Monitor.java diff --git a/src/main/java/org/bench4q/monitor/performance/windows/UDPv4Monitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/UDPv4Monitor.java similarity index 100% rename from src/main/java/org/bench4q/monitor/performance/windows/UDPv4Monitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/UDPv4Monitor.java diff --git a/src/main/java/org/bench4q/monitor/performance/windows/UDPv6Monitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/UDPv6Monitor.java similarity index 100% rename from src/main/java/org/bench4q/monitor/performance/windows/UDPv6Monitor.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/windows/UDPv6Monitor.java diff --git a/src/main/java/org/bench4q/monitor/service/linux/LogicalDiskServiceLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/LogicalDiskServiceLinux.java similarity index 100% rename from src/main/java/org/bench4q/monitor/service/linux/LogicalDiskServiceLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/LogicalDiskServiceLinux.java diff --git a/src/main/java/org/bench4q/monitor/service/linux/MemoryServiceLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/MemoryServiceLinux.java similarity index 100% rename from src/main/java/org/bench4q/monitor/service/linux/MemoryServiceLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/MemoryServiceLinux.java diff --git a/src/main/java/org/bench4q/monitor/service/linux/NetworkInterfaceServiceLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/NetworkInterfaceServiceLinux.java similarity index 96% rename from src/main/java/org/bench4q/monitor/service/linux/NetworkInterfaceServiceLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/NetworkInterfaceServiceLinux.java index e3cb1352..f2e80434 100644 --- a/src/main/java/org/bench4q/monitor/service/linux/NetworkInterfaceServiceLinux.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/NetworkInterfaceServiceLinux.java @@ -1,29 +1,29 @@ -package org.bench4q.monitor.service.linux; - -import java.io.IOException; - -import org.bench4q.monitor.model.NetworkInterfaceModel; -import org.bench4q.monitor.performance.linux.NetworkInterfaceMonitor; - -public class NetworkInterfaceServiceLinux { - public NetworkInterfaceServiceLinux() throws IOException { - this.networkInterfaceMonitor = new NetworkInterfaceMonitor(); - } - - private NetworkInterfaceMonitor networkInterfaceMonitor; - - public NetworkInterfaceMonitor getNetworkInterfaceMonitor() { - return networkInterfaceMonitor; - } - - public void setNetworkInterfaceMonitor( - NetworkInterfaceMonitor networkInterfaceMonitor) { - this.networkInterfaceMonitor = networkInterfaceMonitor; - } - - public NetworkInterfaceModel getNetworkInterfaceInfo(int idleTime) - throws IOException, InterruptedException { - return this.getNetworkInterfaceMonitor().getNetworkInterfaceInfo( - idleTime); - } -} +package org.bench4q.monitor.service.linux; + +import java.io.IOException; + +import org.bench4q.monitor.model.NetworkInterfaceModel; +import org.bench4q.monitor.performance.linux.NetworkInterfaceMonitor; + +public class NetworkInterfaceServiceLinux { + public NetworkInterfaceServiceLinux() throws IOException { + this.networkInterfaceMonitor = new NetworkInterfaceMonitor(); + } + + private NetworkInterfaceMonitor networkInterfaceMonitor; + + public NetworkInterfaceMonitor getNetworkInterfaceMonitor() { + return networkInterfaceMonitor; + } + + public void setNetworkInterfaceMonitor( + NetworkInterfaceMonitor networkInterfaceMonitor) { + this.networkInterfaceMonitor = networkInterfaceMonitor; + } + + public NetworkInterfaceModel getNetworkInterfaceInfo(int idleTime) + throws IOException, InterruptedException { + return this.getNetworkInterfaceMonitor().getNetworkInterfaceInfo( + idleTime); + } +} diff --git a/src/main/java/org/bench4q/monitor/service/linux/PhysicalDiskServiceLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/PhysicalDiskServiceLinux.java similarity index 96% rename from src/main/java/org/bench4q/monitor/service/linux/PhysicalDiskServiceLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/PhysicalDiskServiceLinux.java index 59c35fa8..95c7cea6 100644 --- a/src/main/java/org/bench4q/monitor/service/linux/PhysicalDiskServiceLinux.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/PhysicalDiskServiceLinux.java @@ -1,30 +1,30 @@ -package org.bench4q.monitor.service.linux; - -import java.io.FileNotFoundException; -import java.io.IOException; - -import org.bench4q.monitor.model.PhysicalDiskModel; -import org.bench4q.monitor.performance.linux.PhysicalDiskMonitor; - -public class PhysicalDiskServiceLinux { - public PhysicalDiskServiceLinux() throws FileNotFoundException { - this.physicalDiskMonitor = new PhysicalDiskMonitor(); - - } - - private PhysicalDiskMonitor physicalDiskMonitor; - - public PhysicalDiskMonitor getPhysicalDiskMonitor() { - return physicalDiskMonitor; - } - - public void setPhysicalDiskMonitor(PhysicalDiskMonitor physicalDiskMonitor) { - this.physicalDiskMonitor = physicalDiskMonitor; - } - - public PhysicalDiskModel getPhysicalFDiskInfo(Integer idleTime) - throws IOException, InterruptedException { - return this.physicalDiskMonitor.getPhysicalDiskInfo(idleTime); - } - +package org.bench4q.monitor.service.linux; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.bench4q.monitor.model.PhysicalDiskModel; +import org.bench4q.monitor.performance.linux.PhysicalDiskMonitor; + +public class PhysicalDiskServiceLinux { + public PhysicalDiskServiceLinux() throws FileNotFoundException { + this.physicalDiskMonitor = new PhysicalDiskMonitor(); + + } + + private PhysicalDiskMonitor physicalDiskMonitor; + + public PhysicalDiskMonitor getPhysicalDiskMonitor() { + return physicalDiskMonitor; + } + + public void setPhysicalDiskMonitor(PhysicalDiskMonitor physicalDiskMonitor) { + this.physicalDiskMonitor = physicalDiskMonitor; + } + + public PhysicalDiskModel getPhysicalFDiskInfo(Integer idleTime) + throws IOException, InterruptedException { + return this.physicalDiskMonitor.getPhysicalDiskInfo(idleTime); + } + } \ No newline at end of file diff --git a/src/main/java/org/bench4q/monitor/service/linux/ProcessServiceLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/ProcessServiceLinux.java similarity index 100% rename from src/main/java/org/bench4q/monitor/service/linux/ProcessServiceLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/ProcessServiceLinux.java diff --git a/src/main/java/org/bench4q/monitor/service/linux/ProcessorServiceLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/ProcessorServiceLinux.java similarity index 96% rename from src/main/java/org/bench4q/monitor/service/linux/ProcessorServiceLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/ProcessorServiceLinux.java index fd5c8694..f84885c4 100644 --- a/src/main/java/org/bench4q/monitor/service/linux/ProcessorServiceLinux.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/ProcessorServiceLinux.java @@ -1,30 +1,30 @@ -package org.bench4q.monitor.service.linux; - -import java.io.FileNotFoundException; -import java.io.IOException; - -import org.bench4q.monitor.model.ProcessorModel; -import org.bench4q.monitor.performance.linux.ProcessorMonitor; - -public class ProcessorServiceLinux { - - public ProcessorServiceLinux() throws FileNotFoundException { - // TODO Auto-generated constructor stub - this.processorMonitor = new ProcessorMonitor(); - } - - private ProcessorMonitor processorMonitor; - - public ProcessorMonitor getProcessorMonitor() { - return processorMonitor; - } - - public void setProcessorMonitor(ProcessorMonitor processorMonitor) { - this.processorMonitor = processorMonitor; - } - - public ProcessorModel getProcessorInfo(Integer idleTime) - throws IOException, InterruptedException { - return this.processorMonitor.getProcessorInfo(idleTime); - } -} +package org.bench4q.monitor.service.linux; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.bench4q.monitor.model.ProcessorModel; +import org.bench4q.monitor.performance.linux.ProcessorMonitor; + +public class ProcessorServiceLinux { + + public ProcessorServiceLinux() throws FileNotFoundException { + // TODO Auto-generated constructor stub + this.processorMonitor = new ProcessorMonitor(); + } + + private ProcessorMonitor processorMonitor; + + public ProcessorMonitor getProcessorMonitor() { + return processorMonitor; + } + + public void setProcessorMonitor(ProcessorMonitor processorMonitor) { + this.processorMonitor = processorMonitor; + } + + public ProcessorModel getProcessorInfo(Integer idleTime) + throws IOException, InterruptedException { + return this.processorMonitor.getProcessorInfo(idleTime); + } +} diff --git a/src/main/java/org/bench4q/monitor/service/linux/SystemServiceLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/SystemServiceLinux.java similarity index 100% rename from src/main/java/org/bench4q/monitor/service/linux/SystemServiceLinux.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/SystemServiceLinux.java diff --git a/src/main/java/org/bench4q/monitor/service/windows/LogicalDiskServiceWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/LogicalDiskServiceWindows.java similarity index 97% rename from src/main/java/org/bench4q/monitor/service/windows/LogicalDiskServiceWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/LogicalDiskServiceWindows.java index 76a76b68..fc908c35 100644 --- a/src/main/java/org/bench4q/monitor/service/windows/LogicalDiskServiceWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/LogicalDiskServiceWindows.java @@ -1,79 +1,79 @@ -package org.bench4q.monitor.service.windows; - -import org.bench4q.monitor.model.LogicalDiskModel; -import org.bench4q.monitor.model.LogicalDiskModelChild; -import org.bench4q.monitor.performance.windows.LogicalDiskMonitor; - -public class LogicalDiskServiceWindows { - private LogicalDiskMonitor logicalDiskMonitor; - - public LogicalDiskServiceWindows() { - this.setLogicalDiskMonitor(new LogicalDiskMonitor()); - } - - public LogicalDiskMonitor getLogicalDiskMonitor() { - return logicalDiskMonitor; - } - - public void setLogicalDiskMonitor(LogicalDiskMonitor logicalDiskMonitor) { - this.logicalDiskMonitor = logicalDiskMonitor; - } - - public LogicalDiskModel getLogicalDiskInfo(int idleTime) { - - String[] instances = this.getLogicalDiskMonitor().getInstances(); - LogicalDiskModel logicalDiskModel = new LogicalDiskModel(); - - for (String elem : instances) { - - LogicalDiskModelChild logicalDiskModelChild = new LogicalDiskModelChild(); - logicalDiskModelChild.setInstance(elem); - logicalDiskModelChild.setDiskBytesPerSecond(this - .getLogicalDiskMonitor().getDiskBytesPerSecond(elem, - idleTime)); - logicalDiskModelChild.setDiskWriteBytesPerSecond(this - .getLogicalDiskMonitor().getDiskWriteBytesPerSecond(elem, - idleTime)); - logicalDiskModelChild.setDiskReadBytesPerSecond(this - .getLogicalDiskMonitor().getDiskReadsPerSecond(elem, - idleTime)); - logicalDiskModelChild.setAverageDiskQueueLength(this - .getLogicalDiskMonitor().getAverageDiskQueueLength(elem, - idleTime)); - logicalDiskModelChild.setAverageDiskReadTimeInSecond(this - .getLogicalDiskMonitor().getAverageDiskReadQueueLength( - elem, idleTime)); - - logicalDiskModelChild.setAverageDiskTransferTimeInSecond(this - .getLogicalDiskMonitor() - .getAverageDiskTransferTimeInSecond(elem, idleTime)); - logicalDiskModelChild.setCurrentDiskQueueLength(this - .getLogicalDiskMonitor().getCurrentDiskQueueLength(elem)); - logicalDiskModelChild.setAverageDiskWriteTimeInSecond(this - .getLogicalDiskMonitor().getAverageDiskWriteTimeInSecond( - elem, idleTime)); - - logicalDiskModelChild.setDiskReadTimePercent(this - .getLogicalDiskMonitor().getDiskReadTimePercent(elem, - idleTime)); - logicalDiskModelChild - .setDiskTimePercent(this.getLogicalDiskMonitor() - .getDiskTimePercent(elem, idleTime)); - logicalDiskModelChild.setDiskWriteTimePercent(this - .getLogicalDiskMonitor().getDiskWriteTimePercent(elem, - idleTime)); - - logicalDiskModelChild.setFreeMegabytes(this.getLogicalDiskMonitor() - .getFreeMegabytes(elem)); - logicalDiskModelChild.setFreeSpacePercent(this - .getLogicalDiskMonitor().getFreeSpacePercent(elem)); - logicalDiskModelChild - .setIdleTimePercent(this.getLogicalDiskMonitor() - .getIdleTimePercent(elem, idleTime)); - - logicalDiskModel.getLogicalDiskList().add(logicalDiskModelChild); - } - return logicalDiskModel; - } - -} +package org.bench4q.monitor.service.windows; + +import org.bench4q.monitor.model.LogicalDiskModel; +import org.bench4q.monitor.model.LogicalDiskModelChild; +import org.bench4q.monitor.performance.windows.LogicalDiskMonitor; + +public class LogicalDiskServiceWindows { + private LogicalDiskMonitor logicalDiskMonitor; + + public LogicalDiskServiceWindows() { + this.setLogicalDiskMonitor(new LogicalDiskMonitor()); + } + + public LogicalDiskMonitor getLogicalDiskMonitor() { + return logicalDiskMonitor; + } + + public void setLogicalDiskMonitor(LogicalDiskMonitor logicalDiskMonitor) { + this.logicalDiskMonitor = logicalDiskMonitor; + } + + public LogicalDiskModel getLogicalDiskInfo(int idleTime) { + + String[] instances = this.getLogicalDiskMonitor().getInstances(); + LogicalDiskModel logicalDiskModel = new LogicalDiskModel(); + + for (String elem : instances) { + + LogicalDiskModelChild logicalDiskModelChild = new LogicalDiskModelChild(); + logicalDiskModelChild.setInstance(elem); + logicalDiskModelChild.setDiskBytesPerSecond(this + .getLogicalDiskMonitor().getDiskBytesPerSecond(elem, + idleTime)); + logicalDiskModelChild.setDiskWriteBytesPerSecond(this + .getLogicalDiskMonitor().getDiskWriteBytesPerSecond(elem, + idleTime)); + logicalDiskModelChild.setDiskReadBytesPerSecond(this + .getLogicalDiskMonitor().getDiskReadsPerSecond(elem, + idleTime)); + logicalDiskModelChild.setAverageDiskQueueLength(this + .getLogicalDiskMonitor().getAverageDiskQueueLength(elem, + idleTime)); + logicalDiskModelChild.setAverageDiskReadTimeInSecond(this + .getLogicalDiskMonitor().getAverageDiskReadQueueLength( + elem, idleTime)); + + logicalDiskModelChild.setAverageDiskTransferTimeInSecond(this + .getLogicalDiskMonitor() + .getAverageDiskTransferTimeInSecond(elem, idleTime)); + logicalDiskModelChild.setCurrentDiskQueueLength(this + .getLogicalDiskMonitor().getCurrentDiskQueueLength(elem)); + logicalDiskModelChild.setAverageDiskWriteTimeInSecond(this + .getLogicalDiskMonitor().getAverageDiskWriteTimeInSecond( + elem, idleTime)); + + logicalDiskModelChild.setDiskReadTimePercent(this + .getLogicalDiskMonitor().getDiskReadTimePercent(elem, + idleTime)); + logicalDiskModelChild + .setDiskTimePercent(this.getLogicalDiskMonitor() + .getDiskTimePercent(elem, idleTime)); + logicalDiskModelChild.setDiskWriteTimePercent(this + .getLogicalDiskMonitor().getDiskWriteTimePercent(elem, + idleTime)); + + logicalDiskModelChild.setFreeMegabytes(this.getLogicalDiskMonitor() + .getFreeMegabytes(elem)); + logicalDiskModelChild.setFreeSpacePercent(this + .getLogicalDiskMonitor().getFreeSpacePercent(elem)); + logicalDiskModelChild + .setIdleTimePercent(this.getLogicalDiskMonitor() + .getIdleTimePercent(elem, idleTime)); + + logicalDiskModel.getLogicalDiskList().add(logicalDiskModelChild); + } + return logicalDiskModel; + } + +} diff --git a/src/main/java/org/bench4q/monitor/service/windows/MemoryServiceWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/MemoryServiceWindows.java similarity index 97% rename from src/main/java/org/bench4q/monitor/service/windows/MemoryServiceWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/MemoryServiceWindows.java index c073f45c..827319dd 100644 --- a/src/main/java/org/bench4q/monitor/service/windows/MemoryServiceWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/MemoryServiceWindows.java @@ -1,45 +1,45 @@ -package org.bench4q.monitor.service.windows; - -import org.bench4q.monitor.model.MemoryModel; -import org.bench4q.monitor.performance.windows.MemoryMonitor; - -public class MemoryServiceWindows { - - public MemoryServiceWindows() { - // TODO Auto-generated constructor stub - this.memoryMonitor = new MemoryMonitor(); - } - - private MemoryMonitor memoryMonitor; - - public MemoryMonitor getMemoryMonitor() { - return memoryMonitor; - } - - public void setMemoryMonitor(MemoryMonitor memoryMonitor) { - this.memoryMonitor = memoryMonitor; - } - - public MemoryModel getMemoryInfo(int idleTime) { - // double - // getPageFaultsPerSecond=memoryMonitor.getPageFaultsPerSecond(idleTime);//锟斤拷锟斤拷锟斤拷硬缺页 - double getPagesPerSecond = memoryMonitor.getPagesPerSecond(idleTime); - double getPagesInputPerSecond = memoryMonitor - .getPagesInputPerSecond(idleTime); - double getPageOuputPerSecond = memoryMonitor - .getPagesOutputPerSecond(idleTime); - double getCacheBytes = memoryMonitor.getCacheBytes(); - double getCommittedBytes = memoryMonitor.getCommittedBytes();// 占锟矫碉拷锟斤拷锟斤拷锟节达拷锟斤拷纸锟� - double getAvailableKiloBytes = memoryMonitor.getAvailableKiloBytes(); - MemoryModel memoryModel = new MemoryModel(); - memoryModel.setAvailableKiloBytes(getAvailableKiloBytes); - memoryModel.setCacheBytes(getCacheBytes); - memoryModel.setCommittedBytes(getCommittedBytes); - memoryModel.setPagesOutputPerSecond(getPageOuputPerSecond); - memoryModel.setPagesInputPerSecond(getPagesInputPerSecond); - memoryModel.setPagesPerSecond(getPagesPerSecond); - return memoryModel; - - } - -} +package org.bench4q.monitor.service.windows; + +import org.bench4q.monitor.model.MemoryModel; +import org.bench4q.monitor.performance.windows.MemoryMonitor; + +public class MemoryServiceWindows { + + public MemoryServiceWindows() { + // TODO Auto-generated constructor stub + this.memoryMonitor = new MemoryMonitor(); + } + + private MemoryMonitor memoryMonitor; + + public MemoryMonitor getMemoryMonitor() { + return memoryMonitor; + } + + public void setMemoryMonitor(MemoryMonitor memoryMonitor) { + this.memoryMonitor = memoryMonitor; + } + + public MemoryModel getMemoryInfo(int idleTime) { + // double + // getPageFaultsPerSecond=memoryMonitor.getPageFaultsPerSecond(idleTime);//锟斤拷锟斤拷锟斤拷硬缺页 + double getPagesPerSecond = memoryMonitor.getPagesPerSecond(idleTime); + double getPagesInputPerSecond = memoryMonitor + .getPagesInputPerSecond(idleTime); + double getPageOuputPerSecond = memoryMonitor + .getPagesOutputPerSecond(idleTime); + double getCacheBytes = memoryMonitor.getCacheBytes(); + double getCommittedBytes = memoryMonitor.getCommittedBytes();// 占锟矫碉拷锟斤拷锟斤拷锟节达拷锟斤拷纸锟� + double getAvailableKiloBytes = memoryMonitor.getAvailableKiloBytes(); + MemoryModel memoryModel = new MemoryModel(); + memoryModel.setAvailableKiloBytes(getAvailableKiloBytes); + memoryModel.setCacheBytes(getCacheBytes); + memoryModel.setCommittedBytes(getCommittedBytes); + memoryModel.setPagesOutputPerSecond(getPageOuputPerSecond); + memoryModel.setPagesInputPerSecond(getPagesInputPerSecond); + memoryModel.setPagesPerSecond(getPagesPerSecond); + return memoryModel; + + } + +} diff --git a/src/main/java/org/bench4q/monitor/service/windows/NetworkInterfaceServiceWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/NetworkInterfaceServiceWindows.java similarity index 97% rename from src/main/java/org/bench4q/monitor/service/windows/NetworkInterfaceServiceWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/NetworkInterfaceServiceWindows.java index a4035b63..eda38702 100644 --- a/src/main/java/org/bench4q/monitor/service/windows/NetworkInterfaceServiceWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/NetworkInterfaceServiceWindows.java @@ -1,43 +1,43 @@ -package org.bench4q.monitor.service.windows; - -import org.bench4q.monitor.model.NetworkInterfaceModel; -import org.bench4q.monitor.model.NetworkInterfaceModelChild; -import org.bench4q.monitor.performance.windows.NetworkInterfaceMonitor; - -public class NetworkInterfaceServiceWindows { - private NetworkInterfaceMonitor networkInterfaceMonitor; - - public NetworkInterfaceMonitor getNetworkInterfaceMonitor() { - return networkInterfaceMonitor; - } - - public void setNetworkInterfaceMonitor( - NetworkInterfaceMonitor networkInterfaceMonitor) { - this.networkInterfaceMonitor = networkInterfaceMonitor; - } - - public NetworkInterfaceServiceWindows() { - this.setNetworkInterfaceMonitor(new NetworkInterfaceMonitor()); - } - - public NetworkInterfaceModel getNetworkInterfaceInfo(int idleTime) { - NetworkInterfaceModel networkInterfaceModel = new NetworkInterfaceModel(); - String[] instances = this.getNetworkInterfaceMonitor().getInstances(); - for (String elem : instances) { - NetworkInterfaceModelChild networkInterfaceModelChild = new NetworkInterfaceModelChild(); - networkInterfaceModelChild.setInstance(elem); - networkInterfaceModelChild.setBytesTotalPerSecond(this - .getNetworkInterfaceMonitor().getBytesTotalPerSecond(elem, - idleTime)); - networkInterfaceModelChild.setBytesReceivedPerSecond(this - .getNetworkInterfaceMonitor().getBytesReceivedPerSecond( - elem, idleTime)); - networkInterfaceModelChild.setBytesSentPerSecond(this - .getNetworkInterfaceMonitor().getBytesSentPerSecond(elem, - idleTime)); - networkInterfaceModel.getNetworkList().add( - networkInterfaceModelChild); - } - return networkInterfaceModel; - } -} +package org.bench4q.monitor.service.windows; + +import org.bench4q.monitor.model.NetworkInterfaceModel; +import org.bench4q.monitor.model.NetworkInterfaceModelChild; +import org.bench4q.monitor.performance.windows.NetworkInterfaceMonitor; + +public class NetworkInterfaceServiceWindows { + private NetworkInterfaceMonitor networkInterfaceMonitor; + + public NetworkInterfaceMonitor getNetworkInterfaceMonitor() { + return networkInterfaceMonitor; + } + + public void setNetworkInterfaceMonitor( + NetworkInterfaceMonitor networkInterfaceMonitor) { + this.networkInterfaceMonitor = networkInterfaceMonitor; + } + + public NetworkInterfaceServiceWindows() { + this.setNetworkInterfaceMonitor(new NetworkInterfaceMonitor()); + } + + public NetworkInterfaceModel getNetworkInterfaceInfo(int idleTime) { + NetworkInterfaceModel networkInterfaceModel = new NetworkInterfaceModel(); + String[] instances = this.getNetworkInterfaceMonitor().getInstances(); + for (String elem : instances) { + NetworkInterfaceModelChild networkInterfaceModelChild = new NetworkInterfaceModelChild(); + networkInterfaceModelChild.setInstance(elem); + networkInterfaceModelChild.setBytesTotalPerSecond(this + .getNetworkInterfaceMonitor().getBytesTotalPerSecond(elem, + idleTime)); + networkInterfaceModelChild.setBytesReceivedPerSecond(this + .getNetworkInterfaceMonitor().getBytesReceivedPerSecond( + elem, idleTime)); + networkInterfaceModelChild.setBytesSentPerSecond(this + .getNetworkInterfaceMonitor().getBytesSentPerSecond(elem, + idleTime)); + networkInterfaceModel.getNetworkList().add( + networkInterfaceModelChild); + } + return networkInterfaceModel; + } +} diff --git a/src/main/java/org/bench4q/monitor/service/windows/PhysicalDiskServiceWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/PhysicalDiskServiceWindows.java similarity index 97% rename from src/main/java/org/bench4q/monitor/service/windows/PhysicalDiskServiceWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/PhysicalDiskServiceWindows.java index 00b5e3b1..95282d57 100644 --- a/src/main/java/org/bench4q/monitor/service/windows/PhysicalDiskServiceWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/PhysicalDiskServiceWindows.java @@ -1,50 +1,50 @@ -package org.bench4q.monitor.service.windows; - -import org.bench4q.monitor.model.PhysicalDiskModel; -import org.bench4q.monitor.model.PhysicalDiskModelChild; -import org.bench4q.monitor.performance.windows.PhysicalDiskMonitor; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class PhysicalDiskServiceWindows { - private PhysicalDiskMonitor physicalDiskMonitor; - - public PhysicalDiskMonitor getPhysicalDiskrMonitor() { - return physicalDiskMonitor; - } - @Autowired - public void setPhysicalDiskrMonitor(PhysicalDiskMonitor physicalDiskrMonitor) { - this.physicalDiskMonitor = physicalDiskrMonitor; - } - - public PhysicalDiskModel getPhysicalDiskInfo(int idleTime) { - - PhysicalDiskModel physicalDiskModel = new PhysicalDiskModel(); - String instances[] = physicalDiskMonitor.getInstances(); - System.out.println(instances.length); - PhysicalDiskModelChild physicalDiskModelChild = new PhysicalDiskModelChild(); - for (String elem : instances) { - physicalDiskModelChild.setInstance(elem); - physicalDiskModelChild - .setAverageDiskQueueLength(physicalDiskMonitor - .getAverageDiskQueueLength(elem, idleTime)); - physicalDiskModelChild - .setCurrentDiskQueueLength(physicalDiskMonitor - .getCurrentDiskQueueLength(elem)); - physicalDiskModelChild.setDiskBytesPerSecond(physicalDiskMonitor - .getDiskBytesPerSecond(elem, idleTime)); - physicalDiskModelChild - .setAverageDiskQueueLength(physicalDiskMonitor - .getAverageDiskQueueLength(elem, idleTime)); - physicalDiskModelChild.setDiskTimePercent(physicalDiskMonitor - .getDiskTimePercent(elem, idleTime)); - physicalDiskModelChild.setDiskWriteBytesPerSecond(physicalDiskMonitor.getDiskWriteBytesPerSecond(elem,idleTime)); - - physicalDiskModel.getPhysicalDiskModelList().add(physicalDiskModelChild); - } - return physicalDiskModel; - } - -} +package org.bench4q.monitor.service.windows; + +import org.bench4q.monitor.model.PhysicalDiskModel; +import org.bench4q.monitor.model.PhysicalDiskModelChild; +import org.bench4q.monitor.performance.windows.PhysicalDiskMonitor; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class PhysicalDiskServiceWindows { + private PhysicalDiskMonitor physicalDiskMonitor; + + public PhysicalDiskMonitor getPhysicalDiskrMonitor() { + return physicalDiskMonitor; + } + @Autowired + public void setPhysicalDiskrMonitor(PhysicalDiskMonitor physicalDiskrMonitor) { + this.physicalDiskMonitor = physicalDiskrMonitor; + } + + public PhysicalDiskModel getPhysicalDiskInfo(int idleTime) { + + PhysicalDiskModel physicalDiskModel = new PhysicalDiskModel(); + String instances[] = physicalDiskMonitor.getInstances(); + System.out.println(instances.length); + PhysicalDiskModelChild physicalDiskModelChild = new PhysicalDiskModelChild(); + for (String elem : instances) { + physicalDiskModelChild.setInstance(elem); + physicalDiskModelChild + .setAverageDiskQueueLength(physicalDiskMonitor + .getAverageDiskQueueLength(elem, idleTime)); + physicalDiskModelChild + .setCurrentDiskQueueLength(physicalDiskMonitor + .getCurrentDiskQueueLength(elem)); + physicalDiskModelChild.setDiskBytesPerSecond(physicalDiskMonitor + .getDiskBytesPerSecond(elem, idleTime)); + physicalDiskModelChild + .setAverageDiskQueueLength(physicalDiskMonitor + .getAverageDiskQueueLength(elem, idleTime)); + physicalDiskModelChild.setDiskTimePercent(physicalDiskMonitor + .getDiskTimePercent(elem, idleTime)); + physicalDiskModelChild.setDiskWriteBytesPerSecond(physicalDiskMonitor.getDiskWriteBytesPerSecond(elem,idleTime)); + + physicalDiskModel.getPhysicalDiskModelList().add(physicalDiskModelChild); + } + return physicalDiskModel; + } + +} diff --git a/src/main/java/org/bench4q/monitor/service/windows/ProcessServiceWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/ProcessServiceWindows.java similarity index 96% rename from src/main/java/org/bench4q/monitor/service/windows/ProcessServiceWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/ProcessServiceWindows.java index 7ecfe361..fcaa7c1b 100644 --- a/src/main/java/org/bench4q/monitor/service/windows/ProcessServiceWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/ProcessServiceWindows.java @@ -1,41 +1,41 @@ -package org.bench4q.monitor.service.windows; - -import org.bench4q.monitor.model.ProcessModel; -import org.bench4q.monitor.model.ProcessModelChild; -import org.bench4q.monitor.performance.windows.ProcessMonitor; - -public class ProcessServiceWindows { - public ProcessServiceWindows() { - this.processMonitor = new ProcessMonitor(); - } - - private ProcessMonitor processMonitor; - - public ProcessMonitor getProcessMonitor() { - return processMonitor; - } - - public void setProcessMonitor(ProcessMonitor processMonitor) { - this.processMonitor = processMonitor; - } - - public ProcessModel getProcessInfo(int idleTime) { - - ProcessModel processModel = new ProcessModel(); - String instances[] = processMonitor.getInstances(); - for (String elem : instances) { - ProcessModelChild processModelChild = new ProcessModelChild(); - processModelChild.setInstanceString(elem); - processModelChild.setPrivateBytes(this.getProcessMonitor() - .getPrivateBytes(elem)); - processModelChild.setProcessId(this.getProcessMonitor().getProcessId(elem)); - processModelChild.setProcessorTimePercent(this.getProcessMonitor().getProcessorTimePercent(elem, idleTime)); - - processModelChild.setVirtualBytes(this.getProcessMonitor().getVirtualBytes(elem)); - processModel.getProcesModelList().add(processModelChild); - } - return processModel; - - } - -} +package org.bench4q.monitor.service.windows; + +import org.bench4q.monitor.model.ProcessModel; +import org.bench4q.monitor.model.ProcessModelChild; +import org.bench4q.monitor.performance.windows.ProcessMonitor; + +public class ProcessServiceWindows { + public ProcessServiceWindows() { + this.processMonitor = new ProcessMonitor(); + } + + private ProcessMonitor processMonitor; + + public ProcessMonitor getProcessMonitor() { + return processMonitor; + } + + public void setProcessMonitor(ProcessMonitor processMonitor) { + this.processMonitor = processMonitor; + } + + public ProcessModel getProcessInfo(int idleTime) { + + ProcessModel processModel = new ProcessModel(); + String instances[] = processMonitor.getInstances(); + for (String elem : instances) { + ProcessModelChild processModelChild = new ProcessModelChild(); + processModelChild.setInstanceString(elem); + processModelChild.setPrivateBytes(this.getProcessMonitor() + .getPrivateBytes(elem)); + processModelChild.setProcessId(this.getProcessMonitor().getProcessId(elem)); + processModelChild.setProcessorTimePercent(this.getProcessMonitor().getProcessorTimePercent(elem, idleTime)); + + processModelChild.setVirtualBytes(this.getProcessMonitor().getVirtualBytes(elem)); + processModel.getProcesModelList().add(processModelChild); + } + return processModel; + + } + +} diff --git a/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java similarity index 97% rename from src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java index 55570946..0d0e17ad 100644 --- a/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java @@ -1,45 +1,45 @@ -package org.bench4q.monitor.service.windows; - -import org.bench4q.monitor.model.ProcessorModel; -import org.bench4q.monitor.model.ProcessorModelChild; -import org.bench4q.monitor.performance.windows.ProcessorMonitor; -import org.springframework.beans.factory.annotation.Autowired; - -public class ProcessorServiceWindows { - public ProcessorServiceWindows() { - // TODO Auto-generated constructor stub - this.processorMonitor = new ProcessorMonitor(); - } - - private ProcessorMonitor processorMonitor; - - public ProcessorMonitor getProcessorMonitor() { - return processorMonitor; - } - - @Autowired - public void setProcessorMonitor(ProcessorMonitor processorMonitor) { - this.processorMonitor = processorMonitor; - } - - public ProcessorModel getProcessorInfo(int idleTime) { - String instances[] = this.getProcessorMonitor().getInstances(); - ProcessorModel processorModel = new ProcessorModel(); - - for (String elem : instances) { - ProcessorModelChild processorModelChild = new ProcessorModelChild(); - processorModelChild.setInstance(elem); - processorModelChild.setPrivilegedTimePercent(this - .getProcessorMonitor().getPrivilegedTimePercent(elem, - idleTime)); - processorModelChild.setProcessorTimePercent(this - .getProcessorMonitor().getProcessorTimePercent(elem, - idleTime)); - processorModelChild.setUserTimePercent(this.getProcessorMonitor() - .getUserTimePercent(elem, idleTime)); - processorModel.getProcessorModelList().add(processorModelChild); - } - return processorModel; - } - -} +package org.bench4q.monitor.service.windows; + +import org.bench4q.monitor.model.ProcessorModel; +import org.bench4q.monitor.model.ProcessorModelChild; +import org.bench4q.monitor.performance.windows.ProcessorMonitor; +import org.springframework.beans.factory.annotation.Autowired; + +public class ProcessorServiceWindows { + public ProcessorServiceWindows() { + // TODO Auto-generated constructor stub + this.processorMonitor = new ProcessorMonitor(); + } + + private ProcessorMonitor processorMonitor; + + public ProcessorMonitor getProcessorMonitor() { + return processorMonitor; + } + + @Autowired + public void setProcessorMonitor(ProcessorMonitor processorMonitor) { + this.processorMonitor = processorMonitor; + } + + public ProcessorModel getProcessorInfo(int idleTime) { + String instances[] = this.getProcessorMonitor().getInstances(); + ProcessorModel processorModel = new ProcessorModel(); + + for (String elem : instances) { + ProcessorModelChild processorModelChild = new ProcessorModelChild(); + processorModelChild.setInstance(elem); + processorModelChild.setPrivilegedTimePercent(this + .getProcessorMonitor().getPrivilegedTimePercent(elem, + idleTime)); + processorModelChild.setProcessorTimePercent(this + .getProcessorMonitor().getProcessorTimePercent(elem, + idleTime)); + processorModelChild.setUserTimePercent(this.getProcessorMonitor() + .getUserTimePercent(elem, idleTime)); + processorModel.getProcessorModelList().add(processorModelChild); + } + return processorModel; + } + +} diff --git a/src/main/java/org/bench4q/monitor/service/windows/SystemServiceWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/SystemServiceWindows.java similarity index 97% rename from src/main/java/org/bench4q/monitor/service/windows/SystemServiceWindows.java rename to Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/SystemServiceWindows.java index 3cf4c865..b8089e28 100644 --- a/src/main/java/org/bench4q/monitor/service/windows/SystemServiceWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/SystemServiceWindows.java @@ -1,37 +1,37 @@ -package org.bench4q.monitor.service.windows; - -import org.bench4q.monitor.model.SystemModel; -import org.bench4q.monitor.performance.windows.ProcessorMonitor; -import org.bench4q.monitor.performance.windows.SystemMonitor; - -public class SystemServiceWindows { - - public SystemServiceWindows(){ - this.systemMonitor=new SystemMonitor(); - this.processorMonitor=new ProcessorMonitor(); - } - private SystemMonitor systemMonitor; - private ProcessorMonitor processorMonitor; - public SystemMonitor getSystemMonitor() { - return systemMonitor; - } - public void setSystemMonitor(SystemMonitor systemMonitor) { - this.systemMonitor = systemMonitor; - } - public ProcessorMonitor getProcessorMonitor() { - return processorMonitor; - } - public void setProcessorMonitor(ProcessorMonitor processorMonitor) { - this.processorMonitor = processorMonitor; - } - - public SystemModel getSystemInfo(int idleTime){ - SystemModel systemModel=new SystemModel(); - - systemModel.setFileDataOperationsPerSecond(this.getSystemMonitor().getFileDataOperationsPerSecond(idleTime)); - systemModel.setProcessorQueueLength(this.getSystemMonitor().getProcessorQueueLength()); - double totalProceesorTimePercent=this.getProcessorMonitor().getProcessorTimePercent("_Total", idleTime); - systemModel.setTotalProceesorTimePercent(totalProceesorTimePercent); - return systemModel; - } -} +package org.bench4q.monitor.service.windows; + +import org.bench4q.monitor.model.SystemModel; +import org.bench4q.monitor.performance.windows.ProcessorMonitor; +import org.bench4q.monitor.performance.windows.SystemMonitor; + +public class SystemServiceWindows { + + public SystemServiceWindows(){ + this.systemMonitor=new SystemMonitor(); + this.processorMonitor=new ProcessorMonitor(); + } + private SystemMonitor systemMonitor; + private ProcessorMonitor processorMonitor; + public SystemMonitor getSystemMonitor() { + return systemMonitor; + } + public void setSystemMonitor(SystemMonitor systemMonitor) { + this.systemMonitor = systemMonitor; + } + public ProcessorMonitor getProcessorMonitor() { + return processorMonitor; + } + public void setProcessorMonitor(ProcessorMonitor processorMonitor) { + this.processorMonitor = processorMonitor; + } + + public SystemModel getSystemInfo(int idleTime){ + SystemModel systemModel=new SystemModel(); + + systemModel.setFileDataOperationsPerSecond(this.getSystemMonitor().getFileDataOperationsPerSecond(idleTime)); + systemModel.setProcessorQueueLength(this.getSystemMonitor().getProcessorQueueLength()); + double totalProceesorTimePercent=this.getProcessorMonitor().getProcessorTimePercent("_Total", idleTime); + systemModel.setTotalProceesorTimePercent(totalProceesorTimePercent); + return systemModel; + } +} diff --git a/src/main/resources/org/bench4q/monitor/config/application-context.xml b/Bench4Q-Monitor/src/main/resources/org/bench4q/monitor/config/application-context.xml similarity index 98% rename from src/main/resources/org/bench4q/monitor/config/application-context.xml rename to Bench4Q-Monitor/src/main/resources/org/bench4q/monitor/config/application-context.xml index 909a7298..6c72d7ff 100644 --- a/src/main/resources/org/bench4q/monitor/config/application-context.xml +++ b/Bench4Q-Monitor/src/main/resources/org/bench4q/monitor/config/application-context.xml @@ -1,10 +1,10 @@ - - - - - + + + + + diff --git a/src/test/java/org/bench4q/monitor/test/LogicalDiskTest.java b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/LogicalDiskTest.java similarity index 96% rename from src/test/java/org/bench4q/monitor/test/LogicalDiskTest.java rename to Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/LogicalDiskTest.java index aee7ebd6..b06882c4 100644 --- a/src/test/java/org/bench4q/monitor/test/LogicalDiskTest.java +++ b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/LogicalDiskTest.java @@ -1,84 +1,84 @@ -package org.bench4q.monitor.test; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.Iterator; -import java.util.List; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -import org.bench4q.monitor.model.LogicalDiskModelChild; -import org.bench4q.monitor.model.LogicalDiskModel; -import org.bench4q.monitor.test.communication.HttpRequester; -import org.bench4q.monitor.test.communication.HttpRequester.HttpResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.stereotype.Component; - -@Component -public class LogicalDiskTest { - private HttpRequester httpRequester; - private static ApplicationContext atx; - - public HttpRequester getHttpRequester() { - return httpRequester; - } - - @Autowired - public void setHttpRequester(HttpRequester httpRequester) { - this.httpRequester = httpRequester; - } - - public static void main(String[] args) { - - String urlString = "http://localhost:5556/Monitor/LogicalDisk"; - atx = new ClassPathXmlApplicationContext( - "classpath*:org/Bench4Q/Monitor/Config/application-context.xml"); - atx.getClass(); - LogicalDiskTest monitorServiceTest = new LogicalDiskTest(); - monitorServiceTest.setHttpRequester(new HttpRequester()); - try { - - HttpResponse httpResponse = monitorServiceTest.getHttpRequester() - .sendGet(urlString, null, null); - - LogicalDiskModel logicalDiskModel = monitorServiceTest - .extractLogicalDiskModel(httpResponse.getContent()); - monitorServiceTest.result(logicalDiskModel); - } catch (IOException e) { - e.printStackTrace(); - } catch (JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - public void result(LogicalDiskModel logicalDiskModel) { - - List list = logicalDiskModel - .getLogicalDiskList(); - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - LogicalDiskModelChild logicalDiskModelChild = iterator.next(); - System.out.println(logicalDiskModelChild.getInstance()); - System.out.println(logicalDiskModelChild.getFreeMegabytes()); - - } - - } - - public LogicalDiskModel extractLogicalDiskModel(String content) - throws JAXBException { - - LogicalDiskModel resultModel = new LogicalDiskModel(); - Unmarshaller ummarshaller = JAXBContext.newInstance( - resultModel.getClass()).createUnmarshaller(); - resultModel = (LogicalDiskModel) ummarshaller - .unmarshal(new ByteArrayInputStream(content.getBytes())); - return resultModel; - } -} +package org.bench4q.monitor.test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.bench4q.monitor.model.LogicalDiskModelChild; +import org.bench4q.monitor.model.LogicalDiskModel; +import org.bench4q.monitor.test.communication.HttpRequester; +import org.bench4q.monitor.test.communication.HttpRequester.HttpResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.stereotype.Component; + +@Component +public class LogicalDiskTest { + private HttpRequester httpRequester; + private static ApplicationContext atx; + + public HttpRequester getHttpRequester() { + return httpRequester; + } + + @Autowired + public void setHttpRequester(HttpRequester httpRequester) { + this.httpRequester = httpRequester; + } + + public static void main(String[] args) { + + String urlString = "http://localhost:5556/Monitor/LogicalDisk"; + atx = new ClassPathXmlApplicationContext( + "classpath*:org/Bench4Q/Monitor/Config/application-context.xml"); + atx.getClass(); + LogicalDiskTest monitorServiceTest = new LogicalDiskTest(); + monitorServiceTest.setHttpRequester(new HttpRequester()); + try { + + HttpResponse httpResponse = monitorServiceTest.getHttpRequester() + .sendGet(urlString, null, null); + + LogicalDiskModel logicalDiskModel = monitorServiceTest + .extractLogicalDiskModel(httpResponse.getContent()); + monitorServiceTest.result(logicalDiskModel); + } catch (IOException e) { + e.printStackTrace(); + } catch (JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public void result(LogicalDiskModel logicalDiskModel) { + + List list = logicalDiskModel + .getLogicalDiskList(); + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + LogicalDiskModelChild logicalDiskModelChild = iterator.next(); + System.out.println(logicalDiskModelChild.getInstance()); + System.out.println(logicalDiskModelChild.getFreeMegabytes()); + + } + + } + + public LogicalDiskModel extractLogicalDiskModel(String content) + throws JAXBException { + + LogicalDiskModel resultModel = new LogicalDiskModel(); + Unmarshaller ummarshaller = JAXBContext.newInstance( + resultModel.getClass()).createUnmarshaller(); + resultModel = (LogicalDiskModel) ummarshaller + .unmarshal(new ByteArrayInputStream(content.getBytes())); + return resultModel; + } +} diff --git a/src/test/java/org/bench4q/monitor/test/MemoryTest.java b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/MemoryTest.java similarity index 96% rename from src/test/java/org/bench4q/monitor/test/MemoryTest.java rename to Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/MemoryTest.java index f317b0d7..29852d10 100644 --- a/src/test/java/org/bench4q/monitor/test/MemoryTest.java +++ b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/MemoryTest.java @@ -1,78 +1,78 @@ -package org.bench4q.monitor.test; - -import java.io.ByteArrayInputStream; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -import org.bench4q.monitor.model.MemoryModel; -import org.bench4q.monitor.test.communication.HttpRequester; -import org.bench4q.monitor.test.communication.HttpRequester.HttpResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.stereotype.Component; - -@Component -public class MemoryTest { - private HttpRequester httpRequester; - private static ApplicationContext atx; - - public HttpRequester getHttpRequester() { - return httpRequester; - } - - @Autowired - public void setHttpRequester(HttpRequester httpRequester) { - this.httpRequester = httpRequester; - } - - public static void main(String[] args) { - - String urlString = "http://localhost:5556/Mon/File"; - atx = new ClassPathXmlApplicationContext( - "org/Bench4Q/Monitor/Config/application-context.xml"); - atx.getClass(); - - MemoryTest memoryTest = new MemoryTest(); - memoryTest.httpRequester = new HttpRequester(); - try { - HttpResponse httpResponse = memoryTest.getHttpRequester().sendGet( - urlString, null, null); - System.out.println(httpResponse.getContent()); - System.out.println("ok"); - - } catch (Exception e) { - System.out.println(e); - } - } - - /* - * try { - * - * HttpResponse httpResponse = memoryTest.getHttpRequester() - * .sendGet(urlString, null, null); - * - * MemoryModel memoryModel = memoryTest - * .extractLogicalDiskModel(httpResponse.getContent()); - * - * memoryTest.result(memoryModel); } catch (IOException e) { - * e.printStackTrace(); } catch (JAXBException e) { // TODO Auto-generated - * catch block e.printStackTrace(); } - * - * } - */ - - public MemoryModel extractLogicalDiskModel(String content) - throws JAXBException { - - MemoryModel resultModel = new MemoryModel(); - Unmarshaller ummarshaller = JAXBContext.newInstance( - resultModel.getClass()).createUnmarshaller(); - resultModel = (MemoryModel) ummarshaller - .unmarshal(new ByteArrayInputStream(content.getBytes())); - return resultModel; - } - -} +package org.bench4q.monitor.test; + +import java.io.ByteArrayInputStream; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.bench4q.monitor.model.MemoryModel; +import org.bench4q.monitor.test.communication.HttpRequester; +import org.bench4q.monitor.test.communication.HttpRequester.HttpResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.stereotype.Component; + +@Component +public class MemoryTest { + private HttpRequester httpRequester; + private static ApplicationContext atx; + + public HttpRequester getHttpRequester() { + return httpRequester; + } + + @Autowired + public void setHttpRequester(HttpRequester httpRequester) { + this.httpRequester = httpRequester; + } + + public static void main(String[] args) { + + String urlString = "http://localhost:5556/Mon/File"; + atx = new ClassPathXmlApplicationContext( + "org/Bench4Q/Monitor/Config/application-context.xml"); + atx.getClass(); + + MemoryTest memoryTest = new MemoryTest(); + memoryTest.httpRequester = new HttpRequester(); + try { + HttpResponse httpResponse = memoryTest.getHttpRequester().sendGet( + urlString, null, null); + System.out.println(httpResponse.getContent()); + System.out.println("ok"); + + } catch (Exception e) { + System.out.println(e); + } + } + + /* + * try { + * + * HttpResponse httpResponse = memoryTest.getHttpRequester() + * .sendGet(urlString, null, null); + * + * MemoryModel memoryModel = memoryTest + * .extractLogicalDiskModel(httpResponse.getContent()); + * + * memoryTest.result(memoryModel); } catch (IOException e) { + * e.printStackTrace(); } catch (JAXBException e) { // TODO Auto-generated + * catch block e.printStackTrace(); } + * + * } + */ + + public MemoryModel extractLogicalDiskModel(String content) + throws JAXBException { + + MemoryModel resultModel = new MemoryModel(); + Unmarshaller ummarshaller = JAXBContext.newInstance( + resultModel.getClass()).createUnmarshaller(); + resultModel = (MemoryModel) ummarshaller + .unmarshal(new ByteArrayInputStream(content.getBytes())); + return resultModel; + } + +} diff --git a/src/test/java/org/bench4q/monitor/test/ProcessorTest.java b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/ProcessorTest.java similarity index 96% rename from src/test/java/org/bench4q/monitor/test/ProcessorTest.java rename to Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/ProcessorTest.java index 08f65d1b..73218792 100644 --- a/src/test/java/org/bench4q/monitor/test/ProcessorTest.java +++ b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/ProcessorTest.java @@ -1,87 +1,87 @@ -package org.bench4q.monitor.test; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.Iterator; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -import org.bench4q.monitor.model.ProcessorModel; -import org.bench4q.monitor.model.ProcessorModelChild; -import org.bench4q.monitor.test.communication.HttpRequester; -import org.bench4q.monitor.test.communication.HttpRequester.HttpResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.stereotype.Component; - -@Component -public class ProcessorTest { - private HttpRequester httpRequester; - private static ApplicationContext atx; - - public HttpRequester getHttpRequester() { - return httpRequester; - } - @Autowired - public void setHttpRequester(HttpRequester httpRequester) { - this.httpRequester = httpRequester; - } - - public static void main(String[] args) { - - String urlString = "http://localhost:5556/Monitor/Processor"; - atx = new ClassPathXmlApplicationContext("org/Bench4Q/Monitor/Config/application-context.xml"); - - ProcessorTest ProcessorTest =(ProcessorTest)atx.getBean("processorTest"); - - try { - - HttpResponse httpResponse = ProcessorTest.getHttpRequester() - .sendGet(urlString, null, null); - - ProcessorModel ProcessorModel = ProcessorTest - .extractLogicalDiskModel(httpResponse.getContent()); - - ProcessorTest.result(ProcessorModel); - } catch (IOException e) { - e.printStackTrace(); - } catch (JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - public void result(ProcessorModel ProcessorModel) { - - Iterator iterator=ProcessorModel.getProcessorModelList().iterator(); - while(iterator.hasNext()){ - ProcessorModelChild processorModelChild=iterator.next(); - System.out.println("instance"+processorModelChild.getInstance()); - - System.out.println("privilegedTimePercent"+processorModelChild.getPrivilegedTimePercent()); - System.out.println("processorTimePercent"+processorModelChild.getProcessorTimePercent()); - System.out.println("userTimePercent"+processorModelChild.getUserTimePercent()); - } - - - - - } - - public ProcessorModel extractLogicalDiskModel(String content) - throws JAXBException { - - ProcessorModel resultModel = new ProcessorModel(); - Unmarshaller ummarshaller = JAXBContext.newInstance( - resultModel.getClass()).createUnmarshaller(); - resultModel = (ProcessorModel) ummarshaller - .unmarshal(new ByteArrayInputStream(content.getBytes())); - return resultModel; - } - - -} +package org.bench4q.monitor.test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Iterator; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.bench4q.monitor.model.ProcessorModel; +import org.bench4q.monitor.model.ProcessorModelChild; +import org.bench4q.monitor.test.communication.HttpRequester; +import org.bench4q.monitor.test.communication.HttpRequester.HttpResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.stereotype.Component; + +@Component +public class ProcessorTest { + private HttpRequester httpRequester; + private static ApplicationContext atx; + + public HttpRequester getHttpRequester() { + return httpRequester; + } + @Autowired + public void setHttpRequester(HttpRequester httpRequester) { + this.httpRequester = httpRequester; + } + + public static void main(String[] args) { + + String urlString = "http://localhost:5556/Monitor/Processor"; + atx = new ClassPathXmlApplicationContext("org/Bench4Q/Monitor/Config/application-context.xml"); + + ProcessorTest ProcessorTest =(ProcessorTest)atx.getBean("processorTest"); + + try { + + HttpResponse httpResponse = ProcessorTest.getHttpRequester() + .sendGet(urlString, null, null); + + ProcessorModel ProcessorModel = ProcessorTest + .extractLogicalDiskModel(httpResponse.getContent()); + + ProcessorTest.result(ProcessorModel); + } catch (IOException e) { + e.printStackTrace(); + } catch (JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public void result(ProcessorModel ProcessorModel) { + + Iterator iterator=ProcessorModel.getProcessorModelList().iterator(); + while(iterator.hasNext()){ + ProcessorModelChild processorModelChild=iterator.next(); + System.out.println("instance"+processorModelChild.getInstance()); + + System.out.println("privilegedTimePercent"+processorModelChild.getPrivilegedTimePercent()); + System.out.println("processorTimePercent"+processorModelChild.getProcessorTimePercent()); + System.out.println("userTimePercent"+processorModelChild.getUserTimePercent()); + } + + + + + } + + public ProcessorModel extractLogicalDiskModel(String content) + throws JAXBException { + + ProcessorModel resultModel = new ProcessorModel(); + Unmarshaller ummarshaller = JAXBContext.newInstance( + resultModel.getClass()).createUnmarshaller(); + resultModel = (ProcessorModel) ummarshaller + .unmarshal(new ByteArrayInputStream(content.getBytes())); + return resultModel; + } + + +} diff --git a/src/test/java/org/bench4q/monitor/test/communication/HttpRequester.java b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/communication/HttpRequester.java similarity index 96% rename from src/test/java/org/bench4q/monitor/test/communication/HttpRequester.java rename to Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/communication/HttpRequester.java index e0f7877a..c6a2f389 100644 --- a/src/test/java/org/bench4q/monitor/test/communication/HttpRequester.java +++ b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/communication/HttpRequester.java @@ -1,275 +1,275 @@ -package org.bench4q.monitor.test.communication; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.Map; -import java.util.Vector; - -import org.springframework.stereotype.Component; - -@Component -public class HttpRequester { - private String defaultContentEncoding; - - public HttpRequester() - { - this.setDefaultContentEncoding(Charset.defaultCharset().name()); - } - - public String getDefaultContentEncoding() { - return defaultContentEncoding; - } - - public void setDefaultContentEncoding(String defaultContentEncoding) { - this.defaultContentEncoding = defaultContentEncoding; - } - - public HttpResponse sendPost(String urlString, Map params) - throws IOException { - return this.send(urlString, "POST", params, "", null); - } - - public HttpResponse sendPostXml(String urlString, String contentString) throws IOException - { - HashMap hashMap = new HashMap(); - hashMap.put("Content-Type", "application/xml"); - return this.send(urlString, "POST", null, contentString, hashMap); - } - - public HttpResponse sendGet(String urlString, Map params, - Map properties) throws IOException { - return this.send(urlString, "GET", params, "", properties); - } - - private HttpResponse send(String urlString, String method, - Map parameters, String Content, Map propertys) - throws IOException { - HttpURLConnection urlConnection = null; - - if (method.equalsIgnoreCase("GET") && parameters != null) { - StringBuffer param = new StringBuffer(); - int i = 0; - for (String key : parameters.keySet()) { - if (i == 0) - param.append("?"); - else - param.append("&"); - param.append(key).append("=").append(parameters.get(key)); - i++; - } - urlString += param; - } - - if (!urlString.startsWith("http://")) { - urlString = "http://" + urlString; - } - //urlString = URLEncoder.encode(urlString, "UTF-8"); - URL url = new URL(urlString); - urlConnection = (HttpURLConnection) url.openConnection(); - - urlConnection.setRequestMethod(method); - urlConnection.setDoOutput(true); - urlConnection.setDoInput(true); - urlConnection.setUseCaches(false); - - if (propertys != null) - for (String key : propertys.keySet()) { - urlConnection.addRequestProperty(key, propertys.get(key)); - } - - if (method.equalsIgnoreCase("POST") && parameters != null) { - StringBuffer param = new StringBuffer(); - for (String key : parameters.keySet()) { - param.append("&"); - param.append(key).append("=").append(parameters.get(key)); - } - urlConnection.getOutputStream().write(param.toString().getBytes()); - urlConnection.getOutputStream().flush(); - urlConnection.getOutputStream().close(); - } - else if (method.equalsIgnoreCase("POST") && !Content.isEmpty()) { - urlConnection.getOutputStream().write(Content.getBytes()); - urlConnection.getOutputStream().flush(); - urlConnection.getOutputStream().close(); - } - - return this.makeContent(urlString, urlConnection); - } - - private HttpResponse makeContent(String urlString, - HttpURLConnection urlConnection) { - // TODO Auto-generated method stub - HttpResponse httpResponser = new HttpResponse(); - try { - InputStream in = urlConnection.getInputStream(); - BufferedReader bufferedReader = new BufferedReader( - new InputStreamReader(in)); - httpResponser.contentCollection = new Vector(); - StringBuffer temp = new StringBuffer(); - String line = bufferedReader.readLine(); - while (line != null) { - httpResponser.contentCollection.add(line); - temp.append(line).append("\r\n"); - line = bufferedReader.readLine(); - } - bufferedReader.close(); - - String ecod = urlConnection.getContentEncoding(); - if (ecod == null) - ecod = this.defaultContentEncoding; - - httpResponser.setUrlString(urlString); - httpResponser.setDefaultPort(urlConnection.getURL() - .getDefaultPort()); - httpResponser.setPort(urlConnection.getURL().getPort()); - httpResponser.setProtocol(urlConnection.getURL().getProtocol()); - - httpResponser.setContent(new String(temp.toString().getBytes(), - ecod)); - httpResponser.setContentEncoding(ecod); - httpResponser.setCode(urlConnection.getResponseCode()); - httpResponser.setMessage(urlConnection.getResponseMessage()); - httpResponser.setContentType(urlConnection.getContentType()); - httpResponser.setConnectTimeout(urlConnection.getConnectTimeout()); - httpResponser.setReadTimeout(urlConnection.getReadTimeout()); - - return httpResponser; - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (urlConnection != null) - urlConnection.disconnect(); - } - return null; - } - - public class HttpResponse { - - String urlString; - - int defaultPort; - - int port; - - String protocol; - - String contentEncoding; - - String content; - - String contentType; - - int code; - - String message; - - int connectTimeout; - - int readTimeout; - - Vector contentCollection; - - public String getUrlString() { - return urlString; - } - - public void setUrlString(String urlString) { - this.urlString = urlString; - } - - public int getDefaultPort() { - return defaultPort; - } - - public void setDefaultPort(int defaultPort) { - this.defaultPort = defaultPort; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getProtocol() { - return protocol; - } - - public void setProtocol(String protocol) { - this.protocol = protocol; - } - - public String getContentEncoding() { - return contentEncoding; - } - - public void setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getContentType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public int getConnectTimeout() { - return connectTimeout; - } - - public void setConnectTimeout(int connectTimeout) { - this.connectTimeout = connectTimeout; - } - - public int getReadTimeout() { - return readTimeout; - } - - public void setReadTimeout(int readTimeout) { - this.readTimeout = readTimeout; - } - - public Vector getContentCollection() { - return contentCollection; - } - - public void setContentCollection(Vector contentCollection) { - this.contentCollection = contentCollection; - } - - } -} +package org.bench4q.monitor.test.communication; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.Charset; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + +import org.springframework.stereotype.Component; + +@Component +public class HttpRequester { + private String defaultContentEncoding; + + public HttpRequester() + { + this.setDefaultContentEncoding(Charset.defaultCharset().name()); + } + + public String getDefaultContentEncoding() { + return defaultContentEncoding; + } + + public void setDefaultContentEncoding(String defaultContentEncoding) { + this.defaultContentEncoding = defaultContentEncoding; + } + + public HttpResponse sendPost(String urlString, Map params) + throws IOException { + return this.send(urlString, "POST", params, "", null); + } + + public HttpResponse sendPostXml(String urlString, String contentString) throws IOException + { + HashMap hashMap = new HashMap(); + hashMap.put("Content-Type", "application/xml"); + return this.send(urlString, "POST", null, contentString, hashMap); + } + + public HttpResponse sendGet(String urlString, Map params, + Map properties) throws IOException { + return this.send(urlString, "GET", params, "", properties); + } + + private HttpResponse send(String urlString, String method, + Map parameters, String Content, Map propertys) + throws IOException { + HttpURLConnection urlConnection = null; + + if (method.equalsIgnoreCase("GET") && parameters != null) { + StringBuffer param = new StringBuffer(); + int i = 0; + for (String key : parameters.keySet()) { + if (i == 0) + param.append("?"); + else + param.append("&"); + param.append(key).append("=").append(parameters.get(key)); + i++; + } + urlString += param; + } + + if (!urlString.startsWith("http://")) { + urlString = "http://" + urlString; + } + //urlString = URLEncoder.encode(urlString, "UTF-8"); + URL url = new URL(urlString); + urlConnection = (HttpURLConnection) url.openConnection(); + + urlConnection.setRequestMethod(method); + urlConnection.setDoOutput(true); + urlConnection.setDoInput(true); + urlConnection.setUseCaches(false); + + if (propertys != null) + for (String key : propertys.keySet()) { + urlConnection.addRequestProperty(key, propertys.get(key)); + } + + if (method.equalsIgnoreCase("POST") && parameters != null) { + StringBuffer param = new StringBuffer(); + for (String key : parameters.keySet()) { + param.append("&"); + param.append(key).append("=").append(parameters.get(key)); + } + urlConnection.getOutputStream().write(param.toString().getBytes()); + urlConnection.getOutputStream().flush(); + urlConnection.getOutputStream().close(); + } + else if (method.equalsIgnoreCase("POST") && !Content.isEmpty()) { + urlConnection.getOutputStream().write(Content.getBytes()); + urlConnection.getOutputStream().flush(); + urlConnection.getOutputStream().close(); + } + + return this.makeContent(urlString, urlConnection); + } + + private HttpResponse makeContent(String urlString, + HttpURLConnection urlConnection) { + // TODO Auto-generated method stub + HttpResponse httpResponser = new HttpResponse(); + try { + InputStream in = urlConnection.getInputStream(); + BufferedReader bufferedReader = new BufferedReader( + new InputStreamReader(in)); + httpResponser.contentCollection = new Vector(); + StringBuffer temp = new StringBuffer(); + String line = bufferedReader.readLine(); + while (line != null) { + httpResponser.contentCollection.add(line); + temp.append(line).append("\r\n"); + line = bufferedReader.readLine(); + } + bufferedReader.close(); + + String ecod = urlConnection.getContentEncoding(); + if (ecod == null) + ecod = this.defaultContentEncoding; + + httpResponser.setUrlString(urlString); + httpResponser.setDefaultPort(urlConnection.getURL() + .getDefaultPort()); + httpResponser.setPort(urlConnection.getURL().getPort()); + httpResponser.setProtocol(urlConnection.getURL().getProtocol()); + + httpResponser.setContent(new String(temp.toString().getBytes(), + ecod)); + httpResponser.setContentEncoding(ecod); + httpResponser.setCode(urlConnection.getResponseCode()); + httpResponser.setMessage(urlConnection.getResponseMessage()); + httpResponser.setContentType(urlConnection.getContentType()); + httpResponser.setConnectTimeout(urlConnection.getConnectTimeout()); + httpResponser.setReadTimeout(urlConnection.getReadTimeout()); + + return httpResponser; + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (urlConnection != null) + urlConnection.disconnect(); + } + return null; + } + + public class HttpResponse { + + String urlString; + + int defaultPort; + + int port; + + String protocol; + + String contentEncoding; + + String content; + + String contentType; + + int code; + + String message; + + int connectTimeout; + + int readTimeout; + + Vector contentCollection; + + public String getUrlString() { + return urlString; + } + + public void setUrlString(String urlString) { + this.urlString = urlString; + } + + public int getDefaultPort() { + return defaultPort; + } + + public void setDefaultPort(int defaultPort) { + this.defaultPort = defaultPort; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getContentEncoding() { + return contentEncoding; + } + + public void setContentEncoding(String contentEncoding) { + this.contentEncoding = contentEncoding; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public int getConnectTimeout() { + return connectTimeout; + } + + public void setConnectTimeout(int connectTimeout) { + this.connectTimeout = connectTimeout; + } + + public int getReadTimeout() { + return readTimeout; + } + + public void setReadTimeout(int readTimeout) { + this.readTimeout = readTimeout; + } + + public Vector getContentCollection() { + return contentCollection; + } + + public void setContentCollection(Vector contentCollection) { + this.contentCollection = contentCollection; + } + + } +} diff --git a/license.txt b/license.txt deleted file mode 100644 index ed5165d8..00000000 --- a/license.txt +++ /dev/null @@ -1,339 +0,0 @@ -GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., [http://fsf.org/] - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {description} - Copyright (C) {year} {fullname} - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - {signature of Ty Coon}, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. \ No newline at end of file