Nagios安装配置
时间:2007-02-13 来源:evegl
nagios安装配置
系统要求
The only requirement of running Nagios is a machine running Linux (or UNIX variant) and a C compiler. You will probably also want to have TCP/IP configured, as most service checks will be performed over the network. You are not required to use the CGIs included with Nagios. However, if you do decide to use them, you will need to have the following software installed...
1。A web server (preferrably Apache)
2。Thomas Boutell's gd library version 1.6.3 or higher (required by the statusmap and trends CGIs)
软件主页:
+ 1.下载源码包
wget http://nchc.dl.sourceforge.net/sourceforge/nagios/nagios-2.0b3.tar.gz
2.解压源码包
tar xfvz nagios-2.0b3.tar.gz
3.配置编译
cd nagios-2.0b3
adduser nagios
mkdir /usr/local/nagios
chown nagios.nagios /usr/local/nagios
grep "^User" /usr/local/apache2/conf/httpd.conf
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd nobody
/usr/sbin/usermod -G nagcmd nagios
./configure --prefix=/usr/local/nagios --with-cgiurl=/nagios/cgi-bin \
--with-htmlurl=/nagios --with-nagios-usr=nagios --with-nagios-group=nagios \
--with-command-group=nagcmd --with-gd-lib --enable-embedded-perl \
--with-perlcache make all
make install
make install-init
make install-commandmode
make install-config
安装nagios-plugs 1.下载源码包
wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.tar.gz
2.解压源码包
tar xfvz nagios-plugins-1.4.tar.gz
3.配置编译
./configure --prefix=/usr/local/nagios --with-mysql --with-cgiurl
make
make install
配置apache ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" AllowOverride AuthConfig
Options ExecCGI
Order allow,deny
Allow from all
Alias /nagios "/usr/local/nagios/share" Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
Authorization In The CGIs
The second step is to create a file named .htaccess in the root your CGI directory (and optionally also you HTML directory) for Nagios (usually /usr/local/nagios/sbin and /usr/local/nagios/share, respectively). The file(s) should have contents similiar to the following... : cd /usr/local/nagios/sbin
vi .htaccess AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user cd /usr/local/nagios/share
vi .htaccess AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user
Setting Up Authenticated Users: htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
格式:
htpasswd -c /usr/local/nagios/etc/htpasswd.users
Enabling Authentication/Authorization Functionality In The CGIs
The next thing you need to do is make sure that the CGIs are configured to use the authentication and authorization functionality in determining what information and/or commands users have access to. This is done be setting the use_authentication variable in the CGI configuration file to a non-zero value. Example: vi /usr/local/nagios/etc/cgi.cfg
use_authentication=1 /usr/local/apache2/bin/apachectl restart
配置文件 一. nagios.cfg
首先,刚装好的nagios,在/usr/local/nagios/etc 下,文件都是以-sample结尾的,要把某些文件去掉- sample。
主配置文件 nagios.cfg
mv nagios.cfg--sample nagios.cfg
vi nagios.cfg
注释这句话
#cfg_file=/usr/local/nagios/etc/minimal.cfg
在 # OBJECT CACHE FILE 这句话前面添加如下语句
cfg_dir=/usr/local/nagios/etc/hosts
cfg_dir=/usr/local/nagios/etc/contacts
cfg_dir=/usr/local/nagios/etc/services
cfg_dir=/usr/local/nagios/etc/commands 存盘退出 mkdir hosts
mkdir contacts
mkdir services
mkdir commands 这样做,主要是为了分类,管理方便。
有些cfg文件可以参照 bigger.cfg-sample,minimal.cfg-sample 这两个文件 cd hosts
vi hosts.cfg ###############################################################################
###############################################################################
#
# HOSTS
#
###############################################################################
############################################################################### # Generic host definition template - This is NOT a real host, just a template! define host{
name generic-host ; The name of this host template
notifications_enabled 1 ; Host notifications are enabled
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
# Since this is a simple configuration file, we only monitor one host - the
# local host (this machine). define host{
use generic-host ; Name of host template to use
host_name SH4
alias SH4
address 192.168.168.244
check_command check-host-alive
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,r
contact_groups admins
}
define host{
use generic-host ; Name of host template to use
host_name SH3
alias SH3
address 192.168.168.243
check_command check-host-alive
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,r
contact_groups admins
}
如果有很多服务器,可以把这些服务器分组 vi hostgroups.cfg ###############################################################################
###############################################################################
#
# HOST GROUPS
#
###############################################################################
############################################################################### # We only have one host in our simple config file, so there is no need to
# create more than one hostgroup. define hostgroup{
hostgroup_name test
alias Test Servers
members SH4, SH3
}
cd /usr/local/nagios/etc/contacts
vi contacts.cfg ###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
############################################################################### # In this simple config file, a single contact will receive all alerts.
# This assumes that you have an account (or email alias) called
# "nagios-admin" on the local host. define contact{
contact_name nagios-admin
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email [email protected]
}
vi contactgroups.cfg ###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
############################################################################### # We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group. define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagios-admin
}
cd /usr/local/nagios/etc/services
vi services.cfg
###############################################################################
###############################################################################
#
# SERVICES
#
###############################################################################
############################################################################### # Generic service definition template - This is NOT a real service, just a template! define service{
name generic-service ; The 'name' of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major per
formance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
notification_options w,u,c,r,f
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
# Define a service to "ping" the machine define service{
use generic-service ; Name of service template to use
host_name ns1
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_ping!100.0,20%!500.0,60%
}
# Define a service to detect "http" define service{
use generic-service ; Name of service template to use
host_name ns1
service_description HTTP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_http
} # Define a service to detect "ftp" define service{
use generic-service ; Name of service template to use
host_name web01
service_description FTP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_ftp
}
# Define a service to detect "DNS" define service{
use generic-service ; Name of service template to use
host_name ns1
service_description DNS
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_dns
} # Define a service to detect "SMTP" define service{
use generic-service ; Name of service template to use
host_name web12
service_description SMTP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_smtp
} # Define a service to detect "POP" define service{
use generic-service ; Name of service template to use
host_name web12
service_description POP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_pop
} # Define a service to detect "IMAP" define service{
use generic-service ; Name of service template to use
host_name web12
service_description IMAP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_imap
} # Define a service to detect "HTTPS" define service{
use generic-service ; Name of service template to use
host_name web05
service_description HTTPS
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_https
}
# Define a service to check the disk space of the root partition
# on the local machine. Warning if < 20% free, critical if
# < 10% free space on partition. define service{
use generic-service ; Name of service template to use
host_name ns1
service_description Root Partition
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_nrpe!check_disk
} # Define a service to check the swap usage on the local machine.
#Warning if < 20% free, critical if < 10% free space on partition. define service{
use generic-service ; Name of service template to use
host_name ns1
service_description Swap Usage
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_nrpe!check_swap
} # Define a service to check the number of currently logged in
# users on the local machine. Warning if > 20 users, critical
# if > 50 users. define service{
use generic-service ; Name of service template to use
host_name ns1
service_description Current Users
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_nrpe!check_users
} # Define a service to check the number of currently running procs
# on the local machine. Warning if > 250 processes, critical if
# > 400 users. define service{
use generic-service ; Name of service template to use
host_name ns1
service_description Total Processes
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_nrpe!check_procs
} # Define a service to check the load on the local machine.
define service{
use generic-service ; Name of service template to use
host_name web21
service_description Current Load
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_nrpe!check_load
}
vi servicegroups.cfg #A service group definition is used to group one or more services together for display purposes in the CGIs. define servicegroup{
servicegroup_name PINGGRP
alias PING Services
members ns1,PING,ns2,PING,pix1,PING,pix2,PING,web01,PING,web02,PING,web03,PING,web04,PING,web05,PING ,web06,P
ING,web07,PING,web08,PING,web09,PING,web10,PING,web11,PING,web12,PING,web13,PING,web14,PING, web15,PING,web16,PING,web17,PING,web18,P
ING,web19,PING,web20,PING,web21,PING
} define servicegroup{
servicegroup_name HTTPGRP
alias HTTP Services
members ns1,HTTP,ns2,HTTP,web01,HTTP,web02,HTTP,web03,HTTP,web04,HTTP,web05,HTTP,web06,HTTP,web07,HT TP,web08
,HTTP,web09,HTTP,web10,HTTP,web11,HTTP,web12,HTTP,web13,HTTP,web14,HTTP,web15,HTTP,web16,HTT P,web17,HTTP,web18,HTTP,web19,HTTP,web20
,HTTP,web21,HTTP
} define servicegroup{
servicegroup_name HTTPSGRP
alias HTTPS Services
members web05,HTTPS,web14,HTTPS,web15,HTTPS
} define servicegroup{
servicegroup_name FTPGRP
alias FTP Services
members web01,FTP,web02,FTP,web03,FTP,web04,FTP,web05,FTP,web06,FTP,web07,FTP,web08,FTP,web09,FTP,we b10,FTP,
web11,FTP,web12,FTP,web13,FTP,web14,FTP,web15,FTP,web16,FTP,web17,FTP,web18,FTP,web19,FTP,we b20,FTP,web21,FTP
} define servicegroup{
servicegroup_name CURRENTLOADGRP
alias Current Load Services
members ns1,Current Load ,ns2,Current Load ,web01,Current Load ,web02,Current Load ,web03,Current Load ,web0
4,Current Load ,web05,Current Load ,web06,Current Load ,web07,Current Load ,web08,Current Load ,web09,Current Load ,web10,Current Lo
ad ,web11,Current Load ,web12,Current Load ,web13,Current Load ,web14,Current Load ,web15,Current Load ,web16,Current Load ,web17,Cu
rrent Load ,web18,Current Load ,web19,Current Load ,web20,Current Load ,web21,Current Load
} define servicegroup{
servicegroup_name CURRENTUSERSGRP
alias Current Users Services
members ns1,Current Users,ns2,Current Users,web01,Current Users,web02,Current Users,web03,Current Users,web0
4,Current Users,web05,Current Users,web06,Current Users,web07,Current Users,web08,Current Users,web09,Current Users,web10,Current Us
ers,web11,Current Users,web12,Current Users,web13,Current Users,web14,Current Users,web15,Current Users,web16,Current Users,web17,Cu
rrent Users,web18,Current Users,web19,Current Users,web20,Current Users,web21,Current Users
} define servicegroup{
servicegroup_name DISKGRP
alias Root Partition Services
members ns1,Root Partition,ns2,Root Partition,web01,Root Partition,web02,Root Partition,web03,Root Partition
,web04,Root Partition,web05,Root Partition,web06,Root Partition,web07,Root Partition,web08,Root Partition,web09,Root Partition,web10
,Root Partition,web11,Root Partition,web12,Root Partition,web13,Root Partition,web14,Root Partition,web15,Root Partition,web16,Root
Partition,web17,Root Partition,web18,Root Partition,web19,Root Partition,web20,Root Partition,web21,Root Partition
} define servicegroup{
servicegroup_name SWAPGRP
alias Swap Usage Services
members ns1,Swap Usage,ns2,Swap Usage,web01,Swap Usage,web02,Swap Usage,web03,Swap Usage,web04,Swap Usage,we
b05,Swap Usage,web06,Swap Usage,web07,Swap Usage,web08,Swap Usage,web09,Swap Usage,web10,Swap Usage,web11,Swap Usage,web12,Swap Usag
e,web13,Swap Usage,web14,Swap Usage,web15,Swap Usage,web16,Swap Usage,web17,Swap Usage,web18,Swap Usage,web19,Swap Usage,web20,Swap
Usage,web21,Swap Usage define servicegroup{
servicegroup_name TPSGRP
alias Total Processes Services
members ns1,Total Processes,ns2,Total Processes,web01,Total Processes,web02,Total Processes,web03,Total Proc
esses,web04,Total Processes,web05,Total Processes,web06,Total Processes,web07,Total Processes,web08,Total Processes,web09,Total Proc
esses,web10,Total Processes,web11,Total Processes,web12,Total Processes,web13,Total Processes,web14,Total Processes,web15,Total Proc
esses,web16,Total Processes,web17,Total Processes,web18,Total Processes,web19,Total Processes,web20,Total Processes,web21,Total Proc
esses
} define servicegroup{
servicegroup_name DNSGRP
alias DNS Services
members ns1,DNS,ns2,DNS
} define servicegroup{
servicegroup_name SEARCHGRP
alias Search Services
members web11,SEARCH
} define servicegroup{
servicegroup_name MAILGRP
alias Mail Services
members web12,SMTP,web12,POP,web12,IMAP
}
cd contacts
vi contacts.cfg
###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
############################################################################### # In this simple config file, a single contact will receive all alerts.
# This assumes that you have an account (or email alias) called
# "nagios-admin" on the local host. define contact{
contact_name nagios-admin
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email [email protected]
} vi contactgroups.cfg ###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
############################################################################### # We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group. define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagios-admin
}
系统要求
The only requirement of running Nagios is a machine running Linux (or UNIX variant) and a C compiler. You will probably also want to have TCP/IP configured, as most service checks will be performed over the network. You are not required to use the CGIs included with Nagios. However, if you do decide to use them, you will need to have the following software installed...
1。A web server (preferrably Apache)
2。Thomas Boutell's gd library version 1.6.3 or higher (required by the statusmap and trends CGIs)
软件主页:
+ 1.下载源码包
wget http://nchc.dl.sourceforge.net/sourceforge/nagios/nagios-2.0b3.tar.gz
2.解压源码包
tar xfvz nagios-2.0b3.tar.gz
3.配置编译
cd nagios-2.0b3
adduser nagios
mkdir /usr/local/nagios
chown nagios.nagios /usr/local/nagios
grep "^User" /usr/local/apache2/conf/httpd.conf
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd nobody
/usr/sbin/usermod -G nagcmd nagios
./configure --prefix=/usr/local/nagios --with-cgiurl=/nagios/cgi-bin \
--with-htmlurl=/nagios --with-nagios-usr=nagios --with-nagios-group=nagios \
--with-command-group=nagcmd --with-gd-lib --enable-embedded-perl \
--with-perlcache make all
make install
make install-init
make install-commandmode
make install-config
安装nagios-plugs 1.下载源码包
wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.tar.gz
2.解压源码包
tar xfvz nagios-plugins-1.4.tar.gz
3.配置编译
./configure --prefix=/usr/local/nagios --with-mysql --with-cgiurl
make
make install
配置apache ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" AllowOverride AuthConfig
Options ExecCGI
Order allow,deny
Allow from all
Alias /nagios "/usr/local/nagios/share" Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
Authorization In The CGIs
The second step is to create a file named .htaccess in the root your CGI directory (and optionally also you HTML directory) for Nagios (usually /usr/local/nagios/sbin and /usr/local/nagios/share, respectively). The file(s) should have contents similiar to the following... : cd /usr/local/nagios/sbin
vi .htaccess AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user cd /usr/local/nagios/share
vi .htaccess AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user
Setting Up Authenticated Users: htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
格式:
htpasswd -c /usr/local/nagios/etc/htpasswd.users
Enabling Authentication/Authorization Functionality In The CGIs
The next thing you need to do is make sure that the CGIs are configured to use the authentication and authorization functionality in determining what information and/or commands users have access to. This is done be setting the use_authentication variable in the CGI configuration file to a non-zero value. Example: vi /usr/local/nagios/etc/cgi.cfg
use_authentication=1 /usr/local/apache2/bin/apachectl restart
配置文件 一. nagios.cfg
首先,刚装好的nagios,在/usr/local/nagios/etc 下,文件都是以-sample结尾的,要把某些文件去掉- sample。
主配置文件 nagios.cfg
mv nagios.cfg--sample nagios.cfg
vi nagios.cfg
注释这句话
#cfg_file=/usr/local/nagios/etc/minimal.cfg
在 # OBJECT CACHE FILE 这句话前面添加如下语句
cfg_dir=/usr/local/nagios/etc/hosts
cfg_dir=/usr/local/nagios/etc/contacts
cfg_dir=/usr/local/nagios/etc/services
cfg_dir=/usr/local/nagios/etc/commands 存盘退出 mkdir hosts
mkdir contacts
mkdir services
mkdir commands 这样做,主要是为了分类,管理方便。
有些cfg文件可以参照 bigger.cfg-sample,minimal.cfg-sample 这两个文件 cd hosts
vi hosts.cfg ###############################################################################
###############################################################################
#
# HOSTS
#
###############################################################################
############################################################################### # Generic host definition template - This is NOT a real host, just a template! define host{
name generic-host ; The name of this host template
notifications_enabled 1 ; Host notifications are enabled
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
# Since this is a simple configuration file, we only monitor one host - the
# local host (this machine). define host{
use generic-host ; Name of host template to use
host_name SH4
alias SH4
address 192.168.168.244
check_command check-host-alive
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,r
contact_groups admins
}
define host{
use generic-host ; Name of host template to use
host_name SH3
alias SH3
address 192.168.168.243
check_command check-host-alive
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,r
contact_groups admins
}
如果有很多服务器,可以把这些服务器分组 vi hostgroups.cfg ###############################################################################
###############################################################################
#
# HOST GROUPS
#
###############################################################################
############################################################################### # We only have one host in our simple config file, so there is no need to
# create more than one hostgroup. define hostgroup{
hostgroup_name test
alias Test Servers
members SH4, SH3
}
cd /usr/local/nagios/etc/contacts
vi contacts.cfg ###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
############################################################################### # In this simple config file, a single contact will receive all alerts.
# This assumes that you have an account (or email alias) called
# "nagios-admin" on the local host. define contact{
contact_name nagios-admin
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email [email protected]
}
vi contactgroups.cfg ###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
############################################################################### # We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group. define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagios-admin
}
cd /usr/local/nagios/etc/services
vi services.cfg
###############################################################################
###############################################################################
#
# SERVICES
#
###############################################################################
############################################################################### # Generic service definition template - This is NOT a real service, just a template! define service{
name generic-service ; The 'name' of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major per
formance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
notification_options w,u,c,r,f
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
# Define a service to "ping" the machine define service{
use generic-service ; Name of service template to use
host_name ns1
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_ping!100.0,20%!500.0,60%
}
# Define a service to detect "http" define service{
use generic-service ; Name of service template to use
host_name ns1
service_description HTTP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_http
} # Define a service to detect "ftp" define service{
use generic-service ; Name of service template to use
host_name web01
service_description FTP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_ftp
}
# Define a service to detect "DNS" define service{
use generic-service ; Name of service template to use
host_name ns1
service_description DNS
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_dns
} # Define a service to detect "SMTP" define service{
use generic-service ; Name of service template to use
host_name web12
service_description SMTP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_smtp
} # Define a service to detect "POP" define service{
use generic-service ; Name of service template to use
host_name web12
service_description POP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_pop
} # Define a service to detect "IMAP" define service{
use generic-service ; Name of service template to use
host_name web12
service_description IMAP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_imap
} # Define a service to detect "HTTPS" define service{
use generic-service ; Name of service template to use
host_name web05
service_description HTTPS
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_https
}
# Define a service to check the disk space of the root partition
# on the local machine. Warning if < 20% free, critical if
# < 10% free space on partition. define service{
use generic-service ; Name of service template to use
host_name ns1
service_description Root Partition
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_nrpe!check_disk
} # Define a service to check the swap usage on the local machine.
#Warning if < 20% free, critical if < 10% free space on partition. define service{
use generic-service ; Name of service template to use
host_name ns1
service_description Swap Usage
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_nrpe!check_swap
} # Define a service to check the number of currently logged in
# users on the local machine. Warning if > 20 users, critical
# if > 50 users. define service{
use generic-service ; Name of service template to use
host_name ns1
service_description Current Users
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_nrpe!check_users
} # Define a service to check the number of currently running procs
# on the local machine. Warning if > 250 processes, critical if
# > 400 users. define service{
use generic-service ; Name of service template to use
host_name ns1
service_description Total Processes
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_nrpe!check_procs
} # Define a service to check the load on the local machine.
define service{
use generic-service ; Name of service template to use
host_name web21
service_description Current Load
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
check_command check_nrpe!check_load
}
vi servicegroups.cfg #A service group definition is used to group one or more services together for display purposes in the CGIs. define servicegroup{
servicegroup_name PINGGRP
alias PING Services
members ns1,PING,ns2,PING,pix1,PING,pix2,PING,web01,PING,web02,PING,web03,PING,web04,PING,web05,PING ,web06,P
ING,web07,PING,web08,PING,web09,PING,web10,PING,web11,PING,web12,PING,web13,PING,web14,PING, web15,PING,web16,PING,web17,PING,web18,P
ING,web19,PING,web20,PING,web21,PING
} define servicegroup{
servicegroup_name HTTPGRP
alias HTTP Services
members ns1,HTTP,ns2,HTTP,web01,HTTP,web02,HTTP,web03,HTTP,web04,HTTP,web05,HTTP,web06,HTTP,web07,HT TP,web08
,HTTP,web09,HTTP,web10,HTTP,web11,HTTP,web12,HTTP,web13,HTTP,web14,HTTP,web15,HTTP,web16,HTT P,web17,HTTP,web18,HTTP,web19,HTTP,web20
,HTTP,web21,HTTP
} define servicegroup{
servicegroup_name HTTPSGRP
alias HTTPS Services
members web05,HTTPS,web14,HTTPS,web15,HTTPS
} define servicegroup{
servicegroup_name FTPGRP
alias FTP Services
members web01,FTP,web02,FTP,web03,FTP,web04,FTP,web05,FTP,web06,FTP,web07,FTP,web08,FTP,web09,FTP,we b10,FTP,
web11,FTP,web12,FTP,web13,FTP,web14,FTP,web15,FTP,web16,FTP,web17,FTP,web18,FTP,web19,FTP,we b20,FTP,web21,FTP
} define servicegroup{
servicegroup_name CURRENTLOADGRP
alias Current Load Services
members ns1,Current Load ,ns2,Current Load ,web01,Current Load ,web02,Current Load ,web03,Current Load ,web0
4,Current Load ,web05,Current Load ,web06,Current Load ,web07,Current Load ,web08,Current Load ,web09,Current Load ,web10,Current Lo
ad ,web11,Current Load ,web12,Current Load ,web13,Current Load ,web14,Current Load ,web15,Current Load ,web16,Current Load ,web17,Cu
rrent Load ,web18,Current Load ,web19,Current Load ,web20,Current Load ,web21,Current Load
} define servicegroup{
servicegroup_name CURRENTUSERSGRP
alias Current Users Services
members ns1,Current Users,ns2,Current Users,web01,Current Users,web02,Current Users,web03,Current Users,web0
4,Current Users,web05,Current Users,web06,Current Users,web07,Current Users,web08,Current Users,web09,Current Users,web10,Current Us
ers,web11,Current Users,web12,Current Users,web13,Current Users,web14,Current Users,web15,Current Users,web16,Current Users,web17,Cu
rrent Users,web18,Current Users,web19,Current Users,web20,Current Users,web21,Current Users
} define servicegroup{
servicegroup_name DISKGRP
alias Root Partition Services
members ns1,Root Partition,ns2,Root Partition,web01,Root Partition,web02,Root Partition,web03,Root Partition
,web04,Root Partition,web05,Root Partition,web06,Root Partition,web07,Root Partition,web08,Root Partition,web09,Root Partition,web10
,Root Partition,web11,Root Partition,web12,Root Partition,web13,Root Partition,web14,Root Partition,web15,Root Partition,web16,Root
Partition,web17,Root Partition,web18,Root Partition,web19,Root Partition,web20,Root Partition,web21,Root Partition
} define servicegroup{
servicegroup_name SWAPGRP
alias Swap Usage Services
members ns1,Swap Usage,ns2,Swap Usage,web01,Swap Usage,web02,Swap Usage,web03,Swap Usage,web04,Swap Usage,we
b05,Swap Usage,web06,Swap Usage,web07,Swap Usage,web08,Swap Usage,web09,Swap Usage,web10,Swap Usage,web11,Swap Usage,web12,Swap Usag
e,web13,Swap Usage,web14,Swap Usage,web15,Swap Usage,web16,Swap Usage,web17,Swap Usage,web18,Swap Usage,web19,Swap Usage,web20,Swap
Usage,web21,Swap Usage define servicegroup{
servicegroup_name TPSGRP
alias Total Processes Services
members ns1,Total Processes,ns2,Total Processes,web01,Total Processes,web02,Total Processes,web03,Total Proc
esses,web04,Total Processes,web05,Total Processes,web06,Total Processes,web07,Total Processes,web08,Total Processes,web09,Total Proc
esses,web10,Total Processes,web11,Total Processes,web12,Total Processes,web13,Total Processes,web14,Total Processes,web15,Total Proc
esses,web16,Total Processes,web17,Total Processes,web18,Total Processes,web19,Total Processes,web20,Total Processes,web21,Total Proc
esses
} define servicegroup{
servicegroup_name DNSGRP
alias DNS Services
members ns1,DNS,ns2,DNS
} define servicegroup{
servicegroup_name SEARCHGRP
alias Search Services
members web11,SEARCH
} define servicegroup{
servicegroup_name MAILGRP
alias Mail Services
members web12,SMTP,web12,POP,web12,IMAP
}
cd contacts
vi contacts.cfg
###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
############################################################################### # In this simple config file, a single contact will receive all alerts.
# This assumes that you have an account (or email alias) called
# "nagios-admin" on the local host. define contact{
contact_name nagios-admin
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email [email protected]
} vi contactgroups.cfg ###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
############################################################################### # We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group. define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagios-admin
}
相关阅读 更多 +