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

CentOS安装Nagios+NRPE

作者头像
星哥玩云
发布2022-06-30 19:01:06
3420
发布2022-06-30 19:01:06
举报
文章被收录于专栏:开源部署

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

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

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

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

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

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档