Page 1 of 2

NSclient Installtion from CMD

Posted: Tue Sep 12, 2017 7:06 am
by vinish098
I am trying to automate the installation of nsclient by using below command:

NSCLIENT-0.4.4.23
msiexec /i C:\Users\abcd\Downloads\NSCP-0.4.4.23-x64.msi CONF_CAN_CHANGE=1 ALLOWED_HOSTS=10.0.0.45 NSCLIENT_PWD=redhat CONF_NSCLIENT=1 /quiet

This command working perfectly except the password is not getting updated in "nsclient.ini" file

I tried to provide password in these formats also:- "redhat" 'redhat' `redhat` but its not updating in the file. Can you please help here.

NSCLIENT-0.5.1.44
msiexec /i C:\Users\abcd\Downloads\NSCP-0.5.1.44-x64.msi CONF_CAN_CHANGE=enabled ALLOWED_HOSTS=10.0.0.45 NSCLIENT_PWD="redhat" CONF_NSCLIENT=enabled /quiet

After running this command, If I manually enable few options in nsclient.ini file given below, its working perfectly otherwise not working.
CheckDisk = enabled
CheckSystem = enabled
NSClientServer = enabled

Please give a solution to enable these options as well in a single command.

Thanks in advance.

Re: NSclient Installtion from CMD

Posted: Tue Sep 12, 2017 1:59 pm
by dwasswa

Re: NSclient Installtion from CMD

Posted: Tue Sep 12, 2017 2:38 pm
by dwhitfield
Thanks @Derick Wasswa!

I'd also like to point out that we do not maintain NSClient, so you may get better answers at http://nsclient.org. I am not suggesting we are unwilling to help. We just do not have the deep knowledge of the code like they do.

Re: NSclient Installtion from CMD

Posted: Tue Sep 12, 2017 2:56 pm
by mcapra
Alternatively, rather than trying to fit all the configuration into a single command-line script, you might look into something like Chef, Puppet, or Ansible. Rather than being at the mercy of what NSClient++ offers as part of it's installer, you could delegate configuration file creation/modification to a process built on any one of those platforms. You could also script out stuff like downloading and setting up specific custom plugins for NSClient++, which I am almost certain cannot be done with the installer alone.

Re: NSclient Installtion from CMD

Posted: Tue Sep 12, 2017 2:58 pm
by dwhitfield
mcapra wrote: you might look into something like Chef, Puppet, or Ansible.
This is a great suggestion. I know chef has spent a lot of time with Windows. We have just begun to use ansible here. I suppose if I have a suggestion, it is to look at one of those two.

Re: NSclient Installtion from CMD

Posted: Tue Sep 12, 2017 7:03 pm
by gormank
I know its tedious, but after installing, I used to stop the service, copy a standard ini file over the new one, and restart the service.

net stop nscp
sc failure nscp reset= 86400 actions= restart/120000/restart/120000/none/120000
xcopy c:\Temp\nsclient.ini "c:\Program Files\NSClient++\nsclient.ini" /q /y
net start nscp

The sc command changed the service settings so it would restart a few times before giving up.

Re: NSclient Installtion from CMD

Posted: Wed Sep 13, 2017 9:17 am
by dwhitfield
Thanks @gormank!

Re: NSclient Installtion from CMD

Posted: Wed Sep 13, 2017 10:25 am
by spurrellian
gormank wrote:I know its tedious, but after installing, I used to stop the service, copy a standard ini file over the new one, and restart the service.

net stop nscp
sc failure nscp reset= 86400 actions= restart/120000/restart/120000/none/120000
xcopy c:\Temp\nsclient.ini "c:\Program Files\NSClient++\nsclient.ini" /q /y
net start nscp

The sc command changed the service settings so it would restart a few times before giving up.
This is exactly how I do it, also run checks for OS Architecture and copy plugins accross

Code: Select all

:::: Check OS Architecture ::::
:CheckOS
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)


:::: Install 64 Bit ::::
:64BIT
msiexec /i "%~dp0NSCP-0.4.3.143-x64.msi" /qb /norestart ADDDEFAULT=ALL REMOVE=Documentation REMOVE=WEBPlugins

copy "%~dp0nsclient.ini" "C:\Program Files\NSClient++\nsclient.ini" /y

GOTO PLUGIN

:::: Install 32 Bit ::::
:32BIT
msiexec /i "%~dp0NSCP-0.4.3.143-Win32.msi" /qb /norestart ADDDEFAULT=ALL REMOVE=Documentation REMOVE=WEBPlugins
copy "%~dp0nsclient.ini" "C:\Program Files\NSClient++\nsclient.ini" /y

GOTO PLUGIN


:::: Copy Nagios Plugins into Correct Directory ::::

:PLUGIN
IF EXIST "C:\WXScript\Scripts" (GOTO Wessex) ELSE (GOTO NonWessex)

:Wessex
md "C:\WXScript\Scripts\Scripts"
copy "%~dp0restart_auto_services.vbs" "C:\WXScript\Scripts\scripts\restart_auto_services.vbs"/y
copy "%~dp0nm-check-certificate-expiration.ps1" "C:\WXScript\Scripts\scripts\nm-check-certificate-expiration.ps1" /y
copy "%~dp0check_ms_win_updates.ps1" "C:\WXScript\Scripts\scripts\check_ms_win_updates.ps1" /y
copy "%~dp0restart_auto_services.vbs" "C:\Program Files\NSClient++\scripts\restart_auto_services.vbs"/y
copy "%~dp0nm-check-certificate-expiration.ps1" "C:\Program Files\NSClient++\scripts\nm-check-certificate-expiration.ps1" /y
copy "%~dp0check_ms_win_updates.ps1" "C:\Program Files\NSClient++\scripts\check_ms_win_updates.ps1" /y

net stop nscp
net start nscp

GOTO END

:NonWessex
copy "%~dp0restart_auto_services.vbs" "C:\Program Files\NSClient++\scripts\restart_auto_services.vbs"/y
copy "%~dp0nm-check-certificate-expiration.ps1" "C:\Program Files\NSClient++\scripts\nm-check-certificate-expiration.ps1" /y
copy "%~dp0check_ms_win_updates.ps1" "C:\Program Files\NSClient++\scripts\check_ms_win_updates.ps1" /y

net stop nscp
net start nscp

GOTO END

:END

Re: NSclient Installtion from CMD

Posted: Wed Sep 13, 2017 2:33 pm
by scottwilkerson
Thanks @spurrellian!

Re: NSclient Installtion from CMD

Posted: Sat Nov 11, 2017 8:21 am
by vinish098
Thanks all for the great suggestions.

I have around 700 windows servers in my environment.

Instead of login to each server and perform NSClient installation, Do we have any other option in order to save time and efforts from where we can push the installation from our Nagios server.