Oct 02

1. Debian Etch installieren

Debian Etch von der Debian webseite herunterladen (www.debian.org) und installieren. Die Standardinstallation reicht.

 2. Nagios installieren

Mit dieser Anleitung hat es bei mir geklappt. 

What You’ll End Up With

If you follow these instructions, here’s what you’ll end up with:

  • Nagios and the plugins will be installed underneath /usr/local/nagios
  • Nagios will be configured to monitor a few aspects of your local system (CPU load, disk usage, etc.)
  • The Nagios web interface will be accessible at http://localhost/nagios/

Required Packages

Make sure you’ve installed the following packages on your Ubuntu installation before continuing.

  • Apache 2
  • GCC compiler and development libraries
  • GD development libraries

You can use apt-get to install these packages by running the following commands:

sudo apt-get install apache2 sudo apt-get install build-essential sudo apt-get install libgd2-dev

Create Account Information

Become the root user.

sudo -s

Create a new nagios user account and give it a password.

/usr/sbin/useradd nagios passwd nagios

On Ubuntu server edition (6.01 and possible newer versions), you will need to also add a nagios group (it’s not created by default). You should be able to skip this step on desktop editions of Ubuntu.

/usr/sbin/groupadd nagios /usr/sbin/usermod -G nagios nagios

Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

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

Download Nagios and the Plugins

Create a directory for storing the downloads.

mkdir ~/downloads cd ~/downloads

