This is our readme. You will find all of the commands we used for the configuration of the client role and server role.

This readme is not for the average user. It is implied that you have a fair working knowledge of the linux OS.

Most of the commands below are entered into a unix/linux command prompt unless otherwise noted.

This is the complete readme file and is the latest version. You will also find some of the sections on their own page.

Sections on their own page are used to speed up the process of the user finding the information they need.

___________________——————-____________________———————___________________________

Topics:

Section 1A: Linux Server Installation - Scripted Method - For CD Disc
Section 1B: Linux Server Installation - Scripted Method - For USB Flash Drive
Section 1C: Linux Server Installation - Manual Method
Section 2: Linux client Installation - Manual Method
Section 3: Configuring the Server for Linux Client - Manual Method
Section 4: Windows client configuration
Section 5: Configuring the Server for Windows Client
Section 6: Troubleshooting

Section 1A: LINUX SERVER INSTALLATION - SCRIPTED METHOD - FOR CD DISC

1. If in Ubuntu Desktop Edition, open terminal by going to the Applications menu, then to the Accessories sub-menu, then click on Terminal

2. Become Root User
 - Enter this command: SU
 - Enter root password

3. Load installation disc into the computer
 A. For Ubuntu Desktop Edition
 i. Simply insert the disc. Ubuntu will auto-mount the disc.
 B. For Ubuntu Server Edition
 i. Insert disc into computer
 ii. Enter this command: sudo mount /dev/scd0 /media/cdrom0
 iii. If the above give you the following error: "mount: mount point /media/cdrom0 does not exist", enter the following command: sudo mkdir /media/cdrom0
 iv. After making that directory, try this command again to mount installation cd: sudo mount /dev/scd0 /media/cdrom0 

4. Go to the Scripts folder inside the install disc:
 A. For Ubuntu Desktop Edition
 i. Enter the following command: cd /media/*THE NAME OF THE DISC (FIX THIS FOR THE FINAL VERSION OF READ ME)*/scripts
 B. For Ubuntu Server Edition
 i. Enter the following command: cd /media/cdrom0/scripts

5. Run one of the following commands to begin the proper install of Nagios to the correct Operating System
 A. For Ubuntu Desktop Edition
 i. ./ubuntu-desktop-server.sh
 B. For Ubuntu Server Edition
 i. ./ubuntu-server-server.sh

The computer will start downloading and installing necessary software packages

6. The script will then ask you to assign a password for the system user "Nagios". This user account is used by the Nagios server to run tasks system wide. It is not meant for the user the log into. Enter the password you wish to use, then hit enter. The script will then ask you to re-enter it. Re-enter the password and hit enter to continue the install process.

7. The install script will then ask you to edit the contacts.cfg file. You have a choice of either opening it in either VI or Nano. Type in v for VI or n for Nano. Once open, scroll down to the email line in the Contacts section. Change the e-mail address accordingly. When done, type in ":wq" then press enter if in VI or press "ctrl", then "x", then "y", and finally press enter if in Nano.

8. The script will then ask you for a password for the "nagiosadmin" account. This account is defined in Nagios and is used to login into the web interface at http://localhost/nagios. Enter the password you wish then press enter. Re-enter the password then hit enter again to continue the setup process.

9. The next time the scripts stops, looks for lines that say "Total Warnings:" and "Total Errors:". If they both say zero next to them and say the following line under them, "Things look ok - No serious problems were detected during the pre-flight check." then that means the install process was successful.

10. Finally, the script will then ask you if you want to clean up the downloaded setup files in /home/downloads. The files that were downloaded into this directory include the various archive and de-compressed files needed to install Nagios and various Nagios plug-ins. Typing either y or n will either delete these files or leave them in there. 

This is at the discretion of the network administrator. These files are not needed for normal operation, so if you wish to remove them, do not worry about Nagios being affected. If you have any other files in that directory not related to Nagios, do not worry about them. They will not be affected.

Section 1B: LINUX SERVER INSTALLATION - SCRIPTED METHOD - FOR USB FLASH DRIVE

