none
View to show primary and failover management server

    Question

  • In Ops Mgr R2, is there a view that will show me the primary and secondary (failover) management server we have set for the agents?

    Thank you,
    Kate
    Wednesday, February 24, 2010 9:39 PM

Answers

  • Looks familiar.  :-)

    I have been meaning to post a blog on this topic.... but it is VERY dangerous because several of our customers have played with powershell here and not fully understood the ramifications.  You can orphan an agent to where it cannot communicate with ANY management server easily if you aren't fully aware understand all the ramifications of managing failover with powershell.

    That said:



    To see all agents reporting to a specific MS:  (I am just including all my management servers as an example – change to yours)

     

    get-agent | where {$_.PrimaryManagementServerName -eq "ms1.opsmgr.net"} | ft name

    get-agent | where {$_.PrimaryManagementServerName -eq "ms2.opsmgr.net"} | ft name

    get-agent | where {$_.PrimaryManagementServerName -eq "ms3.opsmgr.net"} | ft name

    get-agent | where {$_.PrimaryManagementServerName -eq "rms.opsmgr.net"} | ft name

     

     

    To see all possible failover MS's for an agent:

     

    Get-Agent | where {$_.PrincipalName -eq "fqdn-of-agent.domain.com"} | Get-FailoverManagementServer | ft name

     

     

    To set agents back to defaults  (allows all agents reporting to the given management server to fail over to any other MS)  In this example – I am taking all agents that are CURRENTLY assigned to “ms1” and setting their failover management server list to be ANY management server that is NOT “ms1”.  This is what you use once you have screwed up and orphaned agents.  :-)

     

    $agents = get-agent | where {$_.PrimaryManagementServerName -eq "ms1.opsmgr.net"}

    $pri = get-managementserver | where-object {$_.PrincipalName -eq "ms1.opsmgr.net"}

    $sec = get-managementserver | where-object {$_.PrincipalName -ne "ms1.opsmgr.net"}

    set-managementserver -agentmanagedcomputer $agents -primarymanagementserver $pri -failoverserver $sec

     

     

    To control failover of agents to a specific primary and a specific secondary:  (controlling agent>ms failover, and enabling gateway agents to know about their failover option)  This command specifally says.... "if you are assigned to ms1, then you can ONLY fail over to ms2"



    $agents = get-agent | where {$_.PrimaryManagementServerName -eq "ms1.opsmgr.net"}

    $pri = get-managementserver | where-object {$_.PrincipalName -eq "ms1.opsmgr.net"}

    $sec = get-managementserver | where-object {$_.PrincipalName -eq "ms2.opsmgr.net"}

    set-managementserver -agentmanagedcomputer $agents -primarymanagementserver $pri -failoverserver $sec


    Thursday, February 25, 2010 1:37 AM
    Moderator
  • Thank you Rob, Graham, and Kevin for the replies. 

    We currently have a powershell command we run to list primary/failover which I believe is working well:

    get-agent|ft -a name,primarymanagementservername,@{l="secondary";e={$_.getfailovermanagementservers()|foreach{$_.name}}}

    A view would be nice, if possible, but so far it sounds as though this information is not available from the console.

    Kevin brought up a good discussion.  In our environment, we have an rms, m1, m2 and a gw1 (gateway).  When installing agents, we install them with primary m1.  Once agent installation completes, we specifically set the failover to m2 by running:

    D:\Scripts\setfailover.ps1 -agentComputerName:'<mynewlyaddednode>.company.com'  -failoverManagementServerName:'m2.company.com'

    The thought here is to avoid failing over to the RMS in the case where m1 goes down.  From what we've read, it's best to avoid any agents reporting directly to the RMS.


    Our setfailover script is:

    -----------------------------------------------------------------------
    param($agentComputerName,$failoverManagementServerName)

    $agent = get-agent | where {$_.PrincipalName -eq $agentComputerName}

    $primaryManagementServer  = $agent.GetPrimaryManagementServer();

    if($primaryManagementServer -eq $null)
    {
    "Primary management server not found"
    return
    }


    $failoverManagementServer = Get-ManagementServer | where {$_.PrincipalName -eq $failoverManagementServerName}

    if($failoverManagementServer -eq $null)
    {
    "Failover management server not found"
    return
    }


    if($failoverManagementServer.PrincipalName -eq $primaryManagementServer.PrincipalName)
    {
    "The failover management server cannot be the same as the primary management server"
    return
    }


    $failoverServers = New-Object System.Collections.Generic.List``1"[[Microsoft.EnterpriseManagement.Administration.ManagementServer,Microsoft.EnterpriseManagement.OperationsManager,Version=6.0.4900.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35]]"

    $failoverServers.Add($failoverManagementServer)

    $agent.SetManagementServers($primaryManagementServer,$failoverServers)

    -----------------------------------------------------------------------

    I mentioned we have a gateway.  For installing those agents, we install the agent with primary being the gateway and do not do anything specific for setting the failover since there is just the one gateway in that domain.

    Kevin... do you see any concerns with our procedures?

    Thank you all for your thoughts and expertise.

    Kate 


    Thursday, February 25, 2010 3:48 PM
  • In Ops Mgr R2, is there a view that will show me the primary and secondary (failover) management server we have set for the agents?

    Thank you,
    Kate

    Just answering your initial question here to close the loop on this thread.

    get-agent | where {$_.name -match "[computer name]"} | select @{name="Primary";expression={$_.getPrimaryManagementServer().name}}, @{name="FailoverList";expression={$_.getFailoverManagementServers() | foreach-object {$_.name}}} | fl

    You could write in some sort of loop condition to output more than one agent at a time, but that's a starting point for you.
    HTH, Jonathan Almquist - MSFT
    Wednesday, March 10, 2010 1:05 AM
    Moderator

