Home > nagios > HOWTO: Install and distribute Nagios NSCP Agent to all hosts for monitoring with Nagios XI

HOWTO: Install and distribute Nagios NSCP Agent to all hosts for monitoring with Nagios XI

This HOWTO will cover using a batch file and PSexec to distribute the Nagios NSCP v0.4.1.101 agent to all systems and configure it for use. 

The following assumptions are made:
•    An existing NSC.INI exists – possibly from a previous site or configuration, configured as desired. 
o    Configuration of the NSC.INI is not in scope for this document.  This document covers distribution and installation of a known working configuration
•    You will be using the NSCP v0.4.1.101 MSI packages from:
o    http://www.nsclient.org/files/stable//NSCP-0.4.1.101-x64.msi
o    http://www.nsclient.org/files/stable//NSCP-0.4.1.101-Win32.msi
•    The Windows Firewall will require an exception to allow the NSCP.exe to communicate
•    You need to support both 32 and 64 bit environments
•    As always, as the BAT is referencing a network shared MSI file, you MUST call PSEXEC with a username and password, or it will not accurately find the MSI package.

===== INSTALL_NAGIOS.BAT =====
@echo off

REM
REM PSEXEC Usage:
REM E:\ADMIN\BIN\PSEXEC.EXE \\SERVER –u DOMAIN\user -h -f -d -c \\FSRVTSTWSUS1\INSTALLS\NSCLIENT\INSTALL_NSCLIENT.BAT
REM

REM
REM Set variables to make updates easier
REM
set INSTALL_SERVER=FSRVTSTWSUS1
set INSTALL_SHARE=INSTALLS
set INSTALL_FOLDER=NSCLIENT
set INSTALL_LOG=INSTALL_NSCLIENT.LOG

REM
REM Check 32/64bit
REM
if %PROCESSOR_ARCHITECTURE% == AMD64 goto 64BIT
goto 32BIT

:64BIT
echo Installing Nagios nscp 64bit on %COMPUTERNAME% at %DATE% %TIME% >> \\%INSTALL_SERVER%\%INSTALL_SHARE%\%INSTALL_FOLDER%\%INSTALL_LOG%
msiexec /i \\%INSTALL_SERVER%\%INSTALL_SHARE%\%INSTALL_FOLDER%\v0.4.1.101\64bit\NSCP-0.4.1.101-x64.msi /qb
goto COMMON

:32BIT
echo Installing Nagios nscp 32bit on %COMPUTERNAME% at %DATE% %TIME% >> \\%INSTALL_SERVER%\%INSTALL_SHARE%\%INSTALL_FOLDER%\%INSTALL_LOG%
msiexec /i \\%INSTALL_SERVER%\%INSTALL_SHARE%\%INSTALL_FOLDER%\v0.4.1.101\32bit\NSCP-0.4.1.101-win32.msi /qb
goto COMMMON

:COMMON
REM
REM netsh firewall is deprecated, but referenced just in case
REM netsh firewall add allowedprogram "C:\Program Files\nsclient++\nscp.exe" "Nagios NSCP Agent" enable
REM
REM Open the firewall for NSCP Agent
REM
netsh advfirewall firewall add rule name="Nagios NSCP Agent" dir=in action=allow program="C:\Program Files\nsclient++\nscp.exe" profile=Domain
REM
REM Copy the INI file in
REM
xcopy \\%INSTALL_SERVER%\%INSTALL_SHARE%\%INSTALL_FOLDER%\NSC.ini "C:\Program Files\nsclient++\" /s/e/c/k/i/y

REM
REM Install the service and start it
REM
"C:\Program Files\nsclient++\nscp.exe" service –install
"C:\Program Files\nsclient++\nscp.exe" service –stop
"C:\Program Files\nsclient++\nscp.exe" service –start
goto END

:END

 

Advertisements
Categories: nagios
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: