nagios安装配置方法

本篇内容主要讲解“nagios安装配置方法”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“nagios安装配置方法”吧!

创新互联专注于昭平企业网站建设,响应式网站,成都商城网站开发。昭平网站建设公司,为昭平等地区提供建站服务。全流程定制网站制作,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务

一、监控服务器端安装配置

1、下载软件包

   nagios-3.0.6.tar.gz,nagios-plugins-1.4.13.tar.gz,nrpe-2.8.1.tar.gz

2、安装环境和添加用户组

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

   groupadd nagcmd

   yseradd -m nagios

   usermod -a -G nagcmd nagios

   usermod -a -G nagcmd apache

3、编译安装nagios

   tar -zxvf nagios-3.0.6.tar.gz;cd nagios-3.0.6

   ./configure –with-command-group=nagcmd –enable-event-broker

   make all;make install ;make install-init;make install-config;make install-commandmode

说明:第一步执行make install安装主要的程序、CGI及HTML文件,第二步执行make install-init的步骤,它的作用是把nagios做成一个运行脚本,使nagios随系统开机启动,这是一个很方便的措施。第三步执行 make install-config 把配置文件的例子复制到nagios的安装目录。第四步执行 make install-commandmode 给外部命令访问nagios配置文件的权限。

安装完后 查看一下在/usr/local/nagios下是否存在etc、bin、 sbin、 share、 var这五个目录,如果存在则可以表明程序被正确的安装到系统了。这5个目录的作用是:

bin

Nagios执行程序所在目录,这个目录只有一个文件nagios

etc

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

sbin

Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录

Share

Nagios网页文件所在的目录

Var

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

4、http.conf配置

   在http.conf下面增加这一段

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin

<Directory "/usr/local/nagios/sbin">

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName "Nagios Access"

AuthType Basic

AuthUserFile /usr/local/nagios/etc/htpasswd

Require valid-user

</Directory>

Alias /nagios /usr/local/nagios/share

<Directory "/usr/local/nagios/share">

Options None

AllowOverride None

Order allow,deny

Allow from all

AuthName "Nagios Access"

AuthType Basic

AuthUserFile /usr/local/nagios/etc/htpasswd

Require valid-user

</Directory>

重启http

htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadmin

4、编译安装nagios-plugins

   tar -zxvf nagios-plugins-1.4.13.tar.gz;cd nagios-plugins-1.4.13

   ./configure –with-nagios-user=nagios –with-nagios-group=nagios

   make &&make install

5、配置、启动nagios

   chkconfig --add nagios

   chkconfig nagios on

   setenfoce 0

   检查配置文件: /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg  

   service nagios start

6、安装NRPE

   tar -zxvf nrpe-2.8.1.tar.gz ;cd  nrpe-2.8.1

   ./configure

   make all

   make install-plugin

   make install-daemon

   make install-daemon-config

   启动NRPE: /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

   修改nagios配置文件 commands.cfg

   添加

define command{

       command_name check_nrpe

       command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

       }

检查配置文件/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg  

重启nagios service nagios restart

二、被监控机配置

1、下载软件包nagios-plugins-1.4.13.tar.gz,nrpe-2.8.1.tar.gz

2、安装

   tar -zxvf nagios-plugins-1.4.13.tar.gz;cd nagios-plugins-1.4.13

   ./configure –with-nagios-user=nagios –with-nagios-group=nagios

   make &&make install

   tar -zxvf nrpe-2.8.1.tar.gz;cd nrpe-2.8.1

   ./configure

   make all

   make install-plugin

   make install -daemon

   make install-daemon-config

3.配置nrpe信息

   vim /usr/local/nagios/etc/nrpe.cfg

   allowed_hosts=127.0.0.1,1.1.1.1(监控机IP)  //允许监控的IP

   /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d

   如果有防火墙,需要将开通5666端口,关闭selinux

4、检查联通性

  在监控端执行 /usr/local/nagios/libexec/check_nrpe -H 被监控IP,如果测试成功会得到NRPE版本,如果不成功就检查防火墙,检查配置文件设置是否允许监控机IP

三、飞信报警设置

1、下载和安装飞信软件

主软件:wget http://www.it-adv.net/fetion/downng/fetion20091117-linux.tar.gz

主程序:wget http://bbs.it-adv.net/p_w_upload.php?aid=43&k=b1e8997336d66ec8610adc2b790376a2&t=1299230237

库文件:wget http://www.it-adv.net/fetion/linuxso_20101113.rar

安装飞信:

tar zxvf fetion20091117-linux.tar.gz -C /usr/local

将下载的主程序fetion覆盖掉/usr/local/fx/下的fetion

在windows中解压linuxso_20101113.rar并将里面的库文件上传至 /usr/local/fx/

cd /usr/local/fx

cp lib* /usr/lib

2.飞信测试

/usr/local/fx/fetion --mobile=15958045149 --pwd=12346 --to=15958045149 --msg-utf8=test

这样后在fx目录有个手机号的图片,下载下来查看再输入后就好了,以后就不用输入了

3.nagios配置

修改nagios配置文件 commands.cfg

添加如下

define command {  

            command_name            notify-host-by-fei  

            command_line            /usr/local/fx/fetion --mobile=15958045149 --pwd=qazwsxedc --to=$CONTACTPAGER$ --msg-utf8="Host $HOSTSTATE$ alert for $HOSTNAME$! on '$LONGDATETIME$'" $CONTACTPAGER$  

            }  

# 'notify-service-by-fei' command definition  

define command {  

            command_name         notify-service-by-fei  

            command_line         /usr/local/fx/fetion --mobile=15958045149 --pwd=qazwsxedc --to=$CONTACTPAGER$ --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$  

            }  

修改contacts.cfg

在define contact{}里添加下面这段

service_notification_commands   notify-service-by-fei ; send service notifications via email

       host_notification_commands      notify-host-by-fei

pager 15958045149

检查配置文件,重启nagios

到此,相信大家对“nagios安装配置方法”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

本文名称:nagios安装配置方法
标题链接:https://www.cdcxhl.com/article46/jdcdeg.html

成都网站建设公司_创新互联,为您提供品牌网站设计手机网站建设网站维护定制开发网站改版响应式网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

营销型网站建设