Exemplo n.º 1
0
        private static long GetCurrentManagedMemorySize()
        {
            var safelyGetPerformanceCounter = PerformanceCountersUtils.SafelyGetPerformanceCounter(
                ".NET CLR Memory", "# Total committed Bytes", CurrentProcessName.Value);

            return(safelyGetPerformanceCounter ?? GC.GetTotalMemory(false));
        }
Exemplo n.º 2
0
        private static void SetupPerfCounters(string user)
        {
            user = user ?? WindowsIdentity.GetCurrent().Name;
            PerformanceCountersUtils.EnsurePerformanceCountersMonitoringAccess(user);

            var actionToTake = user.StartsWith("IIS") ? "restart IIS service" : "log in the user again";

            Console.Write("User {0} has been added to Performance Monitoring Users group. Please {1} to take an effect.", user, actionToTake);
        }
Exemplo n.º 3
0
        public static ActionResult SetupPerformanceCountersForIISUser(Session session)
        {
            try
            {
                PerformanceCountersUtils.EnsurePerformanceCountersMonitoringAccess(string.Format("{0}\\{1}", session["WEB_APP_POOL_IDENTITY_DOMAIN"], session["WEB_APP_POOL_IDENTITY_NAME"]));
            }
            catch (Exception ex)
            {
                Log.Error(session, "Exception was thrown during SetupPerformanceCountersForIISUser:"******"Warning: The access to performance counters has not been configured for the account '{0}\\{1}'.{2}",
                                      session["WEB_APP_POOL_IDENTITY_DOMAIN"], session["WEB_APP_POOL_IDENTITY_NAME"], Environment.NewLine));


                if (ex is IdentityNotMappedException)
                {
                    sb.Append("The account does not exist.");
                }
                else
                {
                    sb.Append("Exception type: " + ex.GetType());
                }

                if (string.IsNullOrEmpty(session["LOG_FILE_PATH"]) == false)
                {
                    sb.Append(string.Format("{0}For more details check the log file:{0}{1}", Environment.NewLine, session["LOG_FILE_PATH"]));
                }

                MessageBox.Show(sb.ToString(), "Failed to grant permissions", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                return(ActionResult.Success);
            }

            return(ActionResult.Success);
        }