前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS 5.3安装Nagios

CentOS 5.3安装Nagios

作者头像
EltonZheng
发布2021-01-26 14:52:55
6180
发布2021-01-26 14:52:55
举报

安装软件 *******************

确保以下包都被安装

yum install gcc yum install glibc glibc-common yum install gd gd-devel

成为root用户 su -l

创建Nagios用户 /usr/sbin/useradd -m nagios passwd nagios

创建Nagios用户组并把nagios用户和apache用户加入到这个组里

/usr/sbin/groupadd nagcmd /usr/sbin/usermod -a -G nagcmd nagios /usr/sbin/usermod -a -G nagcmd apache

创建下载目录 mkdir ~/downloads cd ~/downloads

下载文件 wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz

解压源文件 cd ~/downloads tar xzf nagios-3.0.6.tar.gz cd nagios-3.0.6

运行配置脚本,指定用户组 ./configure –with-command-group=nagcmd –with-httpd-conf=/usr/local/apache/conf

编译 make all

安装 make install make install-init make install-config make install-commandmode

一些配置可以在这里修改

vi /usr/local/nagios/etc/objects/contacts.cfg

安装Apache的web配置文件到Apache的配置目录. make install-webconf

创建web界面管理员 /usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

重启apache使配置生效 /usr/local/apache/bin/apachectl restart


安装插件 ******************* cd ~/downloads tar xzf nagios-plugins-1.4.11.tar.gz cd nagios-plugins-1.4.11

配置编译 ./configure –with-nagios-user=nagios –with-nagios-group=nagios make make install

如果make的时候出现openssl的错误,需要在make的时候加上 make LDFLAGS+=-ldl(http://yahoon.blog.51cto.com/13184/43020

将Nagios加到系统启动列表中 chkconfig –add nagios chkconfig nagios on

验证配置文件正确性 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

如果没有问题,就启动 service nagios start

然后通过 http://localhost/nagios就可以访问了


安装NRPE ******************* 监控主机需要安装check_nrpe,被监控机器需要安装nrpe。他们需要通SSH连接,使用5666端口通信

被监控机器安装

创建帐号 /usr/sbin/useradd nagios passwd nagios

安装Nagios插件 wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz

tar xzf nagios-plugins-1.4.13.tar.gz cd nagios-plugins-1.4.13

./configure make make install

yum install xinetd

wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz

tar xzf nrpe-2.8.tar.gz cd nrpe-2.8

./configure make all

安装插件(为了测试),守候进程和示例配置文件 make install-plugin make install-daemon make install-daemon-config

安装xinetd的NRPE服务 make install-xinetd

编辑 /etc/xinetd.d/nrpe 文件在 only_from 后加入监控主机的ip. only_from = 127.0.0.1 <nagios_ip_address>

在/etc/services加入下面的条目

nrpe 5666/tcp # NRPE

重启Xinetd

service xinetd restart

本地测试 netstat -at | grep nrpe 会显示 tcp 0 0 :nrpe *: LISTEN /usr/local/nagios/libexec/check_nrpe -H localhost 会显示nrpe的版本信息

打开防火墙

iptables -I RH-Firewall-1-INPUT -p tcp -m tcp –dport 5666 -j ACCEPT

service iptables save

监控主机安装

安装 check_nrpe 插件

wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz

tar xzf nrpe-2.12.tar.gz cd nrpe-2.12

./configure make all

make install-plugin

测试NRPE守候进程 /usr/local/nagios/libexec/check_nrpe -H 192.168.0.1(被监控端的ip) 将会返回被监控端的nrpe版本信息


本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档