Nagios_on_RHEL5
时间:2009-06-23 来源:zsgd
Nagios_on_RHEL5
在 RHEL 5 上部署 Nagios 监控软件
Introduce Nagios
Installation
分别从以下地址下载适合 i386/x86_64 的 Nagios 的 RPM 包:
http://mirrors.cat.pdx.edu/dag/redhat/el5/en/x86_64/dag/RPMS/
http://mirrors.cat.pdx.edu/dag/redhat/el5/en/i386/dag/RPMS/
下载完成后使用 rpm 命令安装即可,需要的依赖包在 RHEL 的 ISO 和上面的链接地址内可以找到。
Configuration
Basic Configuration
Nagios 的主要配置文件都放在 /etc/nagios/ 目录下,主要有以下几个配置文件:
use_authentication=1
authorized_for_all_host_commands=nagiosadmin
authorized_for_all_hosts=nagiosadmin
authorized_for_all_service_commands=nagiosadmin
authorized_for_all_services=nagiosadmin
authorized_for_system_commands=nagiosadmin
authorized_for_system_information=nagiosadmin
改了之后 nagiosadmin 用户才可以登录到 web 界面进行操作。
使用 htpasswd 为 nagiosadmin 生成密码文件:
# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
# /etc/init.d/httpd restart
# /etc/init.d/nagios restart
/var/log/nagios/nagios.log
如果在启动 Nagios 时出现问题,可以在日志文件里找信息进行排错。 如果因为配置文件语法错误而导致无法启动 Nagios,这些错误信息并不会被记录到日志文件中, 但可以通过以下命令查看具体的错误:
# nagios -v /etc/nagios/nagios.cfg
添加联系人
在 /etc/nagios/nagios.cfg 中将这两行的注释给去掉:
#
# Part of file: /etc/nagios/nagios.cfg
#
cfg_file=/etc/nagios/contactgroups.cfg
cfg_file=/etc/nagios/contacts.cfg
为了便于区别,我们在 /etc/nagios/contacts.cfg 中只加入单独的个人, 而 /etc/nagios/contactgroups.cfg 则将这些个人归位不同的组。
#
# Part of file: /etc/nagios/contacts.cfg
#
define contact{
contact_name michaelz
alias Michael Zhang
service_notification_commands notify-by-email
service_notification_period 24x7
service_notification_options w,u,c,r
host_notification_commands notify-by-email
host_notification_period 24x7
host_notification_options d,u,r
email [email protected]
}
这里的 notification_options 的几个值的含义是:
#
# Part of file: /etc/nagios/contactgroups.cfg
#
define contactgroup{
contactgroup_name Linux_Server
alias Linux_Server
members michaelz
}
添加用于监控的命令
在 /etc/nagios/localhost.cfg 中增加以下内容:
添加主机
将 /etc/nagios/nagios.cfg 中的这几行去掉注释:
cfg_file=/etc/nagios/hostgroups.cfg
cfg_file=/etc/nagios/hosts.cfg
#
# Part of file: /etc/nagios/hosts.cfg
#
define host{
use linux-server
host_name IT-MichaelZh
alias IT-MichaelZh
address 192.168.122.1
check_command check_ping!100.0,20%!500.0,60%
notifications_enabled 1
event_handler_enabled 1
notification_period 24x7
notification_options d,u,r
}
#
# Part of file: /etc/nagios/hostgroups.cfg
#
define hostgroup{
hostgroup_name Linux_Server
alias Linux Servers
members IT-MichaelZh,linuxsrv01
}
为主机添加监控的服务
将 /etc/nagios/nagios.cfg 中的这几行去掉注释:
cfg_file=/etc/nagios/services.cfg
在 /etc/nagios/services.cfg 中添加要监控的服务:
define service{
use local-service
host_name IT-MichaelZh
service_description Ping
check_command check_ping!100.0,20%!500.0,60%
}
相关阅读 更多 +