Installation
Apt-get Update
Apt-get Install nagios* Perl
Apt-get Install--no-install-recommends Pnp4nagios
Apt-get Install apache2 apache2-utils php5 php-pear
Modify NPCD Settings
# VIM/ETC/DEFAULT/NPCD
Run= "Yes"
# service NPCD Start
- Add process_perfdata.pl Execute Permissions
chmod +x/usr/lib/pnp4nagios/libexec/process_perfdata.pl
- Modify COMMANDS.CFG settings (Comment old command)
Vi/etc/nagios3/commands.cfg
#'Process-host-perfdata'command definitiondefine command{command_name process-host-PerfData #command_line/usr/bin/printf"%b" "$LASTHOSTCHECK $\t$hostname$\t$hoststate$\t$hostattempt$\t$hoststatetype$\t$hostexecutiontime$\t$hostoutput $\t$hostperfdata$\n">>/var/lib/nagios3/host-perfdata.out command_line/usr/bin/Perl/usr/lib/pnp4nagios/libexec/process_perfdata.pl}#'Process-service-perfdata'command definitiondefine command{command_name process-service-PerfData #command_line/usr/bin/printf"%b" "$LASTSERVICECHECK $\t$hostname$\t$servicedesc$\t$servicestate$\t$serviceattempt$\t$servicestatetype$\t$ serviceexecutiontime$\t$servicelatency$\t$serviceoutput$\t$serviceperfdata$\n">>/var/lib/nagios3/service-perfdata.out command_line/usr/bin/Perl/usr/lib/pnp4nagios/libexec/process_perfdata.pl}
commands.cfg Code
- Modifying the NAGIOS.CFG configuration
Vi/etc/nagios3/nagios.cfg Modify the following 3 line configurations
Process_performance_data=1
Host_perfdata_command=process-host-perfdata
Service_perfdata_command=process-service-perfdata
Modify Check_external_commands=1 (unmodified may cause Web sites to fail to re-schedule monitoring items)
Modify Enable_flap_detection=0 (although the document says the default is 0, but actually 1. Changed to 0 to resolve flapping state)
- Modifying the SERVICES_NAGIOS2.CFG configuration
Vi/etc/nagios3/conf.d/services_nagios2.cfg
Notification_interval 1
Vi/etc/nagios3/conf.d/generic-service_nagios2.cfg
Notification_interval 1
Delete install.php
# cd/usr/share/pnp4nagios/html
# MV Install.php Install.php.bak
- Nagios plug-in directory:/usr/lib/nagios/plugins/
- Add Pnp4nagios Plugin
VI/ETC/NAGIOS3/CONF.D/PNP4NAGOS.CFG Append the following configuration
Define host {name host-PnP Action_url/pnp4nagios/index.php/graph?host= $HOSTNAME $'class='Tips'rel='/pnp4nagios/index.php/popup?host= $HOSTNAME $&srv=_host_ Register0Process_perf_data1}define Service {name SRV-PnP Action_url/pnp4nagios/index.php/graph?host= $HOSTNAME $&srv= $SERVICEDESC $'class='Tips'rel='/pnp4nagios/index.php/popup?host= $HOSTNAME $&srv=$SERVICEDESC $ register0Process_perf_data1}
Code
- The default is no monitoring memory, if you need to monitor the replication check_mem.sh file to the plug-in directory, and then add the relevant configuration file
Adding Custom execution commands
Vi/etc/nagios3/conf.d/custom_commond.cfg
define command{ command_name check_mem command_line $USER 1$/check_mem. SH -w $ARG 1$-c $ARG 2$ }
CodeAdd the Check_mem service for this machine
Vi/etc/nagios3/conf.d/localhost_nagios2.cfg Add the following configuration
define service{ use local-service,srv-pnp host_name localhost service_ Description check_mem check_command check_mem! A. - }
Code
- Monitor server network card traffic
Apt-get Install SNMPD Snmp-mibs-downloader
Vi/etc/snmp/snmpd.conf (can back up snmpd.conf, modify the following localhost-ip as the server IP, save this file)
Com2sec Notconfiguser127.0.0.1Public com2sec notconfiguser localhost-IP Public Group Notconfiggroup v1 notconfiguser Group Notconfiggroup v2c notconfiguser View SystemView included.1.3.6.1.2.1.1view SystemView included.1.3.6.1.2.1.2view SystemView included.1.3.6.1.2.1.25.1.1view all included.1Access Notconfiggroup""Any noauth exact all none none
CodeRestart SNMPD Service
Download check_traffic.sh to plugin directory
cd/usr/lib/nagios/plugins/
Test execution
./check_traffic.sh-v 2c-c public-h your_ip-i 2-w 1200,1500-c 1700,1800-k-B
# vi/etc/nagios3/conf.d/custom_commond.cfg Append
define command{ command_name check_traffic command_line $USER 1$/check_traffic. SH -v 2c-c public-h $HOSTADDRESS $-I $ARG 1$-w $ARG 2$-C $ARG 3$-M-B}
Code
When the service stops re-monitoring fails, run the following 2-line command
# dpkg-statoverride--update--add nagios www-data 2710/VAR/LIB/NAGIOS3/RW
# dpkg-statoverride--update--add nagios www-data 751/var/lib/nagios3
- Configure the Send mail feature
Apt-get install SSMTP (standby: Apt-get install Sendmail-bin sendmail)
Modify ssmpt.conf file configuration
# vi/etc/ssmtp/ssmtp.conf Add Google Mailbox configuration (do not turn on 2-step verification)
authuser= =passwordfromlineoverride = yesmailhub =smtp.gmail.com:usestarttls =yes
code Service SendMail Stop
Chkconfig sendmail off
Cd/usr/sbin
MV sendmail sendmail.bak
Ln-s/usr/sbin/ssmtp/usr/sbin/sendmail
Test outgoing messages
- Attention required to add monitored machines
To monitor other hosts, you need to add the Check_nrpe command, but in the Debian system, the Add Check_nrpe command prompts you to repeat it, but you cannot find any configuration elsewhere.
So you need to change Check_nrpe to another name.
define command{ command_name Custom_check_nrpe command_line $USER 1$/check_nrpe-h $HOSTADDRESS $- c $ARG 1$ }
Code
Debian System installs Nagios server monitoring side