tar zxvf nrpe-2.12.tar.gz cd nrpe-2.12 ./configure make all make install-plugin make install-daemon make install-daemon-config |
tar zxvf 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 |
ll /usr/local/nagios/libexec |
define host{ use linux-server host_name 192.168.1.211 alias 192.168.1.211 address 192.168.1.211 } define service{ use generic-service host_name 192.168.1.211 service_description check_ping check_command check_ping!100.0,20%!200.0,50% max_check_attempts 5 normal_check_interval 1 } define service{ use generic-service host_name 192.168.1.211 service_description check_ftp check_command check_ftp!21 max_check_attempts 5 normal_check_interval 1 } define service{ use generic-service host_name 192.168.1.211 service_description check_ssh check_command check_ssh max_check_attempts 5 normal_check_interval 1 } define service{ use generic-service host_name 192.168.1.211 service_description check_http check_command check_http max_check_attempts 5 normal_check_interval 1 } |
define host{ use linux-server host_name 192.168.1.211 alias 192.168.1.211 address 192.168.1.211 } define service{ use generic-service host_name 192.168.1.211 service_description check_ping check_command check_ping!100.0,20%!200.0,50% max_check_attempts 5 normal_check_interval 1 } |
define host{ name linux-server ; The name of this host template use generic-host ; This template inherits other values from the generic-host template check_period 24x7 ; By default, Linux hosts are checked round the clock check_interval 5 ; Actively check the host every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each Linux host 10 times (max) check_command check-host-alive ; Default command to check Linux hosts notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day ; Note that the notification_period variable is being overridden from ; the value that is inherited from the generic-host template! notification_interval 120 ; Resend notifications every 2 hours notification_options d,u,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE! } |
define command{ command_name check_ping command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5 } |
/usr/local/nagios/libexec/check_ping -H 192.168.1.211 -w 100,20% -c 200,40% |
PING OK - Packet loss = 0%, RTA = 0.54 ms|rta=0.543000ms;100.000000;200.000000;0.000000 pl=0%;20;40;0 |
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg |
Total Warnings: 0 Total Errors: 0 |
service nagios restart |
vi command.cfg |
define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } |
vi nrpe.cfg |
allowed_hosts=127.0.0.1,192.168.1.210 #添加上我的监控主机的IP |
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d |
[root@localhost ~]# netstat -tunlp | grep nrpe tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 4304/nrpe |
/usr/local/nagios/libexec/check_nrpe -H 192.168.1.211 |
NRPE v2.8.1 |
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10 command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20 command[check_sda3]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/sda3 command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200 command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10% |
/usr/local/nagios/libexec/check_nrpe -H 192.168.1.211 -c check_users |
USERS OK - 3 users currently logged in |users=3;5;10;0 |
command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/sda1 |
define service{ use generic-service host_name 192.168.1.211 service_description check_sda1 check_command check_nrpe!check_sda1 max_check_attempts 5 normal_check_interval 1 } |
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg service nagios restart |