Pushing the Envelope;.NET Code in SCOM Management Packs Nathan Jonathan

Slides:



Advertisements
Similar presentations
Designing, Deploying and Managing Workflow in SharePoint Sites Steve Heaney Product Development Manager OBS
Advertisements

Module 4: Deploying and Managing BizTalk Applications
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Introducing the Common Language Runtime for.NET. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution.
Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – @david_Obrien.
Introducing the Common Language Runtime. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution engine.
Your CMDB and PowerShell DSC: DevOps Techniques
Using Microsoft SharePoint to Develop Workflow and Business Process Automation Ted Perrotte National Practice Manager, Quilogy, Microsoft Office SharePoint.
Momentum 2009 Spyder® for Plant Control John Hutchey – Lou Jones.
Module 7: Object-Oriented Programming in Visual Basic .NET
An Object-Oriented Approach to Programming Logic and Design
Developing Workflows with SharePoint Designer David Coe Application Development Consultant Microsoft Corporation.
AUTOBUILD Build and Deployment Automation Solution.
PowerShell DSC v. ConfigMgr Compliance Settings MMS Minnesota 2014 Greg Ramsey David O’Brien Sherry Kissinger #MMSMinnesota.
SCORCH – Fun Recipes for RunBooks MMS Minnesota 2014 Steve Jesok & Matthew #MMSSCOrch.
Service Models in SCOM with VSAE examples
Advanced MP Authoring and Design Getting outside of the wizard and into the MP code with VSAE MMS Minnesota 2014 Nathan Foreman Jonathan Almquist #MMSSCOM.
How Java becomes agile riding Rhino Xavier Casellato VP of engineering, Liligo.com.
Leveraging.NET in SalesLogix Building Customizations in.NET for your Current Version of SalesLogix and a Look at the Future Ryan Farley Customer FX Corporation.
Microsoft SharePoint Server 2010 for the Microsoft ASP.NET Developer Yaroslav Pentsarskyy
Microsoft Tech Days 2012 Cheezia: Developing a Windows Phone XNA Game Rodrigo Barretto Software Engineer - MCPD on Windows Phone
Sage ACT! 2013 SDK Update Brian P. Mowka March 23, 2012 Template date: October 2010.
Singleton and Basic UML CS340100, NTHU Yoshi. What is UML Unified Modeling Language A standardized general-purpose modeling language in the field of software.
Synchronized and Monitors. synchronized is a Java keyword to denote a block of code which must be executed atomically (uninterrupted). It can be applied.
1 Program5 Due Friday, March Prog4 user_thread... amount = … invoke delegate transact (amount)... mainThread... Total + = amount … user_thread...
(c) University of Washington15-1 CSC 143 Java List Implementation via Arrays Reading: 13.
Enterprise Library Extensibility Brian Button VP of Engineering Asynchrony Solutions, Inc.
Running Kuali: A Technical Perspective Ailish Byrne (Indiana University) Jonathan Keller (University of California, Davis)
The Singleton Pattern SE-2811 Dr. Mark L. Hornick 1.
End to End Automation with MDT Managing your reference images. Fred om Daniel
Service Management Automation: 3,2,1, Automate!
Windows 10 Setup InternalsWindows 10 Setup Internals Johan
Are you Ready for Configuration Manager vNext?
PowerShell Package Management for the Enterprise Kirk Aleksandar
Windows 10 Feature & Servicing Updates Options and Demystifying Steven Rachui
Define, bundle, deployDefine, bundle, deploy Working with Windows Server Containers and Docker James David O’Brien.
ConfigMgr! Intune! Azure!ConfigMgr! Intune! Azure! Understanding Cloud Based Management Options Steven Rachui
Monitoring and Managing the Hybrid Cloud with System Center
Managing Third Party Updates with Microsoft’s System Center Configuration Manager Secunia Integration, MMS 2015 Kent AgerlundSherry Kissinger.
Threads and Singleton. Threads  The JVM allows multiple “threads of execution”  Essentially separate programs running concurrently in one memory space.
Nano ServerNano Server The Future of Window Server Mikael Johan
House of tails dogs charity All donations go 100% to the charity #MMSGIVEBACK.
Managing iOS Device Using ConfigMgr and Intune Hybrid MDM John Presenter #2 Twitter Handle Blog or address.
Critical Security Controls & Effective Cyber Defense Hasain “The Wolf”
Automating Reference ImagesAutomating Reference Images Henrik Blog.coretech.dk/hra Kent Blog.coretech.dk/kea.
How to Model an Application for Monitoring Nathan Jonathan
Introduction to Administering a SQL Server Matthew Steve Thompson, stevethompsonmvp.wordpress.com.
The Art of deploying Windows 10 With ConfigMgr 2012 R2 Johan Mikael
XPlatform ManagementxPlatform Management Windows Provisioning from *nix David James.
Midwest Management Summit MMSSQL – What are Your SQL Reporting Questions? #MMSMinnesot a #MMSSQL.
04 |Sharing Code Between Windows 8 and Windows Phone 8 in Visual Studio Ben Riga
ConfigMgr 2012 SQL Refresher MMS Minnesota 2014 Matthew Teegarden/Steve Thompson.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Introduction to T-SQL – Part Deux Matthew Sherry Kissinger kissinger.
OS Deployment - LEVEL 500OS Deployment - LEVEL 500 Johan
App-V: An Overview MMS Minnesota 2014 Fred #MMSMinnesota #MMSAppV.
Server OS Deployment Deep Dive with two crazy guys and ConfigMgr 2012 R2 MMS Minnesota 2014 Greg Nash.
Workflow in Microsoft Office SharePoint Server Jessica Gruber Consultant Microsoft Corporation.
SQL Tips & Tricks Best practices from the field John Nelson Apps Systems Engineer Steve Thompson Senior Consultant,
Concurrent Programming in Java Based on Notes by J. Johns (based on Java in a Nutshell, Learning Java) Also Java Tutorial, Concurrent Programming in Java.
Developing Custom ASP.NET Providers For Membership And Role Manager Stefan Schackow PRS404 Program Manager – Web Platform and Tools Microsoft Corporation.
2.2 Threads  Process: address space + code execution  There is no law that states that a process cannot have more than one “line” of execution.  Threads:
Long Live Azure Automation!Long Live Azure Automation! Cloud-first Configuration Management and Automation Beth Cooper Program Manager.
SCOM and OMS a Love Story
The Singleton Pattern SE-2811 Dr. Mark L. Hornick.
Using FileTables Sam Nasr, MCAD, MCTS, MVP NIS Technologies
Microsoft Connect /17/ :55 PM
Your code is not just…your code
CS510 Operating System Foundations
Keeping ConfigMgr Clean
Presentation transcript:

