Nagios 介绍
Nagios 是一款Linux 上成熟的监视系统运行状态和网络信息的开源软件,可以对对主机或服务进行检测的自动化工具;Nagios 能监控所指定的本地或远程主机及服务,同时提供异常通知、事件处理等功能。与商业IT管理系统相比,Nagios 具有成本低廉、结构简单、可维护性强等诸多优点。
Nagios 安装配置
*安装环境 centos 6.0
*新版本改进
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 (hapsis/archives/fulldisclosure/2012-12/0108.html) for finding this. (Eric Stanley) |
一、创建用户和组
[root@NgsSv ~]# useradd -s /sbin/nologin nagios
[root@NgsSv ~]# mkdir /usr/local/nagios
[root@NgsSv ~]# chown -R nagios:nagios /usr/local/nagios/
二、安装apache、php、sendmail、gd_devel
[root@NgsSv ~]# yum -y install \
gcc gcc-c++ make gd-devel httpd httpd-devel php php-perl sendmail openssl*
三、编译安装Nagios
[root@NgsSv ~]# wget \
sourceforge/projects/nagios/files/nagios-3.x/nagios-3.4.4/nagios-3.4.
[root@NgsSv ~]# tar xf nagios-3.4.
[root@NgsSv ~]# cd nagios #跟老版本有点区别
[root@NgsSv nagios]# ./configure --prefix=/usr/local/nagios/ #指定安装目录
perl下载安装教程[root@NgsSv nagios]# make all
[root@NgsSv nagios]# make install #安装Nagios主程序的CGI和HTML文件
[root@NgsSv nagios]# make install-init #创建Nagios启动脚本
[root@NgsSv nagios]# make install-commandmode #配置目录权限
[root@NgsSv nagios]# make install-config #安装Nagios示例配置文件
* nagios安装完成后,目录对应的功能说明如下:
bin:可执行程序所在目录
etc:配置文件所在目录
sbin:cgi文件所在目录,也就是执行外部命令所需文件所在目录
share:网页文件所在目录
libexec:外部插件所在目录
var:日志文件,lock等文件所在目录
var/archives:日志自动归档目录
var/rw:用来存放外部命令文件的目录
四、编译安装nagios-plugins
[root@NgsSv ~]# wget \
sourceforge/projects/nagiosplug/files/latest/download?source=directory
[root@NgsSv ~]# tar xf nagios-plugins-1.4.
[root@NgsSv ~]# cd nagios-plugins-1.4.16
[root@NgsSv nagios-plugins-1.4.16]# ./configure --prefix=/usr/local/nagios/
[root@NgsSv nagios-plugins-1.4.16]# make && make install
五、配置Apache
[root@NgsSv ~]# vi /etc/httpd/f
#红部分为修改添加部分
User nagios
Group nagios
DirectoryIndex index.php index.html index.html.var
AddType application/x-httpd-php .php
#在配置文件末尾添加如下信息:
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/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
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/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
</Directory>
#添加Apache认证用户:
[root@NgsSv ~]# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd ngsusr
[root@NgsSv ~]# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd ngsusr
New password:nagios
Re-type new password:
Adding password for user ngsusr
[root@NgsSv ~]# cat /usr/local/nagios/etc/htpasswd
ngsusr: 5h247d05R5IZ.
六、配置本机监控
0.备份安装目录下所有内容:
[root@NgsSv local]# cd /usr/local/
[root@NgsSv local]# mkdir /root/ngs_BAK
[root@NgsSv local]# tar zcf /root/ngs_BAK/nagios_ nagios libexec
1.新建monitor 文件,拷贝示例文件到该目录下
[root@NgsSv etc]# cd /usr/local/nagios/etc
[root@NgsSv etc]# mv objects/ monitor
[root@NgsSv monitor]# rm -rf printer.cfg windows.cfg switch.cfg
[root@NgsSv monitor]# grep -v "^$" localhost | grep -v "^#" > hosts.cfg
2.修改联系人配置文件
[root@NgsSv etc]# cd monitor/
[root@NgsSv monitor]# cat contacts.cfg |grep -v "^#"|grep "^$"
define contact{
contact_name ngsuser ; Short name of user
use generic-contact ; 引用generic-contact属性信息
alias Nagios Admin ;Full name of user
email ngsuser@163 ; 告警接收邮箱
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members ngsuser ;添加上面定义的联系人,逗号分隔
}
3.修改cgi.cfg
[root@NgsSv ~]# vi /usr/local/nagios/etc/cgi.cfg
default_user_name= ngsusr ;将用户名修改为nagios界面登录的用户名
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论