Remote and managed Update/Install or check of NSClient++ via psexec and VBScript
You can use the attached VBScript to install, check or update a NSClient++ Version on all your Windows hosts.
Requirements:
1.) one Domain Administrator account which is able to manage all windows based clients
If you omit the admin account psexec is used the current login account but is NOT be able to use this account for network access too.
2.) a server share which store's the new NSClient++ Versions (in the moment 32 and 64 bit supported) as unpacked zip archive.
3.) a configuration file where the definitions from each windows server is configured
4.) psexec.exe from Sysinternals
Explanation
1.) No further explanation is necessary. You need a DOMAIN Admin Account which has local administrator rights on servers, too.
2.) You need a "download server" that has a share with following folder structure:
..\\NSClient++
..\\NSClient++\32 --> unpacked zip archive from 32bit NSClient++ version
..\\NSClient++\64 --> unpacked zip archive from 64bit NSClient++ version
..\\NSClient++\log --> folder where the installation log files are stored
This folder structure MUST exist!
3.) The configuration file MUST have the following format:
- first 17 lines are descriptions
- start your configuration at line 19
- do not use blank lines between your server configuration lines
- column:
first = servername
second = y/n --> is the current NSC.ini to be keep?
third = y/n --> is the current script folder to keep? (where your own scripts are stored)
four = the target full path in which NSClient++ will be installed. If you obmit this column the default is %programfiles%
The delimiter between the columns is a "|" colon character.
example:
server1|y|n means that NSClient++ will be updated on server1, in %programfiles%, use existing NSC.ini and new script folder.
server1|y|n|c:\NSClient++ means that NSClient++ will be updated in "C:\NSClient++", with remain old NSC.ini
If you install or update only one server use:
psexec \\server1 -u [DOMAIN]\[admin] -p [password] cscript \\server6\Nagios\nsclient_update.vbs //nologo /S:\\server6\NSClient++ /c:\\server6\NSClient++\servers.txt
For installing more than one server at the same time, your command needs to be a little bit longer, because psexec will have the informatione on
what hosts the command should run.
Psexec needs only a simple text file for that. Place it, for example, in c:\tmp and name it psexec_servers.txt. Use one line per server name.
psexec @c:\tmp\psexec_servers.txt -u [DOMAIN]\[admin] -p [password] cscript \\server6\Nagios\nsclient_update.vbs //nologo /S:\\server6\NSClient++ /c:\\server6\NSClient++\servers.txt
Output on command line
\\server1: * hostname is: SERVER1 * CPU-Type: x86 * NSClient++ is installed on: C:\Programme\NSClient++ * service NSClientpp is in state: Running * service: NSClientpp successfully stopped * NSClient++ successfully uninstalled * folder: C:\Programme\NSClient++ renamed to: C:\Programme\NSClient++_0.3.3.20 * copy new NSClient++ Version from remote share . . . - 29.09.2008 08:13:12 * copying files from \\muc1mgt6\download\Nagios\NSClient++\32 to C:\Programme \NSClient++ was successfully 29.09.2008 08:13:14 * new NSClient++ version was successfully installed * NSClient++ daemon was successfully started cscript exited on server1 with error code 0. \\server2: * hostname is: SERVER2 * CPU-Type: x86 * NSClient++ is installed on: C:\Programme\NSClient++ * service NSClientpp is in state: Running * service: NSClientpp successfully stopped * NSClient++ successfully uninstalled * folder: C:\Programme\NSClient++ renamed to: C:\Programme\NSClient++_0.3.4.35 * copy new NSClient++ Version from remote share . . . - 29.09.2008 08:13:31 * copying files from \\muc1mgt6\download\Nagios\NSClient++\32 to C:\Programme \NSClient++ was successfully 29.09.2008 08:13:58 * new NSClient++ version was successfully installed * NSClient++ daemon was successfully started cscript exited on server2 with error code 0. \\server3: * hostname is: SERVER3 * CPU-Type: x86 * NSClient++ is installed on: C:\Programme\NSClient++ * ERROR: couldn't get WMI service state from NSClient++ Typen unverträglich * service state from NSClientpp is UNKNOWN, but stopped successfully with 'net stop' * service: NSClientpp successfully stopped * NSClient++ successfully uninstalled * folder: C:\Programme\NSClient++ renamed to: C:\Programme\NSClient++_0.3.4.35 * copy new NSClient++ Version from remote share . . . - 29.09.2008 08:14:14 * copying files from \\muc1mgt6\download\Nagios\NSClient++\32 to C:\Programme \NSClient++ was successfully 29.09.2008 08:14:53 * new NSClient++ version was successfully installed * NSClient++ daemon was successfully started
The VBScript and the config file "servers.txt" are attached here.
If you have some problems or notes, don't hesitate to contact me at tborger[at]esg[dot]de
Updates:
2008-09-25 bug fixed in argument parsing
2008-09-29 new version with some bug fixes and support for 32 and 64 bit
2008-09-30 implement a further check to control if the daemon nsclientpp was installed on the target system
2008-09-30 bug fiexed (NSClientpp couldn't installed as service - only relevant for english windows versions)
2008-10-03 added feature to use other installation target dir as %programfiles% (thx TheCry? in german Nagios forum for this advice)
2008-10-07 in very first versions on NSClient++, no information about plattform is printed out when using command: nsclient++.exe -version
Fixed this issue in the script.(thx on TheCry?)
Attachments
- servers.txt (0.8 kB) - added by tborger on 09/29/08 07:18:40.
- server.txt (1.0 kB) - added by tborger on 10/04/08 13:39:29.
- nsclient_updateV2.vbs (24.0 kB) - added by tborger on 10/07/08 18:43:06.




