这篇文章主要讲解了“nagios的安装配置方法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“nagios的安装配置方法”吧!
简单介绍下nagios
开源网络监控
监控的分类:
状态的连续监控:对实时状态进行监控。
状态的变化监控:但某一时刻监控的状态发生变化时,就进行汇报。
nagios是一款遵循GPLV2的开源网络监控软件,可用来监控制定的多种系统的主机、服务,并在它们的工作状态发生变化时通知管理员。
1)监控网络服务(HTTP/POP3/SMTP/PING/MYSQL等)
2)监控主机资源(磁盘利用率、内存利用率、CPU负载等)
3)简洁的插件设计接口,使得用户可以轻松开发所需的检测脚本(运维则可直接找到相关脚本并使用)
4)并行服务模式
5)轻松描述网络结构,并且能够区辨“宕机”和“主机不可达”
6)通过邮件或用户自定义的方式将主机或服务的工作状态变化情况通知给管理员
7)当服务或主机问题产生与解决时将告警发送给联系人(通过EMail/短信、用户定义方式)
8)自动日志滚动
9)可以通过web方式直观的查看当前网络状态、通知和问题历史、日志文件等,此组件为可选
undefined
Nagios通常由一个主程序(Nagios)、一个插件程序(Nagios-plugins)和四个可选的ADDON(NRPE/NSCA/NSCLIENT++和NDOUTILS)组成。
NRPE:用来在监控的的远程LINUX/UNIX主机上执行脚本插件以实现对这些主机资源的监控;
试验中用到的版本是NRPE-2.1.2.tar.gz
NSCA:用来让被监控的远程Linux/Unix主机主动将监控信息发送给Nagios服务器(这在冗余监控模式中,特别要用到)
NSCLIENT++:用来监控Windows主机时安装在Windows主机上的组件;
NDOUTILS:则用来将NAGIOS的配置信息和各EVETN产生的数据存入数据库,以实现对这些数据的快速检索和处理;
NAGIOS是通过配置文件来驱动这个监控流程,因为所有的内容都是可配置的,所以也就非常灵活,功能自然也就枪弹,把太多的工作留给使用者。
1、新添加监控主机
要修改localhost.cfg或windows.cfg配置文件
这里的默认路径为/usr/local/nagios/etc/objects/localhost.cfg或者/usr/local/nagios/etc/objects/windows.cfg
2、调整监控的命令
要修改commands.cfg配置文件
/usr/local/nagios/etc/objects/commands.cfg
3、要更改联系人的信息
要修改contacts.cfg配置文件
/usr/local/nagios/etc/objects/contacts.cfg
4、要调整监控时间
要修改timeperiods.cfg配置文件
/usr/local/nagios/etc/objects/contacts.cfg
5、添加具体的监控服务
要修改services.cfg配置文件,这里信息都是来自其他配置文件的
6、存放相关的命令执行脚本
/usr/local/nagios/libexecls
7、/usr/local/nagios/etc/objects/commands.cfg 定义相关命令
yum 源安装配置
vi /etc/yum.repos.d/Centos-Media.repo
[xscl]
baseurl=file:///mnt/cdrom/
gpgcheck=0
enabled=1
:wq
安装nagios必须的基本组件的运行依赖于httpd、gcc和gd.
yum clean all
准备工作:
yum -y install httpd* php
yum -y install gcc glibc glibc-common
yum -y install gd gd-devel
groupadd nagcmd
useradd -m nagios
usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache
#j将apache用户加入nagcmd组使之工作时具有足够的权限
下载所需要的安装组件:
服务器端所用的安装包:nagios nagios-plugins ndoutils(非必须)
linux客户端:nrpe
windows客户端:NSCLIENT
创建用户:
chkconfig httpd on
useradd nagios
cd /root
上传软件包我这里下载的nagios-3.3.1.tar.gz
tar-xzvf nagios-3.3.1.tar.gz
cd nagios
#./configure --with-command-group=nagcmd
make install
报错解决方法如下:
今天安装nagios3.3.1,不是第一次安装了,之前都很顺利,这次安装的时候,在执行命令make install的时候,报错了。大致如下
[root@magedunagios]#makeinstall
cd./base&&makeinstall
make[1]:Enteringdirectory`/root/nagios/base'
makeinstall-basic
make[2]:Enteringdirectory`/root/nagios/base'
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/bin
/usr/bin/install-c-m774-onagios-gnagiosnagios/var/www/html/nagios/bin
/usr/bin/install-c-m774-onagios-gnagiosnagiostats/var/www/html/nagios/bin
make[2]:Leavingdirectory`/root/nagios/base'
makestrip-post-install
make[2]:Enteringdirectory`/root/nagios/base'
/usr/bin/strip/var/www/html/nagios/bin/nagios
/usr/bin/strip/var/www/html/nagios/bin/nagiostats
make[2]:Leavingdirectory`/root/nagios/base'
make[1]:Leavingdirectory`/root/nagios/base'
cd./cgi&&makeinstall
make[1]:Enteringdirectory`/root/nagios/cgi'
makeinstall-basic
make[2]:Enteringdirectory`/root/nagios/cgi'
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/sbin
forfilein*.cgi;do\
/usr/bin/install-c-m775-onagios-gnagios$file/var/www/html/nagios/sbin;\
done
make[2]:Leavingdirectory`/root/nagios/cgi'
makestrip-post-install
make[2]:Enteringdirectory`/root/nagios/cgi'
forfilein*.cgi;do\
/usr/bin/strip/var/www/html/nagios/sbin/$file;\
done
make[2]:Leavingdirectory`/root/nagios/cgi'
make[1]:Leavingdirectory`/root/nagios/cgi'
cd./html&&makeinstall
make[1]:Enteringdirectory`/root/nagios/html'
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/media
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/stylesheets
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/contexthelp
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/docs
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/docs/p_w_picpaths
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/p_w_picpaths
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/p_w_picpaths/logos
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/includes
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/includes/rss
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/includes/rss/extlib
/usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/ssi
/usr/bin/install-c-m664-onagios-gnagiosrobots.txt/var/www/html/nagios/share
rm-f/var/www/html/nagios/share/index.html
rm-f/var/www/html/nagios/share/main.html
rm-f/var/www/html/nagios/share/side.html
forfilein*.php;\
do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share;done
forfileinstylesheets/*.css;\
do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/stylesheets;done
forfileincontexthelp/*.html;\
do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/contexthelp;done
forfileinp_w_picpaths/*.gif;\
do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/p_w_picpaths;done
forfileinp_w_picpaths/*.jpg;\
do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/p_w_picpaths;done
forfileinp_w_picpaths/*.png;\
do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/p_w_picpaths;done
forfileinp_w_picpaths/*.ico;\
do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/p_w_picpaths;done
forfileinp_w_picpaths/logos/*.*;\
do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/p_w_picpaths/logos;done
forfileinincludes/*.*;\
do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/includes;done
forfileinincludes/rss/*;\
do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/includes/rss;done
/usr/bin/install:omittingdirectory`includes/rss/extlib'
/usr/bin/install:omittingdirectory`includes/rss/htdocs'
/usr/bin/install:omittingdirectory`includes/rss/scripts'
make[1]:***[install]Error1
make[1]:Leavingdirectory`/root/nagios/html'
make:***[install]Error2
很纠结啊,google了一下,有解决方案,好像是makefile里有语法错误,具体怎么导致的不清楚,执行完以下命令,就OK了
# sed-i's:forfileinincludes/rss/\*;:forfileinincludes/rss/\*.\*;:g'./html/Makefile
# sed-i's:forfileinincludes/rss/extlib/\*;:forfileinincludes/rss/extlib/\*.\*;:g'./html/Makefile
然后,执行以下命令,来完成安装
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。