New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


How to monitor number of active Terminal Server sessions?

Votes:

0

Your Vote:

Up

Down

How can I monitor the number of active Terminal Server sessions on a Windows Terminal Server?

prtg sensor terminal-server windows wql

Created on Feb 8, 2010 7:22:49 PM by  Dirk Paessler [Founder Paessler AG] (10,921) 3 4

Last change on Jan 22, 2014 5:41:39 PM by  Gerald Schoch [Paessler Support]



Best Answer

Accepted Answer

Votes:

0

Your Vote:

Up

Down

In current PRTG versions, there are two dedicated sensors available out of the box for this purpose:

Created on Jan 22, 2014 5:40:32 PM by  Gerald Schoch [Paessler Support]



7 Replies

Votes:

1

Your Vote:

Up

Down

Hi, I wrote s small exe that can be used as a user defined program sensor. It needs a installed Microsoft Net 3.5 environment. Programm and source can be found here: http://www.obeco.de/termseraszip.exe

Created on Feb 9, 2010 11:37:06 AM by  Joachim Berger (10) 1



Votes:

1

Your Vote:

Up

Down

you could use a custom WMI sensor using these WQL querys

depending on the OS...

2003

Total Sessions

SELECT TotalSessions FROM Win32_PerfFormattedData_TermService_TerminalServices

Active Sessions

SELECT ActiveSessions FROM Win32_PerfFormattedData_TermService_TerminalServices

2008

Total Sessions

SELECT TotalSessions FROM Win32_TerminalService

Active Sessions

SELECT ActiveSessions FROM Win32_PerfFormattedData_LocalSessionManager_TerminalServices

Created on Feb 10, 2010 2:28:09 PM by  Aurelio Lombardi [Paessler Support]



Accepted Answer

Votes:

0

Your Vote:

Up

Down

In current PRTG versions, there are two dedicated sensors available out of the box for this purpose:

Created on Jan 22, 2014 5:40:32 PM by  Gerald Schoch [Paessler Support]



Votes:

0

Your Vote:

Up

Down

If you try the above WMI request or the WMI Sensor on a Server 2003 machine, you might find that it lies to you if you are using a non-admin account to make the request. You have to add the non-admin account to Remote Desktop Users on that machine.

This is not true on a Server 2008 machine. The numbers returned by a admin and non-admin account are both accurate without adding the non-admin to Remote Desktop Users. BTW, ActiveSessions doesn't exist in 2008 - there is DisconnectedSessions instead.

The non-admin account I use for PRTG monitoring has been added to DCOM Users, Performance Log Users, and Performance Monitor Users.

Created on Apr 14, 2014 6:35:39 PM by  today (11) 1



Votes:

1

Your Vote:

Up

Down

The EXE Advanced Sensor worked for us . We have several (35) RD Servers (2012) (Under the PRTG's Max of 50 Channels) and instead of having multiple sensor graphs, this script was created to scan all the servers and report back to one sensor graph. It works for Windows 2012 and 2008 servers.

Save this script to the C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML folder. (If the RDS.txt file can't be created when the script is run you may have to adjust the permissions on that folder.)

Add parameters/arguments to the sensor settings using quotes. The QWinsta program reports all sessions to a text file. The script than reads the text file and converts it into XML.

It creates a channel for Total users and each server with the number of logged in users. Options to include disconnected sessions and exclude user accounts. (Services account)

DIM XMLStart, XMLEnd, xmlResult, XmlTotal
DIM strRDServer, TotalUsers
Dim ArgObj, ARG

Set ArgObj = WScript.Arguments 

XMLStart = "<?xml version=" & chr(34) & "1.0" & chr(34) & " encoding=" & chr(34) & "Windows-1252" & chr(34) & " ?>" & vbCRLF & "<prtg>" & vbCRLF
XMLEnd = "</prtg>" & vbCRLF
XMLResult = ""

for each ARG in ARGobj
	strRDServer = UCase(trim(ARG))
	'msgbox strRDServer
	AllUsers()
next

xmlTotal = "<result>" & vbCRLF & "<channel>" & "All Remote Users" & "</channel>" & vbCRLF
xmlTotal = xmlTotal & "<value>" & TotalUsers & "</value>" & vbCRLF
xmlTotal = xmlTotal & "</result>"
XMLFinal = XMLStart & xmlTotal & xmlResult & XMLEnd
wscript.echo XMLFinal

Sub AllUsers
	strError = ""
	'msgbox strRDServer
	Count = 0
	xmlChannel = ""
	xmlValue = ""
	Set objShell = CreateObject("WScript.Shell")
	cmdQuery = "%comspec% /c QWinsta.exe /server:" & strRDServer & " > rds.txt"
	'msgbox cmdQuery
	objshell.run cmdQuery,0,1
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objFile1 = objFSO.OpenTextFile("rds.txt", 1)
	Do Until objFile1.AtEndOfStream
		strSessionID = objFile1.ReadLine
		if left(trim(strSessionID),8) <> "services" Then
			if inSTR(strSessionID,"Active") > 0 Then
				 Count = Count + 1
			end if
			if inSTR(strSessionID,"Disc") > 0 Then
				if instr(trim(strSessionID),".") = 0 or instr(trim(strSessionID),"administrator") = 1 then
					'strError = strError & vbCRLF & "Unknown user" & vbtab & replace(trim(strSessionID)," Disc","")
					'Count = Count + 1 'Optional
				else
					Count = Count + 1
				end if
			end if
		end if
	Loop
	TotalUsers = TotalUsers + Count
	xmlChannel = "<channel>" & strRDServer & "</channel>" & vbCRLF
	xmlValue = "<value>" & Count & "</value>" & vbCRLF
	xmlResult = xmlResult & vbCRLF & "<result>" & vbCRLF & xmlChannel & xmlValue & "</result>" & vbCLRF
end sub

Created on Apr 29, 2016 8:24:13 PM by  Glen Munro (60) 1

Last change on May 2, 2016 8:07:20 AM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

This is exactly what I'd like to do, but the exe page is no longer there? Does anyone have a copy of the exe they can share?

Thanks, Mike

Created on Oct 13, 2020 6:54:27 PM by  MikeWachholz (0) 1



Votes:

0

Your Vote:

Up

Down

Hi Mike,

you don't need the exe file, as there are native PRTG sensors you can use for this purpose:


Kind regards,
Matthias Kupfer - Team Tech Support

Created on Oct 14, 2020 11:55:42 AM by  Matthias Kupfer [Paessler Support]



Please log in or register to enter your reply.


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.