1) Create Account Information
Become the root user.
引用
# su -l
Create a new nagios user account and give it a password.
引用
#/usr/sbin/useradd -m nagios
#passwd nagios
Create a new nagios group. Add the nagios user to the group.
引用
#/usr/sbin/groupadd nagios
#/usr/sbin/usermod -G nagios nagios
#/usr/sbin/usermod -G nagios apache2 //apache2是在Apache2的时候你设置的用户名
2)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.0.5 and 1.4.11, respectively.
引用
#wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.5.tar.gz
#wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz
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 // - This installs the main program, CGIs, and HTML files
引用
#make install-init //- This installs the init script in /etc/rc.d
引用
#make install-commandmode //- This installs and configures permissions on the directory for holding the external command file
引用
#make install-config //- This installs *SAMPLE* config files in /usr/local/nag ios/etc
注意:Don’t start Nagios yet - there’s still more that needs to be done...
4) 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 //更改email地址nagiosadmin的联系人定义信息中的EMail信息为你的EMail信息以接收报警内容。
5) Configure the Web Interface
Install the Nagios web config file in the Apache conf.d directory.
引用
#make install-webconf //- This installs the Apache config file for the Nagios web interface
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you
assign to this account - you’ll need it later.
引用
#/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache to make the new settings take effect.
引用
# /etc/init.d/apachectl restart
6) Compile and Install the Nagios Plugins
Extract the Nagios plugins source code tarball.
进到nagios-plugins-1.4.11.tar.gz所在的目录
引用
#tar xzf nagios-plugins-1.4.11.tar.gz
#cd nagios-plugins-1.4.11
Compile and install the plugins.
引用
#./configure --with-nagios-user=nagios --with-nagios-group=nagios
#make
#make install
7) Start Nagios
Add Nagios to the list of system services and have it automatically start when the system boots.
引用
#chkconfig --add nagios
#chkconfig nagios on
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.
引用
#/usr/local/nagios/bin/nagios start
10) 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.