榕叶 发表于 2015-9-8 12:43:04

nagios安装fail2ban监控

  在nagios监控中加入fail2ban
  注: check_fail2ban这个文件在fail2ban源码的file目录下./fail2ban-0.8.10/files/nagios

  
  
#################################被监控机器 ####################################
一 、复制 check_fail2ban 到 /usr/local/nagios/libexec/ 并且设置所属为nagios
      
二、allow your user to run the script with the sudo rights. Just add something like that in your /etc/sudoers (use visudo) :
      允许你的用户利用root权限运行这个脚本。只需要在你的 /etc/sudoer (use visudo) 添加如下内容
      nagios ALL=(ALL) NOPASSWD: /usr/local/nagios/libexec/check_fail2ban
   注: 还需要将 Defaults    requiretty这一行注释掉
      #Defaults    requiretty
  
三、 then just add this kind of line in your NRPE config file :
   只需要添加如下的行到你的NRPE中
command=/usr/bin/sudo /usr/local/nagios/libexec/check_fail2ban
四、 防火墙添加5666
    iptables -I INPUT-p tcp -m state --state NEW -m tcp --dport 5666 -j ACCEPT

############################监控服务器 ###############################
一、 在监控服务器上的commands.cfg 中添加nrpe的命令
   # 'nrpe' command definnition
define command{
      command_name    check_nrpe
      command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
  
二、 在监控服务器上的services.cfg中添加、
   define service {
      use local-service
      host_nameNagios-Linux
      service_description checkfail2ban
      check_command check_nrpe!check_fail2ban
}
页: [1]
查看完整版本: nagios安装fail2ban监控