1. If in Ubuntu Desktop Edition, open terminal by going to the Applications menu, then to the Accessories sub-menu, then click on Terminal

2. Become Root User
 - Enter this command: SU
 - Enter root password

3. Insert installation USB drive into the computer
 A. For Ubuntu Desktop Edition
 i. Simply insert the USB drive. Ubuntu will auto-mount the USB drive.
 B. For Ubuntu Server Edition
 i. Insert USB drive into computer
 ii. Create the /media/external directory by entering this command: mkdir /media/external
 iii. Enter this command: sudo mount /dev/sdb1 /media/external

4. Go to the Scripts folder inside the install USB drive:
 A. For Ubuntu Desktop Edition
 i. Enter the following command: cd /media/*THE NAME OF THE USB DRIVE (FIX THIS FOR THE FINAL VERSION OF READ ME)*/scripts
 B. For Ubuntu Server Edition
 i. Enter the following command: cd /media/external/scripts

5. If you should get an error saying that the script cannot be executed, run this command: chmod ugo+rx ubuntu-desktop-server.sh

If you have had no problems, continue to step 6.

6. Run one of the following commands to begin the proper install of Nagios to the correct Operating System
 A. For Ubuntu Desktop Edition
 i. ./ubuntu-desktop-server.sh
 B. For Ubuntu Server Edition
 i. ./ubuntu-server-server.sh

The computer will start downloading and installing necessary software packages

7. The script will then ask you to assign a password for the system user "Nagios". This user account is used by the Nagios server to run tasks system wide. It is not meant for the user the log into. Enter the password you wish to use, then hit enter. The script will then ask you to re-enter it. Re-enter the password and hit enter to continue the install process.

8. The install script will then ask you to edit the contacts.cfg file. You have a choice of either opening it in either VI or Nano. Type in v for VI or n for Nano. Once open, scroll down to the email line in the Contacts section. Change the e-mail address accordingly. When done, type in ":wq" then press enter if in VI or press "ctrl", then "x", then "y", and finally press enter if in Nano.

9. The script will then ask you for a password for the "nagiosadmin" account. This account is defined in Nagios and is used to login into the web interface at http://localhost/nagios. Enter the password you wish then press enter. Re-enter the password then hit enter again to continue the setup process.

10. The next time the scripts stops, looks for lines that say "Total Warnings:" and "Total Errors:". If they both say zero next to them and say the following line under them, "Things look ok - No serious problems were detected during the pre-flight check." then that means the install process was successful.

11. Finally, the script will then ask you if you want to clean up the downloaded setup files in /home/downloads. The files that were downloaded into this directory include the various archive and de-compressed files needed to install Nagios and various Nagios plug-ins. Typing either y or n will either delete these files or leave them in there. 

This is at the discretion of the network administrator. These files are not needed for normal operation, so if you wish to remove them, do not worry about Nagios being affected. If you have any other files in that directory not related to Nagios, do not worry about them. They will not be affected.

Section 1C: THE FOLLOWING INSTRUCTIONS ARE FOR SERVER CONFIGURATION

1) Run the commands to install this packages

 sudo apt-get install apache2

 sudo apt-get install build-essential

 sudo apt-get install libgd2-xpm-dev

 sudo aptitude install php5 libapache2-mod-php5

 sudo apt-get install openssh-server

2) Restart Apache server to apply newly installed php packages

 /etc/init.d/apache2 restart

3) creating account:

 (root user)
 sudo -s 

 /usr/sbin/useradd nagios

 passwd nagios

 (used "nagios")

 /usr/sbin/groupadd nagcmd

 /usr/sbin/usermod -G nagcmd nagios

 /usr/sbin/usermod -G nagcmd www-data

4) Downloading and Installing:

 mkdir ~/downloads

 cd ~/downloads

 wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz

 wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz

 cd ~/downloads

 tar xzf nagios-3.2.1.tar.gz

 cd nagios-3.2.1/

 ./configure --with-command-group=nagcmd

 make all

 make install

 make install-init

 make install-config

 make install-commandmode

5) Go to this file and edit accordingly in VI:

 /usr/local/nagios/etc/objects/contacts.cfg (edit accordingly)

