Ejemplo n.º 1
0
        /// <summary>
        /// DO NOT USE UNTIL FIGURE OUT HOW TO ENABLE PERFORMANC METRICS IN IIS and .NET
        /// </summary>
        /// <returns></returns>
        internal static XmlDocument getProcessInfoHistory()
        {
            XmlDocument   doc;
            string        nodeFormat = "<info StartTime=\"{0,12:MM/dd hh:mmt}\" ProcessID=\"{1,5}\" Status=\"{2,12}\" TotalSeconds=\"{3,10:0}\" RequestCount=\"{4,12}\" ShutDownReason=\"{5,18}\" PeakMemoryUsed=\"{6,15:0k}\"/>";
            StringBuilder sb         = new StringBuilder();

            using (XmlWriter xwriter = XmlWriter.Create(sb))
            {
                xwriter.WriteStartElement("process");


                ProcessInfo[] history = ProcessModelInfo.GetHistory(100);


                for (int i = 0; i < history.Length; i++)
                {
                    {
                        var obj = new Object[]
                        {
                            history[i].StartTime,
                            history[i].ProcessID,
                            history[i].Status,
                            history[i].Age.TotalSeconds,
                            history[i].RequestCount,
                            history[i].ShutdownReason,
                            history[i].PeakMemoryUsed
                        };
                        xwriter.WriteRaw(String.Format(nodeFormat, obj));
                    }
                }
                doc = new XmlDocument();
                doc.LoadXml(sb.ToString());
            }
            return(doc);
        }
Ejemplo n.º 2
0
 public void GetHistory_PermitOnly_High()
 {
     try {
         ProcessModelInfo.GetHistory(0);
     }
     catch (HttpException) {
         // expected (as we're not running ASP.NET)
     }
     catch (NotImplementedException) {
         // mono
     }
 }
Ejemplo n.º 3
0
 public void GetHistory_PermitOnly_High()
 {
     try {
         ProcessModelInfo.GetHistory(0);
     }
     catch (HttpException) {
         // ms 2.x - kind of expected (as we're not running ASP.NET)
     }
     catch (NotImplementedException) {
         // mono
     }
     catch (TypeInitializationException) {
         // ms 1.x - fails initializing HttpRuntime
     }
 }
Ejemplo n.º 4
0
 public void GetHistory_Deny_High()
 {
     ProcessModelInfo.GetHistory(0);
 }
