Lync   Lync – Monitor services status using Nagios

This post shows a Powershell script I use to monitor the status of my Lync services.
This state can be manually checked on the Lync console (Lync 2010 in my scenario):
Lync - Monitor services status using Nagios_1

And with the Get-CsWindowsService powershell command:

PS C:\> Get-CsWindowsService

Status   Name            ActivityLevel
------   ----            -------------
Running  MASTER
Running  REPLICA
Running  RTCSRV          Incoming Requests per Second=0,Mess...
Running  RTCCAA          Concurrent Calls=0
Running  RTCCAS          Concurrent Conferences=0
Running  RTCRGS          Current Active Calls=0
Running  RTCCPS          Total Parked Calls=0
Running  RTCATS          Current Active Calls=0
Running  RTCIMMCU        Active Conferences=0,Connected User...
Running  RTCDATAMCU      Active Conferences=0
Running  RTCAVMCU        Number of Conferences=1,Number of U...
Running  RTCASMCU        Active Conferences=1,Connected User...
Running  RTCMEDSRV       Current Outbound Calls=0,Current In...
Running  RTCMEETINGMCU   Active Conferences=0
Running  FTA

The script takes advantage of the Nagios passive checks and the configurations shown on my previous post "Nagios – Using passive checks without agent".

If any of the services is in state different of "Running", Nagios raises a critical alert:

Lync - Monitor services status using Nagios_2

Lync - Monitor services status using Nagios_3

Here is the code (can also be downloaded here):


Get-CsWindowsService | fl status > $SCRIPT_PATH\TEMP.txt

$DATETIMESTAMP = "[{0:G}]" -f [int][double]::Parse((Get-Date -UFormat %s))


foreach ($STAT in $STATUS)
	if ($STAT.Length -gt 0)
		if (-not $STAT.Endswith("Running"))

if ($RESULT -gt 0)
	$MSGTMP = " PROCESS_SERVICE_CHECK_RESULT;$LYNC_SERVER;ServiceStatus;2;There are $RESULT services NOT running"

	if ($MSGTMP.CompareTo($MSGTMP2) -ne 0)

Note that you have to:

  • Configure the parameters (in red at the beginning of the script)
  • Configure a Nagios host and service (in this example the name of the service would ServiceStatus) that accepts passive copies
  • Configure Nagios to accept passive checks remotely ("Nagios – Using passive checks without agent".)

Schedule it to be executed every some minutes and your Lync services status are monitored.

Leave a Reply

Your email address will not be published. Required fields are marked *