Microsoft Dynamics NAV 2013 R2 Management Pack for System Center Released

Microsoft Dynamics NAV 2013 R2 Management Pack for System Center Released

  • Comments 1

We are excited to announce that we have released the Microsoft Dynamics NAV 2013 R2 Management Pack for System Center. You can find the Management Pack and guide on the Microsoft Download Center here: http://www.microsoft.com/en-in/download/details.aspx?id=36388. The guide walks you through the details of deploying, configuring and using the management pack.

In this blog, we are focusing on describing the benefits of the management pack, as well as some of the internals of how it works, and how it is meant to be used.

What is new in the Management Pack?

The Microsoft Dynamics NAV 2013 R2 Management Pack for System  Center is built on top of the previous version. The new features include:

  • New rules that collect data on all Microsoft Dynamics NAV performance counters.
  • Two new monitors for Microsoft Dynamics NAV Server instances. One of the monitors checks certificates that protect communication for the different communication endpoints. The other monitor checks the health of the individual tenants that are mounted on the server instances.

The new monitors are simple event-based monitors that use events that are logged by each server instance. Therefore, each server instance is responsible for notifying the management pack about its own health. For certificates, this functionality is built into the server, but for tenants the story is a little different.

Monitoring tenants with the Task Scheduler

Microsoft Dynamics NAV 2013 R2 does not have built in monitoring, but combined with the windows Task Scheduler, an administrator can create logic that can be used to determine tenants’ health. Rules can be created that detect issues, automatically perform recoveries, and ultimately notify an operations manager of issues if the recoveries are not successful.

Notifying and alerting an operations manager is handled via events, so the management pack has a set of simple event monitors that are triggered based on these events. Events are logged to the Windows Application event log of the computer hosting the Microsoft Dynamics Server instances.

An example

The following is an example of a Task Scheduler task that can be used for monitoring whether all tenant databases are available.

This tasks runs a Windows PowerShell script that contains the actual logic. The script runs every minute. The scripts must be run in elevated mode (as an Administrator) and created as a Microsoft Dynamics NAV user.

<?xml version="1.0" encoding="UTF-16"?>

<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">

  <RegistrationInfo>

    <Date>2013-09-25T11:13:51.6449819</Date>

    <Author>.\Administrator</Author>

    <Description>Test all tenant databases hosted by server instance running on the local machine.</Description>

  </RegistrationInfo>

  <Triggers>

    <TimeTrigger>

      <Repetition>

        <Interval>PT1M</Interval>

        <StopAtDurationEnd>false</StopAtDurationEnd>

      </Repetition>

      <StartBoundary>2013-10-01T11:04:09</StartBoundary>

      <Enabled>true</Enabled>

    </TimeTrigger>

  </Triggers>

  <Principals>

    <Principal id="Author">

      <UserId>.\Administrator</UserId>

      <LogonType>S4U</LogonType>

      <RunLevel>HighestAvailable</RunLevel>

    </Principal>

  </Principals>

  <Settings>

    <MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy>

    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>

    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>

    <AllowHardTerminate>true</AllowHardTerminate>

    <StartWhenAvailable>true</StartWhenAvailable>

    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>

    <IdleSettings>

      <StopOnIdleEnd>true</StopOnIdleEnd>

      <RestartOnIdle>false</RestartOnIdle>

    </IdleSettings>

    <AllowStartOnDemand>true</AllowStartOnDemand>

    <Enabled>true</Enabled>

    <Hidden>false</Hidden>

    <RunOnlyIfIdle>false</RunOnlyIfIdle>

    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>

    <UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>

    <WakeToRun>false</WakeToRun>

    <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>

    <Priority>7</Priority>

    <RestartOnFailure>

      <Interval>PT1M</Interval>

      <Count>2</Count>

    </RestartOnFailure>

  </Settings>

  <Actions Context="Author">

    <Exec>

      <Command>powershell</Command>

      <Arguments>.\Test-TenantDB.ps1</Arguments>

      <WorkingDirectory>C:\ScheduledMonitoring</WorkingDirectory>

    </Exec>

  </Actions>

</Task>

The task expects a working directory that is named C:\ScheduledMonitoring and contains the PowerShell script Test-TenantDB.ps1

The script iterates through all the tenants hosted by all the local Microsoft Dynamics NAV Server instances, and invokes the OnRun function on Codeunit 1. The OnRun function contains no logic, so the invocation will just act as a ping, which detects whether the tenant database is available.

The Invoke-NAVCodeunit script can be used for multiple purposes. It is very easy to use the following template to invoke random methods and execute real synthetic transactions that make sense in your environment.

Test-TenantDB.ps1

#--------------------------------------------------------------------------

