There's also an existing plugin for this: check_user_count.bat <br><a href="http://exchange.nagios.org/directory/Plugins/Remote-Access/Count-number-of-terminal-server-sessions/details">http://exchange.nagios.org/directory/Plugins/Remote-Access/Count-number-of-terminal-server-sessions/details</a><br>
<br>However I suggest to use checkCounter, as Jim Avery mentioned it. That way you keep independent of additional files. <br><br><div class="gmail_quote">On Mon, Jan 23, 2012 at 2:54 PM, Robert Jackson <span dir="ltr"><<a href="mailto:rab@walkermartyn.co.uk">rab@walkermartyn.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jim,<br>
<br>
Many thanks for the excellent reply. I'll give it a bash and see if I<br>
can get it going.<br>
<div><div></div><div class="h5"><br>
-----Original Message-----<br>
From: Jim Avery [mailto:<a href="mailto:jim@jimavery.me.uk">jim@jimavery.me.uk</a>]<br>
Sent: Monday 23 January 2012 13:43<br>
To: Nagios Users List<br>
Subject: <a href="mailto:rab@walkermartyn.co.uk">rab@walkermartyn.co.uk</a> - Re: [Nagios-users] Windows Active<br>
Sessions - Bayesian Filter detected spam<br>
<br>
On 23 January 2012 13:09, Robert Jackson <<a href="mailto:rab@walkermartyn.co.uk">rab@walkermartyn.co.uk</a>> wrote:<br>
> Does anyone know how to return the number of active sessions from a<br>
Windows<br>
> Terminal server? I have installed the NSClient++ service on the<br>
Windows<br>
> server and obviously have the NRPE plugin installed on my Nagios host.<br>
<br>
<br>
Rab,<br>
<br>
if I've understood correctly then you can query a Windows performance<br>
counter.<br>
<br>
I use an entry in the NSClient++ config file in the [External Alias]<br>
section that looks like this:-<br>
<br>
  alias_CheckCounter-ts_act_sess=CheckCounter<br>
"Counter:sessions=\Terminal Services\Active Sessions" ShowAll<br>
MaxWarn=40 MaxCrit=50<br>
<br>
<br>
Then on the Nagios side, the command is simply check_nrpe -H<br>
thehostname -c alias_CheckCounter-ts_act_sess<br>
<br>
So the command definition in Nagios is:-<br>
<br>
<br>
define command{<br>
  command_name    check_nrpe<br>
  command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -u $ARG1$<br>
  }<br>
<br>
<br>
And the service definition looks something like this:-<br>
<br>
define service{<br>
  use                   srv-pnp,generic-service<br>
  host_name             myhost<br>
  service_description   TS_Active_Sessions<br>
  check_command         check_nrpe!-c ts_act_sess<br>
  notes                 Number of Terminal Services Active Sessions<br>
  contact_groups        notify-engineers<br>
}<br>
<br>
<br>
There are lots of similar ways to do this sort of think using<br>
NSClient++.  Precisely how you set it up depends a bit on how<br>
obsessive you are about security and your particular preference.<br>
<br>
The method shown above means you can have allow_arguments=0 and<br>
allow_nasty_meta_chars=0 in the [nrpe] section which is good for<br>
security.  The downside is that if you need to change the warning<br>
theshold, you have to edit the nsc.ini file on the target system.<br>
<br>
hth,<br>
<br>
Jim<br>
<br>
------------------------------------------------------------------------<br>
------<br>
Try before you buy = See our experts in action!<br>
The most comprehensive online learning library for Microsoft developers<br>
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,<br>
Metro Style Apps, more. Free future releases when you subscribe now!<br>
<a href="http://p.sf.net/sfu/learndevnow-dev2" target="_blank">http://p.sf.net/sfu/learndevnow-dev2</a><br>
_______________________________________________<br>
Nagios-users mailing list<br>
<a href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/nagios-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/nagios-users</a><br>
::: Please include Nagios version, plugin version (-v) and OS when<br>
reporting any issue.<br>
::: Messages without supporting info will risk being sent to /dev/null<br>
<br>
<br>
<br>
</div></div><div class="im">************************************************************************<br>
The information in this internet E-mail is confidential and is intended<br>
solely for the addressee. Access, copying or re-use of information in it<br>
by anyone else is unauthorised. Any views or opinions presented are<br>
solely those of the author and do not necessarily represent those of<br>
Walker Martyn Ltd or any of its affiliates. If you are not the<br>
intended recipient please contact  <a href="mailto:administrator@walkermartyn.co.uk">administrator@walkermartyn.co.uk</a><br>
<br>
</div><div class="im">Walker Martyn Ltd, company number SC197533. Company is<br>
registered in Scotland and has its registered office at 1 Park<br>
Circus Place, Glasgow G3 6AH, UK.<br>
****************************************************************<br>
<br>
<br>
<br>
<br>
</div><div><div></div><div class="h5">------------------------------------------------------------------------------<br>
Try before you buy = See our experts in action!<br>
The most comprehensive online learning library for Microsoft developers<br>
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,<br>
Metro Style Apps, more. Free future releases when you subscribe now!<br>
<a href="http://p.sf.net/sfu/learndevnow-dev2" target="_blank">http://p.sf.net/sfu/learndevnow-dev2</a><br>
_______________________________________________<br>
Nagios-users mailing list<br>
<a href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/nagios-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/nagios-users</a><br>
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.<br>
::: Messages without supporting info will risk being sent to /dev/null<br>
</div></div></blockquote></div><br>