Nagios 是一个开放源代码的主机、服务和网络监控平台,有各种应用插件,功能非常强大.
一,主程序的安装:
nagios-*.tar.gz 主程序
nagios-plugins.*.tar.gz 插件
nrpe*.tar.gz 被监控端程序
1,安装主程序:
#tar -zxvf nagios*.tar.gz
#cd nagios*
#./configure --prefix=/usr/local/nagios
#make all
#pw useradd nagios
#mkdir /usr/local/nagios 注:安装的时候如果提示:
#chown nagios:nagios /usr/local/nagios /usr/bin/install -c -m 755 -d -o
#make install root -g root /usr/local/etc/rc.d
#make install-init 只需增加root组,将rc.d改成chown root:root rc.d
#make install-commandmode
#make install-config
2.安装插件
#tar -zxvf nagios-plugins*.tar.gz
#cd nagios-plugins*
#./configure --prefix=/usr/local/nagios
#make && make install
3,将apache的运行用户加入nagios的组
#grep ^user httpd.conf
#pw groupadd nagios -m www
#setting for nagios 20070707
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
//
用于此目录访问身份验证的文件
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
//
用于此目录访问身份验证的文件
Require valid-user
</Directory>
|
联系人
|
contact
|
出了问题像谁报告?一般当然是系统管理员了
|
监控时间段
|
timeperiod
|
7X24小时不间断还是周一至周五,或是自定义的其他时间段
|
被监控主机
|
host
|
所需要监控的服务器,当然可以是监控机自己
|
监控命令
|
command
|
nagios发出的哪个指令来执行某个监控,这也是自己定义的
|
被监控的服务
|
service
|
例如主机是否存活,80端口是否开,磁盘使用情况或者自定义的服务等
|
cfg_file=/usr/local/nagios/etc/contactgroups.cfg //联系组配置文件路径
cfg_file=/usr/local/nagios/etc/contacts.cfg //联系人配置文件路径
cfg_file=/usr/local/nagios/etc/hostgroups.cfg //主机组配置文件路径
cfg_file=/usr/local/nagios/etc/hosts.cfg //主机配置文件路径
cfg_file=/usr/local/nagios/etc/services.cfg //服务配置文件路径
cfg_file=/usr/local/nagios/etc/timeperiods.cfg //监视时段配置文件路径
|
authorized_for_system_information=nagiosadmin,test
authorized_for_configuration_information=nagiosadmin,test
authorized_for_system_commands=test //多个用户之间用逗号隔开
authorized_for_all_services=nagiosadmin,test
authorized_for_all_hosts=nagiosadmin,test
authorized_for_all_service_commands=nagiosadmin,test
authorized_for_all_host_commands=nagiosadmin,test
|
define timeperiod{
timeperiod_name 24x7 //时间段的名称,这个地方不要有空格
alias 24 Hours A Day,7Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
|
define contact{
contact_name test //联系人的名称,这个地方不要有空格
alias sys admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email [email protected]
pager 1338757xxxx
address1 [email protected]
address2 555-555-5555
}
|
service_notification_period 24x7
服务出了状况通知的时间段,这个时间段就是上面在timeperiods.cfg中定义的.
|
host_notification_period 24x7
主机出了状况通知的时间段, 这个时间段就是上面在timeperiods.cfg中定义的
|