使用 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.

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

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

Nagios Web 管理介面 vshell 介面中文化

在 /usr/local/vshell 的目錄下,發現有 locale 目錄,vshell 似乎有支援多國語言,只是裡面沒有正體中文而已。看了一下裡面的英文,覺得還好,而且數量也不多,所以就順手翻了一下。

[@more@]建立目錄
# mkdir -p /usr/local/vshell/locale/zh_TW/LC_MESSAGES
複製英文語系來修改
# cp /usr/local/vshell/locale/en_EN/en_EN/LC_MESSAGES/en_EN.po /usr/local/vshell/locale/zh_TWLC_MESSAGES/zh_TW.po
# cp /usr/local/vshell/locale/en_EN/en_EN/LC_MESSAGES/en_EN.mo /usr/local/vshell/locale/zh_TW/LC_MESSAGES/zh_TW.mo

修改 zh_TW.po 將裡面的英文條項翻成中文,然後將修改好的 zh_TW.mo 複製到 /usr/local/vshell/locale/zh_TW/LC_MESSAGES 目錄之下

修改 /etc/vshell.conf 設定檔,將 LANG = “en_GB” 改成 LANG = “zh_TW”
# sed -i ‘s/LANG = “en_GB”/LANG = “zh_TW”/ /etc/vshell.conf

翻的不是很好,有須要的人,可以由 此處 下載