- 论坛徽章:
- 0
|
About nagios of config
两种模式:ssh采集数据,nrpe采集数据
/usr/local/nagios/etc/nagios.cfg
[root@prmonitor01 etc]# cat nagios.cfg|grep prmweb01.cfg
cfg_file=/usr/local/nagios/etc/panta/prmweb01.cfg
[root@prmonitor01 etc]# cat nagios.cfg|grep commands.cfg
cfg_file=/usr/local/nagios/etc/commands.cfg
[root@prmonitor01 etc]# cat nagios.cfg|grep pr_config.cfg
cfg_file=/usr/local/nagios/etc/panta/pr_config.cfg
/usr/local/nagios/etc/panta/ pr_config.cfg
[root@prmonitor01 panta]#
[root@prmonitor01 panta]# cat pr_config.cfg|grep pr-host
name pr-host
[root@prmonitor01 panta]# cat pr_config.cfg|grep PR24x7
timeperiod_name PR24x7
[root@prmonitor01 panta]# cat pr_config.cfg|grep PR-SYS
contactgroup_name PR-SYS
[root@prmonitor01 panta]# cat pr_config.cfg|grep pr-service
name pr-service
[root@prmonitor01 panta]# cat pr_config.cfg|grep disk
service_description disk
[root@prmonitor01 panta]# cat pr_config.cfg |grep nfs
hostgroup_name prnfsd_group
alias prnfsd Servers
members nfs_server
[root@prmonitor01 panta]# more pr_config.cfg
#time
define timeperiod{
timeperiod_name PR24x7
alias PR,7 Days A Week
sunday 00:00-05:49,06:00-24:00
monday 00:00-05:49,06:00-24:00
tuesday 00:00-05:49,06:00-24:00
wednesday 00:00-05:49,06:00-24:00
thursday 00:00-05:49,06:00-24:00
friday 00:00-05:49,06:00-24:00
saturday 00:00-05:49,06:00-12:00,17:00-24:00
}
#contactgroup
define contactgroup{
contactgroup_name PR-SYS
alias PR-SYS Administrators
members PR,oms,fonox
}
define service{
name pr-service
passive_checks_enabled 0
active_checks_enabled 1
parallelize_check 1
obsess_over_service 0
check_freshness 1
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
failure_prediction_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
register 0
}
#serviceescalation
define serviceescalation{
host_name report_batch,char_master181,chart_slave182,chart_slave183,chart_slave184,GW_DB,GW_BC,GW_LB,tomcat1,tomcat2,tomcat3,tomcat4,tomcat5,tomcat6,ftp_server,apache1,apache2,apache3,jboss1,jboss2,mail_server,middle1,middle2,middle3,middle4,middle7,middle8,main_slave174,main_m_s,main_slave175,main_slave176,main_slave177,main_m,main_back,nagios,ajax1,ajax2,nfs_server,apache_st1,apache_st2
service_description disk
first_notification 1
last_notification 2
notification_interval 0
escalation_period PR24x7
escalation_options w,u,c,r
contact_groups PR-SYS
}
define serviceescalation{
host_name rollover,report_batch,tomcat1,tomcat2,tomcat3,tomcat4,tomcat5,tomcat6
service_description nfs
first_notification 1
last_notification 2
notification_interval 0
escalation_period PR24x7
escalation_options w,u,c,r
contact_groups PR-SYS
}
/usr/local/nagios/etc/panta/prmweb01.cfg
[root@prmonitor01 panta]# more prmweb01.cfg
#############################################
#192.168.99.111 ajax1
#############################################
define host{
use pr-host
host_name ajax1
alias ajax1
address 192.168.99.111
check_command check-host-alive
max_check_attempts 1
notification_interval 1
notification_period PR24x7;24x7
notification_options d,u,r
contact_groups PR-SYS
}
define hostextinfo{
host_name ajax1
notes This is a web server
notes_url http://panta-oms.bestwiz.cn/SL/LDFS_SLSC003.php?id=150
icon_image linux40.png
vrml_image linux40.png
statusmap_image linux40.gd2
2d_coords 100,250
3d_coords 100.0,50.0,75.0
}
define service{
use pr-service
host_name ajax1;192.168.99.111
service_description disk
is_volatile 0
check_period PR24x7;24x7
max_check_attempts 3
normal_check_interval 2
retry_check_interval 1
contact_groups PR-SYS
notification_options w,u,c,r
notification_interval 3
notification_period PR24x7;24x7
check_command check_nrpe_disk!check_disk!10%!5%!/ ; disk
}
define service{
use pr-service
host_name ajax1
service_description nfs
is_volatile 0
check_period PR24x7
max_check_attempts 3
normal_check_interval 2
retry_check_interval 1
contact_groups PR-SYS
notification_options w,u,c,r
notification_interval 3
notification_period PR24x7
check_command check_nfs_mount
}
/usr/local/nagios/etc/commands.cfg
define command{
command_name check_nrpe_disk
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -n -c $ARG1$ -a $ARG2$ $ARG3$ $ARG4$
}
define command{
command_name check_nfs_mount
command_line $USER1$/PR_check_nfs2.sh -H $HOSTADDRESS$
}
/usr/local/nagios/libexec/PR_check_nfs2.sh
[root@prmonitor01 libexec]# cat PR_check_nfs2.sh
#!/bin/sh
if [ $# -lt 2 ]
then
echo "usage: $0 -H "
exit 1
fi
_mount_str="/tmp/mount_str.$2"
ssh $2 "mount -l |grep jhfreport" > $_mount_str
if [ -s $mount_str ]
then
echo "$2 mount to 10.103.90.11 is OK!"
# rm -f $_mount_str
exit 0
else
echo "$2 mount to 10.103.90.11 is Fail!"
# rm -f $_mount_str
exit 1
fi
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/66227/showart_537077.html |
|