0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Nagios使ってみた

Posted at

Nagios環境構築

ネットワーク機器やサーバのモニタリングツールであるNagiosの環境構築手順です。
頼りになる日本語の解説サイトがあったのですが、私の場合途中からそれがうまく機能しなかったのでその対処法を主に記します。
それに加えてVPN環境において、Nagiosそのもののに由来する原因ではありませんでしたが権限エラーが出てどのネット上の情報も当てはまらず困ったので、そのことも書き留めます。

環境

CentOS7
Nagios 4.4.6

手順

詰まった点1(監視対象機器の追加設定)

今回は、サーバとスイッチを監視対象として設定した。
これまで参考にしていたこのページで設定を進めようとしたところ、上手く行かなかった。

公式ドキュメントに沿って設定をするとできた。
ドキュメント大事。

例えばスイッチの設定であれば、まずはvi /usr/local/nagios/etc/nagios.cfgの中に記述してある
#cfg_file=/usr/local/nagios/etc/objects/switch.cfg
という設定ファイルの定義のコメントアウトの"#"を削除する。

そして、vi /usr/local/nagios/etc/objects/switch.cfgの中で

define host{
    use          generic-switch         ; Inherit default values from a template
    host_name    linksys-srw224p        ; 自分でつけて良い名前。The name we're giving to this switch
    alias        Linksys SRW224P Switch ; A longer name associated with the switch
    address      192.168.1.253          ; IP address of the switch
    hostgroups   allhosts,switches      ; Host groups this switch is associated with
}

として定義して以下のserviceの設定時に、そのhost_nameを書き連ねれば複数のスイッチにどんどん適用していける。
hostで監視対象機器の設定、serviceで監視内容の設定が行える。

define service{
    use                    generic-service                ; Inherit values from a template
    host_name              linksys-srw224p                ; 自分でつけて良い名前。The name of the host the service is associated with
    service_description    PING                           ; The service description
    check_command          check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
    normal_check_interval  5                              ; Check the service every 5 minutes under normal conditions
    retry_check_interval   1                              ; Re-check every minute until final/hard state is determined
}

詰まった点2(VPN環境における話)

/var/www/html の下の他のhtmlファイルは表示されるのに、Nagiosの画面のみ403権限エラーが出る、ということがあった。

You don't have permission to access /nagios/

これは、Nagiosのアクセス元IPをプライベートIPに制限設定していたことに由来する。
Nagiosサーバと同じネットワークに居たのだが、VPN環境に繋いでおらず、プライベートIPがNagios許容範囲になかった。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?