CenOS5.6下安装nagios3.2监控服务器群的运行状况
CenOS5.6下安装nagios3.2监控服务器群的运行状况
Nagios功能列表 所需软件包及环境
基本的监控:
NAGIOS gcc、gcc-devel、appache、php、gd、gd-devel
NAGIOS-PLUGINS mysql-devel(防止安装之后无法生存check_mysql的监控文件)
NRPE openssl-devel (Linux系统安装。监控端和被监控端)
NSCLIENT 无(windows系统安装,只安装在被监控端)
邮件告警功能
安装centos时候定制软件选择DNS服务和邮件服务.
绘图功能
Pnp cairo、 pango、 libart_lgpl、 libart_lgpl-devel、 zlib、 zlib-devel 、freetype 、freetype-devel
rrdtool
飞信告警功能
Fetion libACE
MSN告警功能
暂无测试
一:安装nagios
1:安装支持包
#yum -y install gcc gcc-c++ gd gd-devel php httpd openssl-devel mysql-devel
具体依赖的对应服务见上结构
2:添加用户和组
#useradd nagios
#passwd nagios
#groupadd nagcmd
#usermod -G nagcmd nagios
#usermod -G nagcmd apache
记得把apache加入到该用户组
chkconfig httpd on
3:正式安装nagios
tar –xzf nagios-3.2.0.tar.gz
cd nagios-3.2.0
./configure –with-command-group=nagcmd –prefix=/usr/local/nagios
make all
make install
make install-init
make install-config
make install-commandmode
4:配置apache的httpd.conf,允许文件目录被访问
默认安装位置在/etc/httpd/conf/httpd.conf
如何不知道也可以使用如下命令查找
find / name httpd.conf|grep httpd.conf
然后添加以下代码
ScriptAlias /nagios/cgi-bin “/usr/local/nagios/sbin”
<Directory “/usr/local/nagios/sbin”>
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
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”>
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
5:创建apache目录验证文件
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: (输入密码)
Re-type new password: (再输入一次密码)
Adding password for user nagiosadmin
service httpd restart
6:安装nagios插件
tar –xzf nagios-plugins-1.4.13.tar.gz
cd nagios-plugins-1.4.13
./configure –with-nagios-user=nagios –with-nagios-group=nagios –prefix=/usr/local/nagios
make
make install
7:将nagios加入到开机启动项
chkconfig nagios on
8:检查配置文件
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
//这个检测非常有用,可以很快的判断我们的错误在哪里。
9:配置nagios
首先/usr/local/nagios/etc/nagios.cfg,取消前面的”#”即可.如下:
# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
# Definitions for monitoring a Windows machine
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg
# Definitions for monitoring a router/switch
#cfg_file=/usr/local/nagios/etc/objects/switch.cfg
# Definitions for monitoring a network printer
#cfg_file=/usr/local/nagios/etc/objects/printer.cfg
# You can also tell Nagios to process all config files (with a .cfg
# extension) in a particular directory by using the cfg_dir
# directive as shown below:
# cfg_dir=/usr/local/nagios/etc/servers
上面有些配置文件没有,需要自己手动创建
Commands.cfg主要是监控命令的配置文件。Contacts.cfg主要是联系人的配置文件
Timeperiods.cfg主要是时间配置,监控的时间段设置。Hots.cfg是主机配置.
Localhost.cfg监控服务器的配置文件.
Windows.cfg监控微软系统的配置文件.
chown -R nagios.nagios /usr/local/nagios
10.修改commands.cfg配置文件
新增以下内容:
# \’check_nrpe\’ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
11.修改localhost.cfg
define host {
host_name nagios-server
alias nagios server
address 192.168.152.156
contact_groups sagroup
check_command check-host-alive
max_check_attempts 5
notification_interval 10
notification_period 24×7
notification_options d,u,r
}
define hostgroup {
hostgroup_name sa-servers
alias sa servers
members nagios-server
}
#加入如下服务(也可以删除当前文件夹下的其他所有service,我删除了否则验证的时候会报错,只预留以下几个)
define service {
host_name nagios-server
service_description check-host-alive
check_period 24×7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
check_command check-host-alive
}
define service {
host_name nagios-server
service_description check_tcp 80
check_period 24×7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
check_command check_tcp!80
}
define service{
host_name nagios-server
service_description check-disk
check_command check_nrpe!check_df
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups sagroup
}
define service{
host_name nagios-server
service_description check-load
check_command check_nrpe!check_load
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_in
- 本文来自:Linux教程网