The system WebServic has been distributed for too long. I don't know which systems are in use? Which functions are called? Then, write a Soap Extension and add a page to query it.
Let's take a look at the preparation instructions and results.
In web. config
<system.web> <compilation debug="true" targetFramework="4.0" /> <!--
Then visit the query page:
Current run: 0 last record: 20, 3.0 (Call/S), 27.8 (MS/Call) Host: 10.129.0000105, UseTime: 0, Time: 9:15:42, name: GetCanStarFlowList, arg: AComp: = Hengshui branch, ADept: = County company, AUser: = Yang Lihua Host: 10.129.0000105, UseTime: 15.6249, Time: 9:15:42, name: GetAgendumList, Arg: sUserName: = Yang Lihua, sCompany: = Hengshui branch, sDepartment: = County company, sDuty: = manager, sRole: =, type: = all, dbfield: = ReceiveTime, order: = ASC, pageSize: = 25, pageNumber: = 1, pageCount: = 0, recordCount: = 0 Host: 10.129.20.104, UseTime: 46.8747, Time: 9:15:43, name: GetBillData_done, Arg: ABillID: = hour, year: = Host: 10.129.20.104, UseTime: 0, Time: 9:15:43, name: GetCurrentActivityName, Arg: flowInstanceId: = hour: 10.129.20.218, UseTime: 15.6249, Time: 9:15:43, name: GetAgendumList, Arg: sUserName: = zhangshufen, sCompany: = Handan branch, sDepartment: = Guangping branch, sDuty: =, sRole: =, type: = all, dbfield: = ReceiveTime, order: = DESC, pageSize: = 20, pageNumber: = 1, pageCount: = 0, recordCount: = 0 Host: 10.129.2017216, UseTime: 15.6249, time: 9:15:45, name: GetAgendumList, Arg: sUserName: = Wei Guangqin, sCompany: = Zhangjiakou branch, sDepartment: = channel management center, sDuty: =, sRole: =, type: = all, dbfield: = ReceiveTime, order: = DESC, pageSize: = 20, pageNumber: = 1, pageCount: = 0, recordCount: = 0 Host: 10.129.20.104, UseTime: 46.8747, Time: 9:15:46, name: GetUserInfo, Arg: userName: = caoruifen_sjzHost: 10.129.0000104, UseTime: 0, Time: 9:15:46, name: GetDoingFlowInfo, Arg: activeInstId: = c1e1d9ef-6a8f-46e8-98d1-dedac3c6137cHost: 10.129.0000104, UseTime: 0, Time: 9:15:46, name: GetActiveInstInfo, Arg: activeInstID: = c1e1d9ef-6a8f-46e8-98d1-dedac3c6137c, parentBillID: = Cost: 10.129.0000104, UseTime: 62.4996, Time: 9:15:46, name: getBillData_done, Arg: ABillID: = e14d1f34-53b5-4824-afd9-f8207dc4bab3, year: = Host: 10.129.20.104, UseTime: 15.6249, Time: 9:15:46, name: UpdateRead, Arg: ActivityInstanceID: = c1e1d9ef-6a8f-46e8-98d1-dedac3c6137cHost: 10.129.20.104, UseTime: 15.6249, Time: 9:15:46, name: FindNextRouteReturnConnects, Arg: sFlowID: = ae76d210-85f3-403f-ba4b-485c72cbb96e, sFlowInstanceID: = e14d1f34-53b5-4824-afd9-f8207dc4bab3, sActivityID: = c16d997c-f471-49f1-adef-e64cad616d79Host: 10.129.0000104, UseTime: 234.3735, Time: 9:15:47, name: GetBillData_done, Arg: ABillID: = da7276c9-80af-485a-975a-f881be30b0f2, year: = 2008 Host: 10.129.0000105, UseTime: 15.6249, Time: 9:15:47, name: GetActiveInstInfo, Arg: activeInstID: = success, parentBillID: = CLERK: 10.129.0000105, UseTime: 46.8747, Time: 9:15:47, name: GetBillData_done, Arg: ABillID: = clerk, year: = Host: 10.129.0000105, UseTime: 31.2498, Time: 9:15:47, name: UpdateRead, Arg: ActivityInstanceID: = CLERK: 10.129.0000105, UseTime: 0, Time: 9:15:47, name: Clerk, Arg: sFlowID: = ae76d210-85f3-403f-ba4b-485c72cbb96e, sFlowInstanceID: = identifier, sActivityID: = identifier: 10.129.20.104, UseTime: 0, Time: 9:15:47, name: GetCurrentActivityName, Arg: flowInstanceId: = da7276c9-80af-485a-975a-f881be30b0f2Host: 10.129.20.104, UseTime: 0, Time: 9:15:47, name: GetWordField, Arg: flowInstID: = da7276c9-80af-485a-975a-f881be30b0f2Host: 10.129.20.104, UseTime: 0, Time: 9:15:47, name: SaveFavorite, Arg: userName: = Zhang xiangkai, flowInstID: = 7d03a4a1-07ff-4bdc-b2a4-cb381fec357f
Implementation Code: Soap
Using System; using System. collections. generic; using System. linq; using System. text; using System. web. services. protocols; using System. web; using System. collections. specialized; using System. collections. concurrent; using System. collections; using log4net; using System. threading; namespace OA4.CommonLib. soap {public class TimeWatchExtension: SoapExtension {protected static ILog log = LogManager. getLogger (Sy Stem. reflection. methodBase. getCurrentMethod (). declaringType); private static ConcurrentDictionary <Guid, WSInvokeInfo> running = new System. collections. concurrent. concurrentDictionary <Guid, WSInvokeInfo> (); private static ConcurrentQueue <WSInvokeInfo> last = new ConcurrentQueue <WSInvokeInfo> (); private static ConcurrentDictionary <string, ConcurrentQueue <comment> remoteUserHost = new Concurren TDictionary <string, ConcurrentQueue <WSInvokeInfo> (); public static ConcurrentDictionary <Guid, WSInvokeInfo> Running {get {return running ;}} public static ConcurrentQueue <WSInvokeInfo> LastInvoke {get {return last ;}} public static RemoteHostInfo [] RemoteUserHost {get {return remoteUserHost. toList (). convertAll (d => new RemoteHostInfo () {Host = d. key, LastInvoke = d. value. toArray ()}). toArray () ;}} Public static int MaxRunningMilliseconds = int. Parse (System. Configuration. ConfigurationManager. AppSettings ["TimeWatchExtension. MaxRunningMilliseconds"]? "800"); public static Timer timerSnap = null; static TimeWatchExtension () {timerSnap = new Timer (new TimerCallback (e => {if (Running. count> 0) {var running = Running. toList (); running. forEach (d => {if (d. value. useTime. totalMilliseconds> MaxRunningMilliseconds) {log. warn (d. value. toString () ;}}) ;}}); timerSnap. change (1000,100 0);} private WSInvokeInfo invokeInfo = new WSInvokeInfo (); pu Blic override System. IO. stream ChainStream (System. IO. stream stream) {return stream;} public override object GetInitializer (Type serviceType) {return null;} public override object GetInitializer (LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute) {return null ;} public override void Initialize (object initializer) {} public override void ProcessMessage (SoapMessage message) {if (me Ssage is SoapClientMessage) {switch (message. stage) {case SoapMessageStage. beforeSerialize: break; case SoapMessageStage. afterSerialize: break; case SoapMessageStage. beforeDeserialize: break; // About to call methods case SoapMessageStage. afterDeserialize: break; // After Method call default: throw new Exception ("No stage such as this") ;}} else if (message is SoapServerMessage) {SoapServerMes Sage msg = (SoapServerMessage) message; switch (message. stage) {case SoapMessageStage. beforeDeserialize: break; case SoapMessageStage. afterDeserialize: {// collection time this. invokeInfo. beginInvokeTime = DateTime. now; // collect WebService method name this. invokeInfo. methodName = message. methodInfo. name; this. invokeInfo. userHostAddress = System. web. httpContext. current. request. userHostAddress; this. invokeInfo. args = new Di Ctionary <string, object> (); message. methodInfo. inParameters. toList (). forEach (d => {this. invokeInfo. args. add (d. name, message. getInParameterValue (d. position) ;}); running. tryAdd (this. invokeInfo. id, this. invokeInfo); {last. enqueue (invokeInfo); if (last. count> 20) {WSInvokeInfo removed; last. tryDequeue (out removed) ;}{ var queue = remoteUserHost. getOrAdd (invokeInfo. userHostAddress, uha => new ConcurrentQueue <WSInvokeInfo> (); queue. enqueue (invokeInfo); if (queue. count> 5) {WSInvokeInfo removed; queue. tryDequeue (out removed) ;}} break; case SoapMessageStage. beforeSerialize: {// collection time this. invokeInfo. endInvokeTime = DateTime. now; WSInvokeInfo removed; running. tryRemove (this. invokeInfo. id, out removed); if (log. isDebugEnabled) {if (this. invokeInfo. useTime. totalMilliseconds> MaxRunni NgMilliseconds) log. debug (this. invokeInfo. toString () ;}} break; case SoapMessageStage. afterSerialize: break; default: throw new Exception ("No stage such as this") ;}}} public class WSInvokeInfo {public WSInvokeInfo () {Id = Guid. newGuid ();} public Guid Id {get; private set;} public DateTime BeginInvokeTime {get; set;} public string MethodName {get; set;} public string UserHostAddress {Get; set;} public DateTime? EndInvokeTime {get; set;} public Dictionary <string, object> Args {get; set;} public TimeSpan UseTime {get {return (EndInvokeTime. HasValue? EndInvokeTime. value: DateTime. now)-BeginInvokeTime;} public static string GetString (ICollection val) {var ret = new List <string> (); var iter = val. getEnumerator (); while (iter. moveNext () {if (iter. current is ICollection) ret. add (GetString (ICollection) iter. current); else ret. add (iter. current. toString ();} return string. concat ("[", string. join (",", ret. toArray (), "]");} public overrid E string ToString () {return string. format ("Host: {0}, UseTime: {1}, Time: {2}, name: {3}, Arg: {4}", this. userHostAddress ?? "None", this. UseTime. TotalMilliseconds, this. BeginInvokeTime, this. MethodName ?? "Unkown", string. join (",", this. args. toList (). convertAll (d => string. format ("{0 }:={ 1}", d. key, d. value = null? "Null": (d. Value is ICollection? GetString (ICollection) d. value): d. value. toString ()))). toArray () ;}} public class RemoteHostInfo {public string Host {get; set;} public WSInvokeInfo [] LastInvoke {get; set ;}}}
View page:
<% @ WebHandler Language = "C #" Class = "SoapUtil. serverStat "%> using System; using System. collections. generic; using System. linq; using System. web; using OA4.CommonLib. soap; namespace SoapUtil {// <summary> // Alive summary /// </summary> public class ServerStat: IHttpHandler {public void ProcessRequest (HttpContext context) {context. response. contentType = "text/plain"; var resp = context. response; try {var running = TimeWatchExtension. running. toList (); resp. write (string. format ("current run: {0} \ n {1}", running. count, string. join ("\ n", running. convertAll (d => {var ret = "exception"; try {ret = d. value. toString ();} catch (Exception ex) {ret = string. concat (ret, ",", d. value. methodName, ",", d. value. userHostAddress, ",", d. value. beginInvokeTime. toString ();} return ret ;}). toArray (); var last = TimeWatchExtension. lastInvoke. toList (); {var strInfo = ""; if (last. count> 1) {var f = last. first (); TimeSpan ts = DateTime. now-f. beginInvokeTime; var speed = last. count/ts. totalSeconds; var avgUseTime = last. average (d => d. useTime. milliseconds); strInfo = string. format ("{0: 0. 0} (Call/S), {1:0. 0} (MS/Call) ", speed, avgUseTime);} else {} resp. write (string. format ("\ n last record: {0}, \ t {1} \ n {2}", last. count, strInfo, string. join ("\ n", last. convertAll (d => {var ret = "exception"; try {ret = d. toString ();} catch (Exception ex) {ret = string. concat (ret, ",", d. methodName, ",", d. userHostAddress, ",", d. beginInvokeTime. toString ();} return ret ;}). toArray ();} resp. write ("\ n"); var userHost = TimeWatchExtension. remoteUserHost; Array. forEach (userHost, info => {var invoke = info. lastInvoke. toList (); if (invoke. count> 1) {var f = invoke. first (); TimeSpan ts = DateTime. now-f. beginInvokeTime; var speed = invoke. count/ts. totalSeconds; var avgUseTime = invoke. average (d => d. useTime. milliseconds); var strInfo = string. format ("{0: 0. 0} (Call/S), {1:0. (MS/Call) ", speed, avgUseTime); resp. write ("\ n" + info. host + "[" + strInfo + "]:");} else {resp. write ("\ n" + info. host + ":");} resp. write (string. format ("\ n last record: {0} \ n {1}", invoke. count, string. join ("\ n", invoke. convertAll (d => {var ret = "exception"; try {ret = d. toString ();} catch (Exception ex) {ret = string. concat (ret, ",", d. methodName, ",", d. userHostAddress, ",", d. beginInvokeTime. toString ();} return ret ;}). toArray ();} catch (Exception ex) {context. response. write (string. format ("ERROR: {0}", ex. message) ;}} public bool IsReusable {get {return false ;}}}}