Performance Counters

Performance counters helps you monitor the status of a given application, and identify bottlenecks. You can view performance counters in the Computer Management tool, by selecting the Performance (or Reliability &Performance) tab.

To access performance counters programmatically, you’ll use the PerformanceCounter class. To read from an existing counter, use the following method:

PerformanceCounter pc = new PerformanceCounter(“Processor”, “% Processor Time”, “_Total”);
pc.NextValue();
Thread.Sleep(1000);
Console.WriteLine(pc.NextValue);

Continue reading “Performance Counters”

System Processes

To work with system processes, either local or remote ones, you should use the System.Diagnostics namespace’s Process class. I wouldn’t waste time on describing processes, let’s see what are the objectives here:

  • Get a list of running processes
  • Retrieve information about the current process
  • Get a list of modules loaded by a process
  • Start a process by using and not using command-line arguments

Continue reading “System Processes”

Manage an Event Log

Event logs are the best friends of a system administrator. When some unhandled exception occurs, or system failure, etc. you should write it to the event log, so the information won’t be lost later. You can access event logs by clicking the Manage button on the Computer. Then you should select the Event Viewer pane.

There are three categories of events: System, Security and Application. Forget the former two, you’ll only need to (and are able to) work with the Application event log.

All event log related classes live in the System.Diagnostics namespace. The most important types here:

  • EventLog
  • EventLogEntry
  • EventLogEntryCollection
  • EventLogEntryType
  • EventLogPermission
  • EventLogTraceListener
  • EventSourceCreationData

Continue reading “Manage an Event Log”