nagiosイベントハンドラ
最近nagiosをコツコツ勉強してるんだけど。
イベントハンドラで再起動仕込めるのは楽だなあとか。
まあ本にも書いてありますけどねー。
SOFTかつmax_attemptの回数で再起動してもいいけどHARDでいいような気がする。
restart_http.sh
#!/bin/sh case "$1" in OK) ;; WARNING) ;; UNKNOWN) ;; CRITICAL) case "$2" in SOFT) ;; HARD) /usr/bin/sudo /etc/init.d/apache2 restart ;; esac ;; esac exit 0
xxxx.cfg
define command{ command_name restart_http command_line /usr/local/nagios/eventhandler/restart_http.sh $SERVICESTATE$ $SERVICESTATETYPE$ } define service{ use generic-service host_name localhost service_description Web Server is_volatile 0 check_period 24x7 max_check_attempts 5 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_interval 0 notification_period 24x7 notification_options w,u,c,r check_command check_http event_handler_enabled 1 event_handler restart_http }
とまあこんな感じ。
- $SERVICESTATE$
- $SERVICESTATETYPE$
このふたつのマクロ知ってればなんとかなる気がするなあ。
うくく。