What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How to: Lync 2013 monitoring

Votes:

7

Hi all,

I'd like to share the results of the research I've done on how to monitor Lync online users, Lync Inbound Calls and Lync Outbound Calls.

On the internet I've found a Powershell script, which I have modified to monitor the inbound and outbound calls.

Here are the scripts. To use the script in PRTG you have to do the following:

  1. Copy powershell.exe on the probe from c:\windows\system32\windowspowershell\* to the EXE/XML directory in c:\program files (x86)\PRTG Network Monitor\Custom Sensors
  2. Copy the script as a .ps1 file in c:\batch on the probe
  3. Create an EXE/ADVANCED script in PRTG
  4. Select powershell.exe
  5. Enter parameters: -noprofile -executionpolicy bypass -file c:\batch\prtg-lyncuser.ps1 (or your script)
  6. Set security context to Use Windows credentials of parent device

Script to monitor Lync Online Users:

# prtg-lyncuser.ps1
#
# Loading current sip client connections as performance counter
#

param (
	[string]$server= "YOUR LYNC FE SERVER, YOUR SECOND LYNC FE SERVER(OPTIONAL), YOUR THIRD LYNC FE SERVER(OPTIONAL)"  # specify Servers
)

write-host "Start PRTG Sensor" 
write-host "Server:" $Server 

$serverlist = $server.split(",")
write-host "Serverlist count:" $Serverlist.count 

$result="<prtg>`r`n"


foreach ($server in $serverlist){
	write-host "Server: " $server
	$value = (Get-Counter "\LS:SIP - Peers(Clients)\SIP - Connections Active" -ComputerName $server -ErrorAction silentlycontinue)
	if ($error) {
		# Skip Counters
		write-host "Server: $server Unable to read $counter"
		$error.clear()
	}
	else  {
		$result+="  <result>`r`n"
		$result+="    <channel>SIPClients("+$server+")</channel>`r`n"
		$result+="    <value>"+$value.CounterSamples[0].CookedValue+"</value>`r`n"
		$result+="    <unit>Count</unit>`r`n"
		$result+="    <mode>Absolute</mode>`r`n"
		$result+="  </result>`r`n"
	}
}

$result+="<text>LyncUsers:"+$arg+"</text>`r`n"
$result+="</prtg>"

write-host "End: ExitCode "$error.count

Write-host "Sending Result to output pipeline"
$result

if ($error) {
	#write-host "Found Errors"
	EXIT 1
}

Script to monitor Inbound calls:

# prtg-lynccallsin.ps1
#
# Loading current sip client connections as performance counter
#

param (
	[string]$server= "YOUR LYNC FE SERVER, YOUR SECOND LYNC FE SERVER(OPTIONAL), YOUR THIRD LYNC FE SERVER(OPTIONAL)"  # specify Servers
)

write-host "Start PRTG Sensor" 
write-host "Server:" $Server 

$serverlist = $server.split(",")
write-host "Serverlist count:" $Serverlist.count 

$result="<prtg>`r`n"


foreach ($server in $serverlist){
	write-host "Server: " $server
	$value = (Get-Counter -ComputerName $server -Counter "\LS:MediationServer - Inbound Calls(_Total)\- Current" -ErrorAction silentlycontinue)
	if ($error) {
		# Skip Counters
		write-host "Server: $server Unable to read $counter"
		$error.clear()
	}
	else  {
		$result+="  <result>`r`n"
		$result+="    <channel>Inbound Calls("+$server+")</channel>`r`n"
		$result+="    <value>"+$value.CounterSamples[0].CookedValue+"</value>`r`n"
		$result+="    <unit>Count</unit>`r`n"
		$result+="    <mode>Absolute</mode>`r`n"
		$result+="  </result>`r`n"
	}
}

$result+="<text>Calls:"+$arg+"</text>`r`n"
$result+="</prtg>"

write-host "End: ExitCode "$error.count

Write-host "Sending Result to output pipeline"
$result

if ($error) {
	#write-host "Found Errors"
	EXIT 1
}

Script to monitor outbound calls:

# prtg-lyncuser.ps1
#
# Loading current sip client connections as performance counter
#

param (
	[string]$server= "YOUR LYNC FE SERVER, YOUR SECOND LYNC FE SERVER(OPTIONAL), YOUR THIRD LYNC FE SERVER(OPTIONAL)"  # specify Servers
)

