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

CentOS 6.3_Nagios安装配置

[复制链接]

尚未签到

发表于 2019-1-15 10:29:48 | 显示全部楼层 |阅读模式
实验环境

包含3台主机,详细信息如下

主机名

操作系统

IP地址

作用

nagios

CentOS 6.3_x64

10.10.10.254

监控机

web

CentOS 6.3_x64

10.10.10.253

被监控机

winserver

Windows sever 2003

10.10.10.252

被监控机


Nagios定义的监控状态
nagios定义了4中监控状态,代表不同的严重级别,除了OK代表正常不用关心外,其余3种都要引起重视.如下表
状态

代码

颜色

正常

OK

绿色

警告

WARNING

黄色

严重

CRITICAL

红色

未知错误

UNKOWN

深黄色



1、安装前准备
Nagios安装前,首先安装相关软件包,对于RHEL / CentOS系统: (依赖包的安装:wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp openssl openssl-devel)
检看一下是否安装相关软件包:
[root@nagios ~]# rpm -qa |grep *****(略)
[root@nagios ~]# yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp openssl openssl-devel

Nagios源代码程序和插件
监控主机下载:
[root@nagios ~]# wget http://nchc.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.4/nagios-3.4.4.tar.gz
[root@nagios ~]# wget http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
[root@nagios ~]# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz

被监控Linux 主机下载:
[root@nagios ~]# wget http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
[root@nagios ~]# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz

被监控Windows 主机下载:
http://nsclient.org/nscp/downloads
http://files.nsclient.org/0.3.x/NSClient%2B%2B-0.3.9-Win32.zip
http://files.nsclient.org/0.3.x/NSClient%2B%2B-0.3.9-x64.zip

2、添加Nagios用户和组  
[root@nagios ~]# useradd nagios
[root@nagios ~]# passwd nagios
[root@nagios ~]# groupadd nagcmd
[root@nagios ~]# usermod -a -G nagcmd nagios
3、编译与安装Nagios
[root@nagios ~]# tar -zxvf nagios-3.4.4.tar.gz
[root@nagios ~]# cd nagios
[root@nagios nagios]#./configure --with-command-group=nagcmd //编译Nagios 配置脚本并使用先前开设的用户及用户组
[root@nagios nagios]#make all    //编译Nagios 程序包源码
*** Compile finished ***
If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install   //使用make install来安装主程序,CGIHTML文件
     - This installs the main program, CGIs, and HTML files
make install-init  //使用make install-init/etc/rc.d/init.d安装启动脚本
     - This installs the init script in /etc/rc.d/init.d
  make install-commandmode  //使用make install-commandmode来配置目录权限
     - This installs and configures permissions on the
       directory for holding the external command file
  make install-config  //把配置文件的例子复制到nagios的安装目录: /usr/local/nagios/etc
     - This installs *SAMPLE* config files in /usr/local/nagios/etc
       You'll have to modify these sample files before you can
       use Nagios.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!
  make install-webconf   //安装Nagios WEB 配置文件到Apache conf.d 目录下
     - This installs the Apache config file for the Nagios
       web interface
  make install-exfoliation
     - This installs the Exfoliation theme for the Nagios
       web interface
  make install-classicui
     - This installs the classic theme for the Nagios
       web interface
*** Support Notes *******************************************

安装二进制运行程序、初始化脚本、配置文件样本并设置运行目录权限
[root@nagios nagios]#make install  
[root@nagios nagios]#make install-init
[root@nagios nagios]#make install-config
[root@nagios nagios]#make install-commandmode
[root@nagios nagios]#make install-webconf

复制nagios/contrib/eventhandlers目录下所有文件到/usr/local/nagios/libexec下:
[root@nagios nagios]#cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/

修改用户和主权限
[root@nagios nagios]#chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
[root@nagios nagios]# ll /usr/local/nagios/libexec/eventhandlers/
总用量 28
-rwxr-xr-x. 1 nagios nagios  828 9  27 11:33 disable_active_service_checks
-rwxr-xr-x. 1 nagios nagios  759 9  27 11:33 disable_notifications
drwxr-xr-x. 2 nagios nagios 4096 9  27 11:33 distributed-monitoring
-rwxr-xr-x. 1 nagios nagios  827 9  27 11:33 enable_active_service_checks
-rwxr-xr-x. 1 nagios nagios  760 9  27 11:33 enable_notifications
drwxr-xr-x. 2 nagios nagios 4096 9  27 11:33 redundancy-scenario1
-rwxr-xr-x. 1 nagios nagios 1184 9  27 11:33 submit_check_result

验证Nagios配置文件,验证配置是否有误
[root@nagios nagios]#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

重启httpd
[root@nagios ~]# /etc/init.d/httpd start
[root@nagios ~]# chkconfig httpd on

修改配置文件
[root@nagios ~]# vim /usr/local/nagios/etc/objects/contacts.cfg
修改nagiosadmin(这里修改为你自己创建的帐号) 注:nagiosadmin是配置文件默认,可以不用修改。
创建一个默认用户登录Web界面访问: 创建HTTP认证用户登录Nagios,用户名nagiosadmin,密码123456
[root@nagios ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: 123456
Re-type new password: 123456

验证程序是否被正确安装:
切换目录到安装路径(这里是/usr/local/nagios,看是否存在 bin  etc  libexec  sbin  share  var这六个目录,如果存在则可以表明程序被正确的安装到系统了。后表是六个目录功能的简要说明:
bin
Nagios执行程序所在目录,nagios文件即为主程序
etc
Nagios配置文件位置,初始安装完后,只有几个*.cfg-sample文件
libexec
Nagios 系统库文件
sbin
Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录
Share
Nagios网页文件所在的目录
Var
Nagios日志文件、spid 等文件所在的目录
var/archives
Empty directory for the archived logs
var/rw
Empty directory for the external command   file

4、编译并安装Nagios 插件
[root@nagios ~]# tar zxvf nagios-plugins-1.4.16.tar.gz
[root@nagios ~]# cd nagios-plugins-1.4.16
[root@nagios nagios-plugins-1.4.16]#./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@nagios nagios-plugins-1.4.16]# make;make install

会显示安装的插件文件,即所有的插件都安装在libexec这个目录下
[root@nagios ~]# ls /usr/local/nagios/libexec/

验证Nagios 配置文件
[root@nagios ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

5、启动Nagios
Nagios 加入到服务列表中以使之在系统启动时自动启动
[root@nagios ~]#/etc/init.d/nagios start
[root@nagios ~]# chkconfig nagios on

6、登录到WEB界面
输入用户名密码:nagiosadmin  123456
http://localhost/nagios

Services

7、防火墙配置
如果WEB无法访问,检查一下IPtables是否关闭。
[root@nagios ~]# service iptables status
添加httpd 80端口:
[root@nagios ~]# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

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.iyunv.com/thread-663496-1-1.html 上篇帖子: nagios 安装 ppt 下篇帖子: nagios email报警代码,可借鉴
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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