ASP探针

该博客介绍了阿江ASP探针V1.8,可检测多种组件支持情况及版本,还能获取服务器有关参数,如服务器名、IP、端口等。此外,对ASP脚本解释和运算速度进行测试,包括整数和浮点运算,并给出对照服务器的完成时间。

<%@ Language="VBScript" %>
<%
'####################################
'##
'# 阿江ASP探针 V1.8 #
'# 040606 #
'# 阿江守候 http://www.ajiang.net #
'# 电子邮件 info@ajiang.net#
'##
'# 转载本程序时请保留这些信息 #
'# #
'####################################

' 使用输出缓冲区,避免在WIN2003显示过慢
Response.Buffer = true

' 声明待检测数组
Dim ObjTotest(26,4)

ObjTotest(0,0) = "MSWC.AdRotator"
ObjTotest(1,0) = "MSWC.BrowserType"
ObjTotest(2,0) = "MSWC.NextLink"
ObjTotest(3,0) = "MSWC.Tools"
ObjTotest(4,0) = "MSWC.Status"
ObjTotest(5,0) = "MSWC.Counters"
ObjTotest(6,0) = "IISSample.ContentRotator"
ObjTotest(7,0) = "IISSample.PageCounter"
ObjTotest(8,0) = "MSWC.PermissionChecker"
ObjTotest(9,0) = "Scripting.FileSystemObject"
ObjTotest(9,1) = "(FSO 文本文件读写)"
ObjTotest(10,0) = "adodb.connection"
ObjTotest(10,1) = "(ADO 数据对象)"

ObjTotest(11,0) = "SoftArtisans.FileUp"
ObjTotest(11,1) = "(SA-FileUp 文件上传)"
ObjTotest(12,0) = "SoftArtisans.FileManager"
ObjTotest(12,1) = "(SoftArtisans 文件管理)"
ObjTotest(13,0) = "LyfUpload.UploadFile"
ObjTotest(13,1) = "(刘云峰的文件上传组件)"
ObjTotest(14,0) = "Persits.Upload.1"
ObjTotest(14,1) = "(ASPUpload 文件上传)"
ObjTotest(15,0) = "w3.upload"
ObjTotest(15,1) = "(Dimac 文件上传)"

ObjTotest(16,0) = "JMail.SmtpMail"
ObjTotest(16,1) = "(Dimac JMail 邮件收发) <a href='http://www.ajiang.net'>中文手册下载</a>"
ObjTotest(17,0) = "CDONTS.NewMail"
ObjTotest(17,1) = "(虚拟 SMTP 发信)"
ObjTotest(18,0) = "Persits.MailSender"
ObjTotest(18,1) = "(ASPemail 发信)"
ObjTotest(19,0) = "SMTPsvg.Mailer"
ObjTotest(19,1) = "(ASPmail 发信)"
ObjTotest(20,0) = "DkQmail.Qmail"
ObjTotest(20,1) = "(dkQmail 发信)"
ObjTotest(21,0) = "Geocel.Mailer"
ObjTotest(21,1) = "(Geocel 发信)"
ObjTotest(22,0) = "IISmail.Iismail.1"
ObjTotest(22,1) = "(IISmail 发信)"
ObjTotest(23,0) = "SmtpMail.SmtpMail.1"
ObjTotest(23,1) = "(SmtpMail 发信)"

ObjTotest(24,0) = "SoftArtisans.ImageGen"
ObjTotest(24,1) = "(SA 的图像读写组件)"
ObjTotest(25,0) = "W3Image.Image"
ObjTotest(25,1) = "(Dimac 的图像读写组件)"

public IsObj,VerObj,TestObj
public okOS,okCPUS,okCPU

'检查预查组件支持情况及版本

dim i
for i=0 to 25
on error resume next
IsObj=false
VerObj=""
'dim TestObj
TestObj=""
set TestObj=server.CreateObject(ObjTotest(i,0))
If -2147221005 <> Err then'感谢网友iAmFisher的宝贵建议
IsObj = True
VerObj = TestObj.version
if VerObj="" or isnull(VerObj) then VerObj=TestObj.about
end if
ObjTotest(i,2)=IsObj
ObjTotest(i,3)=VerObj
next

'检查组件是否被支持及组件版本的子程序
sub ObjTest(strObj)
on error resume next
IsObj=false
VerObj=""
TestObj=""
set TestObj=server.CreateObject (strObj)
If -2147221005 <> Err then'感谢网友iAmFisher的宝贵建议
IsObj = True
VerObj = TestObj.version
if VerObj="" or isnull(VerObj) then VerObj=TestObj.about
end if
End sub
%>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>ASP探针V1.8-阿江http://www.ajiang.net</TITLE>
<style>
<!--
BODY
{
FONT-FAMILY: 宋体;
FONT-SIZE: 9pt
}
TD
{
FONT-SIZE: 9pt
}
A
{
COLOR: #000000;
TEXT-DECORATION: none
}
A:hover
{
COLOR: #3F8805;
TEXT-DECORATION: underline
}
.input
{
BORDER: #111111 1px solid;
FONT-SIZE: 9pt;
BACKGROUND-color: #F8FFF0
}
.backs
{
BACKGROUND-COLOR: #3F8805;
COLOR: #ffffff;

}
.backq
{
BACKGROUND-COLOR: #EEFEE0
}
.backc
{
BACKGROUND-COLOR: #3F8805;
BORDER: medium none;
COLOR: #ffffff;
HEIGHT: 18px;
font-size: 9pt
}
.fonts
{
COLOR: #3F8805
}
-->
</STYLE>
</HEAD>
<BODY>
<a href="mailto:info@ajiang.net">阿江</a>改写的ASP探针-<font class=fonts>V1.8</font><br><br>
<font class=fonts>是否支持ASP</font>
<br>出现以下情况即表示您的空间不支持ASP:
<br>1、访问本文件时提示下载。
<br>2、访问本文件时看到类似“&lt;%@ Language="VBScript" %&gt;”的文字。
<br><br>

<font class=fonts>服务器的有关参数</font>
<table border=0 width=450 cellspacing=0 cellpadding=0 bgcolor="#3F8805">
<tr><td>

<table border=0 width=450 cellspacing=1 cellpadding=0>
<tr bgcolor="#EEFEE0" height=18>
<td align=left>&nbsp;服务器名</td><td>&nbsp;<%=Request.ServerVariables("SERVER_NAME")%></td>
</tr>
<tr bgcolor="#EEFEE0" height=18>
<td align=left>&nbsp;服务器IP</td><td>&nbsp;<%=Request.ServerVariables("LOCAL_ADDR")%></td>
</tr>
<tr bgcolor="#EEFEE0" height=18>
<td align=left>&nbsp;服务器端口</td><td>&nbsp;<%=Request.ServerVariables("SERVER_PORT")%></td>
</tr>
<tr bgcolor="#EEFEE0" height=18>
<td align=left>&nbsp;服务器时间</td><td>&nbsp;<%=now%></td>
</tr>
<tr bgcolor="#EEFEE0" height=18>
<td align=left>&nbsp;IIS版本</td><td>&nbsp;<%=Request.ServerVariables("SERVER_SOFTWARE")%></td>
</tr>
<tr bgcolor="#EEFEE0" height=18>
<td align=left>&nbsp;脚本超时时间</td><td>&nbsp;<%=Server.ScriptTimeout%> 秒</td>
</tr>
<tr bgcolor="#EEFEE0" height=18>
<td align=left>&nbsp;本文件路径</td><td>&nbsp;<%=Request.ServerVariables("PATH_TRANSLATED")%></td>
</tr>
<tr bgcolor="#EEFEE0" height=18>
<td align=left>&nbsp;服务器解译引擎</td><td>&nbsp;<%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %></td>
</tr>
<%getsysinfo() '获得服务器数据%>
<tr bgcolor="#EEFEE0" height=18>
<td align=left>&nbsp;服务器CPU数量</td><td>&nbsp;<%=okCPUS%> 个</td>
</tr>
<tr bgcolor="#EEFEE0" height=18>
<td align=left>&nbsp;服务器CPU详情</td><td>&nbsp;<%=okCPU%></td>
</tr>
<tr bgcolor="#EEFEE0" height=18>
<td align=left>&nbsp;服务器操作系统</td><td>&nbsp;<%=okOS%></td>
</tr>
</table>

