Установка Nagios описана здесь Установка Nagios на Centos Настройка Nagios и мониторинга локального Nagios-хоста (сам себя мониторит Nagios-хост)
1 |
# systemctl stop nagios |
1 |
# cd /usr/local/nagios/etc/ |
1 |
# cp cgi.cfg cgi.cfg~ |
1 |
# cp nagios.cfg nagios.cfg~ |
1 |
# cp resource.cfg resource.cfg~ |
1 |
# mv objects objects~ |
1 |
# nano cgi.cfg |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
main_config_file=/usr/local/nagios/etc/nagios.cfg physical_html_path=/usr/local/nagios/share url_html_path=/nagios show_context_help=1 use_pending_states=1 use_authentication=1 use_ssl_authentication=0 #default_user_name=guest authorized_for_system_information=nagiosadmin,myname authorized_for_configuration_information=nagiosadmin,myname authorized_for_system_commands=nagiosadmin,myname authorized_for_all_services=nagiosadmin,myname authorized_for_all_hosts=nagiosadmin,myname authorized_for_all_service_commands=nagiosadmin,myname authorized_for_all_host_commands=nagiosadmin,myname #authorized_for_read_only=user1,user2 #statusmap_background_image=smbackground.gd2 #color_transparency_index_r=255 #color_transparency_index_g=255 #color_transparency_index_b=255 default_statusmap_layout=5 default_statuswrl_layout=4 #statuswrl_include=myworld.wrl ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$ refresh_rate=15 result_limit=0 escape_html_tags=1 #host_unreachable_sound=hostdown.wav #host_down_sound=hostdown.wav #service_critical_sound=critical.wav #service_warning_sound=warning.wav #service_unknown_sound=warning.wav #normal_sound=noproblem.wav action_url_target=_blank notes_url_target=_blank lock_author_names=1 #enable_splunk_integration=1 #splunk_url=http://127.0.0.1:8000/ navbar_search_for_addresses=1 navbar_search_for_aliases=1 #ack_no_sticky=0 #ack_no_send=0 |
1 |
# nano resource.cfg |
1 |
$USER1$=/usr/local/nagios/libexec |
1 |
# nano nagios.cfg |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
log_file=/usr/local/nagios/var/nagios.log cfg_dir=/usr/local/nagios/etc/commands.d cfg_dir=/usr/local/nagios/etc/contacts.d cfg_dir=/usr/local/nagios/etc/hosts.d cfg_dir=/usr/local/nagios/etc/services.d cfg_dir=/usr/local/nagios/etc/misc.d object_cache_file=/usr/local/nagios/var/objects.cache precached_object_file=/usr/local/nagios/var/objects.precache resource_file=/usr/local/nagios/etc/resource.cfg status_file=/usr/local/nagios/var/status.dat status_update_interval=10 nagios_user=nagios nagios_group=nagios check_external_commands=1 command_file=/usr/local/nagios/var/rw/nagios.cmd #query_socket=/usr/local/nagios/var/rw/nagios.qh lock_file=/usr/local/nagios/var/nagios.lock temp_file=/usr/local/nagios/var/nagios.tmp temp_path=/tmp event_broker_options=-1 #broker_module=/somewhere/module1.o #broker_module=/somewhere/module2.o arg1 arg2=3 debug=0 log_rotation_method=d log_archive_path=/usr/local/nagios/var/archives use_syslog=1 log_notifications=1 log_service_retries=1 log_host_retries=1 log_event_handlers=1 log_initial_states=1 log_current_states=1 log_external_commands=1 log_passive_checks=1 #global_host_event_handler=somecommand #global_service_event_handler=somecommand service_inter_check_delay_method=s max_service_check_spread=30 service_interleave_factor=s host_inter_check_delay_method=s max_host_check_spread=30 max_concurrent_checks=0 check_result_reaper_frequency=2 max_check_result_reaper_time=5 check_result_path=/usr/local/nagios/var/spool/checkresults max_check_result_file_age=3600 cached_host_check_horizon=15 cached_service_check_horizon=15 enable_predictive_host_dependency_checks=1 enable_predictive_service_dependency_checks=1 soft_state_dependencies=1 #time_change_threshold= auto_reschedule_checks=0 auto_rescheduling_interval=30 auto_rescheduling_window=180 service_check_timeout=60 host_check_timeout=30 event_handler_timeout=30 notification_timeout=30 ocsp_timeout=5 perfdata_timeout=5 retain_state_information=1 state_retention_file=/usr/local/nagios/var/retention.dat retention_update_interval=60 use_retained_program_state=1 use_retained_scheduling_info=1 retained_host_attribute_mask=0 retained_service_attribute_mask=0 retained_process_host_attribute_mask=0 retained_process_service_attribute_mask=0 retained_contact_host_attribute_mask=0 retained_contact_service_attribute_mask=0 interval_length=60 #check_for_updates=1 #bare_update_check=0 use_aggressive_host_checking=0 execute_service_checks=1 accept_passive_service_checks=1 execute_host_checks=1 accept_passive_host_checks=1 enable_notifications=1 enable_event_handlers=1 process_performance_data=0 #host_perfdata_command=process-host-perfdata #service_perfdata_command=process-service-perfdata #host_perfdata_file=/usr/local/nagios/var/host-perfdata #service_perfdata_file=/usr/local/nagios/var/service-perfdata #host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIO$ #service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVIC$ #host_perfdata_file_mode=a #service_perfdata_file_mode=a #host_perfdata_file_processing_interval=0 #service_perfdata_file_processing_interval=0 #host_perfdata_file_processing_command=process-host-perfdata-file #service_perfdata_file_processing_command=process-service-perfdata-file #host_perfdata_process_empty_results=1 #service_perfdata_process_empty_results=1 obsess_over_services=0 #ocsp_command=somecommand obsess_over_hosts=0 #ochp_command=somecommand translate_passive_host_checks=0 passive_host_checks_are_soft=0 check_for_orphaned_services=1 check_for_orphaned_hosts=1 check_service_freshness=1 service_freshness_check_interval=60 service_check_timeout_state=c check_host_freshness=0 host_freshness_check_interval=60 additional_freshness_latency=15 enable_flap_detection=0 low_service_flap_threshold=5.0 high_service_flap_threshold=20.0 low_host_flap_threshold=5.0 high_host_flap_threshold=20.0 date_format=iso8601 #use_timezone=US/Mountain #use_timezone=Australia/Brisbane illegal_object_name_chars=`~!$%^&*|'"<>?,()= illegal_macro_output_chars=`~$&|'"<> use_regexp_matching=0 use_true_regexp_matching=0 admin_email=my@email admin_pager=my@email daemon_dumps_core=0 use_large_installation_tweaks=0 enable_environment_macros=1 #free_child_process_memory=1 #child_processes_fork_twice=1 debug_level=0 debug_verbosity=1 debug_file=/usr/local/nagios/var/nagios.debug max_debug_file_size=10000000 allow_empty_hostgroup_assignment=0 #check_workers=3 host_down_disable_service_checks=1 |
1 |
# mkdir -p /usr/local/nagios/etc/{commands.d,contacts.d,hosts.d,services.d,misc.d} |
1 |
# chown -R nagios:nagios commands.d contacts.d hosts.d misc.d services.d |
1 |
# chmod -R 4775 commands.d contacts.d hosts.d misc.d services.d |
1 |
# chmod 600 resource.cfg |
1 |
# cp objects~/commands.cfg commands.d/notify.cfg |
1 |
# nano commands.d/notify.cfg |
1 2 3 4 5 6 7 8 9 10 11 |
# 'notify-host-email' command definition define command{ command_name notify-host-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ } # 'notify-service-email' command definition define command{ command_name notify-service-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ } |
1 |
# cp objects~/timeperiods.cfg misc.d/ |
1 |
# nano misc.d/timeperiods.cfg |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days 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 } # 'workhours' timeperiod definition define timeperiod{ timeperiod_name workhours alias Normal Work Hours monday 09:00-18:00 tuesday 09:00-18:00 wednesday 09:00-18:00 thursday 09:00-18:00 friday 09:00-18:00 } # not 'workhours' timeperiod definition define timeperiod{ timeperiod_name non-workhours alias Normal Work Off Hours monday 00:00-09:00,18:00-24:00 tuesday 00:00-09:00,18:00-24:00 wednesday 00:00-09:00,18:00-24:00 thursday 00:00-09:00,18:00-24:00 friday 00:00-09:00,18:00-24:00 saturday 00:00-24:00 sunday 00:00-24:00 } # 'none' timeperiod definition define timeperiod{ timeperiod_name none alias No Time Is A Good Time } |
1 |
# nano contacts.d/contacts-template.cfg |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
define contact { name contact-template-generic host_notifications_enabled 1 service_notifications_enabled 1 host_notification_period 24x7 service_notification_period 24x7 host_notification_options d,u,r service_notification_options w,u,c,r can_submit_commands 1 retain_status_information 1 retain_nonstatus_information 1 register 0 } define contact { name contact-template-email use contact-template-generic host_notification_commands notify-host-email service_notification_commands notify-service-email register 0 } |
1 |
# nano contacts.d/contacts.cfg |
1 2 3 4 5 6 |
define contact { contact_name myname alias MyName MySurname email my@email use contact-template-email } |
1 |
# nano contacts.d/contactgroups-administrators.cfg |
1 2 3 4 5 |
define contactgroup { contactgroup_name all-admins alias All Administrators members myname } |
1 |
# nano hosts.d/host-template-generic.cfg |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
define host { name host-template-generic check_command check-host-alive initial_state u max_check_attempts 3 check_interval 1 retry_interval 1 active_checks_enabled 1 passive_checks_enabled 1 check_period 24x7 obsess_over_host 1 check_freshness 1 event_handler_enabled 1 flap_detection_enabled 0 # flap_detection_options u process_perf_data 0 retain_status_information 1 retain_nonstatus_information 1 notification_interval 0 first_notification_delay 3 notification_period 24x7 notification_options d,u,r,f,s notifications_enabled 1 register 0 } |
1 |
# nano hosts.d/host-template-all-generic.cfg |
1 2 3 4 5 6 7 |
define host { name host-template-all-generic use host-template-generic contact_groups all-admins notification_options d,r,s register 0 } |
1 |
# nano hosts.d/hosts-myproject.cfg |
1 2 3 4 5 6 7 |
define host { host_name server.mydomain.com alias server.mydomain.com display_name server.mydomain.com address 127.0.0.1 use host-template-all-generic } |
1 |
# nano hosts.d/hostgroups-myproject.cfg |
1 2 3 4 5 |
define hostgroup { hostgroup_name hostgroup-myproject-all-servers alias All Myproject servers members server.mydomain.com } |
1 |
# nano services.d/service-template-generic.cfg |
[…]