Zabbix

Zabbix 是由 Alexei Vladishev 開發的一種網路監視、管理系統,基於 Server-Client 架構。可用於監視各種網路服務、伺服器和網路機器等狀態。 Zabbix 使用 MySQL、PostgreSQL、SQLite、Oracle 或 IBM DB2 儲存資料。

AIX Configure SNMP

Reference

Requirements

Hardware

 

 

 

Installation

Tutorials
Platform to install
Zabbix Version 5.0 LTS
OS Distribution CENTOS
OS Version 7
Database MySQL
Web Server Apache
Prerequisites

php 7.2

Zabbix frontend requires PHP version 7.2 or newer starting with Zabbix 5.0. Note that RHEL/CentOS 7 only provide PHP 5.4. So don't install the php for pre-installed version on system.

Step 1: Install and Configure Apache httpd server
yum install httpd
systemctl start httpd
systemctl enable httpd
Step 2: Install MariaDB Database server

Remove MariaDB 5.x

systemctl stop mariadb
yum remove mariadb mariadb-server mariadb-libs

Add new MariaDB repository
https://downloads.mariadb.org/mariadb/repositories/#mirror=mephi&distro=CentOS&distro_release=centos7-amd64--centos7

vi /etc/yum.repos.d/mariadb.repo
# MariaDB 10.5 CentOS repository list - created 2020-08-17 13:04 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Install MariaDB

yum clean all
yum install MariaDB-server MariaDB-client

Config MariaDB

vi /etc/my.cnf.d/server.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mariadb/mariadb.log

新增目錄

mkdir /var/log/mariadb
chown mysql.mysql /var/log/mariadb

Start MariaDB

systemctl start mariadb
systemctl enable mariadb

Initial DB Configuration and set password for root

mysql_secure_installation
Step 3: Install and configure Zabbix server

a. Install Zabbix repository

# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all

b. Install Zabbix server and agent

# yum install zabbix-server-mysql zabbix-agent zabbix-get

c. Install Zabbix frontend
Enable Red Hat Software Collections

# yum install centos-release-scl

Install Zabbix frontend packages.

This step will install the php 7.2 packages required for Zabbix.

# yum-config-manager --enable zabbix-frontend
# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl

如果沒有安裝 yum-config-manager,可以改用以下指令安裝:

yum --enablerepo=zabbix-frontend

d. Create initial database
Run the following on your database host.
# mysql -uroot -p <<MYSQL_EOF
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'thisispassword';
grant all privileges on zabbix.* to zabbix@localhost;
MYSQL_EOF
On Zabbix server host import initial schema and data. You will be prompted to enter your newly created password.
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
e. Configure the database for Zabbix server
Edit file /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=password
f. Configure PHP for Zabbix frontend
Edit file /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf, uncomment and set the right timezone for you.
php_value[date.timezone] = Asia/Taipei
g. Start Zabbix server and agent processes
Start Zabbix server and agent processes and make it start at system boot.
# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
h. Configure Zabbix frontend
Connect to your newly installed Zabbix frontend: http://server_ip_or_name/zabbix
zabbix-install-home.png
Optional: Other Zabbix components Installation
Zabbix-Proxy
yum install zabbix-proxy-mysql
Java Gateway
yum install zabbix-java-gateway

Quickstart

Login and Configure user

Default login: Admin / zabbix

Adding User)

Administration -> Users

 

Zabbix Agent

AIX

Download: https://www.zabbix.com/download

AIX 7.2

# Using smitty users to add a user zabbix and the home directory is /usr/local/zabbix

# Untar the zabbix source
su - zabbix
gunzip -c zabbix_agent-4.0.7-aix-7.2-powerpc.tar.gz | tar -xf -

# Edit the config file
vi /usr/local/zabbix/conf/zabbix_agentd.conf

Server=<Zabbix-Server-IP>
ServerActive=<Zabbix-Server-IP>
Hostname=<agent-hostname>

# Startup the agent
/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/conf/zabbix_agentd.conf

start.sh

#!/usr/bin/env bash

zabbix_home="/usr/local/zabbix"
cd $zabbix_home
pid=$(ps -ef | grep "zabbix_agentd.conf" | grep -v grep | awk '{print $2}')
[ -n "$pid" ] && echo "The Zabbix is already running!" && exit
$zabbix_home/sbin/zabbix_agentd -c $zabbix_home/conf/zabbix_agentd.conf
[ $? -eq 0 ] && echo "Started the zabbix"

stop.sh

#!/usr/bin/env bash

zabbix_home="/usr/local/zabbix"
pid=$(ps -ef | grep "zabbix_agentd.conf" | grep -v grep | awk '{print $2}')
[ -n "$pid" ] && kill $pid && echo "Killed the zabbix"