</td></tr>
</table>
<br>
<font class=fonts>组件支持情况</font>
<%
Dim strClass
strClass = Trim(Request.Form("classname"))
If "" <> strClass then
Response.Write "<br>您指定的组件的检查结果:"
Dim Verobj1
ObjTest(strClass)
If Not IsObj then
Response.Write "<br><font color=red>很遗憾,该服务器不支持 " & strclass & " 组件!</font>"
Else
if VerObj="" or isnull(VerObj) then
Verobj1="无法取得该组件版本"
Else
Verobj1="该组件版本是:" & VerObj
End If
Response.Write "<br><font class=fonts>恭喜!该服务器支持 " & strclass & " 组件。" & verobj1 & "</font>"
End If
Response.Write "<br>"
end if
%>


<br>■ IIS自带的ASP组件
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="450">
<tr height=18 class=backs align=center><td width=320>组 件 名 称</td><td width=130>支持及版本</td></tr>
<%For i=0 to 10%>
<tr height="18" class=backq>
<td align=left>&nbsp;<%=ObjTotest(i,0) & "<font color=#888888>&nbsp;" & ObjTotest(i,1)%></font></td>
<td align=left>&nbsp;<%
If Not ObjTotest(i,2) Then
Response.Write "<font color=red><b>×</b></font>"
Else
Response.Write "<font class=fonts><b>√</b></font> <a title='" & ObjTotest(i,3) & "'>" & left(ObjTotest(i,3),11) & "</a>"
End If%></td>
</tr>
<%next%>
</table>

<br>■ 常见的文件上传和管理组件
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="450">
<tr height=18 class=backs align=center><td width=320>组 件 名 称</td><td width=130>支持及版本</td></tr>
<%For i=11 to 15%>
<tr height="18" class=backq>
<td align=left>&nbsp;<%=ObjTotest(i,0) & "<font color=#888888>&nbsp;" & ObjTotest(i,1)%></font></td>
<td align=left>&nbsp;<%
If Not ObjTotest(i,2) Then
Response.Write "<font color=red><b>×</b></font>"
Else
Response.Write "<font class=fonts><b>√</b></font> <a title='" & ObjTotest(i,3) & "'>" & left(ObjTotest(i,3),11) & "</a>"
End If%></td>
</tr>
<%next%>
</table>

<br>■ 常见的收发邮件组件
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="450">
<tr height=18 class=backs align=center><td width=320>组 件 名 称</td><td width=130>支持及版本</td></tr>
<%For i=16 to 23%>
<tr height="18" class=backq>
<td align=left>&nbsp;<%=ObjTotest(i,0) & "<font color=#888888>&nbsp;" & ObjTotest(i,1)%></font></td>
<td align=left>&nbsp;<%
If Not ObjTotest(i,2) Then
Response.Write "<font color=red><b>×</b></font>"
Else
Response.Write "<font class=fonts><b>√</b></font> <a title='" & ObjTotest(i,3) & "'>" & left(ObjTotest(i,3),11) & "</a>"
End If%></td>
</tr>
<%next%>
</table>

<br>■ 图像处理组件
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="450">
<tr height=18 class=backs align=center><td width=320>组 件 名 称</td><td width=130>支持及版本</td></tr>
<%For i=24 to 25%>
<tr height="18" class=backq>
<td align=left>&nbsp;<%=ObjTotest(i,0) & "<font color=#888888>&nbsp;" & ObjTotest(i,1)%></font></td>
<td align=left>&nbsp;<%
If Not ObjTotest(i,2) Then
Response.Write "<font color=red><b>×</b></font>"
Else
Response.Write "<font class=fonts><b>√</b></font> <a title='" & ObjTotest(i,3) & "'>" & left(ObjTotest(i,3),11) & "</a>"
End If%></td>
</tr>
<%next%>
</table>

<br>■ 其他组件支持情况检测<br>
在下面的输入框中输入你要检测的组件的ProgId或ClassId。
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="450">
<FORM action=<%=Request.ServerVariables("SCRIPT_NAME")%> method=post id=form1 name=form1>
<tr height="18" class=backq>
<td align=center height=30><input class=input type=text value="" name="classname" size=40>
<INPUT type=submit value=" 确 定 " class=backc id=submit1 name=submit1>
<INPUT type=reset value=" 重 填 " class=backc id=reset1 name=reset1>
</td>
</tr>
</FORM>
</table>

<%
Response.Flush

if ObjTest("Scripting.FileSystemObject") then

set fsoobj=server.CreateObject("Scripting.FileSystemObject")

%>

<br><font class=fonts>磁盘相关测试</font>

<br>■ 服务器磁盘信息

<table class=backq border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="450">
<tr height="18" align=center class="backs">
<td width="100">盘符和磁盘类型</td>
<td width="50">就绪</td>
<td width="80">卷标</td>
<td width="60">文件系统</td>
<td width="80">可用空间</td>
<td width="80">总空间</td>
</tr>
<%

' 测试磁盘信息的想法来自“COCOON ASP 探针”

set drvObj=fsoobj.Drives
for each d in drvObj
%>
<tr height="18" align=center>
<td align="right"><%=cdrivetype(d.DriveType) & " " & d.DriveLetter%>:</td>
<%
if d.DriveLetter = "A" then'为防止影响服务器,不检查软驱
Response.Write "<td></td><td></td><td></td><td></td><td></td>"
else
%>
<td><%=cIsReady(d.isReady)%></td>
<td><%=d.VolumeName%></td>
<td><%=d.FileSystem%></td>
<td align="right"><%=cSize(d.FreeSpace)%></td>
<td align="right"><%=cSize(d.TotalSize)%></td>
<%
end if
%>
</tr>
<%
next
%>
</td></tr>
</table>

<br>■ 当前文件夹信息
<%

Response.Flush


dPath = server.MapPath("./")
set dDir = fsoObj.GetFolder(dPath)
set dDrive = fsoObj.GetDrive(dDir.Drive)
%>
文件夹: <%=dPath%>
<table class=backq border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="450">
<tr height="18" align="center" class="backs">
<td width="75">已用空间</td>
<td width="75">可用空间</td>
<td width="75">文件夹数</td>
<td width="75">文件数</td>
<td width="150">创建时间</td>
</tr>
<tr height="18" align="center">
<td><%=cSize(dDir.Size)%></td>
<td><%=cSize(dDrive.AvailableSpace)%></td>
<td><%=dDir.SubFolders.Count%></td>
<td><%=dDir.Files.Count%></td>
<td><%=dDir.DateCreated%></td>
</tr>
</td></tr>
</table>

<br>■ 磁盘文件操作速度测试<br>
<%
Response.Flush


' 测试文件读写的想法来自“迷城浪子”

Response.Write "正在重复创建、写入和删除文本文件50次..."

dim thetime3,tempfile,iserr

iserr=false
t1=timer
tempfile=server.MapPath("./") & "\aspchecktest.txt"
for i=1 to 50
Err.Clear

