cd nagios-3.2.2
./configure(nagios默认安装目录即为/usr/local/nagios,可不用加--prefix参数)
根据如下提示:
the main program and CGIs compiled without any errors, you can continue with installing Nagios as follows (type 'make' without any arguments for a list of all possible options): 依次执行如下操作:
make all------编译
make install
- This installs the main program, CGIs, and HTML files
安装主要的程序、CGI及HTML文件
make install-init
- This installs the init script in /etc/rc.d/init.d
把nagios做成一个运行脚本,使nagios随系统开机启动,这是一个很方便的措施。
make install-commandmode
- This installs and configures permissions on the directory for holding the external command file
给外部命令访问nagios配置文件的权限
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can use Nagios. Read the HTML documentation for more info on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how things get monitored!
把配置文件的例子复制到nagios的安装目录
make install-webconf(如果apache用的是自己另外安装的,可以不执行此安装,直接在apache的配置文件httpd.conf中加入6所示内容)
- This installs the Apache config file for the Nagios web interface
把虚拟目录配置文件写入/etc/httpd/conf.d/nagios.conf,不需再往apache配置文件中另加nagios的目录.
2、安装nagios-plugins;
tar zxf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios(默认安装路径为/usr/local/nagios)
make
make install
<Directory "/usr/local/nagios/sbin">
# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
Nagios Core 3.2.1
Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 03-09-2010
License: GPL
....................................
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
在此处中间添加;
cfg_file=/usr/local/nagios/etc/objects/Test.cfg
编辑该文件;
define host{
use linux-server
host_name Test
alias linux-server
address 192.168.0.110
}
define service{
use generic-service
host_name Test
service_description HTTP
check_command check_http
}
define service{
use generic-service
host_name Test
service_description FTP
check_command check_ftp
}
define service{
use generic-service
host_name Test
service_description SSH
check_command check_ssh
}
define service{
use generic-service
host_name Test
service_description SMTP
check_command check_smtp
}
define service{
use generic-service
host_name Test
service_description POP3
check_command check_pop
}
define service{
use generic-service
host_name Test
service_description check-swap
check_command check_nrpe!check_swap
}
define service{
use generic-service
host_name Test
service_description check-load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name Test
service_description check-disk
check_command check_nrpe!check_disk
}
define service{
use generic-service
host_name Test
service_description zombie_procs
check_command check_nrpe!check_zombie_procs
}
define service{
use generic-service
host_name Test
service_description check-users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name Test
service_description total_procs
check_command check_nrpe!check_total_procs
}
define service {
use generic-service
host_name Test
service_description check_mysql
check_command check_mysql!192.168.0.110!3306!nagios!nagios!nagdb!60!600
}
这里面定义的是监控的对象,修改完成后保存退出,就可以了。
7、检查配置文件,重启nagios服务;
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios restart
8、此时可以访问该页面,相关的被监控的对象也将出现。
************************************** M ySQL监控配置 *************************************
1、在要监控的MYSQL数据库里新建库和相应的用户;
CREATE DATABASE nagdb DEFAULT CHARSET=utf8;
GRANT SELECT ON nagdb.* TO 'nagios'@'%';
UPDATE mysql.user SET 'Password' = PASSWORD('********') WHERE 'User' = 'nagios'
FLUSH PRIVILEGES;
2、修改command.cfg,添加对mysql和主从同步的定义;
vi /usr/local/nagios/etc/objects/command.cfg;
define command{
command_name check_mysql
command_line $USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -d $ARG5$
}