asp监控服务器信息,ASP.net 服务器监控

c4908d68341ead44978874998b885d9a.png

参考代码:

1,页面

BackSecondaryColor="White" EnableTheming="False" EnableViewState="True" Height="383px"

Width="521px">

Legend="Legend1" Name="已使用物理内存" XValueType="Double" YValueType="Double">

Name="全部占用内存">

2,页面后台

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Web.UI.DataVisualization.Charting;

using System.Diagnostics;

namespace AFC_web.DataCenter

{

public partial class SMPWebPerformance : System.Web.UI.Page

{

static PerformanceCounter pc = new PerformanceCounter("Processor", "% Processor Time", "_Total");

protected void Page_Load(object sender, EventArgs e)

{

}

protected void UITimer_Tick(object sender, EventArgs e)

{

MEMORY_INFO MemInfo = new MEMORY_INFO();

ComputerInfo.GlobalMemoryStatus(ref MemInfo);

//UseMemory

Series series = Chart1.Series[0];

int xCount = series.Points.Count == 0 ? 0 : series.Points.Count - 1;

double lastXValue = series.Points.Count == 0 ? 1 : series.Points[xCount].XValue + 1;

double lastYValue = (double)(MemInfo.dwTotalPhys - MemInfo.dwAvailPhys) / 1024 / 1024;

series.Points.AddXY(lastXValue, lastYValue);

//Total Memory

series = Chart1.Series[1];

lastYValue = (double)(MemInfo.dwTotalVirtual + MemInfo.dwTotalPhys - MemInfo.dwAvailPhys - MemInfo.dwAvailVirtual) / 1024 / 1024;

series.Points.AddXY(lastXValue, lastYValue);

//CPU

series = Chart1.Series[2];

lastYValue = (double)pc.NextValue();

series.Points.AddXY(lastXValue, lastYValue);

// Remove points from the left chart side if number of points exceeds 100.

while (this.Chart1.Series[0].Points.Count > 80)

{

// Remove series points

foreach (Series s in this.Chart1.Series)

{

s.Points.RemoveAt(0);

}

}

// Adjust categorical scale

double axisMinimum = this.Chart1.Series[0].Points[0].XValue;

this.Chart1.ChartAreas[0].AxisX.Minimum = axisMinimum;

this.Chart1.ChartAreas[0].AxisX.Maximum = axisMinimum + 99;

//------------------------------------------------------------------

//Random rand = new Random();

Add several random point into each series

//foreach (Series series in this.Chart1.Series)

//{

// double lastYValue = series.Points[series.Points.Count - 1].YValues[0];

// double lastXValue = series.Points[series.Points.Count - 1].XValue + 1;

// for (int pointIndex = 0; pointIndex < 5; pointIndex++)

// {

// lastYValue += rand.Next(-3, 4);

// if (lastYValue >= 100.0)

// {

// lastYValue -= 25.0;

// }

// else if (lastYValue <= 10.0)

// {

// lastYValue += 25.0;

// }

// series.Points.AddXY(lastXValue++, lastYValue);

// }

//}

Remove points from the left chart side if number of points exceeds 100.

//while (this.Chart1.Series[0].Points.Count > 100)

//{

// // Remove series points

// foreach (Series series in this.Chart1.Series)

// {

// series.Points.RemoveAt(0);

// }

//}

Adjust categorical scale

//double axisMinimum = this.Chart1.Series[0].Points[0].XValue;

//this.Chart1.ChartAreas[0].AxisX.Minimum = axisMinimum;

//this.Chart1.ChartAreas[0].AxisX.Maximum = axisMinimum + 100;

}

}

}

3,获取CPU 内存 信息

using System;

using System.Collections.Generic;

using System.Linq;

using System.Management; // 添加System.Management引用

using System.Text;

using System.Management.Instrumentation;

using System.Runtime.InteropServices;

using System.Diagnostics;

using System.Threading;

namespace AFC_web

