#=========================================Install Nagios ====================================
CD/OPT
Groupadd Nagios
Groupadd nagcmd
Useradd Nagios-G nagcmd-D/usr/local/Nagios
Chown Nagios. Nagios/usr/local/Nagios/
Chmod 755/usr/local/Nagios
Wget
[Url] URLs
Tar-zxvf nagios-3.0.2.tar.gz
CD nagios-3.0.2
./Configure -- With-command-group = nagcmd
Make all
Make install
Make install-init
Make install-config
Make install-commandmode/usr/local/apache2/bin/htpasswd-C/usr/local/Nagios/etc/htpasswd. Users nagiosadmin
# Editing the httpd. conf configuration file
ScriptAlias/Nagios/cgi-bin "/usr/local/Nagios/sbin" <directory "/usr/local/Nagios/sbin">
# Sslrequiressl
Options execcgi
AllowOverride none
Order allow, deny
Allow from all
# Order deny, allow
# Deny from all
# Allow from 127.0.0.1
Authname "Nagios access"
Authtype basic
Authuserfile/usr/local/Nagios/etc/htpasswd. Users
Require valid-user
</Directory> alias/Nagios "/usr/local/Nagios/share" <directory "/usr/local/Nagios/share">
# Sslrequiressl
Options none
AllowOverride none
Order allow, deny
Allow from all
# Order deny, allow
# Deny from all
# Allow from 127.0.0.1
Authname "Nagios access"
Authtype basic
Authuserfile/usr/local/Nagios/etc/htpasswd. Users
Require valid-user
</Directory> # restart Apache
Killall httpd #========================== install Nagios plugins ======== ==============================
CD/OPT
Wget
[Url] URLs
Tar-zxvf nagios-plugins-1.4.11.tar.gz
CD nagios-plugins-1.4.11
. /Configure -- prefix =/usr/local/Nagios -- With-Nagios-user = Nagios -- With-Nagios-gourp = Nagios -- With-mysql =/usr/local/mysql5 /-- enable-perl-Modules
Make
Make install # configure and start Nagios
/Usr/local/Nagios/bin/Nagios-V/usr/local/Nagios/etc/Nagios. cfg # If "Whoops!" is displayed! Error: cocould not read object configuration data! ", Because the Nagios background process is not started, execute the following command
/Usr/local/Nagios/bin/Nagios-D/usr/local/Nagios/etc/Nagios. CFG #============================== install the nrpe plug-in ======== ======================================
# Monitor a remote Linux host
# Install settings on the Monitoring Server
CD/OPT
Wget
[Url] URLs
# Installation Method on monitoring host
Tar-zxvf nrpe-2.8.1.tar.gz
CD nrpe-2.8.1
./Configure
Make all
Make install
Make install-plugin --- the supervisor needs to install the check_nrpe plug-in, which is not required by the supervisor.
######################################## ##################################
# Installation Method on Monitored hosts
CD/OPT
Useradd Nagios-D/usr/local/Nagios
Chown Nagios. Nagios/usr/local/Nagios/
Tar-zxvf nagios-plugins-1.4.11.tar.gz
CD nagios-plugins-1.4.11
./Configure -- enable-perl-modules -- With-ping-command = Ping
Make
Make installcd/OPT
Tar-zxvf nrpe-2.8.1.tar.gz
CD nrpe-2.8.1
./Configure
Make all
Make install
Make install-plugin
Make install-daemon
Make install-Daemon-configvi/usr/local/Nagios/etc/nrpe. conf
Allowed_hosts = 192.168.8.150
# To monitor swap, add
Command [check_swap] =/usr/local/Nagios/libexec/check_swap-W 20%-C 10%
Command [check_sda1] =/usr/local/Nagios/libexec/check_disk-W 20-C 10-P/dev/sda1
# Sdb1 can be changed according to the actual situation of the root node. The hard disk type here is scsivi/etc/services.
# Add nrpe
Nrpe 5666/tcp # nrpe
# Start nrpe
/Usr/local/Nagios/bin/nrpe-C/usr/local/Nagios/etc/nrpe. cfg-dnetstat-at | grep nrpe
Netstat-an | grep 5666 ################################## ######################################## ###
# Configure the Monitoring Server
# Add nrpe Definition
VI/usr/local/Nagios/etc/objects/commands. cfg
# 'Check _ nrpe 'command Definition
Define command {
Command_name check_nrpe
Command_line $ user1 $/check_nrpe-h $ hostaddress $-C $ arg1 $
} Vi/usr/local/Nagios/etc/cgi. cfg
Change use_authentication = 1 to use_authentication = 0. If the page cannot be displayed
Authorized_for_system_commands = nagiosadmin, Kerry -- Kerry is the HTTP access Authorization User
Authorized_for_all_services = nagiosadmin, Kerry
Authorized_for_all_hosts = nagiosadmin, Kerry
Authorized_for_all_service_commands = nagiosadmin, Kerry
Authorized_for_all_host_commands = nagiosadmin, Kerry # test nrpe. Otherwise, it will work normally.
/Usr/local/Nagios/libexec/check_nrpe-H localhostkillall Nagios
/Usr/local/Nagios/bin/Nagios-D/usr/local/Nagios/etc/Nagios. cfgecho "/usr/local/Nagios/bin/nrpe-C/usr/local/Nagios/etc/nrpe. CFG-d ">/etc/rc. local
EHCO "/usr/local/Nagios/bin/Nagios-D/usr/local/Nagios/etc/Nagios. cfg ">/etc/rc. local # Problem: communications for this service have been disabled
# Solution: Enable configurications for this service # problem: the status map page cannot be displayed.
# Solution: ln-S/usr/local/lib/libgd. so.2/usr/lib/libgd. so.2vi/usr/local/Nagios/etc/Nagios. cfg
# Add
Export _file =/usr/local/Nagios/etc/objects/emos-mailserver.cfg
# Emos-mailserver.cfg this file name can be customized # configure the emos-mailserver.cfg file just defined
VI/usr/local/Nagios/etc/objects/emos-mailserver.cfg
Define host {
Use Linux-Server
Host_name emos-MailServer
Alias emos-MailServer
Address 192.168.8.151
}
Define Service {
Use generic-Service
Host_name emos-MailServer
Service_description HTTP
Check_command check_http
}
Define Service {
Use generic-Service
Host_name emos-MailServer
Service_description SSH
Check_command check_ssh
} Define service {
Use generic-Service
Host_name emos-MailServer
Service_description SMTP
Check_command check_smtp
} Define service {
Use generic-Service
Host_name emos-MailServer
Service_description POP3
Check_command check_pop
}
# Define service {
# Use generic-Service
# Host_name emos-MailServer
# Service_description MySQL
# Check_command check_mysql
#}
Define Service {
Use generic-Service
Host_name emos-MailServer
Service_description check-swap
Check_command check_nrpe! Check_swap
}
Define Service {
Use generic-Service
Host_name emos-MailServer
Service_description check-Load
Check_command check_nrpe! Check_load} define service {
Use generic-Service
Host_name emos-MailServer
Service_description check-disk
Check_command check_nrpe! Check_sda1
} Define service {
Use generic-Service
Host_name emos-MailServer
Service_description zombie_procs
Check_command check_nrpe! Check_zombie_procs
} Define service {
Use generic-Service
Host_name emos-MailServer
Service_description check-Users
Check_command check_nrpe! Check_users
} Define service {
Use generic-Service
Host_name emos-MailServer
Service_description total_procs
Check_command check_nrpe! Check_total_procs
# Restart Nagios after Configuration
Killall Nagios
Service Nagios start
Pstree | grep Nagios [url] HTTP: // 192.168.8.150/Nagios [/url] #============================ install PNP ================================================ ==========
CD/OPT
Tar zxvf pnp-0.4.12.tar.gz
CD pnp-0.4.12
./Configure -- With-Nagios-user = Nagios \
-- With-Nagios-group-Nagios \
-- With-rrdtool =/usr/local/rrdtool/bin/rrdtool \
-- With-perfdata-Dir =/usr/local/Nagios/share/perfdata
Make
Make all
Make install
Make install-config
Make install-init # error message: rrds Perl modules: *** not found ***
# Solution: ln-SV/usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/auto/rrds. so/usr/lib/perl5/5.8.8/i386-linux-thread-multi/# To generate graphical data also needs in commands. the command in CFG is as follows:
Define command {
Command_name process-service-perfdata
Command_line/usr/local/Nagios/libexec/process_perfdata.pl
} # Set the Nagios. cfg file to generate the graphic data:
Process_performance_data = 1
Service_perfdata_command = process-service-perfdata [url] HTTP: // 192.168.8.150/Nagios/PNP/[/url] #======================== monitoring remote Windows host ======================================
# Monitoring Windows Servers
Wget
[Url] URLs
Decompress nsclient+0.3.zip to the c root directory and decompress it to c: \ nsclient ++ # On the Nagios Monitoring Server
VI/usr/local/Nagios/etc/Nagios. cfg
Export _file =/usr/local/Nagios/etc/objects/windows. CFG remove the comments # Go To The win server and open the command window, CD to the decompressed directory # execute nsclient ++/install on the command line interface # And then nsclient ++ configure ray if an error occurs! # In this case, double-click the nsclient service in the "service" and click the "login" tab to check before "allow service interaction with desktop" # edit NES. INI, in the [modules] Option, remove all annotation symbols;
Checkwmi. dll and remoteconfiguration. dll # modify allowd_host = 192.168.8.150 (Nagios Server IP address) in the [settings] Option)
# Remove the Port = 12489 comment in [nsclient! It listens on port 12489, so the firewall needs to open this port! In the [settings] section, set the 'Password' option to set the password, which is required when Nagios is connected. this step is optional. I will skip it for convenience and do not need a password. # Start nsclient
Nsclient ++/start # configure the content in the Nagios server.
VI/usr/local/Nagios/etc/objects/Windows. cfg
Define host {
Use Windows-Server
Host_name winserver alias
My Windows Server
Address 192.168.8.151 -- IP address of the Windows Server
}
# It is important to modify the hostname and address !!
# Restart Nagios on the Monitoring Server
Killall Nagios
Service Nagios start #============================ install sengemail ==== ====================================
# Send an alarm email using sendemail
CD/OPT
Wget
[Url] URLs
Tar-zxvf sendEmail-v1.55.tar.gz
CD sendEmail-v1.55
CP sendemail/usr/local/bin
Chmod + x/usr/local/bin/sendemail
# Sendemail usage
/Usr/local/bin/sendemail-F kerry.hu@3aaa.com-T
Kerry.hu@3aaa.com-s mail.3aaa.com-U "From Nagios"-Xu
Kerry.hu@3aaa.com-XP 11111-m happy
# Explanation:-F indicates the sender's email address.
-T indicates the recipient's email address.
-S indicates the domain name or IP address of the SMTP server
-U indicates the subject of the email.
-Xu indicates the SMTP authentication user name
-XP indicates the password for SMTP verification. (Note that this password seems to be restricted. For example, I use D! 5neyland cannot be correctly identified)
-M indicates the content of the email. If you do not include the-M parameter, you are prompted to enter # edit the configuration file. Nagios uses sendemail to send a warning email.
VI/usr/local/Nagios/etc/objects/commands. cfg
# 'Policy-host-by-Email 'command Definition
Define command {
Command_name sort y-host-by-Email
Command_line/usr/bin/printf "% B" "****** Nagios ***** \ n \ nnotification type: $ icationicationtype $ \ nhost: $ hostname $ \ nstate: $ hoststate $ \ naddress: $ hostaddress $ \ ninfo: $ hostoutput $ \ n \ ndate/Time: $ longdatetime $ \ n "|/usr/local/bin/sendemail-F
Kerry.hu@3aaa.com-T $ contactemail $-s mail.3aaa.com-U "** $ icationicationtype $ host alert: $ hostname $ is $ hoststate $ **"-Xu
Kerry.hu@3aaa.com-XP 11111
} # 'Your y-service-by-Email 'command Definition
Define command {
Command_name sort y-service-by-Email
Command_line/usr/bin/printf "% B" "****** Nagios ***** \ n \ nnotification type: $ icationicationtype $ \ n \ nservice: $ servicedesc $ \ nhost: $ hostalias $ \ naddress: $ hostaddress $ \ nstate: $ servicestate $ \ n \ ndate/Time: $ longdatetime $ \ n \ nadditional info: \ n \ N $ serviceoutput $"
|/Usr/local/bin/sendemail-F kerry.hu@3aaa.com-T $ contactemail $-s mail.3aaa.com-U "** $ icationicationtype $ service alert: $ hostalias $/$ servicedesc $ is $ servicestate $ ** "-Xu
Kerry.hu@3aaa.com-XP 111111
} # Note: You cannot send alarm emails when using sendemail. If you do not know why, you have to use sendmail that comes with the system to send emails !!