你的位置:首页 > 操作系统

[操作系统]Centos6.7 安装Naigos教程

Centos6.7 安装Naigos教程
参考文档:https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart-fedora.html

blog地址:http://www.cnblogs.com/caoguo


一.安装依赖包

[[email protected] ~]# yum install -y httpd php[[email protected] ~]# yum install -y gcc glibc glibc-common[[email protected] ~]# yum install -y gd gd-devel[[email protected] ~]# yum install -y perl ntp unzip[[email protected] ~]# yum install -y openssl-devel[[email protected] ~]# /etc/init.d/ntpd start[[email protected] ~]# chkconfig ntpd on[[email protected] ~]# /usr/sbin/useradd -m nagios[[email protected] ~]# passwd nagios[[email protected] ~]# /usr/sbin/groupadd nagcmd[[email protected] ~]# /usr/sbin/usermod -a -G nagcmd nagios[[email protected] ~]# /usr/sbin/usermod -a -G nagcmd apache[[email protected] ~]# id nagiosuid=500(nagios) gid=500(nagios) groups=500(nagios),501(nagcmd)[[email protected] ~]# id apacheuid=48(apache) gid=48(apache) groups=48(apache),501(nagcmd)

 

二.nagios的安装

[[email protected] ~]# cd /usr/local/src[[email protected] src]# wget http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz[[email protected] src]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz[[email protected] src]# tar zxvf nagios-4.1.1.tar.gz[[email protected] src]# cd nagios-4.1.1[[email protected] nagios-4.1.1]# ./configure --prefix=/usr/local/nagios --with-comand-group=nagcmd[[email protected] nagios-4.1.1]# make all[[email protected] nagios-4.1.1]# make install[[email protected] nagios-4.1.1]# make install-init[[email protected] nagios-4.1.1]# make install-config[[email protected] nagios-4.1.1]# make install-commandmode[[email protected] nagios-4.1.1]# make install-webconf

 

三.nagios plugins的安装

[[email protected] src]# tar xzf nagios-plugins-2.1.1.tar.gz [[email protected] src]# cd nagios-plugins-2.1.1[[email protected] nagios-plugins-2.1.1]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios[[email protected] nagios-plugins-2.1.1]# make && make install

 

四.nrpe插件安装

[[email protected] src]# wget http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz[[email protected] src]# tar zxf nrpe-2.15.tar.gz [[email protected] src]# cd nrpe-2.15[[email protected] nrpe-2.15]# ./configure --prefix=/usr/local/nagios[[email protected] nrpe-2.15]# make all[[email protected] nrpe-2.15]# make install-plugin[[email protected] nrpe-2.15]# make install-daemon[[email protected] nrpe-2.15]# make install-daemon-config# 测试启动# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d# 自带了启动脚本[[email protected] nrpe-2.15]# cp -rf init-script.in /etc/init.d/nrpe[[email protected] nrpe-2.15]# chmod a+x /etc/init.d/nrpe [[email protected] ~]# /etc/init.d/nrpe start

 

注:其实nagios获取信息都是靠/usr/local/nagios/libexec/check_nrpe 这个脚本主动获取nrpe服务端信息

 

五.配置并启动服务

 

[[email protected] ~]# vi /usr/local/nagios/etc/objects/contacts.cfgdefine contact{    contact_name          nagiosadmin           use               generic-contact         alias              Nagios Admin          email              [email protected]     }[[email protected] ~]# vi /usr/local/nagios/etc/objects/commands.cfg    define command{    command_name  check_nrpe    command_line  $USER1$/check_nrpe -H "$HOSTADDRESS$" -c "$ARG1$"}    [[email protected] ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin# 检查配置文件是否正确[[email protected] ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg[[email protected] ~]# chkconfig nagios on[[email protected] ~]# service nagios start[[email protected] ~]# chkconfig nrpe on[[email protected] ~]# /etc/init.d/nrpe start[[email protected] ~]# chkconfig httpd on[[email protected] ~]# service httpd start[[email protected] ~]# touch /var/www/html/index.html