Nagios是一个监视系统运行状态和网络信息的监视系统,能监视所指定的本地或远程主机以及服务,同时提供异常通知功能等,其可运行在Linux/Unix平台之上,同时提供一个可选的基于浏览器的WEB界面以方便系统管理人员查看网络状态,各种系统问题,以及日志等等。
了解 Nagios 的关键在于,它并不是监视和跟踪“普通的”测量数据,如 CPU 使用率,该工具将所有的信息简化为“工作”、“可疑的”和“故障”状态。这可以帮助操作员根据预定义的和可配置的标准,重点关注最重要和最关键的问题。
Nagios的主要功能特点:
这里只介绍一下源码安装,首先安装依赖:
gcc/make/autoconf/automake
libgd/openssl
许多与简单网络管理协议相关的(SNMP 相关的)插件还需要 Perl 和 Net::SNMP 包。
tar -xzvf nagios_xxx.tar.gz cd nagios_xxx/ ./configure --prefix=/usr/local/nagios make;make install
在安装和设置了 Nagios 之后,您应该可以使用缺省的 http://localhost/nagios URL 访问 Nagios。
/etc/nagios/
nagios.cfg #nagios主配置文件,引用其他配置文件
cgi.cfg #nagios Web界面相关配置
resource.cfg #全局变量定义配置
objects/
commands.cfg #命令、插件注册配置
contacts.cfg #联系人和联系人组配置
localhost.cfg #监控本机资源示例配置
printer.cfg #网络打印机示例配置
switch.cfg
templates.cfg # 配置模板
timeperiods.cfg
windows.cfg # windows主机配置示例
hosts.cfg #自定义的所有主机和主机组配置
services.cfg #自定义的所有服务配置
其中各配置文件的作用如上所示。
首先需要设置的组件是联系人和联系人组。联系人是那些接收主机或服务停止运行的通知的人员。在缺省情况下,Nagios 提供了寻呼机和电子邮件通知方式。通过扩展,允许通过 Jabber 和许多其他方式进行通知,这在某些情况下是非常方便的。联系人存储在 contacts.cfg 文件中,并且定义如下:
define contact{
contact_name admin
alias Administrator
service_notification_commands notify-by-email
host_notification_commands host-notify-by-emailes
email zhoubo@netqin.com
}
define contactgroup{
contactgroup_name admins
alias Server Administrators
members admin
}
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name localhost
alias localhost
address 127.0.0.1
contact_groups admins ; Notifications get sent to the admins by default
}define service{
use service-template
host_name ubuntu_1_2
service_description PING
check_period 24x7
contact_groups server-admins
notification_options c,r
check_command check_ping!300.0,20%!1000.0,60%
}