LoginSignup
3
2

More than 5 years have passed since last update.

zabbix_agent staticライブラリ化

Last updated at Posted at 2016-01-07

ライブラリ静的化させて既存システムに入っているライブラリ郡を更新したく無い場合や、
バイナリをばら撒いて叩くだけで動かしたい場合など。

稼働しているアプリケーションのサポート条件として
インストールライブラリが指定されている場合などの時に
zabbix_agentを使いたい場合などに。

今回はzabbix_server側は
別サーバで既に"rpmインストール"している所からテストした。
今回の話からはzabbix_serverのインストール等についてはこちらに記載はしていないのでご了承を。

作成環境

CentOS 6系
Digital Oceanを使い新規で環境作成

Digital Oceanを真っ新から立ち上げて作業する場合は、
wgetなど含め無いのでyumでinstallが必要ですが
この辺りも記載はしていません。

作る

1.zabbixのソースを持ってくる

*2015/11/20現在 latestの2.4.7(移植記事なので日付がだいぶ前です)

# wget http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.7/zabbix-2.4.7.tar.gz

2.unarchiveする

# ls -l zabbix-2.4.7.tar.gz`
-rw-r--r-- 1 root root 15012768 Nov 12 05:42 zabbix-2.4.7.tar.gz
#
# tar zxvf zabbix-2.4.7.tar.gz
# cd zabbix-2.4.7

3.configureする

zabbixのオンラインマニュアルを見ると
static-link作成時は、--enable-static にしろと記載がある
またagentやsenderは --enable-agent を付けろとの事
その他のoptionは ./configure -h で確認可能である
実行後errorが出ていなければokであろう

# ./configure --enable-static --enable-agent

エラーが出た場合の対処例2つほど

失敗例1:この場合は大抵Cコンパイラが入ってないなど
# ./configure --enable-static --enable-agent
configure: error: in `/root/zabbix-2.4.7':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
対処:入ってない場合はgcc等をいれましょう
# yum install -y gcc
失敗例2:お前のシステムだとstatic linkの物を作れないと怒られる
# ./configure --enable-static --enable-agent
checking size of void *... 8
checking if static linking is possible... no
configure: error: static linking is not possible on this system
対処:static-link作成の際のライブラリ群をinstall
# yum install -y glibc-static

4. makeでビルド

error等でなければ大丈夫であろう

# make

5.インストールはせずにビルドしたものを確認する

以下の様にstaticになりライブラリが実行ファイルに同封されているようであれば、
入れたい環境に持っていき配置などする

# pwd
/zabbix-2.4.7
#
# file ./src/zabbix_agent/zabbix_agentd
./src/zabbix_agent/zabbix_agentd: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.18, not stripped
#
# ldd ./src/zabbix_agent/zabbix_agentd
not a dynamic executable

6.最後に起動の確認

zabbix-server(rpmインストール)がされているサーバ(CentOS6系)からagentが使えるかを確認する
今回は直接実行して使う事の動作確認
configのPATHはrpmインストールと同じPATHを使用
ちなみに、zabbix_agentdのオプション類はmanで確認可能
*configのPATHはconfigre時に指定できた気もする
*zabbix_agentd.confの中身は適宜設定を
*プロセスを起動するにあたり、zabbixユーザが必要

# ./zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
# ps -ef | grep agent
zabbix   13350     1  0 05:53 ?        00:00:00 ./zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix   13351 13350  0 05:53 ?        00:00:00 ./zabbix_agentd: collector [idle 1 sec]
zabbix   13352 13350  0 05:53 ?        00:00:00 ./zabbix_agentd: listener #1 [waiting for connection]
zabbix   13353 13350  0 05:53 ?        00:00:00 ./zabbix_agentd: listener #2 [waiting for connection]
zabbix   13354 13350  0 05:53 ?        00:00:00 ./zabbix_agentd: listener #3 [waiting for connection]
zabbix   13355 13350  0 05:53 ?        00:00:00 ./zabbix_agentd: active checks #1 [idle 1 sec]
root     13358 12720  0 05:53 pts/1    00:00:00 grep agent

その他

  • senderも同様にstatic化になっていると思いますのでご利用される方はどうぞ
3
2
1

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
3
2