資源簡介
自己寫的用于監控CPU、內存、網絡使用情況,以及進程使用CPU、內存情況的控制臺程序。對需要進行服務器端性能監控的有一定參考價值。
代碼片段和文件信息
using?System;
using?System.Diagnostics;
namespace?SysInfoTest
{
????///?
????///?網絡適配器類
????///?developer:wuxinyong
????///?
????public?class?NetworkAdapter
????{
????????internal?NetworkAdapter(string?name)
????????{
????????????this.name?=?name;
????????}
????????private?long?dlSpeed?ulSpeed;
????????private?long?dlValue?ulValue; //?當前值
????????private?long?dlValueOld?ulValueOld; //?一秒以前的值
????????internal?string?name;
????????internal?PerformanceCounter?dlCounter?ulCounter; //?性能計算器來計算download及upload?speed
????????//初始化
????????internal?void?init()
????????{
????????????this.dlValueOld?=?this.dlCounter.NextSample().RawValue;
????????????this.ulValueOld?=?this.ulCounter.NextSample().RawValue;
????????}
????????//更新性能計算器的值
????????internal?void?refresh()
????????{
????????????this.dlValue?=?this.dlCounter.NextSample().RawValue;
????????????this.ulValue?=?this.ulCounter.NextSample().RawValue;
????????????//?Calculates?download?and?upload?speed.
????????????this.dlSpeed?=?this.dlValue?-?this.dlValueOld;
????????????this.ulSpeed?=?this.ulValue?-?this.ulValueOld;
????????????this.dlValueOld?=?this.dlValue;
????????????this.ulValueOld?=?this.ulValue;
????????}
????????public?override?string?ToString()
????????{
????????????return?this.name;
????????}
????????public?string?Name
????????{
????????????get
????????????{
????????????????return?this.name;
????????????}
????????}
????????public?long?DownloadSpeed
????????{
????????????get
????????????{
????????????????return?this.dlSpeed;
????????????}
????????}
????????public?long?UploadSpeed
????????{
????????????get
????????????{
????????????????return?this.ulSpeed;
????????????}
????????}
????????public?double?DownloadSpeedKbps
????????{
????????????get
????????????{
????????????????return?this.dlSpeed?/?1024.0;
????????????}
????????}
????????public?double?UploadSpeedKbps
????????{
????????????get
????????????{
????????????????return?this.ulSpeed?/?1024.0;
????????????}
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????10240??2009-11-04?17:04??SysInfoTest\SysInfoTest\bin\Debug\SysInfoTest.exe
?????文件??????26112??2009-11-04?17:04??SysInfoTest\SysInfoTest\bin\Debug\SysInfoTest.pdb
?????文件??????14328??2009-11-04?17:04??SysInfoTest\SysInfoTest\bin\Debug\SysInfoTest.vshost.exe
?????文件????????490??2007-07-21?01:33??SysInfoTest\SysInfoTest\bin\Debug\SysInfoTest.vshost.exe.manifest
?????文件????????680??2009-11-04?17:04??SysInfoTest\SysInfoTest\obj\Debug\SysInfoTest.csproj.FileListAbsolute.txt
?????文件??????10240??2009-11-04?17:04??SysInfoTest\SysInfoTest\obj\Debug\SysInfoTest.exe
?????文件??????26112??2009-11-04?17:04??SysInfoTest\SysInfoTest\obj\Debug\SysInfoTest.pdb
?????文件???????5649??2009-10-31?16:28??SysInfoTest\SysInfoTest\Program.cs
?????文件???????1378??2009-10-30?19:20??SysInfoTest\SysInfoTest\Properties\AssemblyInfo.cs
?????文件???????2632??2009-10-31?12:55??SysInfoTest\SysInfoTest\SysInfoTest.csproj
?????文件????????923??2009-10-30?19:20??SysInfoTest\SysInfoTest.sln
????..A..H.?????13312??2009-11-04?17:04??SysInfoTest\SysInfoTest.suo
?????目錄??????????0??2009-10-30?19:20??SysInfoTest\SysInfoTest\obj\Debug\TempPE
?????目錄??????????0??2009-10-30?19:28??SysInfoTest\SysInfoTest\bin\Debug
?????目錄??????????0??2009-11-04?17:04??SysInfoTest\SysInfoTest\obj\Debug
?????目錄??????????0??2009-10-30?19:20??SysInfoTest\SysInfoTest\bin
?????目錄??????????0??2009-10-30?19:20??SysInfoTest\SysInfoTest\obj
?????目錄??????????0??2009-10-30?19:20??SysInfoTest\SysInfoTest\Properties
?????目錄??????????0??2009-10-31?16:29??SysInfoTest\SysInfoTest
?????目錄??????????0??2009-10-30?19:20??SysInfoTest
?????文件???????2177??2009-10-31?16:29??SysInfoTest\SysInfoTest\NetworkAdapter.cs
?????文件???????2813??2009-10-31?16:28??SysInfoTest\SysInfoTest\NetworkMonitor.cs
-----------?---------??----------?-----??----
???????????????117086????????????????????22
評論
共有 條評論