opserver / Opserver

Stack Exchange's Monitoring System
https://opserver.github.io/Opserver/
MIT License
4.5k stars 823 forks source link

State and Votes columns in SQL dashboard are empty #351

Open 0UserName opened 4 years ago

0UserName commented 4 years ago

I have WSFC clusters with multiple AG as resources. The following snippet is an example of my Opserver configuration:

{
   "defaultConnectionString":"Application Name=opserver;Data Source=$ServerName$;Initial Catalog=master;User ID=USER;Password=PASS",
   "clusters":[
      {
         "name":"P001 Cluster",
         "nodes":[
            {
               "name":"P001-A" # listener 
            },
            {
               "name":"P001-B" # listener 
            },
            {
               "name":"P001-C" # listener 
            }
         ]
      },
      {
         "name":"S001 Cluster",
         "nodes":[
            {
               "name":"S001-A" # listener 
            },
            {
               "name":"S001-B" # listener 
            },
            {
               "name":"S001-C" # listener 
            }
         ]
      }
   ]
}

But with the configuration described, I get the following result:

dashboard

If go deeper into the source code, we will find the following code:

foreach (var m in state.Members)
{
    m.IsLocal = string.Equals(m.MemberName, ServerProperties.Data?.ServerName, StringComparison.InvariantCultureIgnoreCase);
}

Something like that: {{machine}} == {{machine}}+{{instance}}. All elements will have the IsLocal property, evaluated to false.

The MemberName property of theAGClusterMemberInfo class is mapped to the member_name column:

SELECT member_name            MemberName,
       member_type            Type,
       member_state           State,
       number_of_quorum_votes Votes
FROM   sys.dm_hadr_cluster_members;  

Then the following method is called:

public AGClusterMemberInfo AGClusterMember =>
    AGClusterInfo.Data?.Members.Find(c => c.IsLocal) ?? new AGClusterMemberInfo();

If the IsLocal property is false, the default object will be returned - State and Votes columns will are empty on SQL dashboard.


If I change the code above to:

foreach (var m in state.Members)
{
    m.IsLocal = string.Equals(m.MemberName, ServerProperties.Data?.MachineName, StringComparison.InvariantCultureIgnoreCase);
} 

Everything works fine, anyway for my configuration.

dashboard

But I'm not sure about this approach. Maybe I misconfigured Opserver? Or is there really an mistake?

0UserName commented 4 years ago

I think using named instances is expected, but using listeners also works, except for showing details by nodes in sql/servers in GetAvailabilityGroups.

@NickCraver, what do you think about using listeners with some limitation? I mean the availability of data only from primary replicas.


I added small changes in PR.

Before: before_0 before_1 before_2

After: after_0 after_1 after_2

0UserName commented 4 years ago

Is it possible get feedback?