Pushing the Envelope;.NET Code in SCOM Management Packs Nathan Jonathan

Solutions Engineer Practice2Perfect.com 10+ years in IT Nathan Foreman

Consultant, blogger, author, speaker TechNet Forum Blogging since years experience in IT, past 10 years focused on Operations Manager Jonathan Almquist

Overview and Agenda Theory Why.NET? What’s.Net Modules Pros (& Cons) Functionality Microsoft Examples Elastic Search DW Development Concepts Threading Batching Persistence Acknowledgments/Notification s Module Lifecycle Implementation Making the Library (.dll) Create VS Project Signing the Builds References Class Construction Required Methods SyncLock Data & Control Flow Get the Module in SCOM Create Library MP Add Deployable Assembly Create & Use Module

Why.NET?Why.NET? It’s not quicker or easier, so what can we gain by going this route?

What are.NET modules? One of three Module Implementation [3,4] Native Managed Composite They’ve been around for a while SCOM 2007 [4] “Creation or modification of native modules and managed modules is not supported...” SCOM 2012 [5] Only create them, when provided modules “are insufficient for your needs”

Advantages Persisted State Compiled.NET code can work faster [1] Harder to Tamper/Reverse Engineer Full Featured IDE Leverage.NET Coding Professionals Disadvantages More Complicated than Scripted Alternatives Additional Knowledge required to write Code Requires additional Steps for Distribution Updates to Code take longer to deploy than scripts. Why.NET? – Pros and Cons

Functionality & Examples Microsoft Examples PowershellProbeBase PowershellProbe PowershellDiscoveryProbeBa se PowershellDiscoveryProbe SystemCenter.GroupPopulat or SystemCenter.EventWriter.DiscoveryDataWriter.PerformanceDataWriter Elastic Search DW High Speed Logging 4,000 items Per Second Perf Collection Every 2 Seconds Reduce Database Size Smaller OpsDB Extended DW Retention Fast Searching and Reporting

Demo.NET Elastic Search DW (Frontend)

