Assembly: Microsoft.EnterpriseManagement.OperationsManager (in microsoft.enterprisemanagement.operationsmanager.dll)
Usage
| Visual Basic |
|---|
Dim instance As AgentManagedComputer |
Syntax
| Visual Basic |
|---|
<SerializableAttribute> _ Public Class AgentManagedComputer Inherits ComputerHealthService |
| C# |
|---|
[SerializableAttribute] public class AgentManagedComputer : ComputerHealthService |
| C++ |
|---|
[SerializableAttribute] public ref class AgentManagedComputer : public ComputerHealthService |
| J# |
|---|
/** @attribute SerializableAttribute() */ public class AgentManagedComputer extends ComputerHealthService |
| JScript |
|---|
SerializableAttribute public class AgentManagedComputer extends ComputerHealthService |
Example
The following example shows how to obtain information about an agent-managed computer. In this example, mg is a ManagementGroup instance and agentFqdn is the fully qualified domain name of the agent-managed computer from which you want to obtain information.
| C# | Copy Code |
|---|---|
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Administration;
using Microsoft.EnterpriseManagement.Common;
using Microsoft.EnterpriseManagement.Configuration;
using Microsoft.EnterpriseManagement.Monitoring;
using System.Text;
namespace SDKSamples
{
class Program
{
static void Main(string[] args)
{
try
{
ManagementGroup mg = new ManagementGroup("localhost");
ManagementGroupAdministration admin = mg.GetAdministration();
string agentFqdn = "AgentFullyQualifiedDomainName";
AgentManagedComputerCriteria agentCriteria = new AgentManagedComputerCriteria("Name = '" + agentFqdn + "'");
//Get the agent-managed computer with the specified FQDN.
ReadOnlyCollection<AgentManagedComputer> agents = admin.GetAgentManagedComputers(agentCriteria);
//Make sure one computer is returned
if (agents.Count > 1 || agents.Count < 1)
{
throw new Exception("Expected one computer with the given FQDN");
}
//Display the name of the computer, its primary management server
//and any failover servers.
foreach (AgentManagedComputer agent in agents)
{
Console.WriteLine("Computer name: " + agent.ComputerName);
Console.WriteLine("Primary management server: " + agent.PrimaryManagementServerName);
Console.WriteLine("Failover servers: ");
ReadOnlyCollection<ManagementServer> servers = agent.GetFailoverManagementServers();
if (servers.Count > 0)
{
foreach (ManagementServer server in servers)
{
Console.WriteLine(server.PrincipalName);
}
}
else
{
Console.WriteLine("No failover servers assigned.");
}
}
}
catch (Exception e)
{
Console.WriteLine("Could not display agent information. " + e.Message);
}
}
}
}
|
|
Remarks
You can get a collection of the agent-managed computers in a Management Group by using GetAgentManagedComputers.
You can get a collection of agent-managed computers that are managed by a specific server by using GetAgentManagedComputers.
Inheritance
Hierarchy
System.Object
Microsoft.EnterpriseManagement.Common.MonitoringBase
Microsoft.EnterpriseManagement.Administration.ComputerHealthService
Microsoft.EnterpriseManagement.Administration.AgentManagedComputer
Microsoft.EnterpriseManagement.Common.MonitoringBase
Microsoft.EnterpriseManagement.Administration.ComputerHealthService
Microsoft.EnterpriseManagement.Administration.AgentManagedComputer
Thread Safety
Any public static (Shared in Visual
Basic) members of this type are thread safe. Any instance members
are not guaranteed to be thread safe.


