Install Apache on the server first. Download the following software from http://www.nagios.org: nagios-3.2.3.tar.gznagios-plugins-1.4.15.tar.gznrpe-2.12.tar.gz install NagiosCore # Switch to root user su-l # Add na
Install Apache on the server first.
Download the following software from http://www.nagios.org:
- Nagios-3.2.3.tar.gz
- Nagios-plugins-1.4.15.tar.gz
- Nrpe-2.12.tar.gz
Install Nagios Core
- # Switch to the root user
- Su-l
- # Add a nagios user
- Useradd-m nagios
- Passwd nagios
- # Create a nagcmd group to allow users to execute commands on the web.
- Groupadd nagcmd
- Usermod-a-G nagcmd nagios
- Usermod-a-G nagcmd apache
- Tar xzvf nagios-3.2.3.tar.gz
- Cd nagios-3.2.3
- ./Configure -- with-command-group = nagcmd
- Make all
- Make install
- Make install-init
- Make install-config
- Make install-commandmode
After configure is complete, the following prompt is displayed:
- General Options:
- -------------------------
- Nagios executable: nagios
- Nagios user/group: nagios,nagios
- Command user/group: nagios,nagcmd
- Embedded Perl: no
- Event Broker: yes
- Install ${prefix}: /usr/local/nagios
- Lock file: ${prefix}/var/nagios.lock
- Check result directory: ${prefix}/var/spool/checkresults
- Init directory: /etc/rc.d/init.d
- Apache conf.d directory: /etc/httpd/conf.d
- Mail program: /bin/mail
- Host OS: linux-gnu
-
- Web Interface Options:
- ------------------------
- HTML URL: http://localhost/nagios/
- CGI URL: http://localhost/nagios/cgi-bin/
- Traceroute (used by WAP): /bin/traceroute
Configuration file directory/usr/local/nagios/etc
Modify the email address in/usr/local/nagios/etc/objects/contacts. cfgNagios@xxx.edu.cn. This mailbox is configured with a filter rule to forward all emailsXxx@139.com
Copy the fragment in/root/nagios-3.2.3/sample-config/httpd. conf to/usr/local/apache2/conf/httpd. conf.
Add a nagiosadmin user
/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Install Nagios Plugins
- tar xzvf nagios-plugins-1.4.15.tar.gz
- cd nagios-plugins-1.4.15
-
- ./configure --with-nagios-user=nagios --with-nagios-group=nagios
-
- make
-
- make install
Command installed in the/usr/local/nagios/libexec/directory
Start Nagios
- Chkconfig -- add nagios # add nagios to the service
- Chkconfig nagios on # enable this service
- Chkconfig -- list nagios # view service startup status
- # Check whether the script is correct
- /Usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios. cfg
- Service nagios start
Access http: // ip/nagios/
Install NRPE
Install Nagios Plugins first. If the agent is installed on the monitored host, add a nagios user first.
- tar xzvf nrpe-2.12.tar.gz
- cd nrpe-2.12
-
- ./configure
- make all
-
- make install-plugin
Install NRPE Daemon
NRPE Daemon port 5666
Follow the previous steps to install NRPE
- make install-daemon
- make install-daemon-config
-
- make install-xinetd
After the installation is complete, the configuration file of NRPE is in/usr/local/nagios/etc/nrpe. cfg.
Edit/etc/xinetd. d/nrpe
Only_from = 127.0.0.1 # Only one IP address can be added here
Edit/etc/services and add
nrpe 5666/tcp # NRPE
Restart the xinetd service
service xinetd restart
Run the following command to check whether the service is started properly
Netstat-at | grep nrpe # The following prompt should appear:Tcp 0 0 *: nrpe *: * LISTEN
Test the NRPE Deamon Service
# Test the Local Machine/Usr/local/nagios/libexec/check_nrpe-H localhost # Remote Test/Usr/local/nagios/libexec/check_nrpe-H 202.195.160.46 # Normal displayNRPE v2.12
Edit/usr/local/nagios/etc/objects/commands. cfg on the monitoring host and add the following command.
- define command{
- command_name check_nrpe
- command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
- }
Restart the Nagios service of the monitoring host
service nagios restart