您的位置:首页 > 移动开发 > IOS开发

nagios-安装配置

2016-03-18 14:39 495 查看
1. 开篇介绍:

Nagios 可以监控的功能有:
1、监控网络服务(SMTP、POP3、HTTP、NNTP、PING 等)

2、监控主机资源(处理器负荷、磁盘利用率等);
3、简单地插件设计使得用户可以方便地扩展自己服务的检测方法;
4、并行服务检查机制;
5、具备定义网络分层结构的能力,用"parent"主机定义来表达网络主机间的关系,
这种关系可被用来发现和明晰主机宕机或不可达状态;
6、当服务或主机问题产生与解决时将告警发送给联系人(通过 EMail、短信、用户
定义方式);
7、可以定义一些处理程序,使之能够在服务或者主机发生故障时起到预防作用;
8、自动的日志滚动功能;
9、可以支持并实现对主机的冗余监控;
10、可选的 WEB 界面用于查看当前的网络状态、通知和故障历史、日志文件等。

2. nagios 定义的监控状态:

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







3. nagios官方网站: www.nagios.org

版本:

DIY版本:免费,但对维护人员技术要求过高。
Student版本:收费版本,功能相对与DIY更强一些。
Professional版本:专业版本,相对于前两者增加了SNMP报告功能,商业进程监视功能等。
Business版本:商业版本,费用最高,用于商业管理,功能最强。性能好,稳定性高。

4 nagios的安装

a. 安装前的准备:

a1. 下载nagios core 和nagios plugins

a2. 搭建lamp平台

a3. nagios依赖组件:

#yum   -y   install    httpd   gcc   glibc   glibc-common   gd   gd-devel   php   php-mysql  mysql
mysql-server   mysql-devel   openssl-devel

a4. 添加nagios运行所需要的用户及用户组

#groupadd   -r   nagcmd
#useradd   -m   -G   nagcmd   nagios
#passwd   nagios

a5. 将apache运行用户添加到nagcmd组,源码安装的apache默认用户为daemon, rpm,yum安装的默认用户为apache.

#usermod -G nagcmd apache


b. 编译安装:

b1.
# ./configure --sysconfdir=/etc/nagios --enable-event-broker --with-command-group=nagcmd --prefix=/usr/local/nagios




b2. make all

#make all


输出结果如下:

输出如下:
make install
- This installs the main program, CGIs, and HTML files
#使用make install来安装主程序,CGI和HTML文件
make install-init
- This installs the init script in /etc/rc.d/init.d
#在/etc/rc.d/init.d安装启动脚本
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
#使用make install-commandmode来配置目录权限
make install-config
- This installs *SAMPLE*config files in /etc/nagios
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-commandmode来安装示例配置文件,安装的路径是/etc/nagios
make install-webconf

- 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 *******************************************

If you have questions about configuring or running Nagios,
please make sure that you:

- Look at the sample config files
- Read the documentation on the Nagios Library at:
http://library.nagios.com

before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
help others help you. This might include:

- What version of Nagios you are using
- What version of the plugins you are using
- Relevant snippets from your config files
- Relevant error messages from the Nagios log file

For more information on obtaining support for Nagios, visit:

http://support.nagios.com

*************************************************************

Enjoy.

b3. 接下来要做的:

# make install
# make install-init
# make install-commandmode
# make install-config


5. nagios的配置


5.1 创建nagios的web程序配置文件

#make install-webconf


nagios的网页存放目录: /usr/local/nagios/share

# ls /usr/local/nagios/share
config.inc.php  docs    includes   js        media       rss-corefeed.php  side.php  stylesheets
contexthelp     images  index.php  main.php  robots.txt  rss-newsfeed.php  ssi


5.2 修改apache的配置文件

vim /etc/httpd/conf/httpd.conf

加入如下语句: nagios.conf 在编译安装Nagios的时候会自动创建,因为我们编译源码时加了apache的conf路径

Include conf.d/*.conf

5.3 创建登录nagios web程序的用户, 这个用户在以后web登录nagios认证时所用。

# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin


6. nagios的目录结构


binnagios执行程序所在的目录,nagios文件即为主程序
etcnagios配置文件位置,初始安装后,只有几个*.cfg-sample文件
sbinnagios Cgi 文件所在目录,也就是执行外部命令所需文件所在目录
sharenagios网页文件所在的目录
libexec插件所在的目录
varnagios日志文件所在的目录
var/archivesempty directory for the archived logs

7. 编译安装nagios-plugins


nagios的有监控工作都是通过插件完成的,因此在启动nagios之前要为其安装官方提供的插件。

/var/lib/mysql 是yum安装mysqll的默认路径

# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql=/var/lib/mysql


make && make install


到这里nagios已经基本安装完成了,但这时别着急启动nagios,需要以下设置:

将 nagios 添加到服务中
设置服务为自启动
检测 nagios 的配置是否正确,在后面配置 nagios 过程中我们为了检测配置的是否正确
需要不断执行该命令来检查配置文件。
#service nagios start 启动 nagios
需要注意的是,Centos 默认打开了 selinux 并且运行于强制安全模式,这将导致在打开
nagios 的 web 界面时会出现 Internet Server Error 的错误。
查看是否运行于强制模式,结果为 1 表示是
更改 selinux 运行于宽容模式
但是这个设置重启后就会失效,如需要重启后保持该设置需要修改
/etc/sysconfig/selinux,将其中的 SELINUX= enforcing 更改为 SELINUX= permissive
并重启系统。当然你也可以改成 disable 禁用 selinux。


8 . 启动前的准备工作

8.1 将nagios添加为系统服务,并将其加入到自动启动服务队列

# chkconfig --add nagios
# chkconfig nagios on
# chkconfig --list nagios
nagios             0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭

8.2 检查配置文件的语法是否正确

# /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg





9. 启动 nagios

# service nagios start
Starting nagios: done.


10. 通过web访问

http://IP/nagios 输入nagiosadmin及其密码。





至此,安装全部结束。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: