1 / 8

SCOM 2007 Development

SCOM 2007 Development. Wei Wang Consultant MCS. SCOM SDK. Assembly.

china
Télécharger la présentation

SCOM 2007 Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SCOM 2007 Development Wei Wang Consultant MCS

  2. SCOM SDK

  3. Assembly • Each Management Group contains a Root Management Server, which hosts an SDK Service. The SDK Service is a Windows service that processes all external requests to access Operations Manager features and data. To access Operations Manager functionality, an application must connect as a client to the SDK Service. Operations Manager provides two .NET managed code libraries that you can use to connect to the SDK Service, perform Operations Manager functions, and access Operations Manager data. These libraries are: • Microsoft.EnterpriseManagement.OperationsManager.dll • Microsoft.EnterpriseManagement.OperationsManager.Common.dll

  4. SCOM Connection SecureString password = new SecureString(); foreach (Char pwdChar in userPassword.ToCharArray()) { password.AppendChar(pwdChar); } try { ManagementGroupConnectionSettings mgSettings = new ManagementGroupConnectionSettings(server); mgSettings.UserName = name; mgSettings.Domain = userDomain; mgSettings.Password = password; richTextBox1.Text += "Connecting to the SDK Service as user: " + name + "\r\n"; ManagementGroup mg = ManagementGroup.Connect(mgSettings); if (mg.IsConnected) { richTextBox1.Text += "Connection succeeded.\r\n"; return mg; } else { throw new InvalidOperationException("Not connected to an SDK Service."); } } catch (Exception ex) { richTextBox1.Text += "\nConnection failed. " + ex.Message + "\r\n"; if (ex.InnerException != null) { richTextBox1.Text += ex.InnerException.Message + "\r\n"; } }

  5. Get MonitoringObject ManagementGroup mg = ConnectScom(serverName, name, userDomain, userPassword); // The criteria specifies that you want to collect computers running Windows Server 2003. MonitoringClassCriteria classCriteria = new MonitoringClassCriteria("Name = 'Microsoft.Windows.Server.2003.Computer'"); richTextBox1.Text += "Querying for data...\r\n"; // There should only be one item in the monitoringClasses collection. ReadOnlyCollection<MonitoringClass> monitoringClasses = mg.GetMonitoringClasses(classCriteria); if (monitoringClasses.Count > 0) { // Get all instances of computers running Windows Server 2003 in the management group. ReadOnlyCollection<MonitoringObject> monitoringObjects = mg.GetMonitoringObjects(monitoringClasses[0]); if (monitoringObjects.Count > 0) { richTextBox1.Text += "Monitoring Object name: " + monitoringObjects[0].DisplayName + "\r\n"; DisplayHierarchyInformation(monitoringObjects[0]); DisplayPerformanceData(monitoringObjects[0]); DisplayPropertyValues(monitoringObjects[0]); DisplayRelationshipInformation(monitoringObjects[0]); DisplayRelatedObjects(monitoringObjects[0]); DisplayMonitoringStateHierarchy(monitoringObjects[0]); } else { richTextBox1.Text += "MonitoringObjects count=0. \r\n"; } } else { richTextBox1.Text += "MonitoringClasses count=0. \r\n"; }

  6. Get Monitoring Object Property void DisplayPropertyValues(MonitoringObject mObject) { richTextBox1.Text += "Property value information: \r\n"; foreach (MonitoringClassProperty property in mObject.GetMonitoringProperties()) { richTextBox1.Text += " " + property.Name + " = " + mObject.GetMonitoringPropertyValue(property) + "\r\n"; } }

  7. Get MonitoringObject Hierarchy //--------------------------------------------------------------------------------- // Get the monitoring hierarchy and display information about the hierarchy. void DisplayHierarchyInformation(MonitoringObject mObject) { MonitoringHierarchyNode<ManagementPackMonitor> hierarchy = mObject.GetMonitorHierarchy(); richTextBox1.Text += "Monitoring hierarchy: \r\n"; // Parent node information. if (hierarchy.ParentNode != null) { richTextBox1.Text += " Parent node: " + hierarchy.ParentNode.Item.DisplayName + "\r\n"; } else { richTextBox1.Text += " No parent node.\r\n"; } // Child node information. if (hierarchy.TotalChildNodeCount > 0) { richTextBox1.Text += " Child nodes: \r\n"; foreach (MonitoringHierarchyNode<ManagementPackMonitor> child in hierarchy.ChildNodes) { richTextBox1.Text += " " + child.Item.DisplayName + "\r\n"; } } else { richTextBox1.Text += " No child nodes available.\r\n"; } }

  8. Q&A Thanks!

More Related