LoginSignup
4
4

More than 5 years have passed since last update.

Intel Edisonでzabbixエージェントを動かす

Last updated at Posted at 2015-01-14

はじめに

意外とあっさり出来たので拍子抜け

事前準備

「電源を供給すれば自動的に無線LANに接続して、静的なIPでLANに接続される」までを事前準備とします。

最新ファームウェアの適用

これを行わないと、無線LAN経由でのSSH操作が非常に重たく、まともに操作すらできないことがあるようです。
→こちら参照 http://trac.switch-science.com/wiki/IntelEdisonStart

無線LANの設定

→こちら参照 http://trac.switch-science.com/wiki/IntelEdisonBreakoutBoardWiFi

wpa_supplicantの自動起動

デフォルトで自動起動になっていない場合、電源を入れていくら待っても無線LAN経由では接続出来ないので。

# systemctl enable wpa_supplicant

固定IPアドレスの割り当て

→こちら参照 http://nanicananica.blog.fc2.com/blog-entry-40.html
参照先では設定の反映のためにEdison自体をrebootしていますが、

# systemctl restart wpa_supplicant

で大丈夫だと思います(多分)

ここまでで、「電源(Not PC)に接続すれば自動的に無線LANに接続されて、SSHでログインできる状態」になっていること。

zabbixエージェントのビルド

ソースをダウンロードしてきて一般的な環境と同様にビルド。
zabbixエージェント自体はそれほど大きいプログラムではないので、クロスコンパイル環境を構築するよりは楽かな、と。

URLはダミーなので、その時の最新のURLを http://www.zabbix.com/download.php からどうぞ。

# wget http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.3/zabbix-2.4.X.tar.gz
# tar zxvf zabbix-2.4.X.tar.gz
# cd zxvf zabbix-2.4.3
# ./configure --enable-agent
# make

※起動スクリプトのコピーは不要なのでmake installは行わない

RHEL7用の公式パッケージからsystemd用設定ファイルを取り出す

systemd用の設定ファイル(zabbix-agent.service)はzabbixの開発元で公開しているRHEL7用のインストールパッケージのrpmから拝借する。
ここの作業に関してはEdison内ではなく、wgetとrpm2cpioコマンドが使用できる環境(CentOS等)で行ってください。

# cd /home/
# wget http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-agent-2.4.3-1.el7.x86_64.rpm
# mkdir work
# cd work
# rpm2cpio ../zabbix-agent-2.4.3-1.el7.x86_64.rpm | cpio -idv

バイナリ・設定ファイルを適宜配置

取りあえず↓の方針で

  • ビルドで得られたバイナリは/usr/sbin/
  • zabbix_agentd用の設定ファイルのzabbix_agentd.confは/etc/
  • sytemd用の設定ファイルのzabbix-agent.serviceは/etc/systemd/system/

設定ファイルを適宜修正

zabbix_agentd.confとzabbix-agent.serviceを、上記で配置したパスに合わせていい感じに修正

  • zabbix_agentd.conf

普通のサーバのエージェントと同様

# diff zabbix-2.4.3/conf/zabbix_agentd.conf /etc/zabbix_agentd.conf
--- zabbix-2.4.3/conf/zabbix_agentd.conf
+++ /etc/zabbix_agentd.conf
@@ -78,7 +78,7 @@
 # Default:
 # Server=

-Server=127.0.0.1
+Server=192.168.X.X

 ### Option: ListenPort
 #      Agent will listen on this port for connections from the server.
@@ -119,7 +119,7 @@
 # Default:
 # ServerActive=

-ServerActive=127.0.0.1
+ServerActive=192.168.X.X

 ### Option: Hostname
 #      Unique, case sensitive hostname.
@@ -130,7 +130,7 @@
 # Default:
 # Hostname=

-Hostname=Zabbix server
+Hostname=edison

 ### Option: HostnameItem
 #      Item used for generating Hostname if it is undefined. Ignored if Hostname is defined.
  • ↓zabbix-agent.service パスを上述でコピーした先に合わせる。

それ以外はそのまま。

# diff zabbix-agent.service.org zabbix-agent.service
--- zabbix-agent.service.org
+++ zabbix-agent.service
@@ -4,11 +4,11 @@
 After=network.target

 [Service]
-Environment="CONFFILE=/etc/zabbix/zabbix_agentd.conf"
+Environment="CONFFILE=/etc/zabbix_agentd.conf"
 EnvironmentFile=-/etc/sysconfig/zabbix-agent
 Type=forking
 Restart=always
-PIDFile=/run/zabbix/zabbix_agentd.pid
+PIDFile=/tmp/zabbix_agentd.pid
 KillMode=process
 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE

zabbixユーザを作る

AllowRoot=1するなら不要かもしれない

# useradd zabbix -c "Zabbix Monitoring System" -d "/var/lib/zabbix" -s "/sbin/nologin"
# grep zabbix /etc/passwd
zabbix:x:1000:1000:Zabbix MonitoringSystem:/var/lib/zabbix:/sbin/nologin

systemctlコマンドでサービスの確認・起動

# systemctl status zabbix-agent.service
# systemctl enable zabbix-agent.service
# systemctl start zabbix-agent.service
# ps |grep zabbix

zabbixサーバ側で動作確認

Web UIでホストを設定して、上手く認識できればOK

4
4
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
4
4