您好,登錄后才能下訂單哦!
nagios監控
(1)創建nagios運行的用戶和組
# 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通信協議軟件
# ./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數據庫通信工具
# ./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系統
# 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數據庫所需要的信息
# 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通信設置
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、客戶端安裝
被監控端只需要安裝nagios-plugins和nrpe(安裝方法參考前面)
例:使用nagios監控10.0.5.100主機的登錄用戶數,負載和根分區的使用情況
(1)在command.cfg配置文件定義監控的命令
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
(2)添加要監控的主機和具體的服務信息
# 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 \\定義監控的主機
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 \\添加要監控的服務
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)被監控主機的配置
# 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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。