Download the source code tarballs of both Nagios and the Nagios plugins (visit http://www.nagios.org/download/ for links to the latest versions). At the time of writing, the latest versions of Nagios and the Nagios plugins were 3.0b4 and 1.4.7, respectively.

wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0b4.tar.gz wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.7.tar.gz

Compile and Install Nagios

Extract the Nagios source code tarball.

cd ~/downloads tar xzf nagios-3.0b4.tar.gz cd nagios-3.0b4

Run the Nagios configure script, passing the name of the group you created earlier like so:

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

Compile the Nagios source code.

make all

Install binaries, init script, sample config files and set permissions on the external command directory.

make install make install-init make install-config make install-commandmode

Don’t start Nagios yet – there’s still more that needs to be done…

Customize Configuration

Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. You’ll need to make just one change before you proceed…

Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alerts.

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

Configure the Web Interface

Install the Nagios web config file in the Apache conf.d directory.

make install-webconf

Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account – you’ll need it later.

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

Restart Apache to make the new settings take effect.

/etc/init.d/apache2 reload

Compile and Install the Nagios Plugins

Extract the Nagios plugins source code tarball.

cd ~/downloads tar xzf nagios-plugins-1.4.7.tar.gz cd nagios-plugins-1.4.7

Compile and install the plugins.

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

Start Nagios

Configure Nagios to automatically start when the system boots.

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

Verify the sample Nagios configuration files.

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

If there are no errors, start Nagios.

/etc/init.d/nagios start

Login to the Web Interface

You should now be able to access the Nagios web interface at the URL below. You’ll be prompted for the username (nagiosadmin) and password you specified earlier.

http://localhost/nagios/

Click on the “Service Detail” navbar link to see details of what’s being monitored on your local machine. It will take a few minutes for Nagios to check all the services associated with your machine, as the checks are spread out over time.

Other Modifications

If you want to receive email notifications for Nagios alerts, you need to install the mailx (Postfix) package.

sudo apt-get install mailx

You’ll have to edit the Nagios email notification commands found in /usr/local/nagios/etc/commands.cfg and change any ‘/bin/mail’ references to ‘/usr/bin/mail’. Once you do that you’ll need to restart Nagios to make the configuration changes live.

sudo /etc/init.d/nagios restart

Configuring email notifications is outside the scope of this documentation. Refer to your system documentation, search the web, or look to the NagiosCommunity.org wiki for specific instructions on configuring your Ubuntu system to send email messages to external addresses.

 3. Windows Client installieren

Introduction

This document describes how you can monitor “private” services and attributes of Windows machines, such as:

  • Memory usage
  • CPU load
  • Disk usage
  • Service states
  • Running processes
  • etc.

Publicly available services that are provided by Windows machines (HTTP, FTP, POP3, etc.) can be monitored easily by following the documentation on monitoring publicly available services.

Note Note: These instructions assume that you’ve installed Nagios according to the quickstart guide. The sample configuration entries below reference objects that are defined in the sample config files (commands.cfg, templates.cfg, etc.) that are installed if you follow the quickstart.

Overview

Monitoring a Windows Machine

Monitoring private services or attributes of a Windows machine requires that you install an agent on it. This agent acts as a proxy between the Nagios plugin that does the monitoring and the actual service or attribute of the Windows machine. Without installing an agent on the Windows box, Nagios would be unable to monitor private services or attributes of the Windows box.

For this example, we will be installing the NSClient++ addon on the Windows machine and using the check_nt plugin to communicate with the NSClient++ addon. The check_nt plugin should already be installed on the Nagios server if you followed the quickstart guide.

Other Windows agents (like NC_Net) could be used instead of NSClient++ if you wish – provided you change command and service definitions, etc. a bit. For the sake of simplicity I will only cover using the NSClient++ addon in these instructions.

Steps

There are several steps you’ll need to follow in order to monitor a new Windows machine. They are:

  1. Perform first-time prerequisites
  2. Install a monitoring agent on the Windows machine
  3. Create new host and service definitions for monitoring the Windows machine
  4. Restart the Nagios daemon

What’s Already Done For You

To make your life a bit easier, a few configuration tasks have already been done for you:

  • A check_nt command definition has been added to the commands.cfg file. This allows you to use the check_nt plugin to monitor Window services.
  • A Windows server host template (called windows-server) has already been created in the templates.cfg file. This allows you to add new Windows host definitions in a simple manner.

The above-mentioned config files can be found in the /usr/local/nagios/etc/objects/ directory. You can modify the definitions in these and other definitions to suit your needs better if you’d like. However, I’d recommend waiting until you’re more familiar with configuring Nagios before doing so. For the time being, just follow the directions outlined below and you’ll be monitoring your Windows boxes in no time.

Prerequisites

The first time you configure Nagios to monitor a Windows machine, you’ll need to do a bit of extra work. Remember, you only need to do this for the *first* Windows machine you monitor.

Edit the main Nagios config file.

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

Remove the leading pound (#) sign from the following line in the main configuration file:

#cfg_file=/usr/local/nagios/etc/objects/windows.cfg

Save the file and exit.

What did you just do? You told Nagios to look to the /usr/local/nagios/etc/objects/windows.cfg to find additional object definitions. That’s where you’ll be adding Windows host and service definitions. That configuration file already contains some sample host, hostgroup, and service definitions. For the *first* Windows machine you monitor, you can simply modify the sample host and service definitions in that file, rather than creating new ones.

Installing the Windows Agent

Before you can begin monitoring private services and attributes of Windows machines, you’ll need to install an agent on those machines. I recommend using the NSClient++ addon, which can be found at http://sourceforge.net/projects/nscplus. These instructions will take you through a basic installation of the NSClient++ addon, as well as the configuration of Nagios for monitoring the Windows machine.

1. Download the latest stable version of the NSClient++ addon from http://sourceforge.net/projects/nscplus

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 (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.

10. Success! The Windows server can now be added to the Nagios monitoring configuration…

Configuring Nagios

Now it’s time to define some object definitions in your Nagios configuration files in order to monitor the 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 	}

Good. 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 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. This is useful when it comes time to upgrade your Windows servers to a newer version of the addon, as you’ll be able to tell which Windows machines still need to be upgraded to the latest version of NSClient++.

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 	}

That’s it for now. You’ve added some basic services that should be monitored on the Windows box. Save the configuration file.

Password Protection

If you specified a password in the NSClient++ configuration file on the Windows machine, you’ll need to modify the check_nt command definition to include the password. Open the commands.cfg file for editing.

vi /usr/local/nagios/etc/commands.cfg

Change the definition of the check_nt command to include the “-s <PASSWORD>” argument (where PASSWORD is the password you specified on the Windows machine) like this:

define command{ 	command_name	check_nt 	command_line	$USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s PASSWORD -v $ARG1$ $ARG2$ 	}

Save the file.

Restarting Nagios

You’re done with modifying the Nagios configuration, so you’ll need to verify your configuration files and restart Nagios.

If the verification process produces any errors messages, fix your configuration file before continuing. Make sure that you don’t (re)start Nagios until the verification process completes without any errors!

Weitere Links: 

http://nagios.sourceforge.net/docs/2_0/int-snmptrap.html

http://nagios.sourceforge.net/docs/2_0/int-snmptrap.html

http://www.nagiosexchange.org/Windows.49.0.html

http://nagios.sourceforge.net/docs/2_0/configcgi.html#default_statusmap_layout

http://ovrt.nist.gov/cosmo/