使用 Nagios 來偵測 FTP / SSH / HTTP 服務狀態

首先先在  /etc/nagios/objects/commands.cfg 檔案中找尋相對應的命令
# vim /etc/nagios/objects/commands.cfg
# ‘check_ftp’ command definition
define command{
        command_name    check_ftp
        command_line    $USER1$/check_ftp -H $HOSTADDRESS$
        }

# ‘check_http’ command definition
define command{
        command_name    check_http
        command_line    $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
        }

# ‘check_ssh’ command definition
define command{
        command_name    check_ssh
        command_line    $USER1$/check_ssh $ARG1$ $HOSTADDRESS$
        }
[@more@]
建立要偵測的主機檔案
# vim /etc/nagios/servers/www.cfg
define host {
        use                     linux-server
        host_name               www.test.ilc.edu.tw
        alias                   www.test.ilc.edu.tw
        address                 192.168.1.1
        }

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       www.test.ilc.edu.tw
        service_description             SSH
        check_command                   check_ssh
        notifications_enabled           0
        }

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       www.test.ilc.edu.tw
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       www.test.ilc.edu.tw
        service_description             FTP
        check_command                   check_ftp
        notifications_enabled           0
        }

重新啟動 Nagios
# service nagios restart
Running configuration check…done.
Stopping nagios: .done.
Starting nagios: done.

如果沒有出現錯誤訊息,代表設定成功

這時候應該可以看到下面的圖