Showing posts from March, 2015

C# - Performance Counters

Reading performance counters (in C#) require the use of the PerformanceCounter class to read existing predefined or custom counters. The PerformanceCounter class is included in the System.Diagnostic namespace, and provides accessibility to several counters.

The most common counters include Processor, Memory, and Network Utilization.

// CPU Processor Time (in %) PerformanceCounter cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); Console.WriteLine("Current CPU: {0}", cpuCounter.NextValue() +"%"); // Memory Available (in MB) PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available MBytes", string.Empty); Console.WriteLine("RAM Available: {0}", ramCounter.NextValue()+"MB"); // Network Utilization (in Bytes/Sec) PerformanceCounterCategory category = new PerformanceCounterCategory("Network Interface"); …

SharePoint - An unexpected error has occurred. (Web Part Page Maintenance)

On occasion, a web part may be causing your SharePoint pages to throw an unexpected error.

An unexpected error has occurred. Web Parts Maintenance Page: If you have permission, you can use this page to temporarily close Web Parts or remove personal settings. For more information, contact your site administrator. Troubleshoot issues with Microsoft SharePoint Foundation.

In addition to leveraging the ULS Logs, to investigate the Correlation ID, you can append "?contents=1" to your page URL. This will allow you to close web parts, restore defaults to web parts, or delete web parts from your page.