#     Copyright (c) Microsoft Corporation.  All rights reserved.

#--------------------------------------------------------------------------

 

if ((Get-PSSnapin -Registered "Microsoft.Dynamics.Nav.Management" -ErrorAction SilentlyContinue) -ne $null) {

    Add-PSSnapin "Microsoft.Dynamics.Nav.Management" }

 

$errorVariable = $null

$hasError = $false

 

# test is all tenant databases can be accessed by the running server instance.

Get-NAVServerInstance | where { $_.State -eq "Running" } | foreach {

    $serverInstance =  $_.ServerInstance

    Get-NAVTenant $serverInstance | foreach {

        # codeunit 1 will always exist

        Invoke-NAVCodeunit $ServerInstance -CodeunitId 1 -Tenant $_.Id -ErrorVariable $errorVariable -ErrorAction Continue

        if ($errorVariable -ne $null -and $errorVariable.Count -gt 0) { $hasError = $true }

    }

}

 

if ($hasError -eq $true) {

    # we can respond to this error level

    exit 1

}

Generating event log entries that will be escalated to SCOM

There are two generic event log monitors in the management pack, one for server instances and one for mounted tenants. These monitors are described in detail in the Management Pack Guide for Microsoft Dynamics NAV 2013 R2. The communication with these monitors is rather simple when creating scheduled monitoring tasks. Basically, you can run any type of logic that matches your infrastructure and application, and then either rely on the server instance to create the proper events or create escalation events in your script.

For a server instance named DynamicsNAV71, the format looks like this:

# write a generic server instance event log entry that will be picked up by SCOM

Write-EventLog -LogName 'Application' -Source “MicrosoftDynamicsNavServer$DynamicsNAV71” -EntryType Error -Message "Server instance: DynamicsNAV71 - <Here goes the actual error message, that you will send to the operations manager> " -EventId 911

For tenants, the format differs slightly. If the server instance named DynamicsNAV71 hosts a tenant named default, then the format looks like this:

# write a generic server instance event log entry that will be picked up by SCOM

Write-EventLog -LogName 'Application' -Source “MicrosoftDynamicsNavServer$DynamicsNAV71” -EntryType Error -Message "Server instance: DynamicsNAV71 Tenant ID: default - <Here goes the actual error message, that you will send to the operations manager> " -EventId 911 

The following PowerShell script, which monitors the TCP ports on all the endpoints, shows how to use the manually generated event log entries to communicate with SCOM.

Test-TcpPortState.ps1

#--------------------------------------------------------------------------

#     Copyright (c) Microsoft Corporation.  All rights reserved.

#--------------------------------------------------------------------------

 

if ((Get-PSSnapin -Registered "Microsoft.Dynamics.Nav.Management" -ErrorAction SilentlyContinue) -ne $null) {

    Add-PSSnapin "Microsoft.Dynamics.Nav.Management" }

 

$hasError = $false

 

# call netstat to retrieve the status of the tcp ports on the local machine

Function Get-TcpPortState

{

param(

 

           [Parameter(Position=0,ValueFromPipeline=$true)]

           [System.Int32]$Port='0'

           )

process

           {

           netstat -ano | select-string -Pattern '\s+(TCP)' | foreach {

 

                   $item = $_.line.split(' ',[System.StringSplitOptions]::RemoveEmptyEntries)

 

                   if($item[1] -notmatch '^\[::' -and $item[1].split(':')[-1] -like $Port)

 {

          

                       New-Object -TypeName PSObject -Property @{State = $item[3]} | select -Property 'State'

 }

                      }

           }

}

 

# check the port status for all server instance endpoints

Get-NAVServerInstance | where { $_.State -eq "Running" } | foreach {

    $serverInstanceFull =  $_.ServerInstance

    (Get-NAVServerConfiguration $serverInstanceFull) |  where { $_.key -like '*Port'} | foreach {

        $serverInstanceShort = $serverInstanceFull.Split('$')[1]

        $portName = $_.key

        $port = $_.value

        $state = (Get-TcpPortState $port).State

        if($state -eq $null -or $state -ne 'LISTENING')

        {

            # write an generic event log entry, that will be picked up by SCOM

            Write-EventLog -LogName 'Application' -Source $serverInstanceFull -EntryType Error -Message "Server instance: $serverInstanceShort - is not listening on $portName=$port" -EventId 911

            $hasError = $true

        }

    }

}

 

if ($hasError -eq $true) {

    # we can respond to this error level

    exit 1

}

 

Best regards,

Stefan Omdahl & John Swymer

Leave a Comment
  • Please add 5 and 8 and type the answer here:
  • Post
  • thanks

Page 1 of 1 (1 items)