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.

Raspberry pi4 (Cent OS7) にZabbix agentをInstallする

Last updated at Posted at 2021-04-02

Zabbix agentをRaspberry pi4にインストールしたいと思っていつも通りにrpmしようと思ったがエラー。
それもそのはずCPUも違うし、InstallしたOSがCent OS7なので例も少なく、苦戦したのでメモ。
ようは、Raspberry piとCent OS7というレアな組み合わせなためにソースからコンパイルするしかありません。

・・・言ったものの、基本的には先人のコピペです。

[root@raspberrypi4 ~]# cat /etc/redhat-release

CentOS Linux release 7.9.2009 (AltArch)

(OSのインストール)

ここでは詳しく解説しません。下記Webサイトを参照ください。
https://www.clara.jp/media/?p=5792

いろいろ をインストール

OSの更新と、必要なもの一式をインストールします。実はこの辺りきちんと調べていないのでいらないものが混ざっているかもしれません。

yum -y update 
yum -y install gcc make tar wget net-snmp net-snmp-utils net-snmp-devel

Zabbix download

執筆時点で最新のLTSであるVer5.0で進めていきます。
https://www.zabbix.com/jp/download_sources

mkdir -p /opt/tmp/
cd /opt/tmp/
wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.9.tar.gz

コンパイル& インストール

まずは解凍

ダウンロードしてきたソースを解凍します。

tar -xzvf zabbix-5.0.9.tar.gz

コンパイル

解凍してできたフォルダに移動し、コンパイルします。
このとき、Agentのみをコンパイルするよう、オプションで指定します。

# 解凍してできたフォルダに移動
cd zabbix-5.0.9

# コンパイル
./configure --enable-agent

無事完了したらmake install してね!と表示されます。
エラーを吐いた場合、大方
yum install net-snmp-devel libevent-devel libcurl-devel
の辺りを忘れていると思います。詳細はエラー文をよく読んでください。

インストール

さきほど言われたとおりに

make install

makeコマンドは-jオプションで並列できますが、make install は並列でやらないほうが良いと思います。

ユーザー・ディレクトリ・Config作成

zabbixユーザーを作成します。なお、zabbixユーザーはログイン不可のアカウントで作ります。

# ユーザーとグループ作成
groupadd -g 300 zabbix
useradd -u 300 -g zabbix -d /var/empty -s /sbin/nologin zabbix

# 必要なディレクトリ作成し、所有者をzabbixに変更
mkdir /etc/zabbix/
mkdir /var/log/zabbix
mkdir /var/run/zabbix/
chown -R zabbix:zabbix /var/log/zabbix
chown -R zabbix*zabbix /var/run/zabbix/

# config作成
cp /opt/tmp/zabbix-5.0.9/conf/zabbix_agentd.conf /etc/zabbix/

systemd用のservice作成

自動で作成されないのでこれも手動で作ります。
[すばらしい先人][link-1]がいらしたので拝借させていただきます。
[link-1]:http://extstrg.asabiya.net/pukiwiki/index.php?ZABBIX%203.2%20Agent%20%A5%B3%A5%F3%A5%D1%A5%A4%A5%EB%A5%A4%A5%F3%A5%B9%A5%C8%A1%BC%A5%EB%BC%EA%BD%E7%A1%CACentOS7%20%2B%20Raspberry%20Pi3%A1%CB

cat <<EOF > /usr/lib/systemd/system/zabbix-agent.service
   [Unit]
   Description=Zabbix Agentd
   After=network.target
   [Service]
   Type=oneshot
   ExecStart=/usr/local/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
   PIDFile=/var/run/zabbix/zabbix_agentd.pid
   RemainAfterExit=yes
   [Install]
   WantedBy=multi-user.target
EOF

config 編集

最低限起動するために、ConfigにZabbix-ServerのIPアドレスを書く必要があります。
113行目付近の#Server=127.0.0.1と154行目付近の#ServerActive=127.0.0.1のコメントアウトを無効にしてサーバーのIPを書き込みます。
私は1行そのままコピーして、コピーした行のコメントアウトを外してZabbix-ServerのIPを書きました。
そのため下記例では行番号がずれていますのでご注意ください。
(110~157はファイル内における行番号です)

vim /etc/zabbix/zabbix_agentd.conf

110 # Default:
111 # Server=
112 
113 #Server=127.0.0.1
114 Server=192.168.1.254
115 

154 
155 #ServerActive=127.0.0.1
156 ServerActive=192.168.1.254
157

起動・自動起動登録

systemctl enable --now zabbix-agent

あとはZabbix-ServerでHostを追加するだけです。
おつかれさまでした。

参考文献

[1] https://www.zabbix.com/documentation/5.0/manual
[2] http://extstrg.asabiya.net/pukiwiki/index.php?ZABBIX%203.2%20Agent%20%A5%B3%A5%F3%A5%D1%A5%A4%A5%EB%A5%A4%A5%F3%A5%B9%A5%C8%A1%BC%A5%EB%BC%EA%BD%E7%A1%CACentOS7%20%2B%20Raspberry%20Pi3%A1%CB
[3] http://extstrg.asabiya.net/pukiwiki/index.php?ZABBIX%204.0%A6%C1%C8%C7%20Proxy%20Raspberry-Pi%A4%D8%A4%CE%A5%A4%A5%F3%A5%B9%A5%C8%A1%BC%A5%EB%BC%EA%BD%E7
[4] https://fingerease.work/archives/raspi_zabbix_install/

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?