Solaris10下Nagios安装
1. 前言
Nagios是一个系统和网络监控软件,它可以监测所指定的主机和服务,并在出现问题以及问题恢复后发出报警。Nagios最早是被设计运行于Linux环境下的,但在大多数Unix操作系统下也可以使用。同时它是一个开源软件,我们可以免费获得它的源码,和使用它。Nagios是个不错的系统监控软件,应用的范围也比较广泛。
本文将介绍Nagios在Solaris10操做系统下的安装过程,其中包括,源码的编译、安装;Apache的安装、Nagios CGI的配置;Nagios监控配置等。
本文参考了Nagios的官方文档和Nagios社区的文章,以及互联网上其他人的相关帖子。
2. 环境、资源准备
要安装Nagios首先你得有一个能运行Nagios软件的操作系统,我选用的操作系统是Solaris10(x86),当然还要有Nagios源代码。nagios-plugins也是必不可少的,没有它Nagios就不能获得你要监控资源的任何信息。
在solaris10下安装Nagios,还需要C编译环境,一般选择gcc和make。还有一些必须的软件包。
需要的软件包如下:
Nagios和nagios-plugins的源码包如下:
Nagios的版本是3.0.3,plugins为1.4.11。
2.1. 安装gcc、make 配置C编译环境
2.1.1. 安装gcc
使用gcc需要安装libiconv和libintl。
将/usr/local/bin 和 /usr/ccs/bin 添加到PATH中
设置LD_LIBRARY_PATH,加入/usr/local/lib
2.1.2. 安装make和openssl
安装make
安装openssl
3. 安装Nagios
当c编译环境准备完毕后,下一步就可以安装Nagios了。
一般来讲安装Nagios,需要安装如下几个软件包,一个是Nagios软件包;一个是Nagios Plugins,这是个插件,监控脚本和程序都在这个包里;还有,如果需要监控远程主机,那么NRPE也是必不可少的(对于Unix主机,Windows用的是NSCA)。
此外,Nagios还提供一个用cgi编写的web应用,可以将其部署到apache服务器下,提供一个可视化的监控情况的浏览界面。
下面逐步介绍一下安装和配置过程。
3.1. 安装Nagios
安装Nagios之前需要创建用户、用户组(默认nagios、nagios)。
确认/usr/ccs/bin存在于PATH中。
创建Nagios的安装目录 /usr/local/nagios
安装Nagios
安装Nagios Plugins
3.2. 安装、配置Apache
安装Apache
配置/usr/local/apache2/conf/httpd.conf 文件。
修改apahce的执行用户、用户组为nagios、nagios。
配置Nagios的web应用。
在/usr/local/apache2/conf/httpd.conf文件追加如下内容。
生成登录用户和验证口令。
此处的user_name为登录Nagios Web应用需要输入的用户名。我所使用的是sky。
按照提示输入要设置的口令即可。
配置/usr/local/nagios/etc/cgi.cfg,添加用户sky。
启动Apache登录[url]http://<IP>/nagios[/url],IP是主机ip地址,检查配置是否正确。
在IE地址栏输入[url]http://<IP>/nagios[/url]
如果可以看到如上界面,那么你的配置就成功了。
3.3. 配置、启动Nagios
在nagios的etc目录下存放的是配置文件,Nagios从nagios.cfg文件中读取配置信息,从而确定监控的内容。nagios.cfg文件仅仅是配置信息的入口,该文件中有很多指向(cfg_file=...),指定其余配置文件的路径,包括模板配置文件(templates.cfg)、命令配置文件(commands.cfg)、时间周期文件(timeperiods.cfg)等等。
3.3.1. 配置监控内容
编辑/usr/local/nagios/etc/objects/localhost.cfg文件,监控本机运行状况。
修改/usr/local/nagios/etc/nagios.cfg如下
3.3.2. 启动Nagios
Nagios的启动程序是/usr/local/nagios/bin/nagios
首先通过-v选项验证配置文件是否正确。
如果没有错误,就可以启动它了。
查看/usr/local/nagios/var/nagios.log日志文件,观察启动是否正常。
在IE浏览器中查看监控情况。
点击左边导航栏的 Host Detail
点击 localhost 查看详细情况。
3.4. 安装NRPE
通过Nagios的安装和配置,我们看到了本机(localhost)系统的运行状况。我们需要监控的不仅仅是我们本机,还应该可以监控网络中其它服务器的运行状况,NRPE就是用来解决这个问题的。简单的说NRPE就是运行在远程主机(被监控主机)上的进程,它负责与Nagios主监控进程进行通信,将监控的结果传给主监控机器(Nagios所在主机)。
Nagios和NRPE之间的关系如下图所示
图中蓝色部分就是NRPE,它主要包括两个部分一个是NRPE程序(图中Remote Linux/Unix Host所包含的蓝色部分NRPE),另一个是NRPE插件(也就是check_nrpe程序)。Nagios通过调用check_nrpe和运行在远程主机上的NRPE程序来通讯,NRPE程序通过要调用Nagios的插件(Nagios Plugins)获得监控结果、信息,将其传回给监控主机(Monitoring Host)。
3.4.1. NRPE的安装
从NRPE原理图我们不难看出,安装NRPE软件需要安装如下几个部分,首先,在监控主机(Monitoring Host)也就是Nagios所在的主机上要安装NRPE插件(check_nrpe);其次,在远程主机(Remote Linux/Unix Host),即被监控主机上,安装NRPE程序(nrpe);最后,如果远程主机(Remote Linux/Unix Host)只有NRPE程序(nrpe)是不能监控本机的任何信息的,当然还要在远程主机上安装Nagios插件(Nagios Plugins)。
以下讲述一下NRPE和NRPE插件的安装过程,Nagios插件的安装参见之前的Nagios安装部分,这里就不重复了。
首先在远程主机上准备好C编译环境,参考之前的章节。创建nagios用户和nagios用户组,以及软件的安装目录/usr/local/nagios。
3.4.1.1. Configuration
解压软件包
当看到没有错误后就可以Make了。
3.4.1.2. Make
在make之前,需要对./src/nrpe.c进行必要的修改,否则编译会报错。
编译
如果没有错误,则表明编译通过了,下一步就是安装了。在监控主机(Monitoring Host)和远程主机(Remote Host)上安装方法是不一样的,下面将逐一说明。
3.4.1.3. 在监控主机(Monitoring Host)安装NRPE插件
在监控主机上安装NRPE插件
这个过程实际上就是将编译好的check_nrpe拷贝到/usr/local/nagios/libexec下。
3.4.1.4. 在远程主机(Remote Host)安装NRPE程序和配置文件模板
在远程主机上安装NRPE和配置模板文件
nrpe程序被拷贝到了/usr/local/nagios/bin下。
配置文件nrpe.cfg位于/usr/local/nagios/etc下。
3.4.2. NRPE的配置和启动(远程主机)
修改远程主机上的/usr/local/nagios/etc/nrpe.cfg文件。
需修改allowed_hosts,设置为监控主机的IP。
启动NRPE(远程主机)
查看daemon的后台日志,检查是否启动正常。
通过在监控主机(Monitoring Host)运行check_nrpe命令检查访问是否正常。
3.4.3. 配置监控主机(Monitoring Host),使其能监控远程主机(Remote Host)
首先修改/usr/local/nagios/etc/objects/commands.cfg,增加check_nrpe命令定义。
创建一个新的主机监控配置文件,/usr/local/nagios/etc/objects/unixhost_<Remote Host IP>.cfg。
将unixhost_172.17.101.150.cfg添加到nagios.cfg中。
验证配置信息是否正确。
重新启动Nagios,查看远程主机是否已被添加进来。
主机列表
服务信息情况
4. 结语
以上内容仅是简单的介绍了一下Nagios在Solaris10上的安装、配置过程主要是Nagios、Nagios Plugins和NRPE的安装,以及Nagios和NRPE的配置过程。Nagios是一功能较强大的开源软件,其扩展性很好,通过Nagios Plugins新版本的方法其监控将更强大,当然你也可以根据API规则编写能够满足自己需要的监控方法。
本文出自 “sky” 博客,请务必保留此出处[url]http://skymax.blog.51cto.com/365901/98351[/url] 本文出自 51CTO.COM技术博客 |
Solaris10下Nagios安装
精选 转载上一篇:Linux系统信息查看命令大全
下一篇:apache 无法启动故障排查
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
XP下安装solaris10
安装solaris10笔记
xp 职场 windows solaris 休闲 -
虚拟机下安装Solaris10
由于才开始用这个blog,图片还是上传不上来,总是有4张限制,使用图床也不行,具体是怎么回事我也不清楚,图片显示不出来,所以我在下面使用百度文库显示。
安装unix Solaris10安装 安装Solaris10 虚拟机安装 -
solaris10 安装图解
solaris10 安装的全过程,全部都是用截图和说名来完成的,这个对刚入门的朋友一定可以有很好的帮助。在附件里。
安装 职场 solaris 系统 休闲 -
solaris10下安装mysql5
solaris10下安装mysql5
安装 mysql 数据库 solaris10 mysql5