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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。