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

nagios 安装配置说明(一)

[复制链接]

尚未签到

发表于 2019-1-14 06:39:31 | 显示全部楼层 |阅读模式
Nagios安装配置说明

  •   修改YUM源为国内sohu的站点;
  [root@nagios ~]# cd/etc/yum.repos.d/
  [root@nagios yum.repos.d]# ls
  CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo
  [root@nagios yum.repos.d]# mvCentOS-Base.repo CentOS-Base.repo.backup
  [root@nagios yum.repos.d]# wgethttp://mirrors.sohu.com/help/CentOS-Base-sohu.repo
  --2014-06-08 22:34:38-- http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
  Resolving mirrors.sohu.com...119.188.36.70
  Connecting tomirrors.sohu.com|119.188.36.70|:80... connected.
  HTTP request sent, awaitingresponse... 200 OK
  Length: 2299 (2.2K)[application/octet-stream]
  Saving to:`CentOS-Base-sohu.repo'
  100%[===================================================================================>]2,299       --.-K/s   in 0.1s
  2014-06-08 22:34:43 (20.6 KB/s)- `CentOS-Base-sohu.repo' saved [2299/2299]
  [root@nagios yum.repos.d]# ls
  CentOS-Base-sohu.repo  CentOS-Base.repo.backup  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo
  [root@nagios yum.repos.d]# mv CentOS-Base-sohu.repoCentOS-Base.repo

  •   解决perl编译问题;
  [root@nagios ~]# echo 'exportLC_ALL=C'>> /etc/profile
  [root@nagios ~]# tail -1/etc/profile
  export LC_ALL=C
  [root@nagios ~]# source/etc/profile
  [root@nagios ~]# echo $LC_ALL
  C

  •   关闭iptables防火墙;
  [root@nagios ~]#/etc/init.d/iptables stop
  [root@nagios ~]#/etc/init.d/iptables status
  iptables: Firewall is notrunning.
  [root@nagios ~]# chkconfigiptables off
  [root@nagios ~]# chkconfig--list|grep iptables
  iptables             0:off 1:off 2:off 3:off 4:off 5:off 6:off

  •   关闭selinux;
  [root@nagios ~]# cat /etc/selinux/config
  # This file controls the stateof SELinux on the system.
  # SELINUX= can take one ofthese three values:
  #     enforcing - SELinux security policy isenforced.
  #     permissive - SELinux prints warningsinstead of enforcing.
  #     disabled - No SELinux policy is loaded.
  SELINUX=enforcing
  # SELINUXTYPE= can take one ofthese two values:
  #     targeted - Targeted processes areprotected,
  #     mls - Multi Level Security protection.
  SELINUXTYPE=targeted
  [root@nagios ~]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g'/etc/selinux/config
  [root@nagios ~]# cat/etc/selinux/config
  # This file controls the stateof SELinux on the system.
  # SELINUX= can take one ofthese three values:
  #     enforcing - SELinux security policy is enforced.
  #     permissive - SELinux prints warningsinstead of enforcing.
  #     disabled - No SELinux policy is loaded.
  SELINUX=disabled
  # SELINUXTYPE= can take one ofthese two values:
  #     targeted - Targeted processes areprotected,
  #     mls - Multi Level Security protection.
  SELINUXTYPE=targeted
  [root@nagios ~]# setenforce 0
  [root@nagios ~]# getenforce
  Disabled
  五、解决时间同步问题;
  [root@nagios ~]#/usr/sbin/ntpdate pool.net.org   #更新当前时间
  8 Jun 22:55:22 ntpdate[2165]: no serversuitable for synchronization found
  [root@nagios ~]# echo '#timesync by jerry at 20140131'>> /var/spool/cron/root
  [root@nagios ~]# echo '*/10 * ** * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1'>>/var/spool/cron/root
  [root@nagios ~]# crontab -l
  #time sync by jerry at 20140131
  */10 * * * * /usr/sbin/ntpdatepool.ntp.org >/dev/null 2>&1
  六、安装nagios所需的基础软件包;
  [root@nagios ~]# yum installgcc glibc glibc-common gd gd-devel mysql* httpd php php-gd –y
  七、创建用户和组;
  [root@nagios ~]# useradd nagios
  [root@nagios ~]# groupaddnagcmd
  [root@nagios ~]# usermod -a -Gnagcmd nagios
  [root@nagios ~]# usermod -a -Gnagcmd apache
  八、创建软件存放文件夹及下载相关软件;
  [root@nagios tools]#mkdir –p /home/jerry/tools
  [root@nagios tools]#cd/home/jerry/tools
  九、解压并安装nagios;
  [root@nagios tools]# tar zxfnagios-3.5.0-1374045102000.tar.gz
  [root@nagios tools]# ls
  nagios  nagios-3.5.0-1374045102000.tar.gz  nagios-plugins-1.5.tar.gz
  [root@nagios tools]# cd nagios
  [root@nagios nagios]#./configure --with-command-group=nagcmd
  [root@nagios nagios]# make all
  [root@nagios nagios]# makeinstall
  [root@nagios nagios]# makeinstall-init
  [root@nagios nagios]# makeinstall-config
  [root@nagios nagios]# makeinstall-commandmode
  十、安装nagios web 配置文件及创建登陆用户;
  [root@nagios nagios]# makeinstall-webconf
  /usr/bin/install -c -m 644sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
  *** Nagios/Apache conf fileinstalled ***
  [root@nagios nagios]# grep -v"#" /etc/httpd/conf.d/nagios.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.users
  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.users
  Require valid-user
  
  [root@nagios nagios]# htpasswd-c /usr/local/nagios/etc/htpasswd.users nagiosadmin
  New password:
  Re-type new password:
  Adding password for usernagiosadmin
  十一、添加监控报警的接收email地址;
  [root@nagios nagios]# vim/usr/local/nagios/etc/objects/contacts.cfg +35
  email                           nagios@localhost
  更改为
  email                           46718718@qq.com
  1.       启动sendmail时时间过长请检查主机名是否一致
  [root@nagios nagios]#/etc/init.d/sendmail start
  Starting sendmail: ^C
  [root@nagios nagios]# cat/etc/hosts
  127.0.0.1   localhost localhost.localdomain localhost4localhost4.localdomain4
  ::1         localhost localhost.localdomainlocalhost6 localhost6.localdomain6
  [root@nagios nagios]# uname -n
  Nagios
  修改为:
  [root@nagios nagios]# cat/etc/hosts
  127.0.0.1   nagios localhost.localdomain localhost4 localhost4.localdomain4
  ::1         localhost localhost.localdomainlocalhost6 localhost6.localdomain6
  [root@nagios nagios]#/etc/init.d/sendmail start
  Starting sendmail:                                         [  OK  ]
  Starting sm-client:                                        [  OK  ]
  [root@nagios nagios]# lsof -i:25
  COMMAND  PID USER  FD   TYPE DEVICE SIZE/OFF NODENAME
  master  1771 root  12u  IPv4  11293     0t0  TCP nagios:smtp (LISTEN)
  master  1771 root  13u  IPv6  11295     0t0  TCP localhost:smtp (LISTEN)
  [root@nagios nagios]# chkconfigsendmail on
  [root@nagios nagios]# chkconfig--list|grep sendmail
  sendmail           0:off 1:off 2:on 3:on 4:on 5:on 6:off
  2.       启动apache;
  [root@nagios nagios]# netstat-lnt|grep 80
  tcp        0     0 :::80                      :::*                        LISTEN
  [root@nagios nagios]# chkconfig--list|grep httpd
  httpd              0:off 1:off 2:off 3:off 4:off 5:off 6:off
  [root@nagios nagios]# chkconfighttpd on
  [root@nagios nagios]# chkconfig--list|grep httpd
  httpd              0:off 1:off 2:on 3:on 4:on 5:on 6:off
  打开浏览器输入http://server-ip/nagios  会有一个用户名密码提示窗口,输入之前创建的用户名密码即可进入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-662900-1-1.html 上篇帖子: 搭建Nagios监控平台 下篇帖子: nagios 监控NFS
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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