6) Configuring Web interface:

 make install-webconf

 htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 

 used "nagios"

7) restarting apache for new settings:

 /etc/init.d/apache2 reload

8) Installing nagios plug ins:

 cd ~/downloads

 tar xzf nagios-plugins-1.4.14.tar.gz

 cd nagios-plugins-1.4.14/

 ./configure --with-nagios-user=nagios --with-nagios-group=nagios

 make

 make install

9) Configuring nagios to start up on boot:

 ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

10)Verify Nagios configuration files:

 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

11)If not errors type the following command:

 /etc/init.d/nagios start

NOTE:

- it may still give a ssh error. Within 30 seconds after an active check is ran by Nagios on localhost, the error should go away

- to remove the "2 services disabled" error in the tactical overview: go to the tactical overview, click on the error, and it will
show you the "http" and the "ssh" services. Look in the "status column for a symbol that looks like a speaker-muted symbol.
Click on that and nagios will ask you if you want to enable the notifications for this services. Enable it and do the same for both services.

Section 2:
LINUX CLIENT INSTALLATION:

1) Download Nagios and NRPE add-on and run the commands:

 # mkdir /home/downloads

 # cd /home/downloads

 # wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz

 # wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz

2) Open terminal and type in the following commands:

 # apt-get install libssl-dev

 # apt-get install xinetd

 # useradd nagios

 # passwd nagios
 (used "nagios")

 # tar xvfz nagios-plugins-1.4.11.tar.gz

 # cd nagios-plugins-1.4.14

 # export LDFLAGS=-ldl

 # ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround

 # make

 # make install

 # chown nagios.nagios /usr/local/nagios

 # chown -R nagios.nagios /usr/local/nagios/libexec/

 # cd /home/downloads

 # tar xvfz nrpe-2.12.tar.gz

 # cd nrpe-2.12

 # ./configure

 # make all

 # make install-plugin

 # make install-daemon

 # make install-daemon-config

 # make install-xinetd

3) modify the following file in NANO or VI:

 /etc/xinetd.d/nrpe   

 + In the file go to the part that said "only_from" and enter the external IP of the nagios server next to the 127.0.0.1 entry. Make sure to have a space in between the 127.0.0.1 address and the external address of the nagios server.

 /etc/services

 + Go to the end of the file and add the following to the end:

 nrpe 5666/tcp #NRPE

4) Run the following commands:

 # service xinetd restart

5) Type the following command to verify NRPE is running properly:

 # /usr/local/nagios/libexec/check_nrpe -H localhost

 This is the output you should get:

 NRPE v2.12

6) Type the following command to verify status of NRPE:

 # netstat -at | grep nrpe

 This is the output you should get:

 tcp 0      0 *:nrpe *:*                         LISTEN

7) Go to /usr/local/nagios/etc/nrpe.cfg

 -Scroll down to were it mentions the hardcoded commands arguments

 - update the "check_disk"

 change the command /dev/hda1 to /dev/sda1 

SECTION 3:CONFIGURING THE SERVER FOR LINUX CLIENT

(THE FOLLOWING IS DONE ON THE NAGIOS LINUX SERVER)

1) Run and download the following files:

 # wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz

 # tar xvfz nrpe-2.12.tar.gz

 # cd nrpe-2.1.2

 # apt-get install libssl-dev

 # ./configure

 # make all

 # make install-plugin

 # /usr/local/nagios/libexec/check_nrpe -H *external IP of client*

 # cd /usr/local/nagios/etc/objects

2) Run VI or NANO and copy all of the following:

Add the following and replace the values “host_name” “alias” “address” with the values that match your setup:

** The “host_name” you set for the “define_host” section must match the “host_name” in the “define_service” section **

define host{
 name                  linux-box-remote             ; Name of this template
 use                   generic-host          ; Inherit default values
 check_period          24x7
 check_interval        5
 retry_interval        1
 max_check_attempts    10
 check_command         check-host-alive
 notification_period   24x7
 notification_interval 30
 notification_options  d,r
 contact_groups        admins
 register              0          ; DONT REGISTER THIS - ITS A TEMPLATE
 }