{

public class ComputerInfo

{

///

/// 取得Windows的目录

///

///

///

[DllImport("kernel32")]

public static extern void GetWindowsDirectory(StringBuilder WinDir, int count);

///

/// 获取系统路径

///

///

///

[DllImport("kernel32")]

public static extern void GetSystemDirectory(StringBuilder SysDir, int count);

///

/// 取得CPU信息

///

///

[DllImport("kernel32")]

public static extern void GetSystemInfo(ref CPU_INFO cpuinfo);

///

/// 取得内存状态

///

///

[DllImport("kernel32")]

public static extern void GlobalMemoryStatus(ref MEMORY_INFO meminfo);

///

/// 取得系统时间

///

///

[DllImport("kernel32")]

public static extern void GetSystemTime(ref SYSTEMTIME_INFO stinfo);

public ComputerInfo()

{

}

}

//定义CPU的信息结构

[StructLayout(LayoutKind.Sequential)]

public struct CPU_INFO

{

public uint dwOemId;

public uint dwPageSize;

public uint lpMinimumApplicationAddress;

public uint lpMaximumApplicationAddress;

public uint dwActiveProcessorMask;

public uint dwNumberOfProcessors;

public uint dwProcessorType;

public uint dwAllocationGranularity;

public uint dwProcessorLevel;

public uint dwProcessorRevision;

}

//定义内存的信息结构

[StructLayout(LayoutKind.Sequential)]

public struct MEMORY_INFO

{

public uint dwLength;

public uint dwMemoryLoad;

public uint dwTotalPhys;

public uint dwAvailPhys;

public uint dwTotalPageFile;

public uint dwAvailPageFile;

public uint dwTotalVirtual;

public uint dwAvailVirtual;

}

//定义系统时间的信息结构

[StructLayout(LayoutKind.Sequential)]

public struct SYSTEMTIME_INFO

{

public ushort wYear;

public ushort wMonth;

public ushort wDayOfWeek;

public ushort wDay;

public ushort wHour;

public ushort wMinute;

public ushort wSecond;

public ushort wMilliseconds;

}

}

// auxiliary print methods

// constants used to select the performance counter.

软件介绍: 本系统采用无数据库记录数据以及XMLHTML无刷新的“双无”技术对您的网站实行超级管理。只要将程序代码放入ASP网站或空间,所有浏览你网站的访问者行踪均在你的监视之下。你可以根据实际情况在后台对访问者进行友好或不友好的实时远程控制。主要特点:1、本系统采用无数据库记录数据技术:特点是不与网站其它程序冲突,记录的数据无遗漏。2、XMLHTML无刷新技术:特点是访问者在瞬间会收到你发送的讯息或封锁、反攻击措施,而你的网站不会刷新。 主要作用:1、对访问者访问你网站的时间、从哪一页面而来、已经浏览了哪些页面、正在浏览哪个页面等具体情况一览无遗,了如指掌!2、如果你的网站有登录入口,无论是访问者登录成功或试图登录而未成功的,其填入的用户名和密码会在“用户”栏清晰地暴露在你面前。3、新添了最新IP地址数据库,你可以随时掌握访问者的IP地址和物理位置(精确到国家、省、市、县或更小的单位、网吧和其它区域)。4、你可以对指定的访问者发出友好提示,对方迅即就可收到你的提示信息。5、你可以随时掌握不怀好意的访问者的动态情况,甚至对攻击你网站的黑客进行反攻击(因采用无刷新技术,对方在瞬间就会就范),让你的网站远离黑客(对方从此无法访问你的网站)或让黑客电脑挂起、死机!(并非病毒)6、你对访问者采取的友好或不友好的措施,可以事先提示或警告对方,也可以不加任何提示或警告。这些措施还可以根据你的意愿随时解除。7、本系统适用于任意大中小型ASP网站和ASP空间(默认支持XMLHTTP),不与网站其它程序相冲突,占用资源少,各项设置一目了然,有详细说明。8、本系统记录的数据准确、全面、真实、无遗漏,可下载本地保存,其界面清晰友好,功能全面强大,兼具实用性娱乐性,版本不断完善升级(正式版升级免费)。版权声明:本程序由XuJia设计制作,版权归徐佳所有。免费版不提供无刷新技术,访问者只有刷新网站页面才收到讯息。不提供封锁和攻击功能。演示地址:http://xu.bigwww.com/feng默认用户名:admin 默认密码:admin联系QQ:174215095(不在时留言,必复)联系电话:13607259528(随时)邮箱:yh163cn@yahoo.com.cn(必复)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值