美文网首页
nagios安装配置

nagios安装配置

作者: iceriot | 来源:发表于2017-10-25 13:53 被阅读0次
nagios安装简介

nagios本身并没有监控的功能,所有的监控是由插件完成的,插件将监控的结果返回给nagios,nagios分析这些结果以web的方式展现给我们,同时提供相应的报警功能(这个报警的功能也是由插件完成的)。

nagios core 完成核心功能比如调用插件执行任务
nagios plugins 完成具体的某个任务比如检查远程主机是否存活
apache,php 前端页面展示和cgi脚本执行
nrpe 远程插件执行,监控远程linux主机需要安装

系统及环境

centos==7.3.1611 (Core)
nagios==4.3.2
nagios-plugins==2.2.1
nrpe==2.12
apr==1.4.5
apr-util==1.3.12
pcre==8.33
httpd==2.4.28
php==5.6.25

用户创建
/usr/sbin/groupadd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/groupadd apache
/usr/sbin/useradd  nagios -g nagios -s /sbin/nologin
/usr/sbin/useradd  apache -g apache -s /sbin/nologin
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
安装系统依赖
yum remove -y apr-util-devel apr apr-util-mysql \
                    apr-docs apr-devel apr-util \
                    apr-util-docs
yum install gcc glibc glibc-common  gcc-c++ \
                  gd gd-devel openssl openssl-devel \
                  unzip  bzip2  libxml2 libxml2-devel
编译安装apache,php
#安装apr
wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
tar -xf apr-1.4.5.tar.gz
cd apr-1.4.5
./configure  --prefix=/usr/local/apr
make && make install
#安装apr-util
wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
tar -xf apr-util-1.3.12.tar.gz
cd apr-util-1.3.12
./configure  --prefix=/usr/local/apr-util \
   --with-apr=/usr/local/apr/bin/apr-1-config
make && make install
#安装pcre
 wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
tar -xf pcre-8.33.tar.gz
cd  pcre-8.33
./configure  --prefix=/usr/local/pcre
make && make install
#安装httpd
wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.28.tar.gz
tar -xf httpd-2.4.28.tar.gz
cd httpd-2.4.28
./configure  --prefix=/usr/local/apache2 \
  --with-apr=/usr/local/apr \
  --with-apr-util=/usr/local/apr-util \
  --with-pcre=/usr/local/pcre
make && make install
#安装php
wget http://cn2.php.net/distributions/php-5.6.25.tar.gz
tar -xf php-5.6.25.tar.gz
cd php-5.6.25
./configure  --prefix=/usr/local/php \
   --with-apxs2=/usr/local/apache2/bin/apxs
make && make install
编译安装nagios
#安装nagios core
tar -xf nagios-4.3.2.tar.gz
cd nagios-4.3.2
./configure --with-command-group=nagcmd         
make all                                     
make install                                 
make install-init                          
make install-config                         
make install-commandmode
#添加apache nagios配置
cp sample-config/httpd.conf /usr/local/apache2/conf/extra/httpd-nagios.conf 
#添加web界面管理用户
/usr/local/apache2/bin/htpasswd -bc /usr/local/nagios/etc/htpasswd.users nagiosadmin admin 
#设置开机自启动
chkconfig --add nagios                        
chkconfig nagios on    

###################################
#安装nagios-plugin
tar -xf nagios-plugins-2.2.1.tar.gz
cd nagios-plugins-2.2.1
./configure --with-nagios-user=nagios  --with-nagios-group=nagios
make && make install

###################################
#安装nrpe
tar -xvf nrpe-2.12.tar.gz 
cd nrpe-2.12
./configure 
make all
make install-plugin
配置apache和nagios
#!/bin/bash

conf=/usr/local/apache2/conf/httpd.conf

#1开启apache cgi模块,解决点击页面下载cgi情况
sed -i "s+^#LoadModule cgid_module+LoadModule cgid_module+g" $conf

#2.开启apache php模块,解决403禁止访问问题
sed -i "s/DirectoryIndex index.html/& index.php/g"  $conf
sed -i "/application\/x-gzip/aAddType application\/x-httpd-php .php" $conf

#3.添加apache nagios配置文件
echo "Include conf/extra/httpd-nagios.conf" >> $conf

#4.设置apache 运行用户和组为apache"
sed -i "s/^User.*$/User apache/g"   $conf
sed -i "s/^Group.*$/Group apache/g" $conf
启动nagios apache
service nagios start
/usr/local/apache2/bin/apachectl start

至此nagios的基本安装已经完成,登录浏览器访问ip/nagios即可。

相关文章

  • Nagios安装配置nrpe

    监控工具-Nagios-Nagios安装配置nrpe 参考链接1 参考文件: 远程被监控主机安装配置 用户设置 A...

  • nagios配置文件概述

    nagios core配置文件概述 配置文件路径,安装目录下的etc子目录 主配置文件nagios.cfg 通常命...

  • Nagios监控服务

    安装Nagios 安装前准备 部署Nagios运行环境 安装Nagios 创建用户、用户组 编译安装Nagios ...

  • nagios nrpe客户端安装

    如果想要监控远程linux主机需要安装nrpe 添加用户 安装nrpe 安装nagios-plugin 修改配置 ...

  • Linux - Nagios 监控 硬盘 I/O 端口

    上一篇《Linux下Nagios的安装与配置 及遇到的坑 》 Nagios 自带的包里没有直接检查硬盘 I/O 的...

  • nagios安装配置

    nagios安装简介 nagios本身并没有监控的功能,所有的监控是由插件完成的,插件将监控的结果返回给nagio...

  • 编译安装nagios

    本文主要描述如何编译安装nagios主程序及nagios插件, 安装依赖包 下载相应的nagios core包及插...

  • nagios pnp4nagios图形插件安装

    pnp4nagios安装 nagios 是3.5+ 1. 检查环境安装: 如果环境少包,yum安装 2. 安装p...

  • Nagios安装

    1. 环境 nagios分为客户端与服务端 服务端(监控机)放在中控机上 客户端放在各个服务器上 服务端环境: c...

  • CentOS源码安装、配置Nagios(core)+Plugin

    禁用SELinux 根据官方的指导文件需要禁用SELinux,首先我们获取SELinux状态,如果处于启用状态,切...

网友评论

      本文标题:nagios安装配置

      本文链接:https://www.haomeiwen.com/subject/djfqpxtx.html