CentOS7をZabbixで監視する

Zabbix Serverの構築はできたので
取り敢えず Linux (CentOS) Agentを入れて、Linux Templateまで適用してみようかと

1. Zabbix Repositoryを導入

https://www.zabbix.com/jp/download ここから、Repositoryを選択して

# rpm -i https://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.VSZpP1: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
#
# yum repolist
zabbix/x86_64                Zabbix Official Repository - x86_64                                223
zabbix-non-supported/x86_64  Zabbix Official Repository non-supported - x86_64                    4
2. Zabbix Agentのインストール
# yum info zabbix-agent
Available Packages
Name        : zabbix-agent
Arch        : x86_64
Version     : 3.4.14
Release     : 1.el7
Size        : 367 k
Repo        : zabbix/x86_64
Summary     : Zabbix Agent
URL         : http://www.zabbix.com/
License     : GPLv2+
Description : Zabbix agent to be installed on monitored systems.
#
# yum install zabbix-agent

GPG KEYの警告がでるけど、「Y」をおして Agentをインストール

3. zabbix_agentd.conの修正

環境に合わせて以下を修正する

# vi /etc/zabbix/zabbix_agentd.conf
server=<Zabbix Server IP>
ServerActive=<Zabbix Server IP>
HostnameItem=system.hostname <- 有効化
4. Zabbix Agentの起動と自動起動設定
# systemctl status zabbix-agent
● zabbix-agent.service - Zabbix Agent
   Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
#
# systemctl start zabbix-agent
# systemctl status zabbix-agent
● zabbix-agent.service - Zabbix Agent
   Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-09-18 02:21:12 JST; 1s ago
  Process: 2480 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
 Main PID: 2482 (zabbix_agentd)
   CGroup: /system.slice/zabbix-agent.service
           tq2482 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
           tq2483 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
           tq2484 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
           tq2485 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
           tq2486 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
           mq2487 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Sep 18 02:21:12 rep2 systemd[1]: Starting Zabbix Agent...
Sep 18 02:21:12 rep2 systemd[1]: PID file /run/zabbix/zabbix_agentd.pid not readable (yet?) a...art.
Sep 18 02:21:12 rep2 systemd[1]: Started Zabbix Agent.
Hint: Some lines were ellipsized, use -l to show in full.
#
# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
#
# systemctl status zabbix-agent
● zabbix-agent.service - Zabbix Agent
   Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-09-18 02:21:12 JST; 3min 12s ago
 Main PID: 2482 (zabbix_agentd)
   CGroup: /system.slice/zabbix-agent.service
           tq2482 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
           tq2483 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
           tq2484 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
           tq2485 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
           tq2486 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
           mq2487 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Sep 18 02:21:12 rep2 systemd[1]: Starting Zabbix Agent...
Sep 18 02:21:12 rep2 systemd[1]: PID file /run/zabbix/zabbix_agentd.pid not readable (yet?) a...art.
Sep 18 02:21:12 rep2 systemd[1]: Started Zabbix Agent.
Hint: Some lines were ellipsized, use -l to show in full.
#
5. Zabbix Server <-> Agentの疎通確認

zabbix_get コマンドを使用して、Agentと通信できることを確認する
Zabbix Serverで以下を実行

# zabbix_get -s <Agent IP> -k system.hostname <- Agentのホスト名
# zabbix_get -s <Agent IP> -k agent.version <- AgentのVer
6. Zabbix Serverに登録

あとはよしなに