# Install Nagioscd/optgroupaddnagiosgroupaddnag?useraddnagios-gnagcmd-d/usr/local/nagioschownnagios. nagios/u...
#=========================================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"
# 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
Alias/nagios "/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
# 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-config
Vi/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"-xukerry.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 $ ** "-xukerry.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 $ SERVICEOUTPUT $ "|/usr/local/bin/sendEmail-f kerry.hu@3aaa.com-t $ CONTACTEMAIL $-s mail.3aaa.com-u" ** $ icationicationtype $ Service Alert: $ HOSTALIAS $/$ SERVICEDESC $ is $ SERVICESTATE $ ** "-xukerry.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 !! From: Wang Yingchun's column