All replies

  • in adminstration you can see the primary ms. But i don't think you can see failover ms'.
    Rob Korving
    http://jama00.wordpress.com/
    Wednesday, February 24, 2010 9:44 PM
  • Hi Kate

    I seem to have picked the following powershell code up from somewhere.

    Cheers

    Graham

    To see all agents assigned to a specific MS:

    get-agent | where {$_.PrimaryManagementServerName -eq
    "fqdn-of-managementserver.domain.com"} | ft name


    To see all possible failover MS's for an agent:

    Get-Agent | where {$_.PrincipalName -eq "fqdn-of-agent.domain.com"} |
    Get-FailoverManagementServer | ft name


    View OpsMgr tips and tricks at http://systemcentersolutions.wordpress.com/
    Wednesday, February 24, 2010 10:45 PM
    Moderator
  • Looks familiar.  :-)

    I have been meaning to post a blog on this topic.... but it is VERY dangerous because several of our customers have played with powershell here and not fully understood the ramifications.  You can orphan an agent to where it cannot communicate with ANY management server easily if you aren't fully aware understand all the ramifications of managing failover with powershell.

    That said:



    To see all agents reporting to a specific MS:  (I am just including all my management servers as an example – change to yours)

     

    get-agent | where {$_.PrimaryManagementServerName -eq "ms1.opsmgr.net"} | ft name

    get-agent | where {$_.PrimaryManagementServerName -eq "ms2.opsmgr.net"} | ft name

    get-agent | where {$_.PrimaryManagementServerName -eq "ms3.opsmgr.net"} | ft name

    get-agent | where {$_.PrimaryManagementServerName -eq "rms.opsmgr.net"} | ft name

     

     

    To see all possible failover MS's for an agent:

     

    Get-Agent | where {$_.PrincipalName -eq "fqdn-of-agent.domain.com"} | Get-FailoverManagementServer | ft name

     

     

    To set agents back to defaults  (allows all agents reporting to the given management server to fail over to any other MS)  In this example – I am taking all agents that are CURRENTLY assigned to “ms1” and setting their failover management server list to be ANY management server that is NOT “ms1”.  This is what you use once you have screwed up and orphaned agents.  :-)

     

    $agents = get-agent | where {$_.PrimaryManagementServerName -eq "ms1.opsmgr.net"}

    $pri = get-managementserver | where-object {$_.PrincipalName -eq "ms1.opsmgr.net"}

    $sec = get-managementserver | where-object {$_.PrincipalName -ne "ms1.opsmgr.net"}

    set-managementserver -agentmanagedcomputer $agents -primarymanagementserver $pri -failoverserver $sec

     

     

    To control failover of agents to a specific primary and a specific secondary:  (controlling agent>ms failover, and enabling gateway agents to know about their failover option)  This command specifally says.... "if you are assigned to ms1, then you can ONLY fail over to ms2"



    $agents = get-agent | where {$_.PrimaryManagementServerName -eq "ms1.opsmgr.net"}

    $pri = get-managementserver | where-object {$_.PrincipalName -eq "ms1.opsmgr.net"}

    $sec = get-managementserver | where-object {$_.PrincipalName -eq "ms2.opsmgr.net"}

    set-managementserver -agentmanagedcomputer $agents -primarymanagementserver $pri -failoverserver $sec


    Thursday, February 25, 2010 1:37 AM
    Moderator
  • Thank you Rob, Graham, and Kevin for the replies. 

    We currently have a powershell command we run to list primary/failover which I believe is working well:

    get-agent|ft -a name,primarymanagementservername,@{l="secondary";e={$_.getfailovermanagementservers()|foreach{$_.name}}}

    A view would be nice, if possible, but so far it sounds as though this information is not available from the console.

    Kevin brought up a good discussion.  In our environment, we have an rms, m1, m2 and a gw1 (gateway).  When installing agents, we install them with primary m1.  Once agent installation completes, we specifically set the failover to m2 by running:

    D:\Scripts\setfailover.ps1 -agentComputerName:'<mynewlyaddednode>.company.com'  -failoverManagementServerName:'m2.company.com'

    The thought here is to avoid failing over to the RMS in the case where m1 goes down.  From what we've read, it's best to avoid any agents reporting directly to the RMS.


    Our setfailover script is:

    -----------------------------------------------------------------------
    param($agentComputerName,$failoverManagementServerName)

    $agent = get-agent | where {$_.PrincipalName -eq $agentComputerName}

    $primaryManagementServer  = $agent.GetPrimaryManagementServer();

    if($primaryManagementServer -eq $null)
    {
    "Primary management server not found"
    return
    }


    $failoverManagementServer = Get-ManagementServer | where {$_.PrincipalName -eq $failoverManagementServerName}

    if($failoverManagementServer -eq $null)
    {
    "Failover management server not found"
    return
    }


    if($failoverManagementServer.PrincipalName -eq $primaryManagementServer.PrincipalName)
    {
    "The failover management server cannot be the same as the primary management server"
    return
    }


    $failoverServers = New-Object System.Collections.Generic.List``1"[[Microsoft.EnterpriseManagement.Administration.ManagementServer,Microsoft.EnterpriseManagement.OperationsManager,Version=6.0.4900.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35]]"

    $failoverServers.Add($failoverManagementServer)

    $agent.SetManagementServers($primaryManagementServer,$failoverServers)

    -----------------------------------------------------------------------

    I mentioned we have a gateway.  For installing those agents, we install the agent with primary being the gateway and do not do anything specific for setting the failover since there is just the one gateway in that domain.

    Kevin... do you see any concerns with our procedures?

    Thank you all for your thoughts and expertise.

    Kate 


    Thursday, February 25, 2010 3:48 PM
  • ms1 has all directly connected agents.
    ms2 has the gateway.

    gateway and agents can failover to the other ms. I think that's the way i'd set it up, at least if it aren't too many agents.

    As for your script. i don't understand why you don't set the primairy ms1 by a script as well. Now you could forget to set an agent to ms1 and have the rms as primary instead and then add ms2 as failover. so basically kevin's last example only do $agents = get-agent | where {$_.PrincipalName -eq "fqdnofagent.youwant.toset"}


    Rob Korving
    http://jama00.wordpress.com/
    Thursday, February 25, 2010 6:27 PM
  • Rob...

    If I'm understanding correctly, are you suggesting using something similar to this:  http://jama00.wordpress.com/2009/11/27/setting-the-primary-management-server/  Will this posting work for us since we install all of our agents from the console?  Is it a better solution to load balance the agents between the two servers? 

    During the agent install, we specify MS1.  I guess that's why we have never specifically thought to set the primary.  If we accidentally installed an agent with the RMS as the primary and ran a script which sets primary to MS1 and failover to MS2, are there any issues with updating the primary to be a server other than the one used during the install?  If there's no issues, is that why you say why not set the primary as well?

    Thanks for the clarification.
    Kate
    • Proposed as answer by chaunteclear831 Thursday, December 23, 2010 3:48 PM
    Thursday, February 25, 2010 10:20 PM
  • Kate - your method sounds really good to me. 

    1.  It is good to keep agents from being assigned to, or failing over to - the RMS.  Check.
    2.  You set all agents to be assigned to MS1, and fail over to MS2.  You have redundancy.  Check.
    3.  It is bad to have agents and gateways reporting to the same MS.  You dont (unless there is a failover situation which isnt a big deal).  Check.

    As far as load balancing... in general this is fine to do.  In general - however - I dont recommend it.  Load balancing the MS can actually cause issues.... when people deploy too many management servers in a management group - then have LOTS of simultaneous writes all going to the DB.  I have seen environments where the DB was under pressure, and this was removed by moving agents to one or two MS.  The only time I load blanace agents between MS's is when there is a scale issue (too many agents).   In your case it would be bad to load blance - because you dont want gateways and agents reporting to the same OS all the time - this slows down config updates to agents behind the gateway.


    Sure - you could automate your script so it requires zero parameters or manual involvement... which would make your life a bit easier - but what you are doing is fine.

    It really isnt that big of a deal to control the agents of the RMS during a short-term failover situation, in smaller environments.... its only in the larger management groups with lots of agents and large instance spaces with an already stressed RMS where this can cause the RMS to not be able to handle the load.  If you have good hardware, no RMS issues, and under 500 agents... I wouldnt even sweat it.
    Thursday, February 25, 2010 10:41 PM
    Moderator
  • i wasn't suggesting our script at all. The reason why i didn't link it is because you have a gateway and we don't. And our mg is going to hold over 6,000 agents.
    like kevin said, i would just make life easier and set ms1 as primary and ms2 as failover (other way round for the gateway) by a script, since you do it the same way for all agents.
    Rob Korving
    http://jama00.wordpress.com/
    Friday, February 26, 2010 9:12 AM
  • Thanks Kevin and Rob.  Sounds like we are mostly on track.

    I just checked and unfortunately, my gw is set to primary M1 with no failover in one management group, and primary M1 / failover M2 in the other management group. 

    Based on the suggestions above, we should really have the gw reporting through M2, and set failover to M1. 

    I am considering running this for the gateway:

    $primaryMS = Get-ManagementServer | where {$_.Name -eq 'm2.company.com'}
    $failoverMS = Get-ManagementServer | where {$_.Name -eq 'm1.company.com'}
    $gatewayMS = Get-GatewayManagementServer | where {$_.Name -eq 'gw1.companydomain.com'}
    Set-ManagementServer -GatewayManagementServer: $gatewayMS -primarymanagementserver: $primaryMS -FailoverServer: $failoverMS

    This kind-of goes along with the question of... are there any issues with updating the primary to be a server other than the one used during the install?  I just want to make sure this is supported for a regular agent and for the gateway server itself.

    Thanks,
    Kate
    Friday, February 26, 2010 9:48 PM
  • Thanks Kevin and Rob.  Sounds like we are mostly on track.

    I just checked and unfortunately, my gw is set to primary M1 with no failover in one management group, and primary M1 / failover M2 in the other management group. 

    Based on the suggestions above, we should really have the gw reporting through M2, and set failover to M1. 

    I am considering running this for the gateway:

    $primaryMS = Get-ManagementServer | where {$_.Name -eq 'm2.company.com'}
    $failoverMS = Get-ManagementServer | where {$_.Name -eq 'm1.company.com'}
    $gatewayMS = Get-GatewayManagementServer | where {$_.Name -eq 'gw1.companydomain.com'}
    Set-ManagementServer -GatewayManagementServer: $gatewayMS -primarymanagementserver: $primaryMS -FailoverServer: $failoverMS

    This kind-of goes along with the question of... are there any issues with updating the primary to be a server other than the one used during the install?  I just want to make sure this is supported for a regular agent and for the gateway server itself.

    Thanks,
    Kate
    Yes, it's supported.

    HTH, Jonathan Almquist - MSFT
    Saturday, February 27, 2010 5:49 PM
    Moderator
  • In Ops Mgr R2, is there a view that will show me the primary and secondary (failover) management server we have set for the agents?

    Thank you,
    Kate

    Just answering your initial question here to close the loop on this thread.

    get-agent | where {$_.name -match "[computer name]"} | select @{name="Primary";expression={$_.getPrimaryManagementServer().name}}, @{name="FailoverList";expression={$_.getFailoverManagementServers() | foreach-object {$_.name}}} | fl

    You could write in some sort of loop condition to output more than one agent at a time, but that's a starting point for you.
    HTH, Jonathan Almquist - MSFT
    Wednesday, March 10, 2010 1:05 AM
    Moderator
  • Is there a command that will also show which UNIX machines report to which MS?  I noticed the get-agent commands above only return Windows machines.
    Monday, August 22, 2011 7:47 PM
  • I have bee looking for this as well and have been unable to find anyone who has come up with a script for unix
    Wednesday, September 21, 2011 3:59 PM