# tar zxf nagios-3.1.2.tar.gz
# cd nagios-3.1.2
# ./configure --with-command-group=nagios --enable-event-broker --prefix=/var/www/nagios
# make all
# make install
# make install-init
# make install-config
# make install-commandmode
为email指定您想用来接收nagios警告信息的邮件地址,默认是本机的nagios用户:
# vi /usr/local/nagios/etc/objects/contacts.cfg
email nagios@localhost #这个是默认设置
在httpd的配置文件目录(conf.d)中创建Nagios的Web程序配置文件:
# make install-webconf
3.在监控服务器上修改nagios配置文件nagios.cfg
去掉注释cfg_file=/usr/local/nagios/etc/objects/windows.cfg
定义windows.cfg
define host{
use windows-server ; Inherit default values from a template
host_name winserver ; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 192.168.0.191 ; 你主机的IP
}
#################################################################
linux端
被监控端
先添加nagios用户
useradd nagios
为了安装nrpe,先安装nagios-plugins-1.4.15.tar.gz 插件
# tar zxf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install
tar -zxvf nrpe-2.12.tar.gz
cd nrpe-2.12.tar.gz
./configure (会自动加载SSL)
#如果后面make报错,加如下参数
./configure --enable-ssl --with-ssl-lib=/usr/lib/(当然前提要有openssl)
make all
make install-plugin
make install-daemon
make install-daemon-config
4.配置nrpe信息
vim /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1 //允许监控的IP
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d
服务端
3.安装NRPE
cd nagios-nrpe_2.8.1
./configure #默认自动添加了openssl
#因为传送过程要加密,如果后面make报错,加如下参数
rpm -qa| grep ssl
openssl-devel-0.9.7a-43.17.el4_6.1
rpm -ql openssl-devel-0.9.7a-43.17.el4_6.1 | more
./configure --enable-ssl --with-ssl-lib=/lib/(当然前提要有openssl)
make all
make install-plugin
4.commands.cfg定义外部构件nrpe
vi /usr/local/nagios/etc/objects/commands.cfg
#添加
#check nrpe
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
定义 mylinux.cfg
define host{
use linux-server
host_name mylinux
alias mylinux
address 192.168.0.27(客户端IP既被监控的IP)
}
define service{
use generic-service
host_name mylinux
service_description check-swap
check_command check_nrpe!check_swap
}
define service{
use generic-service
host_name mylinux
service_description check-load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name mylinux
service_description check-disk
check_command check_nrpe!check_had1
}
define service{
use generic-service
host_name mylinux
service_description check-users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name mylinux
service_description otal_procs
check_command check_nrpe!check_total_procs
}
#################################################################################
define service{
use generic-service
host_name mylinux
service_description httpd
check_command check_http! -H 192.168.0.27
}
###########################################################################################################
nagios监控mysql服务器:
1、建立专用数据库:
[root@svr3 ~]# /usr/local/webserver/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 51910
Server version: 5.5.3-m3-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.