Development ConceptsDevelopment Concepts To get the most from your.NET modules there are a few things to keep in mind. Design and Development notes from Microsoft:

Development Concepts Threading Not a Unique concern to.NET Health Service is a Shared Environment IO Bound: Use Async Methods CPU Bound: Perform work Synchronously Batching [6] Allows Multiple Items per Execution Not relevant for composite module types Consolidation Modules with multiple Items

Development Concepts Persistence Save State between Executions Module Host handles data Cleared on Module Change Acknowledgments Transactional Data Flow not Supported [5] Responsible until Acknowledgment Completion Notifications Notifies Health Service work is Complete Must Notify Completion before next Request

Development Concepts Startup and Shutdown Constructor Start Called After Constructor Completes Must be Thread Safe with NotifyStop NotifyStop Notifies of a graceful shutdown Shutdown About to be Unloaded, time to save State Engine may Unload without Notice Module must not corrupt threads

Making the LibraryMaking the Library Implementation is where the fun really is.

New Visual Studio Project Create a Class Library Project Sign the Build Set the Namespace Strong Named Assemblies Required us/library/ms227566(v=vs.80).aspx Handle Required References Are they on the Target? Embed Resources you may Need Embedded-Resource

Class Definition Attributes MonitoringModule(ModuleType.WriteAction) ModuleOutput (True/False) Inherits ModuleBase Of DataItemBase Global Variables SyncLock Object Shutdown in Progress Boolean

