日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
CentOS7下Nagios的安裝及配置

簡介

Nagios 是一款自動化運維工具,可以協(xié)助運維人員監(jiān)控服務器的運行狀況,并且擁有報警功能。本文章將介紹其安裝方法和詳細的配置方法。

創(chuàng)新互聯(lián)建站專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務,包含不限于成都做網(wǎng)站、網(wǎng)站建設、外貿(mào)營銷網(wǎng)站建設、桐鄉(xiāng)網(wǎng)絡推廣、微信小程序定制開發(fā)、桐鄉(xiāng)網(wǎng)絡營銷、桐鄉(xiāng)企業(yè)策劃、桐鄉(xiāng)品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)建站為所有大學生創(chuàng)業(yè)者提供桐鄉(xiāng)建站搭建服務,24小時服務熱線:13518219792,官方網(wǎng)址:www.cdcxhl.com

nagios 監(jiān)控服務應用指南
本地資源:負載,CPU,磁盤,內(nèi)存。IO,RAID,溫度,passwd文件變化,本地所有文件指紋識別
網(wǎng)絡服務:端口,URL,丟包,進程,網(wǎng)絡流量
其他設備:交換機,打印機,windows等。
業(yè)務數(shù)據(jù):用戶登錄失敗次數(shù),用戶登錄網(wǎng)站次數(shù),輸入驗證碼失敗的次數(shù),某個API接口流量并發(fā),電商網(wǎng)站訂單,支付交易的數(shù)量

nagios成員:主程序nagios,插件nagios-plugins,和一些可選的客戶端nrpe,NSClient++,NSCA和NDOUtils

  • NRPE--半被動模式
    存放位置:安裝在客戶端
    NRPE作用:在客戶端執(zhí)行相關(guān)的腳本插件來獲取數(shù)據(jù),實現(xiàn)對客戶端主機資源的監(jiān)控。
    存在形式:守護進程(agent)模式,開啟的端口5666

  • NSClient++:半被動模式,相當于linux系統(tǒng)的nrpe

  • NDOUtils(不推薦用)
    存在位置:服務端
    作用:用于將nagios的配置信息和各event產(chǎn)生的數(shù)據(jù)存入數(shù)據(jù)庫中,以實現(xiàn)對這些數(shù)據(jù)的檢索和處理。

  • NSCA:純被動模式--->用在分布式監(jiān)控環(huán)境中
    位置:NSCA需要同時安裝在nagios的服務器端和客戶端

軟件版本

nagios版本:4.3.1
nagios-plugins版本:2.2.1
nrpe版本:3.1.0

實現(xiàn)環(huán)境

CentOS版本:CentOS Linux release 7.3.1611 (Core) 64位
Apache版本:Apache/2.4.6
Nginx版本: nginx 1.12.0
Mysql版本:mysql 5.7.18
PHP版本:php 7.1.4

下載nagios軟件及插件包

[root@nagios ~]# cd /software/
[root@nagios software]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.1.tar.gz
[root@nagios software]# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
[root@nagios software]# wget https://sourceforge.net/projects/nagios/files/nrpe-3.x/nrpe-3.1.0.tar.gz
[root@nagios software]# ll
-rw-r--r--   1 root  root  11095797 4月  21 15:57 nagios-4.3.1.tar.gz
-rw-r--r--   1 root  root   2728818 4月  20 00:04 nagios-plugins-2.2.1.tar.gz
-rw-r--r--   1 root  root    501028 4月  17 22:36 nrpe-3.1.0.tar.gz

安裝nagios-server服務端

安裝依賴包

[root@nagios software]# yum -y install httpd httpd-devel gcc glibc glibc-common gd gd-devel perl-devel perl-CPAN fcgi perl-FCGI perl-FCGI-ProcManager

解壓nagios源碼包

[root@nagios software]# tar zxvf nagios-4.3.1.tar.gz

進入解壓后的目錄

[root@nagios software]# cd nagios-4.3.1/

