统计WebService的调用者、调用函数、运行时间
发布时间:2020-12-16 21:42:28 所属栏目:安全 来源:网络整理
导读:系统WebServic分布太久了, 都不知道哪些系统在用? 调用的哪些函数?于是乎,写一个Soap Extension, 再加一个页面,来查询一下。 先看一下配制说明,和效果 web.config中 system.web ???? compilation debug= "true" ? targetFramework= "4.0" ? / ?? !--h
系统WebServic分布太久了, 都不知道哪些系统在用? 调用的哪些函数?于是乎,写一个Soap Extension, 再加一个页面,来查询一下。 先看一下配制说明,和效果 web.config中
然后访问查询页面: ? 当前运行:0
?
最后记录:20,??? 3.0 (Call/S),27.8 (MS/Call)
Host:10.129.255.105,? UseTime:0,Time:2012-9-4 9:15:42,name:GetCanStarFlowList,Arg:AComp:=衡水分公司,ADept:=县公司,AUser:=杨立华
Host:10.129.255.104,? UseTime:46.8747,Time:2012-9-4 9:15:43,name:GetBillData_done,Arg:ABillID:=54533f29-8979-4b1d-adf8-b8fbf2cf7678,year:=
Host:10.129.255.218,Arg:sUserName:=耿书芬,sCompany:=邯郸分公司,sDepartment:=广平分公司,sDuty:=,order:=DESC,pageSize:=20,recordCount:=0
Host:10.129.255.216,Time:2012-9-4 9:15:45,Arg:sUserName:=魏广芹,sCompany:=张家口分公司,sDepartment:=渠道管理中心,recordCount:=0
|
查看页面:
<%@ WebHandler Language=
"C#"
?
Class=
"SoapUtil.ServerStat"
?
%>
System;
System.Collections.Generic;
System.Linq;
System.Web;
OA4.CommonLib.Soap;
?
SoapUtil
{
????
/// <summary>
/// Alive 的摘要说明
/// </summary>
ServerStat : IHttpHandler
?
ProcessRequest(HttpContext context)
{
context.Response.ContentType =
"text/plain"
;
resp = context.Response;
try
{
running = TimeWatchExtension.Running.ToList();
?
resp.Write(
"当前运行:{0}n{1}"
????????????????????????????????????????
running.Count,
????????????????????????????????????????
"n"
{
????????????????????????????????????????????
ret =
"exception"
;
try?
{ ret = d.Value.ToString(); }
catch?
(Exception ex)
????????????????????????????????????????????
{
????????????????????????????????????????????????
.Concat(ret,d.Value.MethodName,d.Value.UserHostAddress,d.Value.BeginInvokeTime.ToString());
}
ret;
}).ToArray())
)
???????????????????????????
);
?
last = TimeWatchExtension.LastInvoke.ToList();
{
strInfo =
""
;
(last.Count > 1)
{
f = last.First();
TimeSpan ts = DateTime.Now - f.BeginInvokeTime;
speed = last.Count / ts.TotalSeconds;
avgUseTime = last.Average(d => d.UseTime.Milliseconds);
?
?
strInfo =
"{0:0.0} (Call/S),{1:0.0} (MS/Call)"
}
else
{
?
}
"n最后记录:{0},t{1}n{2}"
???????????????????????????????????????????
last.Count,
strInfo,
???????????????????????????????????????????
{
???????????????????????????????????????????????
;
{ ret = d.ToString(); }
(Exception ex)
???????????????????????????????????????????????
{
???????????????????????????????????????????????????
}
ret;
}).ToArray())
)
??????????????????????????????
);
}
?
resp.Write(
);
userHost = TimeWatchExtension.RemoteUserHost;
Array.ForEach(userHost,info =>
{
invoke = info.LastInvoke.ToList();
(invoke.Count > 1)
f = invoke.First();
?
TimeSpan ts = DateTime.Now - f.BeginInvokeTime;
speed = invoke.Count / ts.TotalSeconds;
avgUseTime = invoke.Average(d => d.UseTime.Milliseconds);
?
?
"nn"
?
+ info.Host +
"["
?
+ strInfo +
"]:"
);
}
else
{
":"
);
}
"n最后记录:{0}n{1}"
??????????????????????????????????????
invoke.Count,
??????????????????????????????????????
{
??????????????????????????????????????????
{ ret = d.ToString(); }
(Exception ex)
??????????????????????????????????????????
{
??????????????????????????????????????????????
}
ret;
}).ToArray())
)
?????????????????????????
);
});
?
}
(Exception ex)
{
context.Response.Write(
"ERROR:{0}"
}
}
?
bool
?
IsReusable
{
get
{
false
;
}
}
}
}