设为首页 收藏本站
查看: 1073|回复: 0

nagios安装配置及飞信报警

[复制链接]

尚未签到

发表于 2019-1-14 13:58:34 | 显示全部楼层 |阅读模式
  一、监控服务器端安装配置

  1、下载软件包
      nagios-3.0.6.tar.gz,nagios-plugins-1.4.13.tar.gz,nrpe-2.8.1.tar.gz
  2、安装环境和添加用户组

      yum -y install httpd gcc glibc glibc-common gd gd-devel php php-mysql mysql mysql-server
      groupadd nagcmd

      yseradd -m nagios

      usermod -a -G nagcmd nagios

      usermod -a -G nagcmd apache

  3、编译安装nagios
      tar -zxvf nagios-3.0.6.tar.gz;cd nagios-3.0.6
      ./configure –with-command-group=nagcmd –enable-event-broker
      make all;make install ;make install-init;make install-config;make install-commandmode

  说明:第一步执行make install安装主要的程序、CGI及HTML文件,第二步执行make install-init的步骤,它的作用是把nagios做成一个运行脚本,使nagios随系统开机启动,这是一个很方便的措施。第三步执行 make install-config 把配置文件的例子复制到nagios的安装目录。第四步执行 make install-commandmode 给外部命令访问nagios配置文件的权限。
安装完后 查看一下在/usr/local/nagios下是否存在etc、bin、 sbin、 share、 var这五个目录,如果存在则可以表明程序被正确的安装到系统了。这5个目录的作用是:
bin
Nagios执行程序所在目录,这个目录只有一个文件nagios
etc
Nagios配置文件位置,初始安装完后,只有几个*.cfg-sample文件
sbin
Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录
Share
Nagios网页文件所在的目录
Var
Nagios日志文件、spid 等文件所在的目录
  4、http.conf配置
      在http.conf下面增加这一段

  ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
  
  Options ExecCGI
  AllowOverride None
  Order allow,deny
  Allow from all
  AuthName "Nagios Access"
  AuthType Basic
  AuthUserFile /usr/local/nagios/etc/htpasswd
  Require valid-user
  
  Alias /nagios /usr/local/nagios/share
  
  Options None
  AllowOverride None
  Order allow,deny
  Allow from all
  AuthName "Nagios Access"
  AuthType Basic
  AuthUserFile /usr/local/nagios/etc/htpasswd
  Require valid-user
  
  重启http
  htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadmin
  4、编译安装nagios-plugins
      tar -zxvf nagios-plugins-1.4.13.tar.gz;cd nagios-plugins-1.4.13
      ./configure –with-nagios-user=nagios –with-nagios-group=nagios
      make &&make install

  5、配置、启动nagios
      chkconfig --add nagios
      chkconfig nagios on

      setenfoce 0

      检查配置文件: /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg  
      service nagios start

  6、安装NRPE
      tar -zxvf nrpe-2.8.1.tar.gz ;cd  nrpe-2.8.1
      ./configure

      make all

      make install-plugin

      make install-daemon
      make install-daemon-config
      启动NRPE: /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
      修改nagios配置文件 commands.cfg

      添加
  define command{
          command_name check_nrpe
          command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
          }
  检查配置文件/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg  

  重启nagios service nagios restart
  二、被监控机配置
  1、下载软件包nagios-plugins-1.4.13.tar.gz,nrpe-2.8.1.tar.gz
  2、安装
      tar -zxvf nagios-plugins-1.4.13.tar.gz;cd nagios-plugins-1.4.13
      ./configure –with-nagios-user=nagios –with-nagios-group=nagios
      make &&make install
      tar -zxvf nrpe-2.8.1.tar.gz;cd nrpe-2.8.1
      ./configure

      make all

      make install-plugin

      make install -daemon

      make install-daemon-config

  3.配置nrpe信息
  
      vim /usr/local/nagios/etc/nrpe.cfg
      allowed_hosts=127.0.0.1,1.1.1.1(监控机IP)  //允许监控的IP
      /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d
      如果有防火墙,需要将开通5666端口,关闭selinux
  4、检查联通性
     在监控端执行 /usr/local/nagios/libexec/check_nrpe -H 被监控IP,如果测试成功会得到NRPE版本,如果不成功就检查防火墙,检查配置文件设置是否允许监控机IP
  

  三、飞信报警设置
  1、下载和安装飞信软件
  主软件:wget http://www.it-adv.net/fetion/downng/fetion20091117-linux.tar.gz
  主程序:wget http://bbs.it-adv.net/attachment.php?aid=43&k=b1e8997336d66ec8610adc2b790376a2&t=1299230237
  库文件:wget http://www.it-adv.net/fetion/linuxso_20101113.rar
  安装飞信:
  tar zxvf fetion20091117-linux.tar.gz -C /usr/local
  将下载的主程序fetion覆盖掉/usr/local/fx/下的fetion
  在windows中解压linuxso_20101113.rar并将里面的库文件上传至 /usr/local/fx/
  cd /usr/local/fx
  cp lib* /usr/lib
  2.飞信测试
  /usr/local/fx/fetion --mobile=15958045149 --pwd=12346 --to=15958045149 --msg-utf8=test
  这样后在fx目录有个手机号的图片,下载下来查看再输入后就好了,以后就不用输入了
  3.nagios配置
  修改nagios配置文件 commands.cfg
  添加如下
  define command {  
               command_name            notify-host-by-fei  
               command_line            /usr/local/fx/fetion --mobile=15958045149 --pwd=qazwsxedc --to=$CONTACTPAGER$ --msg-utf8="Host $HOSTSTATE$ alert for $HOSTNAME$! on '$LONGDATETIME$'" $CONTACTPAGER$   
               }  
  

  # 'notify-service-by-fei' command definition   
  

  define command {  
               command_name         notify-service-by-fei  
               command_line         /usr/local/fx/fetion --mobile=15958045149 --pwd=qazwsxedc --to=$CONTACTPAGER$ --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$   
               }  
   修改contacts.cfg
  在define contact{}里添加下面这段
   service_notification_commands   notify-service-by-fei ; send service notifications via email
          host_notification_commands      notify-host-by-fei
  pager 15958045149
  检查配置文件,重启nagios
  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-663245-1-1.html 上篇帖子: CentOS安装配置nagios(2) 下篇帖子: nagios插件监控cpu,可pnp画图
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表