masayuki5160's diary

名古屋でエンジニアしてます。

Nagiosで監視サーバ構築

気づいたらサーバを5台もってたので監視サーバでもつくってみようと思い、
いろいろしらべた結果Nagiosをつかってみることに。


参考資料

Nagios統合監視[実践]リファレンス (Software Design plus)

新品価格
¥8,624から
(2017/3/19 15:40時点)

Nagiosにてサーバ死活監視 http://d.hatena.ne.jp/kiwamaru/20111117/p1
yumレポジトリサーバ http://thinkit.co.jp/free/article/0706/14/4/
RPMリポジトリ導入(RPMforge) http://centossrv.com/rpmforge.shtml


基本的に上記の本で勉強。
本の手順とおりにrpmでNagiosをインストールするも、
NagiosのWebインターフェースの表示がおかしい。。。
こまったこまったと思っていたら、RPMforgeをレポジトリサーバとして追加したら
yumでnagiosインストールできるらしいとわかり、やってみたらうまくいった!



以下作業手順メモ(CentOS 5)

yum-prioritiesプラグイン導入。
インストール後に
/etc/yum.repos.d/CentOS-Base.repoをpriority=1として設定。

# yum install yum-priorities
# vi /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#追加
priority=1

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#追加
priority=1

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#追加
priority=1

#additional packages that extend functionality of existing packages


yumリポジトリとしてRPMforgeを追加。

#wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
#rpm -ivh rpmforge-release-0.5.2-2.el5.rf.i386.rpm

※ここまでがRPMforgeの設定。



Nagiosのインストール。

# yum install nagios
# yum install nagios-plugins

Nagiosへの権限(下記ではadminという管理者アカウントを作成している)

# htpasswd -c /etc/nagios/htpasswd.users admin
New password:

Re-type new password:

Adding password for user admin

Apacheのリロード後、
ブラウザから下記へアクセス。

http://[IP]/nagios/

とりあえずここまで。
Nagiosのもろもろ設定はまた今度。