Ejemplo n.º 5
0
        public static void Info(ScriptContext /*!*/ scriptContext)
        {
            TextWriter  output = scriptContext.Output;
            HttpContext ctx    = HttpContext.Current;

            output.WriteLine("<br><div style='background-color:oldlace'><H3>Phalanger debug info:</H3><PRE>");

            output.WriteLine("</PRE><H3>HttpRuntime</H3><PRE>");

            output.WriteLine("AppDomainAppId = {0}", HttpRuntime.AppDomainAppId);
            output.WriteLine("AppDomainAppPath = {0}", HttpRuntime.AppDomainAppPath);
            output.WriteLine("AppDomainAppVirtualPath = {0}", HttpRuntime.AppDomainAppVirtualPath);
            output.WriteLine("AppDomainId = {0}", HttpRuntime.AppDomainId);
            output.WriteLine("AspInstallDirectory = {0}", HttpRuntime.AspInstallDirectory);
            output.WriteLine("BinDirectory = {0}", HttpRuntime.BinDirectory);
            output.WriteLine("ClrInstallDirectory = {0}", HttpRuntime.ClrInstallDirectory);
            try
            {
                output.WriteLine("CodegenDir = {0}", HttpRuntime.CodegenDir);
            }
            catch (Exception)
            {
                output.WriteLine("CodegenDir = N/A");
            }
            output.WriteLine("MachineConfigurationDirectory = {0}", HttpRuntime.MachineConfigurationDirectory);

            output.WriteLine("</PRE><H3>Worker Process</H3><PRE>");

            output.Write("Worker processes: ");
            if (ctx != null)
            {
                foreach (ProcessInfo pi in ProcessModelInfo.GetHistory(20))
                {
                    output.Write(pi.ProcessID + ";");
                }
                output.WriteLine();

                output.WriteLine("Current Worker Process start time: {0}", ProcessModelInfo.GetCurrentProcessInfo().StartTime);
            }
            else
            {
                output.WriteLine("N/A");
            }

            Process proc = Process.GetCurrentProcess();

            output.WriteLine("Current process: Id = {0}", proc.Id);
            output.WriteLine("Current PrivateMemorySize: {0} MB", proc.PrivateMemorySize64 / (1024 * 1024));
            output.WriteLine("Current WorkingSet: {0} MB", proc.WorkingSet64 / (1024 * 1024));
            output.WriteLine("Current VirtualMemorySize: {0} MB", proc.VirtualMemorySize64 / (1024 * 1024));
            output.WriteLine("Current thread: HashCode = {0}", Thread.CurrentThread.GetHashCode());
            output.WriteLine("Current domain: {0}", Thread.GetDomain().FriendlyName);

            AppDomainInfo(AppDomain.CurrentDomain, output);
            if (ctx != null)
            {
                AppDomainInfo(AppDomain.CurrentDomain, output);
            }

            output.WriteLine("</PRE><H3>Libraries</H3><PRE>");

            foreach (PhpLibraryAssembly a in scriptContext.ApplicationContext.GetLoadedLibraries())
            {
                a.Descriptor.Dump(output);
            }

            //output.WriteLine("</PRE><H3>Invalidated Precompiled Scripts</H3><PRE>");
            //foreach (string item in WebServerManagersDebug.GetInvalidatedScripts())
            //  output.WriteLine(item);

            output.WriteLine("</PRE><H3>Cache</H3><PRE>");
            foreach (DictionaryEntry item in HttpRuntime.Cache)
            {
                if (item.Value is string)
                {
                    output.WriteLine("{0} => '{1}'", item.Key, item.Value);
                }
                else
                {
                    output.WriteLine("{0} => instance of {1}", item.Key, item.Value.GetType().FullName);
                }
            }

            if (ctx != null)
            {
                output.WriteLine("</PRE><H3>Query Variables</H3><PRE>");
                String[] keys;
                keys = ctx.Request.QueryString.AllKeys;
                for (int i = 0; i < keys.Length; i++)
                {
                    output.WriteLine("{0} = \"{1}\"", keys[i], ctx.Request.QueryString.GetValues(keys[i])[0]);
                }

                if (ctx.Session != null)
                {
                    output.WriteLine("</PRE><H3>Session Variables</H3><PRE>");

                    output.WriteLine("IsCookieless = {0}", ctx.Session.IsCookieless);
                    output.WriteLine("IsNewSession = {0}", ctx.Session.IsNewSession);
                    output.WriteLine("SessionID = {0}", ctx.Session.SessionID);

                    foreach (string name in ctx.Session)
                    {
                        output.Write("{0} = ", name);
                        PhpVariable.Dump(ctx.Session[name]);
                    }
                }

                output.WriteLine("</PRE><H3>Cookies</H3><PRE>");
                foreach (string cookie_name in ctx.Request.Cookies)
                {
                    HttpCookie cookie = ctx.Request.Cookies[cookie_name];
                    Console.WriteLine("{0} = {1}", cookie.Name, cookie.Value);
                }

                output.WriteLine("</PRE><H3>Server Variables</H3><PRE>");

                keys = ctx.Request.ServerVariables.AllKeys;
                for (int i = 0; i < keys.Length; i++)
                {
                    output.WriteLine("{0} = \"{1}\"", keys[i], ctx.Request.ServerVariables.GetValues(keys[i])[0]);
                }
            }
            else
            {
                output.WriteLine("</PRE><H3>Missing HttpContext</H3><PRE>");
            }

            output.WriteLine("</PRE></DIV>");
        }