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安装配置方法”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

新闻名称:nagios安装配置方法-创新互联
链接地址:https://www.cdcxhl.com/article26/dijccg.html

成都网站建设公司_创新互联,为您提供网站导航域名注册微信公众号App开发品牌网站制作软件开发

广告

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

绵阳服务器托管