$ vim /usr/local/nagios/etc/nagios.cfg
# Add following lines on cfg_dir blockcfg_dir=/usr/local/nagios/etc/contacts
cfg_dir=/usr/local/nagios/etc/contactgroups
cfg_dir=/usr/local/nagios/etc/services
cfg_dir=/usr/local/nagios/etc/commands
cfg_dir=/usr/local/nagios/etc/hosts
cfg_dir=/usr/local/nagios/etc/hostgroups
$ vim /usr/local/nagios/etc/contactgroups/oncall-admin.cfg
define contactgroup{
contactgroup_name oncall-admins
alias On-call Admins
members ops
}
Nagios Hosts
$ vim /usr/local/nagios/etc/hosts/example.com
define host {
use linux-server
host_name example.com
alias example.com
address example.com
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
notification_options d,u,r
}
$ vim /usr/local/nagios/etc/hosts/test.com
define host {
use linux-server
host_name test.com
alias test.com
address test.com
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
notification_options d,u,r
}
Nagios Host Groups
$ vim /usr/local/nagios/etc/hostgroups/http.cfg
define hostgroup{
hostgroup_name HTTP
alias HTTP
members example.com,test.com
}
$ vim /usr/local/nagios/etc/hostgroups/https.cfg
define hostgroup{
hostgroup_name HTTPS
alias HTTPS
members example.com
}
$ vim /usr/local/nagios/etc/hostgroups/remote_mysql.cfg
define hostgroup{
hostgroup_name REMOTE_MYSQL
alias REMOTE MYSQL
members example.com,test.com
}
$ vim /usr/local/nagios/etc/hostgroups/remote_nginx.cfg
define hostgroup{
hostgroup_name REMOTE_NGINX
alias REMOTE NGINX
members example.com,test.com
}
$ define hostgroup{
hostgroup_name REMOTE
alias Remote Linux Servers
members example.com,test,com
}
Nagios Services
$ vim /usr/local/nagios/etc/services/http.cfg
define service{
use local-service ; Name of service template to use
service_description HTTP
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
contact_groups oncall-admins
hostgroup_name HTTP
notification_interval 30
notification_period 24x7
notification_options c,r
check_command check_http
}
$ vim /usr/local/nagios/etc/services/https.cfg
define service{
use local-service ; Name of service template to use
service_description HTTPS
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
contact_groups oncall-admins
hostgroup_name HTTPS
notification_interval 30
notification_period 24x7
notification_options w,c,r
check_command check_https
}
$ vim /usr/local/nagios/etc/services/remote_mysql.cfg
define service{
use local-service ; Name of service template to use
service_description Remote MYSQL
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
contact_groups oncall-admins
hostgroup_name REMOTE_MYSQL
notification_interval 30
notification_period 24x7
notification_options c,r
check_command check_nrpe!check_mysql
}
$ vim /usr/local/nagios/etc/services/remote_nginx.cfg
define service{
use local-service ; Name of service template to use
service_description Remote NGINX
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
contact_groups oncall-admins
hostgroup_name REMOTE_NGINX
notification_interval 30
notification_period 24x7
notification_options c,r
check_command check_nrpe!check_nginx
}
$ vim /usr/local/nagios/etc/services/remote.cfg
define service{
use generic-service ; Name of service template to use
service_description Root Partition
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
contact_groups oncall-admins
hostgroup_name REMOTE
notification_interval 30
notification_period 24x7
notification_options c,r
check_command check_nrpe!check_hda1
}
define service{
use generic-service ; Name of service template to use
service_description Current Load
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
contact_groups oncall-admins
hostgroup_name REMOTE
notification_interval 30
notification_period 24x7
notification_options c,r
check_command check_nrpe!check_load
}
define service{
use generic-service ; Name of service template to use
service_description Memory Swap
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
contact_groups oncall-admins
hostgroup_name REMOTE
notification_interval 30
notification_period 24x7
notification_options c,r
check_command check_nrpe!check_memory
}#define service{# use generic-service ; Name of service template to use# service_description Total Process# is_volatile 0# check_period 24x7# max_check_attempts 3# normal_check_interval 3# retry_check_interval 1# contact_groups oncall-admins# hostgroup_name REMOTE# notification_interval 30# notification_period 24x7# notification_options c,r# check_command check_nrpe!check_total_procs#}