define host{
 use       linux-box-remote     ; Inherit default values from a template
 host_name Centos5    ; The name we're giving to this server
 alias     Centos5 ; A longer name for the server
 address   192.168.0.5   ; IP address of the server
 }

define service{
 use                 generic-service
 host_name           Centos5
 service_description CPU Load
 check_command       check_nrpe!check_load
 }
define service{
 use                 generic-service
 host_name           Centos5
 service_description Current Users
 check_command       check_nrpe!check_users
 }
define service{
 use                 generic-service
 host_name           Centos5
 service_description /dev/hda1 Free Space
 check_command       check_nrpe!check_hda1
 }
define service{
 use                 generic-service
 host_name           Centos5
 service_description Total Processes
 check_command       check_nrpe!check_total_procs
 }
define service{
 use                 generic-service
 host_name           Centos5
 service_description Zombie Processes
 check_command       check_nrpe!check_zombie_procs
 }

2) Save it to:
 /usr/local/nagios/etc/objects/linux-box-remote.cfg

3) Copy the PING, Root Partition, Swap Usage services from localhost.cfg and add those to the file listed above

4) Open VI or NANO and go to the following files:

 /usr/local/nagios/etc/nagios.cfg

5) Add the following to the file:

 # Definitions for monitoring remote Linux machine
 cfg_file=/usr/local/nagios/etc/objects/linux-box-remote.cfg

6) Type in reload and restart nagios:

 # service nagios reload

 # service nagios restart

This is complete and you now have setup the LINUX client to the server

Section 4: WINDOWS INSTALLATION (NRPE)

1. Copy NSClient to the C: drive

2. Unzip the NSClient++ files into a new C:\NSClient++ directory

3. Open a command prompt and change to the C:\NSClient++ directory

4. Register the NSClient++ system service with the following command:

 nsclient++ /install

5. Install the NSClient++ systray with the following command ('SysTray' is case-sensitive):

 nsclient++ SysTray

6. Open the services manager and make sure the NSClientpp service is allowed to interact with the desktop
(if is not the server right click my computer and scroll down to manage, then services and applications click on services and it is in there,
Last right click the NSclient)
(see the 'Log On' tab of the services manager). If it isn't already allowed to interact with the desktop, check the box to allow it to.

NSClientpp

7. Edit the NSC.INI file (located in the C:\NSClient++ directory) and make the following changes:

 * Uncomment all the modules listed in the [modules] section, except for CheckWMI.dll and RemoteConfiguration.dll
 * Optionally require a password for clients by changing the 'password' option in the [Settings] section.
 * Uncomment the 'allowed_hosts' option in the [Settings] section. Add the IP address of the Nagios server to this line,
 or leave it blank to allow all hosts to connect.
 * Make sure the 'port' option in the [NSClient] section is uncommented and set to '12489' (the default port).

8. Start the NSClient++ service with the following command:

 nsclient++ /start

9. If installed properly, a new icon should appear in your system tray. It will be a yellow circle with a black 'M' inside.

Section 5: CONFIGURING THE SERVER FOR LINUX CLIENT

Monitoring new windows machine
Open the windows.cfg file for editing.

vi /usr/local/nagios/etc/objects/windows.cfg

Add a new host definition for the Windows machine that you're going to monitor. If this is the *first* Windows machine you're monitoring,
 you can simply modify the sample host definition in windows.cfg. Change the host_name, alias, and address fields to appropriate values for the Windows box.

define host{

 use        windows-server    ; Inherit default values from a Windows server template (make sure you keep this line!)

 host_name        winserver

 alias        My Windows Server

 address        192.168.1.2

 }

Now you can add some service definitions (to the same configuration file) in order to tell Nagios to monitor different aspects of the Windows machine.
 If this is the *first* Windows machine you're monitoring, you can simply modify the sample service definitions in windows.cfg.

Note: Replace "winserver" in the example definitions below with the name you specified in the host_name directive of the host definition you just added.

Add the following service definition to monitor the version of the NSClient++ addon that is running on the Windows server.

