1、安装配置zabbix
1.1 环境准备
Ubuntu 18.04 :192.168.7.101 zabbix server
Ubuntu 18.04 :192.168.7.102 mysql
Ubuntu 18.04 :192.168.7.103 tomcat
1.2 准备mysql(192.168.7.102)
#apt install mysql-server
#mysql mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@"192.168.7.%" identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)
#vim /etc/mysql/mysql.conf.d/mysqld.cnf bind-address = *
#systemctl restart mysql
1.3 安装配置zabbix
#安装相关依赖
# apt install openjdk-8-jdk -y
# apt-get install apache2 apache2-bin apache2-data apache2-utils \fontconfig-config fonts-dejavu-core fping libapache2-mod-php \
libapache2-mod-php7.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 \
libaprutil1-ldap libfontconfig1 libgd3 libiksemel3 \
libjbig0 libjpeg-turbo8 libjpeg8 liblua5.2-0 libodbc1 \
libopenipmi0 libsensors4 \
libsnmp-base libsnmp30 libsodium23 libssh2-1 \
libtiff5 libwebp6 libxpm4 php-bcmath php-common php-gd php-ldap \
php-mbstring php-mysql php-xml php7.2-bcmath php7.2-cli \
php7.2-common php7.2-gd php7.2-json php7.2-ldap php7.2-mbstring \
php7.2-mysql php7.2-opcache php7.2-readline php7.2-xml snmpd ssl-cert \
ttf-dejavu-core libmysqlclient-dev libxml2-dev libxml2 snmp \
libsnmp-dev libevent-dev openjdk-8-jdk curl libcurl4-openssl-dev lrzsz php-fpm -y
#编译安装zabbix
# groupadd -r zabbix && useradd -g zabbix -r zabbix
# cd /usr/local/src/
# wget https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.24.tar.gz
# tar xvf zabbix-4.0.24.tar.gz
# cd zabbix-4.0.24/
# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-java
# make && make install
#初始化数据库
#mysql -uzabbix -p123456 -h192.168.7.102 zabbix < database/mysql/schema.sql
#mysql -uzabbix -p123456 -h192.168.7.102 zabbix < database/mysql/images.sql
#mysql -uzabbix -p123456 -h192.168.7.102 zabbix < database/mysql/data.sql
#编辑zabbix_server.con配置文件
#mkdir /var/log/zabbix && chown zabbix.zabbix /var/log/zabbix -R
#grep "^[a-Z]" /usr/local/zabbix/etc/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log
PidFile=/usr/local/zabbix/run/zabbix_server.pid
DBHost=192.168.7.102
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=3306
Timeout=30
LogSlowQueries=3000
#制作zabbix-server systemd启动脚本
#mkdir /usr/local/zabbix/run
#chown zabbix.zabbix /usr/local/zabbix/run
#cat /lib/systemd/system/zabbix-server.service [Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf"
EnvironmentFile=-/etc/default/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/usr/local/zabbix/run/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/local/zabbix/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=0s
[Install]
WantedBy=multi-user.target
#启动zabbix
#systemctl daemon-reload
#systemctl start zabbix-server
#systemctl enable zabbix-server Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /lib/systemd/system/zabbix-server.service
#启动apache2
#rm-f /var/www/html/*
#cp -a /usr/local/src/zabbix-4.0.24/frontends/php/* /var/www/html/
#systemctl restart apache2
#访问zabbix
#解决报错,配置php限制
#vim /etc/php/7.2/apache2/php.ini post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
# systemctl restart apache2
上传配置
1.4 设置中文界面
看系统内安装的locale:locale -a
若未装入中文语言包,安装zh_CN.UTF-8:locale-gen zh_CN.UTF-8
#sudo dpkg-reconfigure locales
#vim /var/www/html/include/locales.inc.php 'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => true]
1.5 解决中文乱码
将:\Windows\Fonts中文字体导入/var/www/html/fonts目录中:SIMSUN.TTC
# vim /var/www/html/include/defines.inc.phpdefine('ZBX_GRAPH_FONT_NAME', 'DejaVuSans');
define('ZBX_FONT_NAME', 'DejaVuSans');
修改为
define('ZBX_GRAPH_FONT_NAME', 'SIMSUN');
define('ZBX_FONT_NAME', 'SIMSUN');
2、监控tomcat(待完成)
2.1 配置zabbix服务端
#grep "^[a-Z]" /usr/local/zabbix/sbin/zabbix_java/settings.sh LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
PID_FILE="/tmp/zabbix_java.pid"
START_POLLERS=20
TIMEOUT=15
#启动
#chmod a+x /usr/local/zabbix/sbin/zabbix_java/*
#cd /usr/local/zabbix/sbin/zabbix_java
#sh startup.sh
#配置zabbix server调用java gateway
#grep "^[a-Z]" /usr/local/zabbix/etc/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log
PidFile=/usr/local/zabbix/run/zabbix_server.pid
DBHost=192.168.7.102
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=3306
JavaGateway=192.168.7.101
JavaGatewayPort=10052
StartJavaPollers=20
Timeout=30
LogSlowQueries=3000
#systemctl restart zabbix-server
2.2 配置tomcat (192.168.7.103 )
#apt install openjdk-8-jdk tomcat8 -y
#vim /usr/share/tomcat8/bin/catalina.sh CATALINA_OPTS="$CATALINA_OPTS
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=12345
-Djava.rmi.server.hostname=192.168.7.103"
#/usr/share/tomcat8/bin/catalina.sh stop
#/usr/share/tomcat8/bin/catalina.sh start
2.3配置zabbix客户端
#安装相关依赖
# apt install openjdk-8-jdk -y
# apt install libmysqld-dev libmysqlclient-dev libxml2-dev libxml2 snmp libsnmp-dev libevent-dev curl libcurl4-openssl-dev -y
#编译安装zabbix
# groupadd -r zabbix && useradd -g zabbix -r zabbix
# cd /usr/local/src/
# wget https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.24.tar.gz
# tar xvf zabbix-4.0.24.tar.gz
# cd zabbix-4.0.24/
# ./configure --enable-agent --prefix=/usr/local/zabbix
#编辑zabbix_agentd.conf配置文件
#grep "^[a-Z]" /usr/local/zabbix/etc/zabbix_agentd.conf LogFile=/tmp/zabbix_agentd.log
Server=192.168.7.101
ServerActive=127.0.0.1
Hostname=192.168.7.103
#/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf
2.4 下载工具包测试
http://crawler.archive.org/cmdline-jmxclient/downloads.html
#java -jar cmdline-jmxclient-0.10.3.jar - 192.168.7.103:12345 'Catalina:name="http-nio-8080",type=ThreadPool' maxThreads 09/01/2020 21:12:31 +0800 org.archive.jmx.Client maxThreads: 200