創(chuàng)建ngaios用戶和組(把nginx啟動用戶www加入到nagios相關(guān)組)

[root@nagios nagios-4.3.1]# useradd nagios -s /sbin/nologin 
[root@nagios nagios-4.3.1]# id www
[root@nagios nagios-4.3.1]# groupadd nagcmd
[root@nagios nagios-4.3.1]# usermod -a -G nagcmd nagios 
[root@nagios nagios-4.3.1]# usermod -a -G nagcmd www
[root@nagios nagios-4.3.1]# id -n -G nagios
[root@nagios nagios-4.3.1]# id -n -G www

配置nagios

[root@client1 nagios-4.3.1]# ./configure --with-command-group=nagcmd

編譯和安裝

[root@nagios nagios-4.3.1]# make all
[root@nagios nagios-4.3.1]# make install-init
[root@nagios nagios-4.3.1]# make install-commandmode
[root@nagios nagios-4.3.1]# make install-config
[root@nagios nagios-4.3.1]# make install    
[root@nagios nagios-4.3.1]# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
[root@nagios nagios-4.3.1]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
[root@nagios nagios-4.3.1]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

生成apache配置文件

[root@nagios nagios-4.3.1]# make install-webconf
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
if [ 0 -eq 1 ]; then \
    ln -s /etc/httpd/conf.d/nagios.conf /etc/apache2/sites-enabled/nagios.conf; \
fi

*** Nagios/Apache conf file installed ***

生成nagios web界面的驗證信息

[root@nagios nagios-4.3.1]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios
New password:   ==> 輸入密碼,這里我輸入的密碼是nagios,記住這個密碼
Re-type new password:  ==> 確認密碼
Adding password for user nagios

修改apache配置文件
vi /etc/httpd/conf/httpd.conf

Listen 80    ===>    修改為    Listen 8080
User apache    ===>    修改為    User www
Group apache    ===>    修改為    Group www
DirectoryIndex index.html    ===>    修改為    DirectoryIndex index.php index.html
AddType application/x-gzip .gz .tgz    ===>    下面添加一行內(nèi)容  AddHandler application/x-httpd-php .php
# LoadModule foo_module modules/mod_foo.so    ===>    下面添加一行內(nèi)容   
 LoadModule php7_module        modules/libphp7.so
