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 1 year has passed since last update.

2022-07-06 Vagrant で Nagios をセットアップする

Last updated at Posted at 2022-07-17

CentOS7 の OS をインストール、セットアップし、そこにペチペチとコマンドを打ち込んでいってもいいが、再現性がないため、 Vagrantfile の provision 等を用いて Nagios をセットアップすることにした。

何かしらハマるようなこともなく、簡単にセットアップを行うことができたため、ここに記す。

手順

vagrant init generic/centos7

Vagrant box generic/centos7 - Vagrant Cloud (vagrantup.com)

Provision 行に、以下のインストール方法に記載されたコマンドをコピペしていった。

Nagios Core - Installing Nagios Core From Source

  config.vm.provision "shell", inline: <<-SHELL
    sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
    setenforce 0
    yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix
    yum install -y openssl-devel
    cd /tmp
    wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.6.tar.gz
    tar xzf nagioscore.tar.gz
    cd /tmp/nagioscore-nagios-4.4.6/
    ./configure
    make all
    make install-groups-users
    usermod -a -G nagios apache
    make install
    make install-daemoninit
    systemctl enable httpd.service
    make install-commandmode
    make install-config
    make install-webconf
    firewall-cmd --zone=public --add-port=80/tcp
    firewall-cmd --zone=public --add-port=80/tcp --permanent
    htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
    systemctl enable httpd.service
    systemctl enable nagios.service
    systemctl start httpd.service
    systemctl start nagios.service

    # plugins
    yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
    yum install -y perl-Net-SNMP
    cd /tmp
    wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    rpm -ihv epel-release-latest-7.noarch.rpm
    yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
    yum install -y perl-Net-SNMP
    cd /tmp
    wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz
    tar zxf nagios-plugins.tar.gz
    cd /tmp/nagios-plugins-release-2.3.3/
    ./tools/setup
    ./configure
    make
    make install
  SHELL

Vagrant の provision にインストールの手順を直書き。

なんと一発で成功した。80:80 のポートフォワードを設定し、 /nagios のパスにアクセスするとベーシック認証の画面が表示された。

# htpasswd /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

ベーシック認証で利用する nagiosadmin のパスワードがわからなくなったのでリセット。

ベーシック認証画面に認証情報を入力したところ、 Nagios の画面が表示された。

余談

OS は CentOS7 で固定されているのだから、特定のバージョンの Nagios をわざわざビルドするようなことはせず、 rpm ファイル利用したほうが簡単かつ安定してよかったかもしれない。

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?