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

centos下nagios的基本安装

[复制链接]

尚未签到

发表于 2019-1-15 08:01:45 | 显示全部楼层 |阅读模式
centos下nagios的基本安装

  一、下载安装软件:
  wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.4.tar.gz
  wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
  wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
  二、创建用户组及用户
  groupadd nagcmd
  useradd nagios -s /sbin/nagios
  usermod -a -G nagcmd nagios
  三、安装apache,mysql,php略
  四、安装nagios/nagios-plugins/nrpe主程序
  安装nagios
  tar -zxvf nagios-3.4.4.tar.gz
  cd nagios
  ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd
  make all
  make install
  make install-init
  make install-config
  make install-commandmode
  cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
  chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
  cp sample-config/httpd.conf /usr/local/apache/conf/nagios.conf
  安装nagios-plugins
  tar -zxvf nagios-plugins-1.4.16.tar.gz
  cd nagios-plugins-1.4.16
  ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql=/usr/local/mysql
  make
  make install
  说明:如果不加--with-mysql=/usr/local/mysql选项,则不能在/usr/local/nagios/libexec/目录中找到check_mysql命令
  安装nrpe
  tar -zxvf nrpe-2.13.tar.gz
  cd nrpe-2.13
  ./configure --prefix=/usr/local/nrpe
  make
  make install
  mkdir /usr/local/nrpe/etc/
  cp sample-config/nrpe.cfg /usr/local/nrpe/etc/
  cp /usr/local/nrpe/check_nrpe /usr/local/nagios/libexec/
  cp /usr/local/nagios/libexec/check_disk /usr/local/nrpe/libexec/
  cp /usr/local/nagios/libexec/check_load /usr/local/nrpe/libexec/
  cp /usr/local/nagios/libexec/check_ping /usr/local/nrpe/libexec/
  cp /usr/local/nagios/libexec/check_procs /usr/local/nrpe/libexec/
