欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

查看主机的内存使用情况

程序员文章站 2023-02-18 14:24:37
888.net>https://www.asp888.net 豆腐技术站这个是我在国外的一个站点上看到的使用asp.net得到一些变量的程序,大家可以看看,其实这个程序没有多大的用...
888.net>https://www.asp888.net 豆腐技术站

这个是我在国外的一个站点上看到的使用asp.net得到一些变量的程序,
大家可以看看,其实这个程序没有多大的用处,只是说明一下asp.net 的强大功能而已。
<script language="c#" runat=server>
void page_load(object sender, eventargs ev)
{
processinfo[] history = processmodelinfo.gethistory(100);
for( int i=0; i<history.length; i++ )
{
response.write("starttime:"+ history[i].starttime.tostring() + "<br>");
response.write("age:" + history[i].age.tostring() + "<br>");
response.write("processid:" + history[i].processid.tostring() + "<br>");
response.write("requestcount:" + history[i].requestcount.tostring() + "<br>");
response.write("status:" + getprocessstatus(history[i].status ) + "<br>");
response.write("shutdownreason:" + getshutdownreason(history[i].shutdownreason) + "<br>");
response.write("peakmemoryused:" + history[i].peakmemoryused.tostring() + "<br>");

}
}

public string getprocessstatus( processstatus ps )
{
string s = "unknown";
if( ps == processstatus.alive )
s = "alive";
else if( ps == processstatus.shuttingdown )
s = "shutting down";
else if( ps == processstatus.shutdown )
s = "shutdown";
else if( ps == processstatus.terminated )
s = "terminated";
return s;
}

public string getshutdownreason( processshutdownreason psr )
{
string s = "unknown";
if( psr == processshutdownreason.none )
s = "n/a";
else if( psr == processshutdownreason.unexpected )
s = "unexpected";
else if( psr == processshutdownreason.requestslimit )
s = "requests limit";
else if( psr == processshutdownreason.requestqueuelimit )
s = "request queue limit";
else if( psr == processshutdownreason.timeout )
s = "timeout";
else if( psr == processshutdownreason.idletimeout )
s = "idle timeout";
else if( psr == processshutdownreason.memorylimitexceeded )
s = "memory limit exceeded";
return s;
}
</script>