How To Graph Terminal Services Active Users

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
chappie
Posts: 1
Joined: Thu Jul 19, 2007 4:19 pm

How To Graph Terminal Services Active Users

Post by chappie »

Here is how to graph the number of active terminal services users on a Microsoft Windows 2000/2003 server from a linux machine running cacti. This solution does not use snmp. Instead, it uses a wmi client installed on linux to get the information from the windows machine's wmi service. You could pay for something like snmp-informant, which will get wmi data and export it to snmp, but you want something free, right?


Setup the Windows 2000/2003 Server:
1. Make sure WMI is installed. Look under Administrative Tools->Services.

If it's not there, install.

For Windows 2003 Server: through Add/Remove Programs->Add/Remove Windows Componets->Management and Monitoring Tools. Select SNMP and "WMI Installer Provider" componets.

For Windows 2000 Server: I have no idea. Maybe someone can shed some light on this? On my test machine it was already installed.

2. Download and install Pegasus WMI Mapper version 2.3 (version 2.0 does not work). This service allows the linux machine to make wmi queries to the windows server. Download from http://h18023.www1.hp.com/support/files/server/us/download/26684.html

3. Modify the config file for Pegasus WMI Mapper. Go into the directory you installed Pegasus WMI Mapper in. By default, this is C:\Program Files\The Open Group\WMI Mapper\

Edit the file

Code: Select all

cimserver_planned.conf
-Turn OFF https by changing the line

Code: Select all

enableHttpsConnection=true
to

Code: Select all

enableHttpsConnection=false
-Turn ON http connections by changing the line

Code: Select all

enableHttpConnection=false
to

Code: Select all

enableHttpConnection=true
Save and close the file.

More info on the Pegasus WMI Mapper is available from http://forums.cacti.net/viewtopic.php?t=11752&postdays=0&postorder=asc&start=15

4. Stop/start the Pegasus WMI Mapper service. (Administrative Tools->Services)


Now the linux configuration:
5. Download and compile sblim-wbemcli. This program allows the linux machine to make WMI queries to the windows machine. Download from http://sourceforge.net/project/showfiles.php?group_id=128809&package_id=141067
(I tested with version 1.5.3 and know it works). If you are on a debian machine, you may have trouble with wbemcli's configure program complaining about not being able to find a www library. This is because debian calls the w3c library libwww0 while the configure program tries to link against libwww. To get around this, I installed the gnome http library by typing "

Code: Select all

apt-get install libghttp-dev
". If you have troubles, you can try my pre-compiled binary attached below as a tarred gzipped file. If you REALLY have trouble, let me know and I may post a statically linked version that should work on any linux machine.

6. Install wbemcli to your cacti scripts directory. On my machine, the command was "

Code: Select all

install -o root -g root -m 0755 wbemcli /usr/share/cacti/site/scripts/
" from the directory where I compiled wbemcli.

7. Copy the script attached below, tsusers.sh to your cacti scripts directory. If your scripts directory is anything other than /usr/share/cacti/site/scripts, then you will need to edit tsusers.sh and change the CACTI_SCRIPT_DIR variable. Oh, make tsusers.sh executable: "

Code: Select all

chmod a+x /usr/share/cacti/site/scripts/tsusers.sh[code]"

8. Download and import the cacti template attached below.

9. Add the template to your host.  You probably know how to add the graph, but if not... 
Assuming you already have a windows host being graphed via snmp/whatever, then go into cacti, click Devices, then click your windows host. Under "Associated Graph Templates", click the drop-down "Add Graph Template", then select "Microsoft Terminal Services - Active Users".  Click the "Add" icon to the right of the drop-down.  Now, go to the top of the page and click "Create Graphs for this Host".
Under the "Graph Templates" section, click the checkbox beside "Create: Microsoft Terminal Services - Active Users".  Go to the bottom of the page and click the icon "create".  Enter the hostname (or ip address) of the windows machine, along with the username of "administrator" and password for the administrator account.  Click "create" icon.  You're done.

You could probably create a new account on the windows machine instead of using the administrator account, but I couldn't figure it out.   It would probably involve giving the appropriate permissions under "Component Services" in the Control Panel.

If anyone figures out ways to improve on this, please post how you did it here.

Thanks and enjoy.
Attachments
tsusers.sh
Shell script to fetch number of TS sessions over wmi. Modified to work with windows 2000 servers also.
(867 Bytes) Downloaded 550 times
active_ts_users.xml
Cacti template
(10.26 KiB) Downloaded 451 times
wbemcli.tgz
wbem binary from debian system

(Linux cobalt 2.4.25-ROM #1 Thu Mar 11 08:47:53 MST 2004 i586 GNU/Linux)

(gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
(587.08 KiB) Downloaded 309 times
User avatar
poypoy
Posts: 11
Joined: Thu Jul 19, 2007 9:27 am
Location: Geneva - Switzerland

Post by poypoy »

Hi and thanks for your post. Ive tried your solution and there is only something wierd with your active_ts_users.xml cacti template.

In fact, the name of this templace is Cisco Active VPN and he calls a pix-vpn-users.pl file...

So I think there is something wrong with your file.

Let me know if you want that I done more tests.

Kindly REgards.

PoY
User avatar
poypoy
Posts: 11
Joined: Thu Jul 19, 2007 9:27 am
Location: Geneva - Switzerland

Post by poypoy »

Hello again,

I take the time finally to do the whole procedure and it works pretty well. Only one little bug, it counts the Administrator if his session is open has an active user too.

Here is the updated xml file working with the tsusers.sh. Be carefull to rename the downloaded file (tsusers_205.sh to tsusers.sh) to make it work on cacti.

Here the updated link to download WMI Mapper 2.3
http://h20000.www2.hp.com/bizsupport/Te ... R1002_USEN

PoY
Attachments
active_ts_users.xml
Active TS file for cacti
(9.74 KiB) Downloaded 667 times
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests