Something or someone disables logons on your Citrix or Terminal server and logons never get enabled.
Now you have a server nobody can log into and you are clueless about it.
If you have Nagios working in your environment-Here is a solution to send alert.
Prerequist: Nagios, NRPE addon, Nagios Agent installed on Windows Server, and a program that can read Reg key and communicate with Nagios.
There is a Nagios utility out there created already, but it contains a serious bug that cannot read a value of Zero properly.
Working together, here is what our team came up with.
We created a custom utility with AutoIT and called tsnenable.exe
Here is the code:
;tsenable - purpose to read registry key for value to see if Terminal Services Logons are enabled 0 or disabled 1
;then based on that, it does either of these two things: 0, then write to console message and set exit code to 0
;else if 1, then write to the console, and set exit code to 1.
;This must be compiled as a non-gui application for it to work.
;This is to be used in conjunction with nagios
;September 1, 2010
dim $RegVal, $i
$RegVal=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "WinStationsDisabled")
If @error <> 0 Then
MsgBox(0, "oops", "Crap! This is not working!")
if $RegVal = 0 then
Note: You must compile this as a Command Line Interface not GUI!
Now the actual steps:
1. Install newer nsclient on Citrix server. If you have old client, uninstall that one first then install nsclient_3.6RC8 and get it working with Nagios.
2. Create a folder called nsscripts put the custom app in that folder.
3. Put nsscripts in the NSclient++ program files folder.
4. Rename nsc.ini in NSClient++ to nsc.ini.org
5. Edit nsc.ini in the NSclient++ folder. I am only going to cover the part for running custom scripts.
; *********** CREATED THIS FOLDER IN THE NSCLIENT++ FOLDER *********
; *********** Custom app **********
6. Reastart Service for nsclient.
7. Create nagios service entry in services.cfg
This is Linux so you have to use vi or nano editor:
NOTE: service_description below uses "check_command" from nrpe2 which calls the tsenable.exe.
In the INI file above notice the "check_tslogon" setting pointing to the custom tsenable.exe.
# Service definition
use generic-service ; Name of service template to use
service_description TS Logons
8. Restart Nagios.