set tempfileOBJ = FsoObj.CreateTextFile(tempfile,true)
if Err <> 0 then
Response.Write "创建文件错误!<br><br>"
iserr=true
Err.Clear
exit for
end if
tempfileOBJ.WriteLine "Only for test. Ajiang ASPcheck"
if Err <> 0 then
Response.Write "写入文件错误!<br><br>"
iserr=true
Err.Clear
exit for
end if
tempfileOBJ.close
Set tempfileOBJ = FsoObj.GetFile(tempfile)
tempfileOBJ.Delete
if Err <> 0 then
Response.Write "删除文件错误!<br><br>"
iserr=true
Err.Clear
exit for
end if
set tempfileOBJ=nothing
next
t2=timer
if iserr <> true then
thetime3=cstr(int(( (t2-t1)*10000 )+0.5)/10)
Response.Write "...已完成!<font color=red>" & thetime3 & "毫秒</font>。<br>"
Response.Flush

%>
<table class=backq border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="450">
<tr height=18 align=center class="backs">
<td width=320>供 对 照 的 服 务 器</td>
<td width=130>完成时间(毫秒)</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.hdidc.com">华东数据hdidc.com主机<font color=#888888> 双至强2.4,1GddrEcc,SCSI36.4G)</font></a></td><td>&nbsp;32~75</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.gdxf.net/wzkj/index.htm">新丰信息港付费ASP+CGI空间</a></td><td>&nbsp;46~62</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.68l.com/">68互联</a></td><td>&nbsp;78</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.diy5.com">第5空间diy5.com四至强主机<font color=#888888>(P42.4,2GddrEcc,SCSI72.8G)</font></a></td><td>&nbsp;46~78</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.100u.com?come=aspcheck&keyword=虚拟主机"
>百优科技 100u 主机</a></td><td>&nbsp;31~62</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.3366.com.cn"
>点击网络主机</a></td><td>&nbsp;31~62</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<font color=red>这台服务器: <%=Request.ServerVariables("SERVER_NAME")%></font>&nbsp;</td><td>&nbsp;<font color=red><%=thetime3%></font></td>
</tr>
</table>
<%
end if

Response.Flush

set fsoobj=nothing

end if%>
<br>
<font class=fonts>ASP脚本解释和运算速度测试</font><br>
<%
Response.Flush

'感谢网际同学录 http://www.5719.net 推荐使用timer函数
'因为只进行50万次计算,所以去掉了是否检测的选项而直接检测

Response.Write "整数运算测试,正在进行50万次加法运算..."
dim t1,t2,lsabc,thetime,thetime2
t1=timer
for i=1 to 500000
lsabc= 1 + 1
next
t2=timer
thetime=cstr(int(( (t2-t1)*10000 )+0.5)/10)
Response.Write "...已完成!<font color=red>" & thetime & "毫秒</font>。<br>"


Response.Write "浮点运算测试,正在进行20万次开方运算..."
t1=timer
for i=1 to 200000
lsabc= 2^0.5
next
t2=timer
thetime2=cstr(int(( (t2-t1)*10000 )+0.5)/10)
Response.Write "...已完成!<font color=red>" & thetime2 & "毫秒</font>。<br>"
%>
<table class=backq border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="450">
<tr height=18 align=center class="backs">
<td width=320>供对照的服务器及完成时间(毫秒)</td>
<td width=65>整数运算</td><td width=65>浮点运算</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.100u.com?come=aspcheck&keyword=虚拟主机"
>百优科技 100u 主机, <font color=#888888>2003-11-1</font></a></td><td>&nbsp;181~233</td><td>&nbsp;156~218</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.west263.com/index.asp?ads=ajiang"
>西部数码 west263 主机, <font color=#888888>2003-11-1</font></a></td><td>&nbsp;171~233</td><td>&nbsp;156~171</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.linkwww.com "
>联网科技 linkwww 主机, <font color=#888888>2003-11-1</font></a></td><td>&nbsp;181~203</td><td>&nbsp;171</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.9s5.com/"
>就是我www.9s5.com全功能(ASP+PHP+JSP)主机,<font color=#888888>2003-11-1</font></a></td><td>&nbsp;171~187</td><td>&nbsp;156~171</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.dnsmy.com/"
>永讯网络 Dnsmy 主机, <font color=#888888>2003-11-1</font></a></td><td>&nbsp;155~180</td><td>&nbsp;122~172</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<a href="http://www.hostidc.net"
>数据互联 Hostidc.net 主机, <font color=#888888>2004-3-28</font></a></td><td>&nbsp;156~171</td><td>&nbsp;140~156</td>
</tr>
<tr height=18>
<td align=left>&nbsp;<font color=red>这台服务器: <%=Request.ServerVariables("SERVER_NAME")%></font>&nbsp;</td><td>&nbsp;<font color=red><%=thetime%></font></td><td>&nbsp;<font color=red><%=thetime2%></font></td>
</tr>
</table>
<br>
<table border=0 width=450 cellspacing=0 cellpadding=0>
<tr><td align=center>
<b>[<a href="http://www.ajiang.net/products/aspcheck/serverlist.asp#notice">提醒·说明</a>]
&nbsp;[<a href="http://www.ajiang.net/products/aspcheck/serverlist.asp">更多空间商即时实测数据</a>]
&nbsp;[<a href="http://www.ajiang.net/products/aspcheck/">查看下载最新版</a>]</b>
</td></tr>
</table>
<br>
<table border=0 width=450 cellspacing=0 cellpadding=0>
<tr><td align=center>
欢迎访问 【阿江守候】 <a href="http://www.ajiang.net">http://www.ajiang.net</a>
<br>本程序由阿江(<a href="mailto:info@ajiang.net?subject=阿江探针">info@ajiang.net</a>)编写,转载时请保留这些信息
</td></tr>
</table>
</BODY>
</HTML>

<%
function cdrivetype(tnum)
Select Case tnum
Case 0: cdrivetype = "未知"
Case 1: cdrivetype = "可移动磁盘"
Case 2: cdrivetype = "本地硬盘"
Case 3: cdrivetype = "网络磁盘"
Case 4: cdrivetype = "CD-ROM"
Case 5: cdrivetype = "RAM 磁盘"
End Select
end function

function cIsReady(trd)
Select Case trd
case true: cIsReady="<font class=fonts><b>√</b></font>"
case false: cIsReady="<font color='red'><b>×</b></font>"
End Select
end function

function cSize(tSize)
if tSize>=1073741824 then
cSize=int((tSize/1073741824)*1000)/1000 & " GB"
elseif tSize>=1048576 then
cSize=int((tSize/1048576)*1000)/1000 & " MB"
elseif tSize>=1024 then
cSize=int((tSize/1024)*1000)/1000 & " KB"
else
cSize=tSize & "B"
end if
end function

sub getsysinfo()
on error resume next
Set WshShell = server.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
okOS = cstr(WshSysEnv("OS"))
okCPUS = cstr(WshSysEnv("NUMBER_OF_PROCESSORS"))
okCPU = cstr(WshSysEnv("PROCESSOR_IDENTIFIER"))
if isnull(okCPUS) then
okCPUS = Request.ServerVariables("NUMBER_OF_PROCESSORS")
elseif okCPUS="" then
okCPUS = Request.ServerVariables("NUMBER_OF_PROCESSORS")
end if
if Request.ServerVariables("OS")="" then okOS=okOS & "(可能是 Windows Server 2003)"
end sub
%>

