Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mikael Deurell Senior Consultant Microsoft Mail: Blog: blogs.msdn.com/deurell.

Similar presentations


Presentation on theme: "Mikael Deurell Senior Consultant Microsoft Mail: Blog: blogs.msdn.com/deurell."— Presentation transcript:

1 Mikael Deurell Senior Consultant Microsoft Mail: mikael.deurell@microsoft.commikael.deurell@microsoft.com Blog: blogs.msdn.com/deurell

2 Are we all developers (or related)? Who has heard of DFO? Design for Operations Who thinks stack traces in event logs are cool? Who thinks editing an XML configuration file in notepad to reconfigure your application is a good idea?

3 Design for Operations Windows Eventing, Performance Counters & WMI Windows PowerShell PowerShell Cmdlets MMC 3.0

4 Design for Operations Building applications that can be deployed Building applications that can be operated Caring about Operations [And about your debugging friends at Microsoft]

5 Developers build applications in a silo Hand application over to Operations Operations operate the application Applications can’t be configured or monitored with management tools used by IT Staff No Knowledge Sharing Developers required to troubleshoot No Feedback Loop

6 Health Model “What is not working and how bad is it?” How to Detect something is wrong How to Correct problem Realized through Instrumentation Events Performance Counters WMI

7 Windows Management Tools Event Viewer Performance Monitor Group Policy Management Console (GPMC) Windows PowerShell Microsoft Management Console (MMC) Snapins Scripting solutions Windows PowerShell Enterprise Scale Tools System Center

8 Online Offline Failed Performance Problem Dependency Problem Other Problem Security Problem Integrity Problem Started (All processes started) Stopped (All processes stopped) Shut down (All processes killed) Failed (Event: Can’t recover can’t even stop) Problem Detected (Event: Database is not available) Recovered Successfully (Event: Database reconnection established) Degraded

9 WMI Provider WMI Events WMI Properties.NET Application EventsConfiguration Performance Counters & Diagnostics Event Logs (Application, User Defined) Performance Counters Debug Tracing

10 Register Event Log Source Write Event if(!EventLog.SourceExists(“Source”)) { EventLog.CreateEventSource(“Source”,”Log”); } if(EventLog.SourceExists(“Source”)) { EventLog myEventLog = new EventLog(); myEventLog.Source=“Source”; myEventLog.Log=“Application”; myEventLog.WriteEntry(“Event Message”, EventLogEntryType.Information, 1000, 45); myEventLog.dispose(); }

11 Create Event Class Derive from BaseEvent Fire the event public class CustomWmiEvent : BaseEvent { private string eventName; public string EventName { set { eventName = value; } } CustomWmiEvent wmiEvent = new CustomWmiEvent(); wmiEvent.Fire();

12 Why Use Windows Eventing 6.0? Better Performance Declarative Event Structure (Meta Data/Discovery) XML based Subscriptions Unified API for Eventing and Tracing Integration with Task Scheduler Any problems? No managed API… Yet… Really sorry… I mean it…

13 Install Counters if (PerformanceCounterCategory.Exists("MySampleCategory")) { PerformanceCounterCategory.Delete("MySampleCategory");} System.Diagnostics.CounterCreationDataCollection CounterDatas = new System.Diagnostics.CounterCreationDataCollection(); // Create the counters and set their properties. System.Diagnostics.CounterCreationData cdCounter1 = new System.Diagnostics.CounterCreationData(); cdCounter1.CounterName = "SimpleCount"; cdCounter1.CounterHelp = "Just a simple numerical count"; cdCounter1.CounterType = System.Diagnostics.PerformanceCounterType.NumberOfItems64; // Add both counters to the collection. CounterDatas.Add(cdCounter1); // Create the category and pass the collection to it. System.Diagnostics.PerformanceCounterCategory.Create("MySampleCategory", "My Sample Category Counters", CounterDatas);

14 Increment Data private PerformanceCounter _Counter1; … try { _Counter1 = new PerformanceCounter("MySampleCategory", "SimpleCount", false); } … if (_Counter1 != null) { _Counter1.Increment(); }

15

16 What is Windows PowerShell? Command Line Shell and Scripting Language Why use Windows PowerShell? A shell that knows.net! Makes ITPro’s and Developers talk the same language! Automates Bulk System Administration Tasks Help gain greater control of system Easy to build Custom Windows PowerShell Commands Easy to Provide GUI (via MMC or Windows Forms)

17

18 Steps to Building CmdLets 1. Download Windows PowerShell 2. Download the Visual Studio Template for Windows PowerShell http://channel9.msdn.com/ShowPost.aspx?PostID=256835 http://channel9.msdn.com/ShowPost.aspx?PostID=256835 3. Create a New Windows PowerShell Project 4. Complete the SnapIn Class Definition 5. Add Classes for your CmdLets 1. Add Attributes 2. Derive from PSCmdLet 3. Implement ProcessRecord 6. Build and Register 1. Use InstallUtil to “install” the snapin 7. Load Into PowerShell 1. Add-PsSnapIn

19

20 What is Microsoft Management Console 3.0? Provides a common administration GUI Why use Microsoft Management Console 3.0? Build administrative consoles Same technology Windows uses Consistent management experience for administrators Admin dudes love it!

21

22 Tree View Result Pane Action Pane Snap-in Node ViewDesc View Selected Data Action Verbs Nodes

23 Windows PowerShell Engine Custom Application Microsoft Management Console 3.0 PSObject Windows PowerShell Cmdlets Command Line GUI Layered Over Windows Forms Early Bound Objects Your Application To Manage

24

25 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "Mikael Deurell Senior Consultant Microsoft Mail: Blog: blogs.msdn.com/deurell."

Similar presentations


Ads by Google