扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
实验平台:LInux-5.8,yum源已配置好,SeLinux处于关闭状态
我们提供的服务有:成都做网站、成都网站制作、微信公众号开发、网站优化、网站认证、电白ssl等。为千余家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的电白网站制作公司
- # yum -y install httpd gcc glibc glibc-common gd gd-devel \
- php php-MySQL mysql mysql-devel mysql-server
- # groupadd nagcmd
- # useradd -G nagcmd nagios
- # passwd nagios
- # usermod -a -G nagcmd apache
- # tar zxf nagios-3.3.1.tar.gz
- # cd nagios
- # ./configure --with-command-group=nagcmd --enable-event-broker
- ##--sysconfdir=/etc/nagios 自己可以指定nagios的配置文件路径
- ##--with-command-group=nagcmd 使用前面创建的组
- ##--enable-event-broker 为使用NDOutils做准备的
- # make all
- # make install ##安装nagios
- # make install-init ##安装nagios的init脚本,即/etc/rc.d/init.d/nagios
- # make install-commandmode ##安装命令模式
- # make install-config ##安装生成配置文件
- # make install-webconf ##安装web接口的,识别nagios程序位置/usr/local/nagios/share
- ##然后进入/etc/httpd/conf.d,会发现多了nagios.conf文件,为访问
- ##nagios的web页面定义了一个别名,当访问172.16.14.15/nagios时就可
- ##以访问/usr/local/nagios/share的文件了
- # htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
- # service httpd restart
- # tar zxf nagios-plugins-1.4.15.tar.gz
- # cd nagios-plugins-1.4.15
- # ./configure --with-nagios-user=nagios --with-nagios-group=nagios
- # make
- # make install
- (1)把nagios添加为系统服务并将之加入到自动启动服务队列:
- # chkconfig --add nagios
- # chkconfig nagios on
- (2)检查其主配置文件的语法是否正确:
- # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
- (3)如果上面的语法检查没有问题,接下来就可以正式启动nagios服务了:
- # service nagios start
- current Load:CPU的负载情况,当前显示是Ok的
- Current Users:用户数
- HTTP:显示HTTP服务事物信息的,当前显示WARNING是因为没有提供web页面
- PING:用来ping主机的
- Root Partition:显示根分区信息的
- SSH:显示SSH的状态的
- Swap Usage:显示交换分区使用情况的
- Total Processes:总进程数状态
- 在右上角还有一个各项状态汇总图
- 安装开发包组:
- yum -y groupinstall "Development Libraries" "Development Tools"
- # useradd -s /sbin/nologin nagios
- # tar zxf nagios-plugins-1.4.15.tar.gz
- # cd nagios-plugins-1.4.15
- # ./configure --with-nagios-user=nagios --with-nagios-
- group=nagios
- # make all
- # make install
- # tar -zxvf nrpe-2.13.tar.gz
- # cd nrpe-2.13.tar.gz
- # ./configure --with-nrpe-user=nagios \ ##添加nrpe用户
- --with-nrpe-group=nagios \ ##nrpe组
- --with-nagios-user=nagios \ ##nagios用户名
- --with-nagios-group=nagios \ ##nagios组名
- --enable-command-args \ ##向命令传递参数的
- --enable-ssl ##默认选项,监控端和被监控端传递信息需要ssl加密
- # make all
- # make install-plugin ##安装插件
- # make install-daemon ##将nrpe安装成守护进程
- # make install-daemon-config ##安装守护进程的配置文件
- # vim /usr/local/nagios/etc/nrpe.conf
- log_facility=daemon ##日志文件的设施
- pid_file=/var/run/nrpe.pid ##pid文件路径,自己可以定义
- server_address=172.16.14.14 ##监听的地址
- server_port=5666 ##端口号
- nrpe_user=nagios ##nrpe用户
- nrpe_group=nagios ##nrpe组名
- allowed_hosts=172.16.14.15 ##定义本机所允许的监控端的IP地址。
- command_timeout=60 ##定义命令的超时时间
- connection_timeout=300 ##链接的超时时间
- debug=0 ##调试功能没打开
- # /usr/local/nagios/bin/nrpe -c
- /usr/local/nagios/etc/nrpe.cfg –d
- #!/bin/bash
- # chkconfig: 2345 88 12
- # description: NRPE DAEMON
- NRPE=/usr/local/nagios/bin/nrpe
- NRPECONF=/usr/local/nagios/etc/nrpe.cfg
- case "$1" in
- start)
- echo -n "Starting NRPE daemon..."
- $NRPE -c $NRPECONF -d
- echo " done."
- ;;
- stop)
- echo -n "Stopping NRPE daemon..."
- pkill -u nagios nrpe
- echo " done."
- ;;
- restart)
- $0 stop
- sleep 2
- $0 start
- ;;
- *)
- echo "Usage: $0 start|stop|restart"
- ;;
- esac
- exit 0
- # chmod +x /etc/init.d/nrped
- # chkconfig --add nrped
- # chkconfig --list nrped
- # service nrped start
- # netstat -tnlp | grep 5666
- tcp 0 0 172.16.14.14:5666 0.0.0.0:* LISTEN \
- 24909/nrpe
- command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
- command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
- command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
- command[check_sda2]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda2
- command[check_sda3]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda3
- command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
- command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
- # tar -zxvf nrpe-2.13.tar.gz
- # cd nrpe-2.13.tar.gz
- # ./configure --with-nrpe-user=nagios \
- --with-nrpe-group=nagios \
- --with-nagios-user=nagios \
- --with-nagios-group=nagios \
- --enable-command-args \
- --enable-ssl
- # make all
- # make install-plugin
- # cd /usr/local/nagios/libexec/
- # ./check_nrpe -H 172.16.14.14
- NRPE v2.13 ##说明监控端与被监控端可以通信了
- 在commands.cfg 定义check_nrpe命令:
- define command
- {
- command_name check_nrpe
- command_line $USER1$/check_nrpe –H $HOSTADDRESS$ -c $ARG1$
- }
- # vim linhost.cfg
- define host{
- use linux-server
- host_name linhost
- alias My Linux Host
- address 172.16.14.14
- }
- define service{
- use generic-service
- host_name linhost
- service_description CHECK USERS
- check_command check_nrpe!check_users
- }
- define service{
- use generic-service
- host_name linhost
- service_description Load
- check_command check_nrpe!check_load
- }
- define service{
- use generic-service
- host_name linhost
- service_description SDA1
- check_command check_nrpe!check_sda1
- }
- define service{
- use generic-service
- host_name linhost
- service_description SDA2
- check_command check_nrpe!check_sda2
- }
- define service{
- use generic-service
- host_name linhost
- service_description SDA3
- check_command check_nrpe!check_sda3
- }
- define service{
- use generic-service
- host_name linhost
- service_description Zombie
- check_command check_nrpe!check_zombie_procs
- }
- define service{
- use generic-service
- host_name linhost
- service_description Total procs
- check_command check_nrpe!check_total_procs
- # vim /usr/local/nagios/etc/nagios.cfg
- cfg_file=/usr/local/nagios/etc/objects/linhost.cfg
- # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
- Total Warnings: 0
- Total Errors: 0
- Things look okay - No serious problems were detected during the pre-flight check
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流