[MonitoringModule(ModuleType.WriteAction)] [ModuleOutput(false)] public sealed class WriteToES : ModuleBase { //Shared objects, accessible from all instances static P2PLogging Logger; static bool ShutdownInProgress; //Global object, controls activity via SyncLocks private object shutdownLock; //Making Global, reducing instantiation cost private ElasticSearchConnector ESConnector; private DataItemProcessor DataItemCollection; _ Public NotInheritable Class WriteToES 'Inherit the ModuleBase we will be working off of Inherits ModuleBase(Of DataItemBase) 'Shared objects are accessible from all instances Shared Logger As P2PLogging Shared ShutdownInProgress As Boolean 'Global object, controls activity via SyncLocks Private shutdownLock As Object 'Making Global, reducing instantiation cost Private ESConnector As ElasticSearchConnector Private DataItemCollection As DataItemProcessor Class Construction: Code VB.NETC# VB.NE T

Required Methods - New Signature moduleHost As ModuleHost(Of DataItemBase) configuration As XmlReader previousState As Byte() Setup your Module Logging Libraries Configuration Parsing

public WriteToES(ModuleHost moduleHost, XmlReader configuration, byte[] previousState) : base(moduleHost) { //Verify we Have everything we need if (configuration == null) { throw (new Exception("configuration is nothing")); } //Add the Additional Libraries to our instantiation LibraryLoader LibraryLoader = new LibraryLoader(Assembly.GetExecutingAssembly(), false); LibraryLoader.LoadLibrariesFromResources(); //Extract from Config what we need and initiate the connections. ParsedConfigData InstanceConfig = new ParsedConfigData(); InstanceConfig = ExtractConfigData(configuration); //Create the Classes we will use throughout the life of this module Logger = new P2PLogging(); DataItemCollection = new DataItemProcessor(Logger); shutdownLock = new object(); Public Sub New(moduleHost As ModuleHost(Of DataItemBase), configuration As XmlReader, previousState As Byte()) 'Call the Base Constructor MyBase.New(moduleHost) 'Verify we Have everything we need If configuration Is Nothing Then Throw New Exception("configuration is nothing") 'Add the Additional Libraries to our instantiation Dim LibraryLoader As New LibraryLoader(Assembly.GetExecutingAssembly(), False) LibraryLoader.LoadLibrariesFromResources() 'Extract from Config what we need and initiate the connections. Dim InstanceConfig As ParsedConfigData InstanceConfig = ExtractConfigData(configuration) 'Create the Classes we will use throughout the life of this module Logger = New P2PLogging DataItemCollection = New DataItemProcessor(Logger) shutdownLock = New Object() New Method: Code VB.NETC# VB.NE T

Required Methods - Start Empty Signature Check for Shutdown Lock ModuleHost.RequestNextDataItem()

public override void Start() { lock(shutdownLock) { //We don't need to continue if Shutdowns are starting. if (ShutdownInProgress) { return ; } //Request the first data batch. //The ME keyword unambiguously refers to this instance this.ModuleHost.RequestNextDataItem(); } Public Overrides Sub Start() SyncLock shutdownLock 'We don't need to continue if Shutdowns are starting. If ShutdownInProgress Then Return End If 'Request the first data batch. 'The ME keyword unambiguously refers to this instance Me.ModuleHost.RequestNextDataItem() End SyncLock End Sub Start Method: Code VB.NETC# VB.NE T

Required Methods - OnNewDataItems Denote Input Stream Number [InputStream(0)] Signature dataItems As DataItemBase() logicallyGrouped As Boolean acknowledgedCallback As DataItemAcknowledgementCallback acknowledgedState As Object completionCallback As DataItemProcessingCompleteCallback completionState As Object Do work with the DataItems() Lock ModuleHost.RequestNextDataItem()

[InputStream(0)] public void OnNewDataItems(DataItemBase[] dataItems, bool logicallyGrouped, DataItemAcknowledgementCallback acknowledgedCallback, object acknowledgedState, DataItemProcessingCompleteCallback completionCallback, object completionState) { // If we have been shutdown stop processing. if (ShutdownInProgress) { Logger.WriteInformation("Shutdown in Progress"); return ; } // This is where you will do your work, code has been removed for Space lock(shutdownLock) { this.ModuleHost.RequestNextDataItem(); } _ Public Sub OnNewDataItems(dataItems As DataItemBase(), logicallyGrouped As Boolean, acknowledgedCallback As DataItemAcknowledgementCallback, acknowledgedState As Object, completionCallback As DataItemProcessingCompleteCallback, completionState As Object) ' If we have been shutdown stop processing. If ShutdownInProgress Then Logger.WriteInformation("Shutdown in Progress") Return End If ' This is where you will perform you work with the DataItems() SyncLock shutdownLock Me.ModuleHost.RequestNextDataItem() End SyncLock End Sub OnNewDataItems Method: Code VB.NETC# VB.NE T

Required Methods - Shutdown Empty Signature Lock Mark Global Shutdown in Progress Cleanup as Needed Finalize()

public override void Shutdown() { //Lock to prevent other operations during Shutdown lock(shutdownLock) { ShutdownInProgress = true; //Cleanup Here } Public Overrides Sub Shutdown() 'Lock to prevent other operations during Shutdown SyncLock shutdownLock ShutdownInProgress = True Me.Finalize() End SyncLock End Sub Shutdown Method: Code VB.NETC# VB.NE T

Getting The Module in SCOMGetting The Module in SCOM It’s time to get back into familiar territory

Creating a Library Management Pack DeployableAssembly Fully Qualified Assembly Name <DeployableAssembly ID="P2P.ManagedScomModules" Accessibility="Public" FileName="ManagedSCOMModules.dll" HasNullStream="false" QualifiedName="ManagedSCOMModules, Version= , Culture=neutral, PublicKeyToken=d49ecc768c087c65"/> DLL in Management Pack Project Set Build Action = Embedded Resource

Create the Write Action Module P2P.ManagedScomModules ManagedSCOMModules.WriteToES System!System.BaseData

Create a Pack with Actions PerformanceCollection. % Processor Time Process true 2 SCOMWinEvents SCOMDataItems true

Demo Putting Everything Together.

References 1. performance-comparison-compiled-code-cmdlet-or-net- callhttp://leporelo.eu/blog.aspx?id=powershell- performance-comparison-compiled-code-cmdlet-or-net- call 2. us/library/7k989cfy(v=vs.90).aspxhttps://msdn.microsoft.com/en- us/library/7k989cfy(v=vs.90).aspx operations-manager-management-pack- authoring-module-implementations.aspxhttp://social.technet.microsoft.com/wiki/contents/articles/ operations-manager-management-pack- authoring-module-implementations.aspx 4. us/library/ff aspxhttps://technet.microsoft.com/en- us/library/ff aspx module-to-rule-them-all-a-custom-scom-managed- module-sysctr/ module-to-rule-them-all-a-custom-scom-managed- module-sysctr/

Evaluations: Please provide session feedback by clicking the EVAL button in the scheduler app (also download slides). One lucky winner will receive a free ticket to the next MMS! Session Title: Pushing the Envelope;.NET Code in SCOM Management Packs Discuss… Ask your questions-real world answers! Plenty of time to engage, share knowledge. SPONSORS