Nagios介绍
Nagios是一款Linux上成熟的监视系统运行状态和网络信息的开源软件,可以对对主机或服务进行检测的自动化工具;Nagios能监控所指定的本地或远程主机及服务,同时提供异常通知、事件处理等功能。与商业IT管理系统相比,Nagios具有成本低廉、结构简单、可维护性强等诸多优点。
Nagios 安装配置:
*安装环境 centos 6.3
*新版本改进
5 | 3.4.4 - 01/12/2013 |
6 | ------------------ |
7 | * Reenabled check for newer versions of Nagios Core (Mike Guthrie) |
8 | * Fixed bug #408: service checks get duplicated on reload (Eric Stanley) |
9 | * Fixed bug #401: segmentation fault on Solaris when parsing unknown timeperiod directives. (Eric Stanley) |
10 | * Added NULL pointer checks to CGI code. (Eric Stanley) |
11 | * Fixed buffer overflow vulnerability in CGI code. Thanks to Neohapsis (http://archives.neohapsis.com/archives/fulldisclosure/2012-12/0108.html) for finding this. (Eric Stanley) |
一、创建用户和组
[root@localhost ~]# useradd -s /sbin/nologin nagios
[root@localhost ~]# mkdir /usr/local/nagios
[root@localhost ~]# chown -R nagios:nagios /usr/local/nagios/
二、安装apache、php、sendmail、gd_devel
[root@localhost ~]# yum install gd-devel httpd httpd-devel php sendmail -y
三、编译安装Nagios
[root@localhost ~]# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.4.4/nagios-3.4.4.tar.gz
[root@localhost ~]# tar zxvf nagios-3.4.4.tar.gz
[root@localhost ~]# cd nagios #跟老版本有点区别
[root@localhost nagios]# ./configure --prefix=/usr/local/nagios/ #指定安装目录
[root@localhost nagios]# make all
[root@localhost nagios]# make install #安装Nagios主程序的CGI和HTML文件
[root@localhost nagios]# make install-init #创建Nagios启动脚本
[root@localhost nagios]# make install-commandmode #配置目录权限
[root@localhost nagios]# make install-config #安装Nagios示例配置文件
* nagios安装完成后,目录对应的功能说明如下:
bin:可执行程序所在目录
etc:配置文件所在目录
sbin:cgi文件所在目录,也就是执行外部命令所需文件所在目录
share:网页文件所在目录
libexec:外部插件所在目录
var:日志文件,lock等文件所在目录
var/archives:日志自动归档目录
var/rw:用来存放外部命令文件的目录
四、编译安装nagios-plugins
成都创新互联专注于察雅网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供察雅营销型网站建设,察雅网站制作、察雅网页设计、察雅网站官网定制、小程序定制开发服务,打造察雅网络公司原创品牌,更为您提供察雅网站排名全网营销落地服务。
[root@localhost ~]# wget http://sourceforge.net/projects/nagiosplug/files/latest/download?source=directory
[root@localhost ~]# tar zxvf nagios-plugins-1.4.16.tar.gz
[root@localhost ~]# cd nagios-plugins-1.4.16
[root@localhost nagios-plugins-1.4.16]# ./configure --prefix=/usr/local/nagios/
[root@localhost nagios-plugins-1.4.16]# make && make install
五、配置Apache
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf
#红色部分为修改添加部分
Usernagios
Groupnagios
DirectoryIndex index.html index.html.varindex.php
AddType application/x-httpd-php .php
#在配置文件末尾添加如下信息:
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
Alias /nagios "/usr/local/nagios/share"
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
#添加Apache认证用户:
[root@localhost ~]# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd user
New password:
Re-type new password:
Adding password for user user
六、配置本机监控
1.新建monitor 文件,拷贝示例文件到该目录下
[root@localhost etc]# pwd
/usr/local/nagios/etc
[root@localhost etc]# mv objects/ monitor
2.修改联系人配置文件
[root@localhost monitor]# cat contacts.cfg |grep -v "#"|grep " "
define contact{
contact_name user ; Short name of user
use generic-contact ; 引用generic-contact属性信息
alias Nagios Admin ; Full name of user
email user@163.com ; 告警接收邮箱
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members user ;添加上面定义的联系人,逗号分隔
}
3.修改cgi.cfg
default_user_name=user ;将用户名修改为nagios界面登录的用户名
4.修改nagios.cfg 将所有cfg_file=都注释掉添加如下一行
cfg_dir=/usr/local/nagios/etc/monitor
#这样配置非常方便以后维护
5.使用命令:/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg检查配置是否有误
6.重启apache、nagios 并加到开启启动项
[root@localhost ~]# service httpd restart
停止 httpd:[确定]
正在启动 httpd:[确定]
[root@localhost ~]# service nagios restart
Running configuration check...done.
Stopping nagios: .done.
Starting nagios: done.
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig nagios on
7.下图为了看的更直观,没有删除其他的配置,目前还没有这个版本的汉化包,3.2版本有汉化包,汉化过的软件比较别扭,英文版的多使用几次就熟悉了。
分享名称:Nagios安装配置
URL地址:
http://dzwzjz.com/article/iedscc.html