五、配置cgi.cfg  vi /usr/local/nagios/etc/cgi.cfg
  authorized_for_system_information=nagiosadmin
  修改为:authorized_for_system_information=tendy(联系人用户名:如tendy)
  authorized_for_configuration_information=tendy
  authorized_for_system_commands=tendy
  authorized_for_all_services=tendy
  authorized_for_all_hosts=nagiosadmin,tendy
  authorized_for_all_service_commands=tendy
  authorized_for_all_host_commands=tendy
  配置nagios.cfg
  vi /usr/local/nagios/etc/nagios.cfg
  将cfg_file=/usr/local/nagios/etc/objects/localhosts.cfg
  修改为:
  cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
  手工添加如下文件:
  cfg_file=/usr/local/nagios/etc/objects/contactgroups.cfg
  cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg
  cfg_file=/usr/local/nagios/etc/objects/services.cfg
  然后在/usr/local/nagios/etc/objects/目录下,创建如下文件:
  hosts.cfg
  contactgroups.cfg
  hostgroups.cfg
  services.cfg
  内容如下:
  [root@jk objects]# more hosts.cfg
  define host{
  host_name               jk-server
  alias                   jk server
  address                 192.168.201.110
  check_period            24x7
  check_interval          5
  retry_interval          1
  max_check_attempts      10
  check_command           check-host-alive
  notification_period     24x7
  notification_interval   10
  notification_options    d,r,u
  contact_groups          jk_nagios_group,jk_db_group
  }
  [root@jk objects]# more hostgroups.cfg
  define hostgroup{
  hostgroup_name  jk-servers
  alias           jk servers
  members         jk-server
  }
  [root@jk objects]# more contactgroups.cfg
  define contactgroup{
  contactgroup_name       jk_nagios_group
  alias                   system administrator group
  members                 tendy
  }
  [root@jk objects]# more contacts.cfg
  define contact{
  contact_name                    tendy
  alias                           system administrator
  service_notification_period     24x7
  host_notification_period        24x7
  service_notification_options    w,u,c,r
  host_notification_options       d,u,r
  service_notification_commands   service-notify-by-email
  host_notification_commands      host-notify-by-email
  email                           tendyjk@163.com
  }
  define service{
  host_name                       jk-server
  service_description             check-host-alive
  check_period                    24x7
  max_check_attempts              4
  normal_check_interval           3
  retry_check_interval            2
  contact_groups                  jk_nagios_group
  notification_options            w,u,c,r
  notification_interval           10
  notification_period             24x7
  check_command                   check-host-alive
  }
  [root@jk objects]# more services.cfg
  define service{
  host_name                       jk-server
  service_description             check-tcp 80
  check_period                    24x7
  max_check_attempts              4
  normal_check_interval           3
  retry_check_interval            2
  contact_groups                  jk_nagios_group
  notification_options            w,u,c,r
  notification_interval           10
  notification_period             24x7
  check_command                   check_tcp!80
  }
  修改commands.cfg
  vi /usr/local/nagios/etc/objects/commands.cfg
  修改:notify-host-by-email----> host-notify-by-email
  修改:notify-service-by-email----> service-notify-by-email
  并新增如下内容:
  # 'check_nrpe' command definition
  define command{
  command_name    check_nrpe
  command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
  }
  六、检查配置文件,配置文件都正确,会有如下输出
  [root@jk objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  Nagios Core 3.4.4
  Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
  Copyright (c) 1999-2009 Ethan Galstad
  Last Modified: 01-12-2013
  License: GPL
  Website: http://www.nagios.org
  Reading configuration data...
  Read main config file okay...
  Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
  Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
  Processing object config file '/usr/local/nagios/etc/objects/contactgroups.cfg'...
  Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
  Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
  Processing object config file '/usr/local/nagios/etc/objects/services.cfg'...
  Processing object config file '/usr/local/nagios/etc/objects/hostgroups.cfg'...
  Processing object config file '/usr/local/nagios/etc/objects/hosts.cfg'...
  Read object config files okay...
  Running pre-flight check on configuration data...
  Checking services...
  Checked 6 services.
  Checking hosts...
  Checked 1 hosts.
  Checking host groups...
  Checked 1 host groups.
  Checking service groups...
  Checked 0 service groups.
  Checking contacts...
  Checked 2 contacts.
  Checking contact groups...
  Checked 2 contact groups.
  Checking service escalations...
  Checked 0 service escalations.
  Checking service dependencies...
  Checked 0 service dependencies.
  Checking host escalations...
  Checked 0 host escalations.
  Checking host dependencies...
  Checked 0 host dependencies.
  Checking commands...
  Checked 26 commands.
  Checking time periods...
  Checked 5 time periods.
  Checking for circular paths between hosts...
  Checking for circular host and service dependencies...
  Checking global event handlers...
  Checking obsessive compulsive processor commands...
  Checking misc settings...
  Total Warnings: 0
  Total Errors:   0
  Things look okay - No serious problems were detected during the pre-flight check
  七、将nagios.conf的内容追加到httpd.conf
  cat nagios >> /usr/local/apache/conf/httd.conf
  八、创建用户tendy
  /usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.user tendy
  九、启动apache、nagios、nrpe
  /usr/local/apache/bin/apachectl start
  /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
  /usr/local/nrpe/bin/nrpe -c /usr/local/nrpe/etc/nrpe.cfg
  十、查看进程
  [root@jk objects]# ps aux |grep nrpe |grep -v grep
  nagios    4216  0.0  0.0   5124   924 ?        Ss   12:42   0:00 /usr/local/nrpe/bin/nrpe -c /usr/local/nrpe/etc/nrpe.cfg -d
  [root@jk objects]# ps aux |grep nagios |grep -v grep
  nagios    4216  0.0  0.0   5124   924 ?        Ss   12:42   0:00 /usr/local/nrpe/bin/nrpe -c /usr/local/nrpe/etc/nrpe.cfg -d
  nagios    5617  0.0  0.0  12952  1036 ?        Ssl  13:48   0:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
  root      6980  0.0  0.0   4664  1324 pts/0    T    15:12   0:00 /bin/sh ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd
  root      8382  0.0  0.0   4664   628 pts/0    T    15:12   0:00 /bin/sh ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd
  十一、查看端口
  [root@jk objects]# netstat -an|grep 5666
  tcp        0      0 192.168.201.110:5666        0.0.0.0:*                   LISTEN
  十二、在web浏览器上查看







运维网声明 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-663369-1-1.html 上篇帖子: nagios配置yum方法 下篇帖子: 使用nagios监控linux、windows、esxi
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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