define service{

 use            generic-service

 host_name            winserver

 service_description    NSClient++ Version

 check_command        check_nt!CLIENTVERSION

 }

Add the following service definition to monitor the uptime of the Windows server.

define service{

 use            generic-service

 host_name            winserver

 service_description    Uptime

 check_command        check_nt!UPTIME

 }

Add the following service definition to monitor the CPU utilization on the Windows server and generate a CRITICAL alert if the 5-minute CPU load is 90%
 or more or a WARNING alert if the 5-minute load is 80% or greater.

define service{

 use            generic-service

 host_name            winserver

 service_description    CPU Load

 check_command        check_nt!CPULOAD!-l 5,80,90

 }

Add the following service definition to monitor memory usage on the Windows server and generate a CRITICAL alert if
memory usage is 90% or more or a WARNING alert if memory usage is 80% or greater.

define service{

 use            generic-service

 host_name            winserver

 service_description    Memory Usage

 check_command        check_nt!MEMUSE!-w 80 -c 90

 }

Add the following service definition to monitor usage of the C:\ drive on the Windows server and generate a CRITICAL alert if
 disk usage is 90% or more or a WARNING alert if disk usage is 80% or greater.

define service{

 use            generic-service

 host_name            winserver

 service_description    C:\ Drive Space

 check_command        check_nt!USEDDISKSPACE!-l c -w 80 -c 90

 }

Add the following service definition to monitor the W3SVC service state on the Windows machine and generate a CRITICAL alert if the service is stopped.

define service{

 use            generic-service

 host_name            winserver

 service_description    W3SVC

 check_command        check_nt!SERVICESTATE!-d SHOWALL -l W3SVC

 }

Add the following service definition to monitor the Explorer.exe process on the Windows machine and generate a CRITICAL alert if the process is not running.

define service{

 use            generic-service

 host_name            winserver

 service_description    Explorer

 check_command        check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe

 }

The Basic configuration have been added, Save the configuration file and it is done.

Section 6: Troubleshooting

Problem 1: My hard drive free space check come back with the following error after installing linux client: "DISK CRITICAL - /dev/hda1 is not accessible: No Such file or directory"!!!!

Solution 1: Assuming that this is a fresh install, and the client and server are installed correctly, this must be a problem with the configuration of the linux client. In particular, the file in question on the client is at /usr/local/nagios/etc/nrpe.cfg. If you open the file and go to near the end of the file (on line 201), you will find the following line:

command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1

If you look at the end of the line, you notice the part that says, "/dev/hda1". Essentially, that is the path of the first IDE device. Typically, this is the first hard drive or sometimes a CD/DVD drive. Now, on newer installations of Ubuntu, it will identify the hard drive as "/dev/sda1". If this isn't corrected, then the check_disk test will fail.

To correct this error, change /dev/hda1 to /dev/sda1. Line 201 of file /usr/local/nagios/etc/nrpe should look like this:

command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1

Problem 2: On step #6 of Section 1A or 1B, I typed in the wrong password the 2nd time and it didn't save my password, but it kept going!

Solution 2: If you didn't enter the same spelling of the password the second time entering it in, don't worry. You can still set it. To insert the password, do the following:

1. Become Root User
 - Enter this command: SU
 - Enter root password

2. Set password for user "nagios"
 - Enter this command: passwd nagios
 - Enter the password you wish to use.
 - Press enter.
 - Re-enter the password you wish to use.
 - Press enter again.

Problem 3: On step # 8 of Section 1A or 1B, I typed in the wrong password the 2nd time and it didn't save my password, but it kept going!

Solution 3: If you didn't enter the same spelling of the password the second time entering it in, don't worry. You can still set it. To insert the password, do the following:

1. Become Root User
 - Enter this command: SU
 - Enter root password

2. Set password for web interface user "nagiosadmin"
 - Enter this command: htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
 - Enter the password you widh to use.
 - Press enter.
 - Re-enter the password you wish to use.
 - Press enter again.

3. Restart Apache Web Server
 - Enter this command: /etc/init.d/apache2 reload