RHEL/CentOS/Fedora安装Nagios 4.0.1

Nagios 4.0.1版本安装,适用于RHEL/CentOS 5.x/6.x 或者Fedora 17/18/19。

我的环境如下:

Centos-6.2

Nagios 4.0.1

Nagios Plugin 1.5

Nagios是一个非常棒的免费的开源的监控工具,它提供给你一个很全面的监控环境,始终密切监视你的机器或者网络,不管是在数据中心还是在你自己的一个小实验室。

步骤1:安装需要的依赖包

需要安装Apache、PHP和一些库像:gcc、glibc、glibc-common、gd、gd-devel、make、net-snmp

[root@taoteng ~]# yum install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp

步骤2:创建一个nagios用户和组

创建一个新的nagios用户和nagcmd组账户并设置密码。[root@taoteng ~]# useradd nagios[root@taoteng ~]# groupadd nagcmd接下来,添加nagios和Apache用户到nagcmd组。

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

步骤3:下载Nagios-4.0.1和Nagios-plugin-1.5

在/root目录下创建一个安装包以及后续需要下载的安装包的目录。

[root@taoteng ~]# mkdir /root/nagios

[root@taoteng ~]# cd /root/nagios

现在来下载最新版本的Nagio-4.0.1和Nagios-plugin-1.5通过wget命令

[root@taoteng nagios]# wget

[root@taoteng nagios]# wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz

步骤4:提取Nagios和nagios-plugins压缩包

我们需要通过tar命令来提取下载的压缩包里面的文件:

[root@taoteng nagios]# tar -zxvf nagios-4.0.1.tar.gz

[root@taoteng nagios]# tar -zxvf nagios-plugins-1.5.tar.gz

紧接着nagios文件夹里面将会出现解压之后的文件夹

[root@taoteng nagios]# ll

总用量 30668

drwxrwxr-x 18 root root 4096 2月 20 21:22 nagios-4.0.1

-r-xr-xr-x 1 root root 1696847 2月 20 20:58 nagios-4.0.1.tar.gz

drwxr-xr-x 15 nagios nagios 4096 2月 24 00:58 nagios-cn-3.2.3

-r-xr-xr-x 1 root root 9638175 2月 20 20:58 nagios-cn-3.2.3.tar.bz2

drwxr-xr-x 15 200 300 4096 2月 20 22:04 nagios-plugins-1.5

-r-xr-xr-x 1 root root 2428258 2月 20 20:58 nagios-plugins-1.5.tar.gz

配置nagios的核心

现在,首先我们将配置nagios核心,将进入到nagios文件夹里面运行configure命令,如果一切运行顺利将会出现下面的界面:

[root@taoteng nagios]# cd nagios-4.0.1

[root@taoteng nagios-4.0.1]# ./configure –with-command-group=nagcmd

输出示例:

Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagcmd Event Broker: yes Install ${prefix}: /usr/local/nagios Install ${includedir}: /usr/local/nagios/include/nagios Lock file: ${prefix}/var/nagios.lock Check result directory: ${prefix}/var/spool/checkresults Init directory: /etc/rc.d/init.d Apache conf.d directory: /etc/httpd/conf.d Mail program: /bin/mail Host OS: linux-gnu Web Interface Options: ———————— HTML URL: CGI URL: Traceroute (used by WAP): /bin/tracerouteReview the options above for accuracy. If they look okay,type ‘make all’ to compile the main program and CGIs.随后配置和编译所有的的二进制文件,make和make install将会在你的机器上安装所需的二进制文件然后才能继续安装,

[root@taoteng nagios-4.0.1]# make

[root@taoteng nagios-4.0.1]# make install

输出样例:

*** Main program, CGIs and HTML files installed ***You can continue with installing Nagios as follows (type ‘make’without any arguments for a list of all possible options): make install-init – This installs the init script in /etc/rc.d/init.d make install-commandmode – This installs and configures permissions on the directory for holding the external command file make install-config – This installs sample config files in /usr/local/nagios/etc其实从上面的样例上可以看出下步我们需要的操作步骤,接着执行make install-init去安装初始化脚本。

[root@taoteng nagios-4.0.1]# make install-init

从输出的命令行上可以看出我们需要安装外部命令文件(libxce)

[root@taoteng nagios-4.0.1]# make install-commandmode

接下来安装nagios示例文件,运行下面的命令:

[root@taoteng nagios-4.0.1]# make install-config

输出示例:/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg*** Config files installed ***Remember, these are *SAMPLE* config files. You’ll need to readthe documentation for more information on how to actually defineservices, hosts, etc. to fit your particular needs.步骤5:自定义nagios配置文件

打开“contacts.cfg”文件编辑当出现报警状态时候的nagios管理员的电子邮箱

[root@taoteng nagios-4.0.1]# vi /usr/local/nagios/etc/objects/contacts.cfg

输出样例:

###############################################################################

#

# CONTACTS

#

###############################################################################

###############################################################################

# Just one contact defined by default – the Nagios admin (that’s you)

# This contact definition inherits a lot of default values from the ‘generic-contact’

# template which is defined elsewhere.

define contact{

contact_name nagiosadmin ; Short name of user

只有经历过地狱般的折磨,才有征服天堂的力量。

RHEL/CentOS/Fedora安装Nagios 4.0.1

相关文章:

你感兴趣的文章:

标签云: