资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

rhel6.2安装Nagios

目录索引

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站设计、成都做网站、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的遵义网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

一、Nagios简介

1.1主要功能

二、Nagios工作原理

2.1.四种监控状态

三、实验环境之前期准备

3.1.挂载光盘并对yum进行配置

3.2.安装网络配置工具

3.3.进行网络配置

3.4.进行测试

四、实验环境之LAMP平台构建

4.1.构建LAMP平台

4.2.建立测试文件

4.3.开启httpd服务并开机自启

4.4.测试

五、实验目标

六、Nagios安装

5.1.下载Nagios及插件

5.2.Nagios准备

5.3.安装Nagios

七、Nagios配置

6.1.创建Nagios的web程序配置文件

6.2.创建Nagios-web程序用户

八、编译安装Nagios插件

7.1.nagios的目录结构

7.2.编译安装Nagios-plugins

7.3.将Nagios添加至系统服务并设置开机自启

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

九、测试

一、Nagios简介

Nagios是一款开源的电脑系统和网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。

Nagios原名为NetSaint,由Ethan Galstad开发并维护至今。NAGIOS是一个缩写形式: "Nagios Ain't Gonna Insist On Sainthood" Sainthood翻译为圣徒,而"Agios"是"saint"的希腊表示方法。Nagios被开发在Linux下使用,但在Unix下也工作得非常好。

1.1主要功能

网络服务监控(SMTP、POP3、HTTP、NNTP、ICMP、SNMP、FTP、SSH)

主机资源监控(CPU load、disk usage、system logs),也包括Windows主机(使用NSClient++ plugin)

可以指定自己编写的Plugin通过网络收集数据来监控任何情况(温度、警告……)

可以通过配置Nagios远程执行插件远程执行脚本

远程监控支持SSH或SSL加通道方式进行监控

