Google+ Followers

2014年5月10日 星期六

[Linux] 使用 Nagios 監控 AWS EC2、RDS 服務狀況 @ Ubuntu 12.04

雖然 AWS 已經有不錯的服務監控系統,但原先已經用 Nagios 監控服務,就順手研究一下對於 EC2、RDS 的監控吧。

由於資安角度,預設都不給 PING 的,此外 RDS (此例是 MySQL port 3306) 則只開放特定 TCP Port 而已,對 Nagios 而言,就可以改測試 TCP Port (HTTP,HTTPS,SSH) 等用法,如此一來就可以解決 Host is Down 囉。

define host {
        host_name aws-rdb
        alias aws-rdb-dns
        address aws-rdb-dns
        use rdb-host
        contact_groups db-services
}

define host {
        host_name aws-dev
        alias aws-dev-dns
        address aws-dev-dns
        hostgroups ssh-servers,http-servers
        use ec2-host
        contact_groups pc-services
}

define command {
        command_name check-rds-host-alive
        command_line /usr/lib/nagios/plugins/check_tcp -H $HOSTADDRESS$ -p 3306
}

define command {
        command_name check-ec2-host-alive
        command_line /usr/lib/nagios/plugins/check_tcp -H $HOSTADDRESS$ -p 80
}

define host{
        name                            rdb-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
                check_command                   check-rds-host-alive
                max_check_attempts              10
                notification_interval           0
                notification_period             24x7
                notification_options            d,u,r
                contact_groups                  admins
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }

define host{
        name                            ec2-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
                check_command                   check-ec2-host-alive
                max_check_attempts              10
                notification_interval           0
                notification_period             24x7
                notification_options            d,u,r
                contact_groups                  admins
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }

沒有留言:

張貼留言