溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

監(jiān)控系統(tǒng)的搭建

發(fā)布時(shí)間:2020-07-01 21:38:11 來源:網(wǎng)絡(luò) 閱讀:735 作者:kenasel 欄目:移動(dòng)開發(fā)

nagios監(jiān)控
 (1)創(chuàng)建nagios運(yùn)行的用戶和組
   # groupadd -g 1000 nagios
   # useradd -g nagios  nagios
   
 (2)安裝nagios
   # ./configure --prefix=/usr/local/nagios  --enable-event-broker --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagios --with-httpd-conf=/etc/httpd/conf.d --with-temp-dir=/tmp --with-init-dir=/etc/init.d/
 
   # make all
   # make install  && make install-init && make install-commandmode && make install-config && make install-webconf
 
   
   (3)安裝nagios-plugins插件
   # yum install perl perl-devel openssl openssl-devel
   # ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr --with-openssl=/usr --with-mysql=/usr/local/mysql --enable-perl-modules --enable-extra-opts --enable-redhat-pthread-workaround
   # make
   # make install
   
  (4)安裝nrpe通信協(xié)議軟件
   # ./configure --prefix=/usr/local/nagios --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-ssl --enable-command-args --enable-bash-command-substitution
   # make all
   # make install
   # make install-daemon-config
   # cp init-script /etc/init.d/nrpe
   # chmod 755 /etc/init.d/nrpe
    (5)安裝ndoutils數(shù)據(jù)庫通信工具
   # ./configure --prefix=/usr/local/nagios --enable-mysql --with-init-dir=/etc/init.d --with-mysql=/usr/local/mysql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
   # make
   # make install
   # make install-config
   # make install-init
   
   mysql> create database nagios default character set utf8;
   mysql> grant all on nagios.* to 'nagios'@'localhost' identified by 'aixocm';
   
   # yum install perl-DBI perl-DBD-MySQL
   # ./installdb -u nagios -p aixocm -h localhost -d nagios
   
   # cd /usr/local/nagios/etc
   # cp ndo2db.cfg-sample ndo2db.cfg
   # cp ndomod.cfg-sample ndomod.cfg
   
2、配置nagios系統(tǒng)
 
    # chown nagios:nagios nagios -R
 
  (1)配置nagios的主配置文件nagios.cfg
   # vim nagios.cfg
   broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
   
   (2)配置ndo2db.cfg文件,用于nagios和ndo2db連接mysql數(shù)據(jù)庫所需要的信息
   # vim ndo2db.cfg
   db_servertype=mysql
   db_host=localhost
   db_port=3306
   db_name=nagios
   db_prefix=nagios_
   db_user=nagios
   db_pass=aixocm
    (3)配置ndomod.cfg通信設(shè)置
   output_type=unixsocket
   output=/usr/local/nagios/var/ndo.sock
   
   (4)配置nrpe.cfg客戶端配置文件
   # vim nrpe.cfg
   server_address=10.0.2.220
   allowed_hosts=10.0.0.0/16
   
   (5)配置web訪問
   # cd /etc/httpd/conf.d
   # vim nagios.conf
   
   (6)檢查配置文件語法
   # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg    
   
   客戶端只需裝3.4
   
   
   3、客戶端安裝
 被監(jiān)控端只需要安裝nagios-plugins和nrpe(安裝方法參考前面)
 
 例:使用nagios監(jiān)控10.0.5.100主機(jī)的登錄用戶數(shù),負(fù)載和根分區(qū)的使用情況

 
 (1)在command.cfg配置文件定義監(jiān)控的命令
   define command{
       command_name check_nrpe
       command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
   }
   (2)添加要監(jiān)控的主機(jī)和具體的服務(wù)信息
   # vim nagios.cfg
   cfg_dir=/usr/local/nagios/etc/hosts
   cfg_dir=/usr/local/nagios/etc/services
 
   # mkdir /usr/local/nagios/etc/hosts
   # mkdir /usr/local/nagios/etc/services
   
   # vim /usr/local/nagios/etc/hosts/linux-hosts.cfg  \\定義監(jiān)控的主機(jī)
   define host{
       use     linux-server
       host_name       server1
       alias   mysql server
       address 10.0.5.100
   }

   define host{
       use     linux-server
       host_name       server2
       alias   apache server
       address 10.0.5.101
   }
   
    # vim /usr/local/nagios/etc/services/linux-services.cfg \\添加要監(jiān)控的服務(wù)
   define service{
       use     generic-service
       host_name        server1
       service_description     login users
       check_command   check_nrpe!check_users
       }
       define service{
       use     generic-service
       host_name        server1
       service_description     load avrerage
       check_command   check_nrpe!check_load
       }

   define service{
       use     generic-service
       host_name        server1
       service_description     root partition
       check_command   check_nrpe!check_root
       }

 (3)被監(jiān)控主機(jī)的配置
   # vim nrpe.cfg
       
    # vim nrpe.cfg
   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_root]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p /dev/sda3
   command[check_mysql]=/usr/local/nagios/libexec/check_mysql -d mysql -H localhost -P 3306 -s /tmp/mysql.sock -u root 

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI