Zabbix Agentのインストール方法のメモです。まずは、インストールから。
CentOS 8 # rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/8/x86_64/zabbix-agent-4.0.44-1.el8.x86_64.rpm CentOS 7 # rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm CentOS 6 # rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm # yum -y install zabbix-agent
設定ファイルを編集します。
# vi /etc/zabbix/zabbix_agentd.conf # ex) # Zabbixサーバ: 123.123.123.123 # 監視対象(自身): target.example.com Server=123.123.123.123 ServerActive=123.123.123.123 Hostname=target.example.com
iptablesの設定をします。
# iptables -nL INPUT --line-numbers
......
18 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:443
======ここに入れたい======
19 LOG all -- 0.0.0.0/0 0.0.0.0/0 limit: avg 1/sec burst 5 LOG flags 0 level 7 prefix 'INPUT DROP:'
20 DROP all -- 0.0.0.0/0 0.0.0.0/0
# iptables -I INPUT 19 -p tcp --dport 10050 -j ACCEPT -s 123.123.123.123
# iptables -nL INPUT --line-numbers
......
18 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:443
19 ACCEPT tcp -- 123.123.123.123 0.0.0.0/0 tcp dpt:10050
20 LOG all -- 0.0.0.0/0 0.0.0.0/0 limit: avg 1/sec burst 5 LOG flags 0 level 7 prefix 'INPUT DROP:'
21 DROP all -- 0.0.0.0/0 0.0.0.0/0
# service iptables save
# service iptables restart
或いはfirewalldの設定をします。
# firewall-cmd --permanent --new-zone=zabbixZone success # firewall-cmd --reload success # firewall-cmd --permanent --zone=zabbixZone --set-target=ACCEPT success # firewall-cmd --permanent --zone=zabbixZone --add-port=10050/tcp success # firewall-cmd --permanent --zone=zabbixZone --add-source=123.123.123.123 success # firewall-cmd --reload success # firewall-cmd --get-active-zones public interfaces: eth0 zabbixZone sources: 153.126.193.178 # firewall-cmd --list-all --zone=zabbixZone zabbixZone (active) target: ACCEPT icmp-block-inversion: no interfaces: sources: 153.126.193.178 services: ports: 10050/tcp protocols: forward: no masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
最後にエージェントを起動。
CentOS 6
# service zabbix-agent start
# chkconfig zabbix-agent on
# chkconfig zabbix-agent --list
zabbix-agent 0:off 1:off 2:on 3:on 4:on 5:on 6:off
CentOS 7
# systemctl start zabbix-agent
# systemctl enable zabbix-agent
# systemctl is-enabled zabbix-agent
enabled
これで行けるはず。