The Operations Manager class libraries allow you to query and change many of the default Management Group settings.
Example
The following example demonstrates how to display the default heartbeat interval for all agent-managed computers in the Management Group. The example then changes the default interval to a new value.
| Visual Basic | Copy Code |
|---|---|
' Displays the current default agent heartbeat interval,
' and then changes the interval to 50 seconds.
Imports System
Imports System.Collections.Generic
Imports Microsoft.EnterpriseManagement
Imports Microsoft.EnterpriseManagement.Administration
Imports System.Text
Namespace SDKSamples
Class Program
Public Overloads Shared Function Main(ByVal args() As String) As Integer
Dim mg As New ManagementGroup("localhost")
Console.WriteLine("Configuring Management Group properties...")
Dim mga As ManagementGroupAdministration = mg.GetAdministration()
Console.WriteLine("The heartbeat interval is currently: " & _
mga.Settings.GetDefaultValue(Settings.Agent.Heartbeats.Interval).ToString())
mga.Settings.SetDefaultValue(Of Integer)(Settings.Agent.Heartbeats.Interval, 50)
' need to call ApplyChanges to save the changes.
'mga.Settings.ApplyChanges();
Console.WriteLine("Agent heartbeat interval has now been set to: " & _
mga.Settings.GetDefaultValue(Settings.Agent.Heartbeats.Interval).ToString())
End Function 'Main
End Class 'Program
End Namespace 'SDKSamples
|
|
| C# | Copy Code |
|---|---|
/// <summary>
/// Displays the current default agent heartbeat interval,
/// and then changes the interval to 50 seconds.
/// </summary>
using System;
using System.Collections.Generic;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Administration;
using System.Text;
namespace SDKSamples
{
class Program
{
static void Main(string[] args)
{
ManagementGroup mg = new ManagementGroup("localhost");
Console.WriteLine("Configuring Management Group properties...");
ManagementGroupAdministration mga = mg.GetAdministration();
Console.WriteLine("The heartbeat interval is currently: "
+ mga.Settings.GetDefaultValue(Settings.Agent.Heartbeats.Interval));
mga.Settings.SetDefaultValue<int>(Settings.Agent.Heartbeats.Interval,
50);
// need to call ApplyChanges to save the changes.
//mga.Settings.ApplyChanges();
Console.WriteLine("Agent heartbeat interval has now been set to: " +
mga.Settings.GetDefaultValue(Settings.Agent.Heartbeats.Interval));
}
}
}
|
|
See Also
Tasks
How to Display Management Pack ContentsOther Resources
Automating Operations Manager AdministrationSend comments about this topic to Microsoft.
