centos安装nagios+nrpe-创新互联

linux下有2大监控神器cacti+nagios,下面我把我自己搭建nagios的步骤记录下来,以便以后需要的时候看。
首先安装依赖包
#yum install -y httpd mysql mysql-devel mysql-server php php-mysql gcc gcc-c++ gblic gblic-devel gd gd-devel openssl-devel
添加nagios用户,用户组
#groupadd nagcmd
#useradd nagios
#usermod -a -G nagcmd nagios
#usermod -a -G nagcmd daemon(http的user)
下载nagios安装包,解压
开始编译
#./configure --prefix=/etc/nagios \
>--with-nagios-user=nagios \
>--with-nagios-group=nagios \
>--enable-event-broker
#make all
#make install
#make install-init
#make install-commandmode
#make install-config
#make install-webconf(编译安装的httpd会出现错误)
安装nagios-plugins
#./configure --with-nagios-user=nagios \
>--with-nagios-group=nagios \
>--with-mysql=/path/to/mysql(监控mysql必须添加此选项)
#make && make install
下面开始安装nrpe
首先确定开发环境
#yum grouplist
确定有Development tools和Development Libraries
如果没有就安装
#yum groupinstall -y "Development tools" "Development Libraries"
开始安装nrpe
#./configure --with-nagios-user=nagios \
>--with-nagios-group=nagios \
>--with-nrpe-user=nagios \
>--with-nrpe-group=nagios \
>--enable-command-args \
>--enable-ssl
#make all
#make install-plugin
服务器端不需要开始nrpe服务

下面开始配置客户端
nrpe依赖于nagios-plugins,首先安装nagios-plugins
#./configure --with-nagios-user=nagios \
>--with-nagios-group=nagios \
>--with-mysql=/path/to/mysql(监控mysql必须添加此选项)
#make && make instal
下面开始安装nrpe
#./configure --with-nagios-user=nagios \
>--with-nagios-group=nagios \
>--with-nrpe-user=nagios \
>--with-nrpe-group=nagios \
>--enable-command-args \
>--enable-ssl
#make all
#make install-plugin
#make install-daemon(安装守护进程)
#make install-daemon-config(安装守护进程配置文件)

修改nrpe.cfg文件
找到allowed_hosts添加你的服务器的IP

启动nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
下面就可以在服务器端定义主机,定义命令开始监控
定义命令
define command{
     command_name     check_nrpe
     command_line      $USER1$/check_nrpe -H  $HOSTADDRESS$  -c $ARG1$(-c表示在远程执行命令)
}
定义主机
define host {
     use               linux-server
     host_name         webserver
     alias              web-server
     address            192.168.0.4
}
定义服务
define service {
     use               linux-service
     host_name          webserver
     service_description   PING
     check_command     check_nrpe!check_ping
}
想要监控什么就在客户端上定义命令,在服务器上填写检测内容就可以了

下面附上nrpe的启动脚本
#!/bin/sh
#
# Source function library
if [ -f /etc/rc.d/init.d/functions ]; then
  . /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ]; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/functions ]; then
  . /etc/rc.d/functions
fi
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
NrpeBin=/usr/local/nagios/bin/nrpe
NrpeCfg=/usr/local/nagios/etc/nrpe.cfg
LockFile=/var/lock/subsys/nrpe
# See how we were called.
case "$1" in
 start)
  # Start daemons.
  echo -n "Starting nrpe: "
  daemon $NrpeBin -c $NrpeCfg -d
  echo
  touch $LockFile
  ;;
 stop)
  # Stop daemons.
  echo -n "Shutting down nrpe: "
  killproc nrpe
  echo
  rm -f $LockFile
  ;;
 restart)
  $0 stop
  $0 start
  ;;
 status)
  status nrpe
  ;;
 *)
  echo "Usage: nrpe {start|stop|restart|status}"
  exit 1
esac
exit 0

创新互联公司服务项目包括顺义网站建设、顺义网站制作、顺义网页制作以及顺义网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,顺义网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到顺义省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

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


文章题目:centos安装nagios+nrpe-创新互联
分享路径:http://pwwzsj.com/article/dcsoii.html