write-host "Start PRTG Sensor" 
write-host "Server:" $Server 

$serverlist = $server.split(",")
write-host "Serverlist count:" $Serverlist.count 

$result="<prtg>`r`n"


foreach ($server in $serverlist){
	write-host "Server: " $server
	$value = (Get-Counter -ComputerName $server -Counter "\LS:MediationServer - Outbound Calls(_Total)\- Current" -ErrorAction silentlycontinue)
	if ($error) {
		# Skip Counters
		write-host "Server: $server Unable to read $counter"
		$error.clear()
	}
	else  {
		$result+="  <result>`r`n"
		$result+="    <channel>Outbound Calls("+$server+")</channel>`r`n"
		$result+="    <value>"+$value.CounterSamples[0].CookedValue+"</value>`r`n"
		$result+="    <unit>Count</unit>`r`n"
		$result+="    <mode>Absolute</mode>`r`n"
		$result+="  </result>`r`n"
	}
}

$result+="<text>Calls:"+$arg+"</text>`r`n"
$result+="</prtg>"

write-host "End: ExitCode "$error.count

Write-host "Sending Result to output pipeline"
$result

if ($error) {
	#write-host "Found Errors"
	EXIT 1
}

It's working seamlessly on our systems in PRTG.

custom-script-exe custom-sensor lync prtg

Created on Feb 8, 2015 9:42:52 AM

Last change on Mar 26, 2015 8:00:35 AM by  Stephan Linke [Paessler Support]



22 Replies

Votes:

1

Thanks for sharing the script! :) Looks like a lot of work went into it. Just note that you don't need to copy the PowerShell.exe into the EXE XML directory.

Simply put the scripts into the C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML directory and it will be available as a script in the EXEXML setup. The NoProfile parameter is already built into the PowerShell call, you just need to execute

Set-ExecutionPolicy Unrestricted

...on the PRTG Server in a elevated 32 Bit PowerShell to make it work :)

Created on Feb 9, 2015 9:11:18 AM by  Stephan Linke [Paessler Support]



Votes:

0

Thanks Herman, very useful! Just a small warning: the inbound/outbound call scripts are missing the parameter '-ComputerName $server' on the line that starts with: $value = (Get-Counter -Counter...

Created on Mar 25, 2015 12:33:32 PM



Votes:

0

Thanks for the hint, Gunter! I fixed the lines in the original post :)

Created on Mar 26, 2015 8:01:06 AM by  Stephan Linke [Paessler Support]



Votes:

0

Just wanted to say awesome job on these! Any more visibility I can get into Lync the happier I'll be!

Created on Apr 27, 2015 9:08:57 PM



Votes:

0

Hello, I have an error when i want use this sensor. It tells me:

"XML: The returned xml does not match the expected schema. (code: PE233) -- JSON: The returned json does not match the expected structure (No mapping for the Unicode character exists in the target multi-byte code page). (code: PE231)"

In fact i am not sure that my settings are ok.

In sensor Settings i have:

EXE/Script: powershell.exe

Parameters: -noprofile -executionpolicy bypass -file C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\Le_script_lync.ps1

My path is correct but i am bad with powershell so i do not know where my mistake is.

Could you help me please?

PS: My server is a lync 2013

Created on May 12, 2015 9:08:57 AM



Votes:

0

Stagiaire2,

Make sure you put these scripts on the probe, and not the main PRTG server.

Created on May 12, 2015 8:58:13 PM



Votes:

0

Can you try to exchange the following line in all scripts:

$result="<prtg>`r`n"

with this one:

$result='<?xml version="1.0" encoding="UTF-8" ?>`r`n<prtg>`r`n'

...does it work then? What's the output when you execute it manually?

Created on May 13, 2015 1:43:01 PM by  Stephan Linke [Paessler Support]

Last change on May 13, 2015 1:43:25 PM by  Stephan Linke [Paessler Support]



Votes:

0

Hello,

If i execute my script manually i have the message :

"PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\Le_script_lync.ps1 Start PRTG Sensor

Server: 10.1.0.56,10.1.0.39

Serverlist count: 2

Server: 10.1.0.56

Server: 10.1.0.56 Unable to read

Server: 10.1.0.39

Server: 10.1.0.39 Unable to read

