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

Nagios服务端安装

[复制链接]

尚未签到

发表于 2019-1-12 12:27:41 | 显示全部楼层 |阅读模式
  系统环境:
  [root@nagios_server ~]# cat /etc/redhat-release
  CentOS release 6.9 (Final)
  

  1、更新yum源
  mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  wget -O /etc/yum.repos.d/CentOS-Base.repo   http://mirrors.aliyun.com/repo/Centos-6.repo
  

  2.调整字符集
  echo 'export LC_ALL=C'>>/etc/profile
  source /etc/profile
  

  3.关闭iptables与selinux
  

  4.更新系统时间
  /usr/sbin/ntpdate pool.ntp.org
  然后放入定时任务
  

  5.安装gcc和LAMP
  yum install gcc glibc glibc-common gd gd-devel php-gd httpd php mysql* unzip -y
  

  6.添加用户
  [root@Nagios tools]# useradd -m nagios
  [root@Nagios tools]# useradd apache
  [root@Nagios tools]# groupadd nagcmd
  [root@Nagios tools]# usermod -a -G nagcmd nagios
  [root@Nagios tools]# usermod -a -G nagcmd apache
  

  7.下载与安装nagios
  [root@Nagios tools]# unzip oldboy_training_nagios_soft.zip
  Archive:  oldboy_training_nagios_soft.zip
  inflating: check_memory.pl #内存监控插件
  inflating: check_mysql     #mysql监控插件
  inflating: Class-Accessor-0.31.tar.gz
  extracting: Config-Tiny-2.12.tar.gz
  inflating: libart_lgpl-2.3.17.tar.gz
  inflating: Math-Calc-Units-1.07.tar.gz
  inflating: Nagios-Plugin-0.34.tar.gz
  inflating: nrpe-2.12.tar.gz  #客户端的nrpe守护进程
  inflating: Params-Validate-0.91.tar.gz
  inflating: pnp-0.4.14.tar.gz #nagios的web图形展示程序
  inflating: Regexp-Common-2010010201.tar.gz
  inflating: rrdtool-1.2.14.tar.gz  #nagios的画图工具
  inflating: check_iostat  #io监控插件
  inflating: nagios-3.5.1.tar.gz  #nagios主程序
  inflating: nagios-plugins-1.4.16.tar.gz  #nagios插件
  [root@Nagios tools]# tar xf nagios-3.5.1.tar.gz
  [root@Nagios tools]# cd nagios
  [root@Nagios nagios]# ./configure --with-command-group=nagcmd
  [root@Nagios nagios]# make all
  [root@Nagios nagios]# make install
  。。。。。。。。。。。。。。。。。。。。。。。。
  make install-init
  - This installs the init script in /etc/rc.d/init.d
  

  make install-commandmode
  - This installs and configures permissions on the
  directory for holding the external command file
  

  make install-config
  - This installs sample config files in /usr/local/nagios/etc
  

  make[1]: Leaving directory `/root/tools/nagios'
  

  [root@Nagios nagios]# make install-init
  /usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
  /usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios
  

  *** Init script installed ***
  

  [root@Nagios nagios]# make install-commandmode
  /usr/bin/install -c -m 775 -o nagios -g nagcmd -d /usr/local/nagios/var/rw
  chmod g+s /usr/local/nagios/var/rw
  

  *** External command directory configured ***
  

  [root@Nagios nagios]# make install-config
  /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
  /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
  /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
  /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
  /usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
  /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
  /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
  /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
  /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
  /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
  /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
  /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
  /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg
  

  *** Config files installed ***
  

  Remember, these are *SAMPLE* config files.  You'll need to read
  the documentation for more information on how to actually define
  services, hosts, etc. to fit your particular needs.
  

  [root@Nagios nagios]# make install-webconf
  /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
  

  *** Nagios/Apache conf file installed ***
  

  8.配置web认证
  [root@Nagios nagios]# vi /etc/httpd/conf.d/nagios.conf
  # SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
  # Last Modified: 11-26-2005
  #
  # This file contains examples of entries that need
  # to be incorporated into your Apache web server
  # configuration file.  Customize the paths, etc. as
  # needed to fit your system.
  

  ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
  

  
  #  SSLRequireSSL
  Options ExecCGI
  AllowOverride None
  Order allow,deny
  Allow from all
  #  Order deny,allow
  #  Deny from all
  #  Allow from 127.0.0.1
  AuthName "Nagios Access"
  AuthType Basic
  AuthUserFile /usr/local/nagios/etc/htpasswd.users
  Require valid-user
  
  

  Alias /nagios "/usr/local/nagios/share"
  [root@Nagios nagios]# htpasswd -cb /usr/local/nagios/etc/htpasswd.users oldboy 123456  #创建登录nagios的web用户名和密码
  Adding password for user oldboy
  

  9.安装nagios插件
  [root@Nagios tools]# yum -y install perl-devel
  [root@Nagios tools]# tar xf nagios-plugins-1.4.16.tar.gz
  [root@Nagios tools]# cd nagios-plugins-1.4.16
  [root@Nagios nagios-plugins-1.4.16]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules
  [root@Nagios nagios-plugins-1.4.16]# make && make install
  [root@Nagios nagios-plugins-1.4.16]# ll /usr/local/nagios/libexec/|wc -l
  60  #此处为60-61个左右
  [root@Nagios nagios-plugins-1.4.16]# cd ../
  

  10.安装nrpe
  [root@Nagios tools]# tar xf nrpe-2.12.tar.gz
  [root@Nagios tools]# cd nrpe-2.12
  [root@Nagios nrpe-2.12]# ./configure
  [root@Nagios nrpe-2.12]# make all
  [root@Nagios nrpe-2.12]# make install-plugin
  [root@Nagios nrpe-2.12]# make install-daemon
  [root@Nagios nrpe-2.12]# make install-daemon-config
  

  11.启动服务与检查
  [root@Nagios tools]# /etc/init.d/nagios start
  Starting nagios: done.
  [root@Nagios tools]# /etc/init.d/httpd start
  Starting httpd:                                        [  OK  ]
  [root@Nagios tools]# netstat -tunlp|grep 80
  tcp        0      0 :::80                       :::*                        LISTEN      7853/httpd
  [root@Nagios tools]# ps -ef|grep nagios
  nagios    7841     1  0 16:31 ?        00:00:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
  root      7871 53845  0 16:32 pts/0    00:00:00 grep 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-662358-1-1.html 上篇帖子: 用nagios监控交换机的端口 下篇帖子: Nagios客户端安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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