jsp探针ceshi.jsp <%@ page contentType="text/html; charset=gb2312" %> <% class LfSpy { boolean supportHibernate = false; boolean supportJNDI = false; boolean supportJavaxSql = false; boolean supportJAF = false; boolean supportMail = false; boolean supportBeanUtils = false; boolean supportCommonLogging = false; boolean supportCommonCodec = false; boolean supportCommonCollection = false; boolean supportCommonDigester = false; boolean supportCommonLang = false; boolean supportJakartaRegExp = false; boolean supportLucene = false; boolean supportDom4j = false; boolean supportLoonframework = false; boolean supportMmMysqlDriver = false; boolean supportComMysqlDriver = false; boolean supportImageProcessing = false; boolean supportStruts = false; boolean supportSpring = false; String serverName; String serverIP="127.0.0.1"; long startTime = System.currentTimeMillis(); long startMemory = Runtime.getRuntime().freeMemory(); java.util.Properties prop = System.getProperties(); String javaVersion=prop.getProperty("java.version"); String FS=prop.getProperty("file.separator"); int CPUTIME = 30; int PERCENT = 100; public LfSpy() { try { Class.forName("org.springframework.context.ApplicationContext"); supportSpring = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.loon.framework.Loon"); supportLoonframework = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.hibernate.Transaction"); supportHibernate = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.apache.struts.action.ActionServlet"); supportStruts = true; } catch (ClassNotFoundException ex) { } try { Class.forName("javax.naming.Name"); supportJNDI = true; } catch (ClassNotFoundException ex) { } try { Class.forName("javax.sql.DataSource"); supportJavaxSql = true; } catch (ClassNotFoundException ex) { } try { Class.forName("javax.activation.DataSource"); supportJAF = true; } catch (ClassNotFoundException ex) { } try { Class.forName("javax.mail.Message"); supportMail = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.apache.commons.beanutils.MethodUtils"); supportBeanUtils = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.apache.commons.logging.LogFactory"); supportCommonLogging = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.apache.commons.codec.Decoder"); supportCommonCodec = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.apache.commons.collections.ArrayStack"); supportCommonCollection = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.apache.commons.digester.Digester"); supportCommonDigester = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.apache.commons.lang.SystemUtils"); supportCommonLang = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.apache.regexp.RE"); supportJakartaRegExp = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.apache.lucene.index.IndexWriter"); supportLucene = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.dom4j.Document"); supportDom4j = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.gjt.mm.mysql.Driver"); supportMmMysqlDriver = true; } catch (ClassNotFoundException ex) { } try { Class.forName("com.mysql.jdbc.Driver"); supportComMysqlDriver = true; } catch (ClassNotFoundException ex) { } loadAddress(); try { java.awt.image.BufferedImage bufferedImage = new java.awt.image.BufferedImage( 10, 10, java.awt.image.BufferedImage.TYPE_INT_RGB); java.awt.Graphics2D g = bufferedImage.createGraphics(); g.drawLine(0, 0, 10, 10); g.dispose(); supportImageProcessing = true; } catch (Throwable ex) { } } public String getOSarch(){ return prop.getProperty("os.arch"); } public String getTimeZone(){ return prop.getProperty("user.timezone"); } public String getNowUser(){ return prop.getProperty("user.name"); } public String getNowUserDir(){ return prop.getProperty("user.dir"); } public String getOSName(){ return prop.getProperty("os.name"); } public String getSystemModel(){ return prop.getProperty("sun.arch.data.model"); } final private long getDiskForLinuxInfo(final String dirPath) { try { String dir = dirPath.startsWith("/") ? dirPath : "/"+dirPath; long space = -1; Process process; Runtime run = Runtime.getRuntime(); String osName = System.getProperty("os.name").toLowerCase(); String command = ""; if (osName.startsWith("linux")) { command = "df -k " + dir; } process = run.exec(command); java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader( process.getInputStream())); String freeSpace = "", line; while ((line = in.readLine()) != null) { if (line.length() > 0) { freeSpace = line; } } if (freeSpace == null || freeSpace.length() == 0) { return -1; } process.destroy(); freeSpace = freeSpace.trim().replaceAll("\\\\", "\\/"); String[] results = freeSpace.split(" "); for (int i = results.length - 1; i > 0; i--) { try { space = Long.parseLong(results[i]); return space; } catch (NumberFormatException ex) { continue; } } } catch (java.io.IOException e) { return -1; } return -1; } /** * 获得windows下指定地址硬盘空间大小 * * @param dirPath * @return */ final private long getDiskForWindowsInfo(String dirPath) { try { long space = -1; Process process; Runtime run = Runtime.getRuntime(); String osName = System.getProperty("os.name").toLowerCase(); String command = ""; if (osName.startsWith("windows") && osName.indexOf("98") == -1) { command = "cmd.exe /c dir " + dirPath; } else if (osName.startsWith("windows") && osName.indexOf("98") != -1) { command = "command.com /c dir " + dirPath; } process = run.exec(command); java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader( process.getInputStream())); String freeSpace = "", line; while ((line = in.readLine()) != null) { freeSpace = line; } if (freeSpace == null) { return -1; } process.destroy(); freeSpace = freeSpace.trim(); freeSpace = freeSpace.replaceAll("\\\\\\\\\\\\\\\\.", ""); freeSpace = freeSpace.replaceAll(",", ""); String[] results = freeSpace.split(" "); for (int i = 1; i < results.length; i++) { try { space = Long.parseLong(results[i]); return space; } catch (NumberFormatException ex) { continue; } } return space; } catch (java.io.IOException e) { return -1; } } public long getObjectDisk() { String path = prop.getProperty("user.dir"); int index = path.indexOf(FS); path = path.substring(0, index); String osName = System.getProperty("os.name").toLowerCase(); if (osName.startsWith("windows")) { return getDiskForWindowsInfo(path); } else if (osName.startsWith("linux")) { return getDiskForLinuxInfo(path); } else { return -1; } } public final String getMacAddress() { String os = System.getProperty("os.name"); try { if(os.startsWith("Windows")) { return windowsParseMacAddress(windowsRunIpConfigCommand()); } else if(os.startsWith("Linux")) { return linuxParseMacAddress(linuxRunIfConfigCommand()); } else { throw new java.io.IOException("unknown operating system: " + os); } } catch(Exception ex) { return "Nothing"; } } private final String linuxParseMacAddress(String ipConfigResponse) throws java.text.ParseException { String localHost = null; try { localHost = java.net.InetAddress.getLocalHost().getHostAddress(); } catch(java.net.UnknownHostException ex) { ex.printStackTrace(); throw new java.text.ParseException(ex.getMessage(), 0); } java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(ipConfigResponse, "\n"); String lastMacAddress = null; while(tokenizer.hasMoreTokens()) { String line = tokenizer.nextToken().trim(); boolean containsLocalHost = line.indexOf(localHost) >= 0; if(containsLocalHost && lastMacAddress != null) { return lastMacAddress; } int macAddressPosition = line.indexOf("HWaddr"); if(macAddressPosition <= 0) continue; String macAddressCandidate = line.substring(macAddressPosition + 6).trim(); if(linuxIsMacAddress(macAddressCandidate)) { lastMacAddress = macAddressCandidate; continue; } } java.text.ParseException ex = new java.text.ParseException ("cannot read MAC address for " + localHost + " from [" + ipConfigResponse + "]", 0); ex.printStackTrace(); throw ex; } private final boolean linuxIsMacAddress(String macAddressCandidate) { if(macAddressCandidate.length() != 17) return false; return true; } private final String linuxRunIfConfigCommand() throws java.io.IOException { Process p = Runtime.getRuntime().exec("ifconfig"); java.io.InputStream stdoutStream = new java.io.BufferedInputStream(p.getInputStream()); StringBuffer buffer= new StringBuffer(); for (;;) { int c = stdoutStream.read(); if (c == -1) break; buffer.append((char)c); } String outputText = buffer.toString(); stdoutStream.close(); return outputText; } private final String windowsParseMacAddress(String ipConfigResponse) throws java.text.ParseException { String localHost = null; try { localHost = java.net.InetAddress.getLocalHost().getHostAddress(); } catch(java.net.UnknownHostException ex) { ex.printStackTrace(); throw new java.text.ParseException(ex.getMessage(), 0); } java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(ipConfigResponse, "\n"); String lastMacAddress = null; while(tokenizer.hasMoreTokens()) { String line = tokenizer.nextToken().trim(); if(line.endsWith(localHost) && lastMacAddress != null) { return lastMacAddress; } int macAddressPosition = line.indexOf(":"); if(macAddressPosition <= 0) continue; String macAddressCandidate = line.substring(macAddressPosition + 1).trim(); if(windowsIsMacAddress(macAddressCandidate)) { lastMacAddress = macAddressCandidate; continue; } } java.text.ParseException ex = new java.text.ParseException("cannot read MAC address from [" + ipConfigResponse + "]", 0); ex.printStackTrace(); throw ex; } private final boolean windowsIsMacAddress(String macAddressCandidate) { if(macAddressCandidate.length() != 17) return false; return true; } private final String windowsRunIpConfigCommand() throws java.io.IOException { Process p = Runtime.getRuntime().exec("ipconfig /all"); java.io.InputStream in = new java.io.BufferedInputStream(p.getInputStream()); StringBuffer buffer= new StringBuffer(); for (;;) { int c = in.read(); if (c == -1) break; buffer.append((char)c); } String outputText = buffer.toString(); in.close(); return outputText; } public double getCpuRatio(){ double cpuRatio = 0; if (getOSName().toLowerCase().startsWith("windows")) { cpuRatio = getCpuRatioForWindows(); } else if (getOSName().toLowerCase().startsWith("linux")) { cpuRatio = getCpuRatioForLinux(); } return cpuRatio; } private double getCpuRatioForWindows() { try { String procCmd = System.getenv("windir") + "\\system32\\wbem\\wmic.exe process get Caption,CommandLine," + "KernelModeTime,ReadOperationCount,ThreadCount,UserModeTime,WriteOperationCount"; long[] c0 = readCpu(Runtime.getRuntime().exec(procCmd)); Thread.sleep(CPUTIME); long[] c1 = readCpu(Runtime.getRuntime().exec(procCmd)); if (c0 != null && c1 != null) { long idletime = c1[0] - c0[0]; long busytime = c1[1] - c0[1]; return Double.valueOf( PERCENT * (busytime) / (busytime + idletime)) .doubleValue(); } else { return 0.0; } } catch (Exception ex) { ex.printStackTrace(); return 0.0; } } final private double getCpuRatioForLinux() { try { java.io.File file = new java.io.File("/proc/stat"); java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader( new java.io.FileInputStream(file))); java.util.StringTokenizer token = new java.util.StringTokenizer(br.readLine()); token.nextToken(); int user = Integer.parseInt(token.nextToken()); int nice = Integer.parseInt(token.nextToken()); int system = Integer.parseInt(token.nextToken()); int idle = Integer.parseInt(token.nextToken()); Thread.sleep(1000); br = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream( file))); token = new java.util.StringTokenizer(br.readLine()); token.nextToken(); int user2 = Integer.parseInt(token.nextToken()); int nice2 = Integer.parseInt(token.nextToken()); int sys2 = Integer.parseInt(token.nextToken()); int idle2 = Integer.parseInt(token.nextToken()); return (double) ((user2 + sys2 + nice2) - (user + system + nice)) / (float) ((user2 + nice2 + sys2 + idle2) - (user + nice + system + idle)); } catch (Exception ex) { return (double) 0.0; } } final String substring(String src, int startidx, int endidx) { byte[] b = src.getBytes(); StringBuffer sbr = new StringBuffer(); for (int i = startidx; i <= endidx; i++) { sbr.append((char) b[i]); } return sbr.toString(); } final long[] readCpu(final Process proc) { long[] retn = new long[2]; try { proc.getOutputStream().close(); java.io.InputStreamReader ir = new java.io.InputStreamReader(proc.getInputStream()); java.io.LineNumberReader input = new java.io.LineNumberReader(ir); String line = input.readLine(); if (line == null || line.length() < 10) { return null; } int capidx = line.indexOf("Caption"); int cmdidx = line.indexOf("CommandLine"); int rocidx = line.indexOf("ReadOperationCount"); int umtidx = line.indexOf("UserModeTime"); int kmtidx = line.indexOf("KernelModeTime"); int wocidx = line.indexOf("WriteOperationCount"); long idletime = 0; long kneltime = 0; long usertime = 0; while ((line = input.readLine()) != null) { if (line.length() < wocidx) { continue; } String caption = substring(line, capidx, cmdidx - 1).trim(); String cmd = substring(line, cmdidx, kmtidx - 1).trim(); if (cmd.indexOf("wmic.exe") >= 0) { continue; } if (caption.equals("System Idle Process") || caption.equals("System")) { idletime += Long.valueOf( substring(line, kmtidx, rocidx - 1).trim()) .longValue(); idletime += Long.valueOf( substring(line, umtidx, wocidx - 1).trim()) .longValue(); continue; } kneltime += Long.valueOf( substring(line, kmtidx, rocidx - 1).trim()).longValue(); usertime += Long.valueOf( substring(line, umtidx, wocidx - 1).trim()).longValue(); } retn[0] = idletime; retn[1] = kneltime + usertime; return retn; } catch (Exception ex) { ex.printStackTrace(); } finally { try { proc.getInputStream().close(); } catch (Exception e) { e.printStackTrace(); } } return null; } public long getStartTime(){ return startTime; } public long getStartMemory(){ return startMemory; } public boolean isSun() { return System.getProperty("java.vm.vendor").indexOf("Sun") != -1; } public String getJavaVersion() { return javaVersion; } public void loadAddress() { try { java.net.InetAddress address = java.net.InetAddress .getLocalHost(); java.net.InetAddress[] all = java.net.InetAddress.getAllByName(address.getHostName()); for (int i = 0; i < all.length; i++) { String temp = null; temp = all[i].getHostAddress().toString(); if (!temp.startsWith("127.0") && !temp.startsWith("169.254")) { serverIP=temp; } } serverName = address.getHostName(); } catch (java.net.UnknownHostException e) { } } /** * 获得所在服务器名称 */ public String getServerName() { return serverName; } public String getServerIP() { return serverIP; } public boolean isSupportSpring(){ return supportSpring; } public boolean isSupportLoonframework(){ return supportLoonframework; } public boolean isSupportStruts() { return supportStruts; } public boolean isSupportJAF() { return supportJAF; } public boolean isSupportJavaxSql() { return supportJavaxSql; } public boolean isSupportHibernate(){ return supportHibernate; } public boolean isSupportJNDI() { return supportJNDI; } public boolean isSupportMail() { return supportMail; } public boolean isSupportBeanUtils() { return supportBeanUtils; } public boolean isSupportCommonLogging() { return supportCommonLogging; } public boolean isSupportCommonCodec() { return supportCommonCodec; } public boolean isSupportCommonCollection() { return supportCommonCollection; } public boolean isSupportCommonDigester() { return supportCommonDigester; } public boolean isSupportCommonLang() { return supportCommonLang; } public boolean isSupportJakartaRegExp() { return supportJakartaRegExp; } public boolean isSupportLucene() { return supportLucene; } public boolean isSupportDom4j() { return supportDom4j; } public boolean isSupportMmMysqlDriver() { return supportMmMysqlDriver; } public boolean isSupportComMysqlDriver() { return supportComMysqlDriver; } public boolean isSupportImageProcessing() { return supportImageProcessing; } public String getDoubleOperation(){ long begin = System.currentTimeMillis(); int flag = 0; double random = (double)new java.util.Random().nextInt( 1000 ); while( flag < 100000 ){ random = Math.sqrt( random ); flag++; } long end = System.currentTimeMillis(); long result = end - begin; return String.valueOf(result); } public String getNumberOperation() { long begin = startTime; int flag = 0; while (flag < 1000000) { flag++; } long end = System.currentTimeMillis(); long result = end - begin; return String.valueOf(result); } } LfSpy spyLib = new LfSpy(); %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>lf-jsp探针 Ver 0.1.0</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <style type="text/css"> <!-- .stylebase {color:red; font-size:14px; font-weight:bold;} .table-header-text { color: #FFFFFF; font-weight: normal; margin: 3px 5px 1px 15px; font-family: Arial, Verdana,Helvetica, Sans-Serif; } td{white-space:normal; word-break:break-all;} A{ COLOR: #000000; TEXT-DECORATION: none} A:hover { COLOR: #f58200} body,td,span { font-size: 9pt} .input { BACKGROUND-COLOR: #E3F1D1;BORDER:#A9D46D 1px solid;FONT-SIZE: 9pt} .tableBorder {BORDER-RIGHT: #84BE3C 1px solid; BORDER-TOP: #84BE3C 1px solid; BORDER-LEFT: #84BE3C 1px solid; BORDER-BOTTOM: #84BE3C 1px solid; BACKGROUND-COLOR: #ffffff; WIDTH: 760;} .backc { BACKGROUND-COLOR: #E3F1D1;BORDER:#A9D46D 1px solid;FONT-SIZE: 9pt;color:#000000;} .PicBar { background-color: #A9D46D; border: 1px solid #ffffff; height: 12px;} .InnerHead { background-color: #E3F1D1; border-top-width: 1px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #FFFFFF; border-right-color: #FFFFFF; border-bottom-color: #FFFFFF; border-left-color: #FFFFFF; text-align: left; padding-left: 10px; padding-top: 3px; } .InnerTable { background-color: #999999; } .InnerMain { background-color: #FFFFFF; padding-left: 10px; padding-top: 3px; } --> </style> </head> <body> <table width="100%" height="45" border="0" cellpadding="0" class="InnerHead"> <tr> <td><div align="center"><span class="stylebase"><a href="http://looframework.sourceforge.net/">LF-Spy Java服务器探针 Ver 0.1.0</a></span></div></td> </tr> </table> <h3>服务器连接速度:</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="29%" height="22" class="InnerHead"><span class="table-header-text">接入设备 </span></td> <td width="45%" height="22" class="InnerHead"><span class="table-header-text">连接速度(理论值) </span></td> <td width="26%" class="InnerHead"><span class="table-header-text">下载速度(理论值) </span></td> </tr> <tr> <td height="20" class="InnerMain">56k Modem</td> <td class="InnerMain"><img align=absmiddle class=PicBar width='1%'> 56 Kbps</td> <td class="InnerMain">7.0 k/s</td> </tr> <tr> <td height="20" class="InnerMain">64k ISDN</td> <td class="InnerMain"><img align=absmiddle class=PicBar width='1%'> 64 Kbps</td> <td class="InnerMain">8.0 k/s</td> </tr> <tr> <td height="20" class="InnerMain">512k ADSL</td> <td class="InnerMain"><img align=absmiddle class=PicBar width='5%'> 512 Kbps</td> <td class="InnerMain">64.0 k/s</td> </tr> <tr> <td height="20" class="InnerMain">1.5M Cable</td> <td class="InnerMain"><img align=absmiddle class=PicBar width='15%'> 1500 Kbps</td> <td class="InnerMain">187.5 k/s</td> </tr> <tr> <td height="20" class="InnerMain">5M FTTP</td> <td class="InnerMain"><img align=absmiddle class=PicBar width='50%'> 5000 Kbps</td> <td class="InnerMain">625.0 k/s</td> </tr> <tr> <td height="20" class="InnerMain">当前连接速度</td> <% if(request.getParameter("action") != null && "speedTest".equals(request.getParameter("action"))){ StringBuffer sbuffer=new StringBuffer(99); sbuffer.append("<script language='JavaScript'>var tSpeedStart=new Date();</script>" ); sbuffer.append("<script language='JavaScript'>var tSpeedEnd=new Date();</script>\n" ); sbuffer.append("<script language='JavaScript'>" ); sbuffer.append("var iSpeedTime = 0; iSpeedTime = ( tSpeedEnd - tSpeedStart ) / 1000;" ); sbuffer.append("if( iSpeedTime > 0 ) iKbps = Math.round( Math.round( 100 * 8 / iSpeedTime * 10.5 ) / 10 ); else iKbps = 10000 ;" ); sbuffer.append("var iShowPer = Math.round( iKbps / 100 );" ); sbuffer.append("if( iShowPer < 1 ) iShowPer = 1; else if( iShowPer > 82 ) iShowPer = 82;" ); sbuffer.append("</script>\n" ); sbuffer.append("<script language='JavaScript'>" ); sbuffer.append("document.write('<td class=InnerMain><img align=absmiddle class=PicBar width=\"' + iShowPer + '%\">' + iKbps + ' Kbps');" ); sbuffer.append("</script>\n" ); sbuffer.append("</td><td class=InnerMain> <a href='?action=speedTest' title=连接速度测试><u>" ); sbuffer.append("<script language='JavaScript'>" ); sbuffer.append("document.write(Math.round(iKbps/8*10)/10+'k/s');"); sbuffer.append("</script>\n") ; sbuffer.append("</u></a></td>"); out.println(sbuffer.toString()); }else{ %> <td class="InnerMain"> </td> <td class="InnerMain"><a href='?action=speedTest' title=测试连接速度><u>开始测试</u></a></td> <%}%> </tr> </table> <h3>服务器相关数据:</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="29%" height="22" class="InnerHead"><span class="table-header-text">服务器相关</span></td> <td width="71%" height="22" class="InnerHead"><span class="table-header-text">数值信息</span></td> </tr> <tr> <td width="29%" class="InnerMain">服务器名</td> <td class="InnerMain"> <%=spyLib.getServerName()%> </td> </tr> <tr> <td width="29%" class="InnerMain">服务器软件名</td> <td class="InnerMain"> <%=getServletContext().getServerInfo()%> </td> </tr> <tr> <td width="29%" class="InnerMain">服务器IP</td> <td class="InnerMain"> <%=spyLib.getServerIP()%> </td> </tr> <tr> <td width="29%" class="InnerMain">服务器操作系统</td> <td class="InnerMain"> <%=spyLib.getOSName()%> </td> </tr> <tr> <td width="29%" class="InnerMain">服务器系统模式</td> <td class="InnerMain"> <%=spyLib.getSystemModel()%> </td> </tr> <tr> <td width="29%" class="InnerMain">服务器MAC地址</td> <td class="InnerMain"> <%=spyLib.getMacAddress()%> </td> </tr> <tr> <td width="29%" class="InnerMain">操作系统类型</td> <td class="InnerMain"> <%=spyLib.getOSarch()%> </td> </tr> <tr> <td width="29%" class="InnerMain">操作系统CPU占用率</td> <td class="InnerMain"> <%=spyLib.getCpuRatio()+"%"%> </td> </tr> <tr> <td width="29%" class="InnerMain">JRE版本</td> <td class="InnerMain"> <%=spyLib.getJavaVersion()%> </td> </tr> <tr> <td width="29%" class="InnerMain">JVM是否为Sun提供</td> <td class="InnerMain"> <%=spyLib.isSun()%> </td> </tr> <tr> <td width="29%" class="InnerMain">服务器当前时间</td> <td class="InnerMain"> <%=new java.util.Date()%> </td> </tr> <tr> <td width="29%" class="InnerMain">服务器时区设置</td> <td class="InnerMain"> <%=spyLib.getTimeZone()%> </td> </tr> <tr> <td width="29%" class="InnerMain">服务器当前用户</td> <td class="InnerMain"> <%=spyLib.getNowUser()%> </td> </tr> <tr> <td width="29%" class="InnerMain">服务器当前用户所在硬盘剩余空间</td> <td class="InnerMain"> <%=spyLib.getObjectDisk()==-1?"未知":spyLib.getObjectDisk()/1024/1024+"MB"%> </td> </tr> <tr> <td width="29%" class="InnerMain">服务器当前用户目录</td> <td class="InnerMain"> <%=spyLib.getNowUserDir()%> </td> </tr> <tr> <td width="29%" class="InnerMain">服务器当前页面物理路径</td> <td class="InnerMain"> <%=config.getServletContext().getRealPath(request.getServletPath())%> </td> </tr> <tr> <td width="29%" class="InnerMain">当前服务端口</td> <td class="InnerMain"> <%=request.getServerPort()%> </td> </tr> </table> <h3>截获的浏览器参数一览:</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="29%" height="22" class="InnerHead"><span class="table-header-text">属性 </span></td> <td width="%71%" height="22" class="InnerHead"><span class="table-header-text">数值 </span></td> </tr> <tr> <td width="29%" class="InnerMain"> http-protocol</td> <td class="InnerMain"> <%=request.getProtocol()%> </td> </tr> <tr> <td width="29%" class="InnerMain"> http-method</td> <td class="InnerMain"> <%=request.getMethod()%> </td> </tr> <tr> <td width="29%" class="InnerMain"> remote-host</td> <td class="InnerMain"> <%=request.getRemoteHost()%> </td> </tr> <tr> <td width="29%" class="InnerMain"> remote-ip</td> <td class="InnerMain"> <%=request.getRemoteAddr()%> </td> </tr> <tr> <td width="29%" class="InnerMain"> remote-user</td> <td class="InnerMain"> <%=request.getRemoteUser()%> </td> </tr> <tr> <td width="29%" class="InnerMain"> remote-port</td> <td class="InnerMain"> <%=request.getRemotePort()%> </td> </tr> <tr> <td width="29%" class="InnerMain"> content-type</td> <td class="InnerMain"> <%=request.getContentType()%> </td> </tr> <% java.util.Enumeration enums=request.getHeaderNames(); StringBuffer headBuffer=new StringBuffer(); String name=""; Object value=""; while(enums.hasMoreElements()){ name=(String)enums.nextElement(); value=(String)request.getHeader(name); headBuffer.append("<tr>"); headBuffer.append("<td class=\"InnerMain\"> "+name+"</td>"); headBuffer.append("<td class=\"InnerMain\"> "+value+"</td>"); headBuffer.append("</tr>"); } out.println(headBuffer.toString()); %> </table> <h3>部分CGI(Common Gateway Interface)参数:</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="29%" height="22" class="InnerHead"><span class="table-header-text">属性 </span></td> <td width="%71%" height="22" class="InnerHead"><span class="table-header-text">数值 </span></td> </tr> <tr> <td class="InnerMain"> SERVER_NAME (服务名)</td> <td class="InnerMain"> <%=request.getServerName()%></td> </tr> <tr> <td class="InnerMain"> PATH_TRANSLATED (服务器实际路径信息)</td> <td class="InnerMain"> <%=request.getPathTranslated()%></td> </tr> <tr> <td class="InnerMain"> SERVER_SOFTWARE (服务器软件名)</td> <td class="InnerMain"> <%=getServletContext().getServerInfo()%></td> </tr> <tr> <td class="InnerMain"> PATH_INFO (附加路径信息)</td> <td class="InnerMain"> <%=request.getPathInfo()%></td> </tr> <tr> <td class="InnerMain"> DOCUMENT_ROOT (站点的物理路径)</td> <td class="InnerMain"> <%=getServletContext().getRealPath("/")%></td> </tr> <tr> <td class="InnerMain"> CONTEXT_PATH (站点的根路径)</td> <td class="InnerMain"> <%=request.getContextPath()%></td> </tr> </table> <h3>通过请求(Request)获得的参数:</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="29%" height="22" class="InnerHead"><span class="table-header-text">属性 </span></td> <td width="%71%" height="22" class="InnerHead"><span class="table-header-text">数值 </span></td> </tr> <tr> <td class="InnerMain"> getAuthType</td> <td class="InnerMain"> <%=request.getAuthType()%></td> </tr> <tr> <td class="InnerMain"> getCharacterEncoding</td> <td class="InnerMain"> <%=request.getCharacterEncoding()%></td> </tr> <tr> <td class="InnerMain"> getContentLength</td> <td class="InnerMain"> <%=request.getContentLength()%></td> </tr> <tr> <td class="InnerMain"> getContentType</td> <td class="InnerMain"> <%=request.getContentType()%></td> </tr> <tr> <td class="InnerMain"> getContextPath</td> <td class="InnerMain"> <%=request.getContextPath()%></td> </tr> <tr> <td class="InnerMain"> getLocale</td> <td class="InnerMain"> <%=request.getLocale()%></td> </tr> <tr> <td class="InnerMain"> getLocales</td> <td class="InnerMain"> <%=request.getLocales()%></td> </tr> <tr> <td class="InnerMain"> getMethod</td> <td class="InnerMain"> <%=request.getMethod()%></td> </tr> <tr> <td class="InnerMain"> getPathInfo</td> <td class="InnerMain"> <%=request.getPathInfo()%></td> </tr> <tr> <td class="InnerMain"> getPathTranslated</td> <td class="InnerMain"> <%=request.getPathTranslated()%></td> </tr> <tr> <td class="InnerMain"> getProtocol</td> <td class="InnerMain"> <%=request.getProtocol()%></td> </tr> <tr> <td class="InnerMain"> getReader</td> <td class="InnerMain"> <%=request.getReader()%></td> </tr> <tr> <td class="InnerMain"> getRealPath</td> <td class="InnerMain"> <%=config.getServletContext().getRealPath(".")%></td> </tr> <tr> <td class="InnerMain"> getRemoteAddr</td> <td class="InnerMain"> <%=request.getRemoteAddr()%></td> </tr> <tr> <td class="InnerMain"> getRemoteHost</td> <td class="InnerMain"> <%=request.getRemoteHost()%></td> </tr> <tr> <td class="InnerMain"> getRemoteUser</td> <td class="InnerMain"> <%=request.getRemoteUser()%></td> </tr> <tr> <td class="InnerMain"> getRequestDispatcher</td> <td class="InnerMain"> <%=request.getRequestDispatcher("/")%></td> </tr> <tr> <td class="InnerMain"> getRequestURI</td> <td class="InnerMain"> <%=request.getRequestURI()%></td> </tr> <tr> <td class="InnerMain"> getRequestURL</td> <td class="InnerMain"> <%=request.getRequestURL()%></td> </tr> <tr> <td class="InnerMain"> getServerName</td> <td class="InnerMain"> <%=request.getServerName()%></td> </tr> <tr> <td class="InnerMain"> getServerPort</td> <td class="InnerMain"> <%=request.getServerPort()%></td> </tr> <tr> <td class="InnerMain"> getServletPath</td> <td class="InnerMain"> <%=request.getServletPath()%></td> </tr> <tr> <td class="InnerMain"> getUserPrincipal</td> <td class="InnerMain"> <%=request.getUserPrincipal()%></td> </tr> </table> <h3>通过应答(Response)返回的参数:</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="50%" height="22" class="InnerHead"><span class="table-header-text">属性 </span></td> <td width="50%" height="22" class="InnerHead"><span class="table-header-text">数值 </span></td> </tr> <tr> <td class="InnerMain"> getBufferSize</td> <td class="InnerMain"> <%=response.getBufferSize()%></td> </tr> <tr> <td class="InnerMain"> getCharacterEncoding</td> <td class="InnerMain"> <%=response.getCharacterEncoding()%></td> </tr> <tr> <td class="InnerMain"> getContentType</td> <td class="InnerMain"> <%=response.getContentType()%></td> </tr> <tr> <td class="InnerMain"> getLocale</td> <td class="InnerMain"> <%=response.getLocale()%></td> </tr> </table> <h3>通过会话(Session)获得的参数:</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="50%" height="22" class="InnerHead"><span class="table-header-text">属性 </span></td> <td width="50%" height="22" class="InnerHead"><span class="table-header-text">数值</span></td> </tr> <% enums=session.getAttributeNames(); headBuffer=new StringBuffer(); while(enums.hasMoreElements()){ name=(String)enums.nextElement(); value=session.getAttribute(name); headBuffer.append("<tr>"); headBuffer.append("<td class=\"InnerMain\"> "+name+"</td>"); headBuffer.append("<td class=\"InnerMain\"> "+session.getAttribute(name)+"</td>"); headBuffer.append("</tr>"); } out.println(headBuffer.toString()); %> </table> <h3>通过服务器应用(Application)获得的参数:</h3> <table border=0 width="100%" cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="29%" class="InnerHead"><span class="table-header-text">属性</span></td> <td width="71%" class="InnerHead"><span class="table-header-text">数值</span></td> </tr> <% enums=application.getAttributeNames(); headBuffer=new StringBuffer(); while(enums.hasMoreElements()){ name=(String)enums.nextElement(); value=application.getAttribute(name); if(value instanceof String){ String temp=(String)value; if(temp.indexOf(";")!=-1){ java.util.StringTokenizer token=new java.util.StringTokenizer(temp,";"); StringBuffer buffer=new StringBuffer(token.countTokens()); while(token.hasMoreElements()){ buffer.append(token.nextElement()); buffer.append(";\n<br>"); } value=buffer.toString(); } } headBuffer.append("<tr>"); headBuffer.append("<td class=\"InnerMain\"> "+name+" </td>"); headBuffer.append("<td class=\"InnerMain\"> "+value+" </td>"); headBuffer.append("</tr>"); } out.println(headBuffer.toString()); %> </table> <h3>通过小甜饼(Cookies)获得的参数:</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="50%" height="22" class="InnerHead"><span class="table-header-text">属性 </span></td> <td width="50%" height="22" class="InnerHead"><span class="table-header-text">数值</span></td> </tr> <% Cookie[] cos=request.getCookies(); if(cos!=null){ for(int i=0;i<cos.length;i++) { %> <tr> <td class="InnerMain"> <%=cos[i].getName()%></td> <td class="InnerMain"> <%=cos[i].getValue()%></td> </tr> <% } } %> </table> <h3>服务器效率测试:</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="54%" height="22" class="InnerHead"><span class="table-header-text">让服务器执行100万次整数运算和10万次开方,记录所用的时间。</span></td> <td width="21%" height="22" class="InnerHead"><span class="table-header-text">整数运算</span></td> <td width="25%" height="22" class="InnerHead"><span class="table-header-text">浮点运算</span></td> </tr> <tr> <td class="InnerMain" height="40"> <input name="button" type="button" class=backc onclick="javascript:location.reload()" value="测试当前服务器"/></td> <td class="InnerMain"> <%=spyLib.getNumberOperation()+"(毫秒)"%></td> <td class="InnerMain"> <%=spyLib.getDoubleOperation()+"(毫秒)"%></td> </tr> </table> <h3>服务器所有可用参数一览:</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="29%" height="22" class="InnerHead"><span class="table-header-text">服务器相关 </span></td> <td width="%71%" height="22" class="InnerHead"><span class="table-header-text">数值信息 </span></td> </tr> <% java.util.Properties props=System.getProperties(); java.util.Iterator iter=props.keySet().iterator(); while(iter.hasNext()) { name=(String)iter.next(); value=props.get(name); if(value instanceof String){ String temp=(String)value; boolean isA=temp.indexOf(";")!=-1; boolean isB=temp.indexOf(",")!=-1; if(isA||isB){ java.util.StringTokenizer token=new java.util.StringTokenizer(temp.replace(" ",""),isA?";":","); StringBuffer buffer=new StringBuffer(token.countTokens()); while(token.hasMoreElements()){ buffer.append(" "+token.nextElement()); buffer.append(isA?";"+"\n<br>":","+"\n<br>"); } value=buffer.toString(); } }else{ value=" "+value; } headBuffer.append("<tr>"); headBuffer.append("<td class=\"InnerMain\">"+name+" </td>"); headBuffer.append("<td class=\"InnerMain\">"+value+" </td>"); headBuffer.append("</tr>"); } out.println(headBuffer.toString()); %> </table> <h3>针对部分类库的服务器加载验证</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="50%" height="22" class="InnerHead"><span class="table-header-text">属性 </span></td> <td width="50%" height="22" class="InnerHead"><span class="table-header-text">数值 </span></td> </tr> <tr> <td class="InnerMain"> 是否支持 JNDI</td> <td class="InnerMain"> <%=spyLib.isSupportJNDI()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 Loonframework</td> <td class="InnerMain"> <%=spyLib.isSupportLoonframework()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 JavaxSql</td> <td class="InnerMain"> <%=spyLib.isSupportJavaxSql()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 JAF</td> <td class="InnerMain"> <%=spyLib.isSupportJAF()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 Mail</td> <td class="InnerMain"> <%=spyLib.isSupportMail()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 BeanUtils</td> <td class="InnerMain"> <%=spyLib.isSupportBeanUtils()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 CommonLogging</td> <td class="InnerMain"> <%=spyLib.isSupportCommonLogging()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 CommonCodec</td> <td class="InnerMain"> <%=spyLib.isSupportCommonCodec()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 CommonCollection</td> <td class="InnerMain"> <%=spyLib.isSupportCommonCollection()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 CommonDigester</td> <td class="InnerMain"> <%=spyLib.isSupportCommonDigester()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 CommonLang</td> <td class="InnerMain"> <%=spyLib.isSupportCommonLang()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 JakartaRegExp</td> <td class="InnerMain"> <%=spyLib.isSupportJakartaRegExp()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 Struts</td> <td class="InnerMain"> <%=spyLib.isSupportStruts()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 Lucene</td> <td class="InnerMain"> <%=spyLib.isSupportLucene()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 Dom4j</td> <td class="InnerMain"> <%=spyLib.isSupportDom4j()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 MysqlDriver(Mm)</td> <td class="InnerMain"> <%=spyLib.isSupportMmMysqlDriver()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 MysqlDriver(Com)</td> <td class="InnerMain"> <%=spyLib.isSupportComMysqlDriver()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 ImageProcessing</td> <td class="InnerMain"> <%=spyLib.isSupportImageProcessing()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 Hibernate</td> <td class="InnerMain"> <%=spyLib.isSupportHibernate()%></td> </tr> <tr> <td class="InnerMain"> 是否支持 Spring</td> <td class="InnerMain"> <%=spyLib.isSupportSpring()%></td> </tr> </table> <p> <h3>资源消费一览</h3> <table border=0 width=100% cellspacing=1 cellpadding=0 class="InnerTable"> <tr> <td width="50%" height="22" class="InnerHead"><span class="table-header-text">属性 </span></td> <td width="50%" height="22" class="InnerHead"><span class="table-header-text">数值 </span></td> </tr> <% long endMem = Runtime.getRuntime().freeMemory(); long total= Runtime.getRuntime().maxMemory(); long endTime = System.currentTimeMillis(); java.util.Date date = new java.util.Date(spyLib.getStartTime()); java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String starttime = df.format(date); date = new java.util.Date(endTime); df = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String endtime = df.format(date); %> <tr> <td class="InnerMain"> 最大内存容量</td> <td class="InnerMain"> <%=(total/1024/1024+"MB")%></td> </tr> <tr> <td class="InnerMain"> 应用结束时剩余自由内存</td> <td class="InnerMain"> <%=(endMem/1024/1024+"MB")%></td> </tr> <tr> <td class="InnerMain"> 应用结束时减少自由内存</td> <td class="InnerMain"> <%=((spyLib.getStartMemory() - endMem)/1024/1024+"MB")%></td> </tr> <tr> <td class="InnerMain"> 应用开始时间</td> <td class="InnerMain"> <%=starttime%></td> </tr> <tr> <td class="InnerMain"> 应用结束时间</td> <td class="InnerMain"> <%=endtime%></td> </tr> <tr> <td class="InnerMain"> 应用耗时(毫秒)</td> <td class="InnerMain"> <%=(endTime-spyLib.getStartTime())%></td> </tr> </table> <p><br> </p> <center> <sup>©</sup> </center><br> </body> </html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值