WMI Adapter

Last Updated On October 15, 2018
You are here:

Overview

This adapter collects values of Windows performance counters when enabled in Sonar monitoring agent for following scenarios with Windows OS version 2008 R2 or above:

  • Servers
  • Windows containers with Hyper-v or process isolation
  • Virtual machines

Configuration

This adapter can be configured in two ways: legacy using Server element and just connection string. To configure adapter, modify Sonar configuration file as follows:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="Sonar" type="Infragravity.Sonar.SonarConfigurationSection, Sonar"/>
  </configSections>
  <connectionStrings>
    <add name="local" providerName="wsman" connectionString="Server=sonar;" />
    <add name="influxdb-udp" providerName="output-influxdb-udp" connectionString="Data Source = udp://host:8092;Initial Catalog=sonar;User Id =; Password =; Application Name = default;Max Pool Size=100;Packet Size=1200;Connection Timeout=10;Flush Timeout=10;"/>
  </connectionStrings>
  <Sonar>
    <Runtime scrapeIntervalSeconds="5" skipSSLCheck="true" threads="1"/>
    <InputAdapters>
      <add provider="wsman" type="Infragravity.Sonar.Adapters.WsMan.WsmanAdapterFactory,Sonar" />
    </InputAdapters>
    <OutputAdapters>
      <add provider="output-influxdb-udp" type="Infragravity.Sonar.Adapters.InfluxDb.Udp.OutputAdapterFactory,Infragravity.Sonar.Adapters.InfluxDb" />
    </OutputAdapters>
    <Arrays>
      <add name="btswin_evlog" array="mslog-basic.sonar.config" input="local" intervalSeconds="15" output="influxdb-udp" />  
    </Arrays>
    <Schedules/>
    <Servers>
      <add name="sonar" url="http://localhost:5985/wsman" username="" password="" timeoutMilliseconds="1000" authType="Negotiate"/>  
    </Servers>
    <Queries/>
  </Sonar>
 </configuration>

Configuring WinRM

The access to WS-Management endpoint can be enabled using HTTPS or HTTP protocols. Sonar monitoring agent can gather metrics via WS-Management protocol locally or remotely. For development on Windows container, virtual machine or host, execute the following commands from PowerShell:

winrm quickconfig

HTTP

To allow access to WinRM listener via HTTP, execute the following command from PowerShell and modify Sonar.config:

winrm set winrm/config/service @{AllowUnencrypted="true"}
<connectionStrings>
    <add name="local" providerName="wsman" connectionString="Server=sonar;" />
</connectionStrings>
<Servers>
      <add name="sonar" url="http://localhost:5985/wsman" username="" password="" timeoutMilliseconds="1000" authType="Negotiate"/>  
</Servers>

HTTPS

To allow access via HTTPS, create X509 certificate and configure WinRM listener for using it:

Get-ChildItem -path cert:\LocalMachine\My\        
winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="<hostname>";CertificateThumbprint="<thumbprint>"}
<connectionStrings>
    <add name="local" providerName="wsman" connectionString="Server=sonar;" />
</connectionStrings>
<Servers>
      <add name="sonar" url="https://localhost:5986/wsman" username="" password="" timeoutMilliseconds="1000" authType="Negotiate"/>  
</Servers>

Note that using Negotiate authentication will require Sonar process running under credentials with sufficient permissions to access WinRM listener. For remote access from Sonar deployed on Linux container, VM or host without  integration with Active Directory, Basic authentication can be used by modifying Sonar.config as follows:   

<Servers>
      <add name="sonar" url="http://localhost:5985/wsman" username="myuser" password="mypassword" timeoutMilliseconds="1000" authType="Basic"/>  
</Servers>

To enable Basic authentication for WinRM, execute following command from console or PowerShell on Windows:

winrm set winrm/config/service/auth @{Basic="true"}