[root@nagios httpd]# grep -v '^$' /etc/httpd/conf/httpd.conf|grep -v '#'
ServerRoot "/etc/httpd"
Listen 8080
LoadModule php7_module        modules/libphp7.so
Include conf.modules.d/*.conf
User www
Group www
ServerAdmin root@localhost

    AllowOverride none
    Require all denied

DocumentRoot "/var/www/html"

    AllowOverride None
    Require all granted


    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted


    DirectoryIndex index.php index.html


    Require all denied

ErrorLog "logs/error_log"
LogLevel warn

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    
    CustomLog "logs/access_log" combined


    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"


    AllowOverride None
    Options None
    Require all granted


    TypesConfig /etc/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddHandler application/x-httpd-php .php
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml

AddDefaultCharset UTF-8

    MIMEMagicFile conf/magic

EnableSendfile on
IncludeOptional conf.d/*.conf

重新編譯一下php,使其直接apache(也就是編譯參數(shù)加上--with-apxs2)

[root@nagios nagios-4.3.1]# cd /software/php-7.1.4/
[root@nagios php-7.1.4]# ./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mysqli --with-zlib --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-mbstring --enable-xml --enable-session --enable-ftp --enable-pdo -enable-tokenizer --enable-zip --with-apxs2
[root@nagios php-7.1.4]# make && make install
[root@nagios php-7.1.4]# cd /etc/httpd/
[root@nagios httpd]# ll /etc/httpd/modules/libphp7.so 
-rwxr-xr-x 1 root root 38908880 4月  24 10:34 /etc/httpd/modules/libphp7.so    ===>    可以看到這個模塊已經(jīng)生成

啟動apache

[root@nagios httpd]# systemctl start httpd
[root@nagios httpd]# systemctl enable httpd

啟動nagios

chkconfig nagios on
/etc/init.d/nagios start

在瀏覽器輸入ip:8080/nagios測試nagios-web頁面是否可以打開



 


 


 

安裝nagios-plugins插件
解壓nagios-plugins源碼包

[root@nagios httpd]# cd /software/
[root@nagios software]# tar zxvf nagios-plugins-2.2.1.tar.gz

進入解壓后的目錄進行配置

[root@nagios software]# cd nagios-plugins-2.2.1/
[root@nagios nagios-plugins-2.2.1]# ./configure --with-nagios-user=nagios --with-nagios-group=nagcmd --enable-perl-modules

編譯及安裝

[root@nagios nagios-plugins-2.2.1]# make && make install

安裝nrpe
解壓nrpe源碼包

[root@nagios nagios-plugins-2.2.1]# cd /software/
[root@nagios software]# tar zxvf nrpe-3.1.0.tar.gz

進去解壓后的目錄進行配置

[root@nagios software]# cd nrpe-3.1.0/
[root@nagios nrpe-3.1.0]# ./configure

編譯及安裝

[root@nagios nrpe-3.1.0]# make all
[root@nagios nrpe-3.1.0]# make install-plugin
[root@nagios nrpe-3.1.0]# make install-daemon
[root@nagios nrpe-3.1.0]# make install-daemon-config
[root@nagios nrpe-3.1.0]# cp sample-config/nrpe.cfg /usr/local/nagios/etc/nrpe.cfg

安裝完成后,查看下libexec下面是否有插件

[root@nagios nrpe-3.1.0]# ls /usr/local/nagios/libexec/
check_apt       check_flexlm        check_log          check_ntp_peer  check_smtp    disable_active_service_checks
check_breeze    check_fping         check_mailq        check_ntp_time  check_spop    disable_notifications
check_by_ssh    check_ftp           check_mrtg         check_nwstat    check_ssh     distributed-monitoring
check_clamd     check_http          check_mrtgtraf     check_Oracle    check_ssmtp   enable_active_service_checks
check_cluster   check_icmp          check_mysql        check_overcr    check_swap    enable_notifications
check_dhcp      check_ide_smart     check_mysql_query  check_ping      check_tcp     eventhandlers
check_dig       check_ifoperstatus  check_nagios       check_pop       check_time    negate
check_disk      check_ifstatus      check_nntp         check_procs     check_udp     redundancy-scenario1
check_disk_smb  check_imap          check_nntps        check_real      check_ups     submit_check_result
check_dns       check_ircd          check_nrpe         check_rpc       check_uptime  urlize
check_dummy     check_jabber        check_nt           check_sensors   check_users   utils.pm
check_file_age  check_load          check_ntp          check_simap     check_wave    utils.sh

啟動nrpe,并測試服務端本地是否可以連通

[root@nagios nrpe-3.1.0]# /usr/local/nagios/bin/nrpe -d -c /usr/local/nagios/etc/nrpe.cfg 
[root@nagios nrpe-3.1.0]# echo "/usr/local/nagios/bin/nrpe -d -c /usr/local/nagios/etc/nrpe.cfg" >> /etc/rc.local
[root@nagios nrpe-3.1.0]# chmod +x /etc/rc.d/rc.local           # centos 7下需要這一步, 不然/etc/rc.local中的內(nèi)容開機可能不執(zhí)行
[root@nagios nrpe-3.1.0]# netstat -lnput|grep 5666
tcp        0      0 0.0.0.0:5666            0.0.0.0:*               LISTEN      67176/nrpe          
tcp6       0      0 :::5666                 :::*                    LISTEN      67176/nrpe    
[root@nagios nrpe-3.1.0]# /usr/local/nagios/libexec/check_nrpe -H localhost 
NRPE v3.1.0-rc1

網(wǎng)站標題:CentOS7下Nagios的安裝及配置
本文地址:http://www.dlmjj.cn/article/djejscj.html