简单的plugin设计允许用户很容易的开发自己需要的检查服务,支持很多开发语言(shell scripts、C++、Perl、ruby、Python、PHP、C#等)

包含很多图形化数据Plugins(Nagiosgraph、Nagiosgrapher、PNP4Nagios等)

可并行服务检查

能够定义网络主机的层次,允许逐级检查,就是从父主机开始向下检查

当服务或主机出现问题时发出通告,可通过email, pager, sms或任意用户自定义的plugin进行通知

能够自定义事件处理机制重新激活出问题的服务或主机

自动日志循环

支持冗余监控

包括Web界面可以查看当前网络状态,通知,问题历史,日志文件等

二、Nagios工作原理

Nagios的功能是监控服务和主机,但是他自身并不包括这部分功能,所有的监控、检测功能都是通过各种插件来完成的。

启动Nagios后,它会周期性的自动调用插件去检测服务器状态,同时Nagios会维持一个队列,所有插件返回来的状态信息都进入队列,Nagios每次都从队首开始读取信息,并进行处理后,把状态结果通过web显示出来。

Nagios提供了许多插件,利用这些插件可以方便的监控很多服务状态。安装完成后,在nagios主目录下的/libexec里放有nagios自带的可以使用的所有插件,如,check_disk是检查磁盘空间的插件,check_load是检查CPU负载的,等等。每一个插件可以通过运行./check_xxx –h来查看其使用方法和功能。

Nagios可以识别4种状态返回信息,即 0(OK)表示状态正常/绿色、1(WARNING)表示出现警告/×××、2(CRITICAL)表示出现非常严重的错误/红色、3(UNKNOWN)表示未知错误/深×××。Nagios根据插件返回来的值,来判断监控对象的状态,并通过web显示出来,以供管理员及时发现故障。

2.1.四种监控状态

再说报警功能,如果监控系统发现问题不能报警那就没有意义了,所以报警也是nagios很重要的功能之一。但是,同样的,Nagios自身也没有报警部分的代码,甚至没有插件,而是交给用户或者其他相关开源项目组去完成的。

Nagios安装,是指基本平台,也就是Nagios软件包的安装。它是监控体系的框架,也是所有监控的基础。

rhel6.2安装Nagios

三、实验环境之前期准备

3.1.挂载光盘并对yum进行配置

rhel6.2安装Nagios

rhel6.2安装Nagios

3.2.安装网络配置工具

rhel6.2安装Nagios

3.3.进行网络配置

rhel6.2安装Nagios

3.4.进行测试

rhel6.2安装Nagios

rhel6.2安装Nagios

四、实验环境之LAMP平台构建

4.1.构建LAMP平台

[root@a ~]# yum -y install httpd gcc glibc glibc-commongdgd-develphpphp-MySQL mysqlmysql-servermysql-developenssl-devel

rhel6.2安装Nagios

4.2.建立测试文件

[root@a ~]# vi /var/www/html/index.php

phpinfo();

?>

$link=mysql_connect('localhost'@'root'S'')

4.3.开启httpd服务并开机自启

[root@a ~]# service httpd start

[root@a ~]# chkconfig httpd on

4.4.测试

rhel6.2安装Nagios

五、实验目标

rhel6.2安装Nagios

六、Nagios安装

6.1.下载Nagios及插件

rhel6.2安装Nagios

6.2.Nagios准备

[root@a nagios]# groupadd -r nagcmd

[root@a nagios]# useradd-m-Gnagcmdnagios

[root@a nagios]# passwdnagios

更改用户 nagios的密码。

新的密码:

重新输入新的密码:

passwd:所有的身份验证令牌已经成功更新。

[root@a nagios]# usermod -G nagcmd apache

6.3.安装Nagios

[root@a ~]# tar -xvzf nagios-3.4.4.tar.gz -C /usr/src

[root@a ~]# cd /usr/src/nagios/

[root@a nagios]# ./configure--sysconfdir=/etc/nagios --enable-event-broker --with-command-group=nagcmd

[root@a nagios]# make all

[root@a nagios]# make install

[root@a nagios]# make install-init

[root@a nagios]# make install-commandmode

[root@a nagios]# make install-config

七、Nagios配置

7.1.创建Nagios的web程序配置文件

在httpd的配置文件目录(conf.d)中创建创建Nagios的web程序配置文件

[root@a nagios]# make install-webconf

/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf

*** Nagios/Apache conf file installed ***

修改apache的配置文件

[root@a nagios]# vi /etc/httpd/conf/httpd.conf

Include conf.d/nagios.conf

7.2.创建Nagios-web程序用户

创建一个登录Nagios web程序的用户,这个用户帐号在以后web登录nagios认证时所用:

[root@a nagios]# htpasswd-c/etc/nagios/htpasswd.usersnagiosadmin

以上过程配置结束后要重新启动httpd

rhel6.2安装Nagios

rhel6.2安装Nagios

八、编译安装Nagios插件

8.1.nagios的目录结构

bin

Nagios执行程序所在目录,nagios文件即为主程序

etc

Nagios配置文件位置,初始安装完后,只有几个*.cfg-sample文件

sbin

Nagios Cgi文件所在目录,也就是执行外部命令所需未找到索引项文件所在的目录

Share

Nagios网页文件所在的目录

libexec

插件所在的目录

Var

Nagios日志文件等文件所在的目录

var/archives

Empty directory for thearchived logs

var/rw

Empty directory for theexternal command file

8.2.编译安装Nagios-plugins

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

[root@a ~]# tar -xvzf nagios-plugins-1.4.16.tar.gz -C /usr/src

[root@a ~]# cd /usr/src/nagios-plugins-1.4.16/

[root@a nagios-plugins-1.4.16]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql=/usr/local/mysql

[root@a nagios-plugins-1.4.16]# make && make install

8.3.将Nagios添加至系统服务并设置开机自启

[root@a nagios-plugins-1.4.16]# chkconfig --add nagios

[root@a nagios-plugins-1.4.16]# chkconfig nagios on

[root@a var]# service nagios restart

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

[root@a nagios-plugins-1.4.16]# /usr/local/nagios/bin/nagios –v /etc/nagios/nagios.cfg

Nagios Core 3.4.4

Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors

Copyright (c) 1999-2009 Ethan Galstad

Last Modified: 01-12-2013

License: GPL

Website: http://www.nagios.org

Reading configuration data...

Read main config file okay...

Processing object config file '/etc/nagios/objects/commands.cfg'...

Processing object config file '/etc/nagios/objects/contacts.cfg'...

Processing object config file '/etc/nagios/objects/timeperiods.cfg'...

Processing object config file '/etc/nagios/objects/templates.cfg'...

Processing object config file '/etc/nagios/objects/localhost.cfg'...

Read object config files okay...

Running pre-flight check on configuration data...

Checking services...

Checked 8 services.

Checking hosts...

Checked 1 hosts.

Checking host groups...

Checked 1 host groups.

Checking service groups...

Checked 0 service groups.

Checking contacts...

Checked 1 contacts.

Checking contact groups...

Checked 1 contact groups.

Checking service escalations...

Checked 0 service escalations.

Checking service dependencies...

Checked 0 service dependencies.

Checking host escalations...

Checked 0 host escalations.

Checking host dependencies...

Checked 0 host dependencies.

Checking commands...

Checked 24 commands.

Checking time periods...

Checked 5 time periods.

Checking for circular paths between hosts...

Checking for circular host and service dependencies...

Checking global event handlers...

Checking obsessive compulsive processor commands...

Checking misc settings...

Total Warnings: 0

Total Errors:0

7.5.关闭selinux及防火墙

[root@a nagios-plugins-1.4.16]# setenfoce 0

[root@a nagios-plugins-1.4.16]# service iptables stop

九、测试

rhel6.2安装Nagios


当前文章:rhel6.2安装Nagios
URL分享:http://cdkjz.cn/article/ppphgs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220