End: ExitCode 0 Sending Result to output pipeline <?xml version="1.0" encoding="UTF-8" ?>`r`n<prtg>`r`n<text>LyncUsers:</text> </prtg>".

I tried to put " $result='<?xml version="1.0" encoding="UTF-8" ?>`r`n<prtg>`r`n' " but it is not the problem.

Should i fix something in my lync-server?

Created on May 27, 2015 10:39:44 AM



Votes:

0

Did you modify the server variable inside the script? If not, you need to pass a parameter containing the FQDN of your lync server. For example:

.\Le_script_lync.ps1 lync.live.local

Is that the case?

Created on May 29, 2015 11:24:39 AM by  Stephan Linke [Paessler Support]



Votes:

0

Thank you for your scripts. They helped me to monitor Skype for business. I made them a bit simpler. Inbound connections; $server = $args $connections = (Get-Counter -ComputerName $server -Counter "\LS:MediationServer - Inbound Calls(_Total)\- Current").CounterSamples.CookedValue write-host $connections":OK"

Outbound connections; $server = $args $connections = (Get-Counter -ComputerName $server -Counter "\LS:MediationServer - Outbound Calls(_Total)\- Current").CounterSamples.CookedValue write-host $connections":OK"

Number of clients; $server = $args $connections = (Get-Counter "\LS:SIP - Peers(Clients)\SIP - Connections Active" -ComputerName $server).CounterSamples.Cookedvalue write-host $connections":OK"

When creating this sensors use ’Custom sensors’ ‘EXE/script’ and in the sensor settings define ‘Parameters’ to ‘%host’ – that is what is read in the script sin $args

You need to have credentials on the target server from PRTG, we add the PRTG-server to trusteed computers via GPU so we can run Powershell scripts on our target servers.

Created on Nov 5, 2015 3:17:19 PM



Votes:

0

Thanks for your input! It will come in handy for people who want to integrate this :)

Created on Nov 6, 2015 6:25:20 AM by  Stephan Linke [Paessler Support]



Votes:

0

Anyone who can show an output from the sensor? I'm about to try adding it.

Created on May 23, 2016 6:44:10 PM



Votes:

0

What stops you from doing so :) There are not many options, either the script works or it will error out. If it's working, you'll see an XML output.

Created on May 24, 2016 7:22:34 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi guys, i just added the Script´s, the Output is green / ok, but values are 0. Any idea?

Created on Oct 13, 2016 7:48:01 AM



Votes:

0

What actual script are we talking about? There are three of them :) Did you install them correctly?

Created on Oct 17, 2016 5:30:48 AM by  Stephan Linke [Paessler Support]



Votes:

0

the command param () is not necessary as this is not part of a function. I wonder if nobody gets an error calling the script.

Created on Jan 23, 2017 11:43:39 AM



Votes:

0

It sure is used? The $servers variable gets split into the $serverList array using $servers.split(',')? ;)

Created on Jan 23, 2017 6:56:47 PM by  Stephan Linke [Paessler Support]



Votes:

0

Just incase this is of use to anyone else, you will recieve issues on this if you run the server list against the skype servers themselves when using a mediation server they will not have the required perfmon entries for

"\LS:MediationServer - Inbound Calls(_Total)\- Current"
"\LS:MediationServer - Outbound Calls(_Total)\- Current"

And will return errors relating to a null array. Aim them at mediation servers if you use them.

Cheers

sam

Created on Mar 6, 2018 2:32:56 PM

Last change on Mar 6, 2018 3:16:22 PM by  Torsten Lindner [Paessler Support]



Votes:

0

Is the same solution fit for Skype For Business 2015?

Created on Jan 31, 2019 8:29:29 AM



Votes:

0

I tend to say no, as the counters most likely differ. One thing I found regarding PRTG and S4B was this. Perhaps it will get you started?


PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Jan 31, 2019 8:54:08 AM by  Stephan Linke [Paessler Support]



Votes:

0

hi , is there any chance I could monitor the failed logon to lync users with any scripts?

Created on Mar 27, 2019 9:57:43 AM



Votes:

0

I can't find anything regarding that to be logged anywhere :( Perhaps someone else has an idea. Note that Lync is already replaced by Skype For Business, which is already being replaced by Microsoft Teams. So it might be time to migrate :)


PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Mar 27, 2019 11:40:58 AM by  Stephan Linke [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.