“Zabbix 5 4 and 3 LTS安装入门教程”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
 
(未显示同一用户的5个中间版本)
第549行: 第549行:
 
<pre>
 
<pre>
  
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
+
#rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
 +
rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
 +
 
 +
yum install zabbix-agent2
 +
 
 +
systemctl restart zabbix-agent2
 +
systemctl enable zabbix-agent2
  
 
</pre>
 
</pre>
 +
https://www.zabbix.com/download?zabbix=5.0&os_distribution=centos&os_version=7&components=agent_2&db=&ws=
  
 
==docker zabbix 5.0==
 
==docker zabbix 5.0==
第647行: 第654行:
  
 
</pre>
 
</pre>
 +
 +
[https://blog.csdn.net/qq_28903377/article/details/128091565  zabbix监控触发器与报警动作]
  
 
https://www.zabbix.com/cn/integrations/telegram#tab:official1
 
https://www.zabbix.com/cn/integrations/telegram#tab:official1
第817行: 第826行:
 
=== zbx红红===
 
=== zbx红红===
 
  Server ServerActive 两个都要写上
 
  Server ServerActive 两个都要写上
 +
 +
=== Zabbix server: Utilization of housekeeper internal processes, in %”===
 +
 +
为了防止数据库持续增大,Zabbix有自动删除历史数据的机制,即housekeeper,而在频繁清理历史数据的时候,MySQL数据库可能出现性能降低的情况,此时就会告警。
 +
 +
一般来说,Zabbix都会监控Zabbix Server本身。如下所示,我们可以分析“Zabbix server: Utilization of housekeeper internal processes, in %”图形,通过分析,我们可以看到Zabbix housekeeper processes在10点32分的时候, housekeeper进程突然开始繁忙
 +
 +
[https://www.cnblogs.com/kerrycode/p/13570463.html Zabbix housekeeper processes more than 75% busy原因分析]
  
 
==参考==
 
==参考==

2022年12月8日 (四) 06:17的最新版本

站内资源

Zabbix 调用API 批量添加主机

zabbix server

pre

lnmp 这些是官网官方安装文档,记得一定要看

https://www.zabbix.com/documentation/5.0/zh/manual/installation/install

https://www.zabbix.com/documentation/3.0/manual/installation/install

https://www.zabbix.org/wiki/InstallOnCentOS_RHEL

Python自动化运维-zabbix-监控系统的实现原理

wget -c  https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.13.tar.gz
#https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.8/zabbix-3.0.8.tar.gz

#wget -c http://tenet.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.13/zabbix-2.2.13.tar.gz

#配置php变量

vi /etc/php.ini

如果是php7.3 
find / -name php.ini
/etc/php/7.3/cli/php.ini
/etc/php/7.3/fpm/php.ini


date.timezone = Asia/Shanghai
post_max_size = 32M
max_execution_time = 300
max_input_time = 300
注:更改完之后需要重启nginx和php

#安装zabbix所需的组件

yum -y install net-snmp-devel curl-devel
#yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath
groupadd zabbix && useradd -g zabbix zabbix

#if debian10 
apt install libmariadb-dev-compat libmariadb-dev  libxml2-dev libsnmp-dev snmp  libxml++2.6-dev libevent-dev libcurl4-openssl-dev

tar xvf zabbix-3.0.8.tar.gz && cd zabbix-3.0.8
#tar xvf zabbix-2.2.13.tar.gz && cd zabbix-2.2.13

#./configure –enable-server –enable-agent –with-mysql –enable-ipv6 –with-net-snmp –with-libcurl –with-libxml2

##或者默认安装路径 make是不用的
./configure --sysconfdir=/etc/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 && make install


#2021 5.0 lst 官方  不要忘记了make install 
#使用Zabbix自带模板监控MySQL时,Zabbix Server编译时需要使用“--with-libxml2”加入“libxml2”库
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 && make install 


#如果要配置 Zabbix server 和 Zabbix proxy 的源代码,您可以运行以下内容:
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

添加zabbix服务对应的端口(可以省略,但是官方建议有)

cat >>/etc/services<< EOF
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
EOF

配置文件

##好像是这个起效果的呢 –sysconfdir=/etc/zabbix 有这个,不用下面的命令了
#vim /usr/local/etc/zabbix_server.conf
#cd zabbix-2.0.7

#mkdir /etc/zabbix
#cp conf/*.conf /etc/zabbix

mkdir /var/log/zabbix ;chown zabbix:zabbix /var/log/zabbix;

#zabbix web代码 3.0
mkdir -p /data/www/zabbix;
cp -r frontends/php/* /data/www/zabbix

#5.0 web  参考 debian lnmp 
[https://wiki.linuxchina.net/index.php/Lnmp debina lnmp]
cp -a  ui/* /var/www/html/z.cn

记得要先下面的db 导入
http://z.cn/setup.php #最后跑起来后 要下载配置文件的 有如mediawiki


find / -name php.ini
/etc/php/7.3/cli/php.ini
/etc/php/7.3/fpm/php.ini





修改zabbix连接的数据库的用户名和密码
vi /etc/zabbix/zabbix_server.conf

DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword='123'
DBPort=3306 #如果数据库是用sock文件的方式,这里可以是sock文件的路径

添加数据库Lib文件位置到/etc/ld.so.conf中,并使其生效
echo ‘/usr/local/mysql/lib/mysql/’ >> /etc/ld.so.conf

ldconfig

为zabbix的启动、关闭和重启的脚本文件做链接,方便系统可以找得到

给zabbix服务端程序做软链接 我用默认的config 应该是不用的
cd /usr/local/zabbix/bin/
for i in *;do ln -s /usr/local/zabbix/bin/${i} /usr/bin/${i};done
cd /usr/local/zabbix/sbin/
for i in *;do ln -s /usr/local/zabbix/sbin/${i} /usr/sbin/${i};done

拷贝zabbix服务端和客户端启动脚本到/etc/init.d目录下.
cp  misc/init.d/debian/{zabbix_agentd,zabbix_server}  /etc/init.d/;chmod o+x /etc/init.d/zabbix_*
  /etc/init.d/zabbix_server start 
 /etc/init.d/zabbix_server status 


#这些老的 
cd misc/init.d/
cp fedora/core/zabbix_server /etc/init.d/
cp fedora/core/zabbix_agentd /etc/init.d/
chmod +x /etc/init.d/zabbix_agentd
chmod +x /etc/init.d/zabbix_server

成功说明


config.status: executing depfiles commands
configure: WARNING: unrecognized options: --with-libxml



 Libraries:              -lmariadb        -lnetsnmp    -lz -lpthread -levent    -lcurl -lm -ldl  -lresolv -lpcre 
    Configuration file:    /usr/local/etc/zabbix_server.conf
    External scripts:      /usr/local/share/zabbix/externalscripts
    Alert scripts:         /usr/local/share/zabbix/alertscripts
    Modules:               /usr/local/lib/modules

  Enable proxy:          no

  Enable agent:          yes
  Agent details:
    TLS:                   no
    Linker flags:                -rdynamic   
    Libraries:              -lz -lpthread    -lcurl -lm -ldl  -lresolv -lpcre 
    Configuration file:    /usr/local/etc/zabbix_agentd.conf
    Modules:               /usr/local/lib/modules




3 Create Zabbix database

SQL scripts are provided for creating database schema and inserting the dataset
#https://www.zabbix.com/documentation/3.0/manual/appendix/install/db_scripts
#https://www.zabbix.com/documentation/2.2/manual/appendix/install/db_scripts

mysql>create database zabbix character set utf8 collate utf8_bin;;grant all on zabbix.* to zabbix@localhost identified by '123';flush privileges;

将zabbix源码包中的数据导入到新建的zabbix数据库
##这个和老的版本有点不同 第一个是zabbix的数据库表结构,要先导入。

. /etc/profile
cd ../..
cd zabbix-5.0.13/database/mysql
mysql -uroot -p'evan' zabbix< database/mysql/schema.sql
mysql -uroot -p'evan' zabbix< database/mysql/images.sql
mysql -uroot -p'evan' zabbix< database/mysql/data.sql

vi /etc/init.d/zabbix_server # 的可以不改,修改一下变量的值 因为我是默认用 configure
# base zabbix dir
BASEDIR=/usr/local
# binary file
ZABBIX_SUCKERD=$BASEDIR/sbin/zabbix_server

fping的安装和使用详解

http://rickie622.blog.163.com/blog/static/2123881120121121111720941/
http://netsecurity.51cto.com/art/201101/242200.htm
#当然 下载zip包也是可以的
git clone https://github.com/schweikert/fping.git
cd fping
./autogen.sh
./configure
make -j2 && make install

#修改一下配置文件
vim /etc/zabbix_server.conf
#vim /usr/local/etc/zabbix_server.conf
FpingLocation=/usr/local/sbin/fping

启动zabbix,并且添加开机自启动

service zabbix_server start
service zabbix_agentd start #启动服务

chkconfig zabbix_server on
chkconfig zabbix_agentd on #开机自启动

在Nginx服务中添加zabbix虚拟主机
#vim /usr/local/nginx/conf/vhosts/monitor.conf

这些都不要,不然没有web安装向导的
#cd zabbix/conf
#cp zabbix.conf.php.example zabbix.conf.php ;
#chmod 777 zabbix.conf.php

iptables -I INPUT -p tcp –dport 80 -j ACCEPT

zabbix server is not running
Zabbix Server is not running: the information displayed may not be current
http://song49.blog.51cto.com/4480450/1200151

web config

Alternatively, you can install it manually:

    Download the configuration file
    Save it as "/var/www/za.com/conf/zabbix.conf.php"


用户 Admin  密码zabbix

vim /usr/local/etc/zabbix_server.conf
#add 
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456

(4)设置zabbix服务IP和端口,name可以忽略

ps:
post_max_size = 16M
PHP option “max_execution_time” 30 300 Fail
PHP option “max_input_time” 60 300 Fail
PHP option “date.timezone” unknown Fai
date.timezone = Asia/Shanghai

PHP option “always_populate_raw_post_data” must be set to “-1”

port 10051

Zabbix frontend is ready! The default user name is Admin, password zabbix.

超级用户密码修改

2.2 用户名第一个字母要大写 也就是Admin
默认的用户名:admin 密码:zabbix

哪里改登录用户和密码呢
use zabbix;
select userid,alias,passwd from users; #查看

+--------+------------+----------------------------------+
| userid | alias      | passwd                           |
+--------+------------+----------------------------------+
|      1 | Admin      | 5fce1b3e34b520afeffb37ce08c7cd66 |


#如果为zabbix 3.0  直接这样就行了 
update users set passwd=MD5('12345') where userid=1;


#zabbix 2.x 
重新开个终端,生成一个MD5加密的密码,这里密码设置的是redhat

[root@localhost ~]# echo -n 12345678 |openssl md5 #-n就表示不输入回车符,不加-n,否则就不是这个结果了。
(stdin)= 25d55ad283aa400af464c76d713c07ad

接着上面的为admin用户设定一个密码

mysql> update users set passwd='25d55ad283aa400af464c76d713c07ad' where userid = '1';
#或者直接使用update users set passwd=md5(“12345678”) where userid=’1′;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye

zabbix登陆账户admin密码修改
http://pvbutler.blog.51cto.com/7662323/1734003

yum install ntp ntpdate -y
chkconfig ntpd on
/etc/init.d/ntpd start

*/30 * * * * /usr/sbin/ntpdate pool.ntp.org

在29行这后添加
sed -i ’29a user=mysql’ /etc/my.cnf
sed -i ’29a character-set-server=utf8′ /etc/my.cnf
sed -i ’29ainnodb_file_per_table=1′ /etc/my.cnf
重启mysqld

防火墙设置

这个要看一下先,尽量用严格些的防火墙设置

#on zabbix-agent

iptables -A INPUT -s zabbixserverip  -p tcp -m tcp --dport 10050 -m comment --comment "zabbix_server listen " -j ACCEPT 
#iptables -A INPUT -s zabbixserverip  -p tcp -m tcp --dport 10050 -m comment --comment "zabbix_agentd listen " -j ACCEPT 

#这下面的防火墙rule 不要用 
vi /etc/sysconfig/iptables
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 10050 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 10051 -j ACCEPT

/etc/init.d/iptables restart

中文在右上角的用户里面哦

Starting php_fpm /usr/local/php/bin/php-cgi: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
failed

by default install the daemon binaries (zabbix_server, zabbix_agentd, zabbix_proxy) in /usr/local/sbin and the client binaries (zabbix_get, zabbix_sender) in /usr/local/bin.

5.2 图像显示字体乱码的解决方法

#version 4.0 and  5.x    to web  eg  zabbix_zabbix-web-nginx-pgsql
另外一种思路  不改配置文件 而是把新的字体起和原来一样的名 
on 
~/data/fonts/wqy-microhei.ttc
#NB
root@myxps:/var/www/za.com/assets/fonts# mv DejaVuSans.ttf DejaVuSans.ttfbak
root@myxps:/var/www/za.com/assets/fonts# ln -s wqy-microhei.ttc DejaVuSans.ttf



1.替换支持中文的字体
#传输字体  或者-u root 
#50fbe46d4c5c        zabbix/zabbix-web-nginx-pgsql:alpine-5.2-latest
docker cp simkai.ttf 50fbe46d4c5c:/usr/share/zabbix/assets/fonts

 cp  /root/STKAITI.TTF  /usr/share/zabbix/assets/fonts
  
2.修改字体配置 php文件
 #修改 指定的字体 或者直接把你的家体改成和默认同名,而默认的那个先删除 连重启都不用 反正在docker
  grep  -rn  BX_GRAPH_FONT_NAM   /usr/share/zabbix/include/defines.inc.php
67:define('ZBX_GRAPH_FONT_NAME',		'DejaVuSans'); // font file name

修改
sed  -i  's!DejaVuSans!simkai!' include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME',           'simkai');  

5.1  jul 10 2021
cp /home/evan/data/fonts/wqy-microhei.ttc  /var/www/za.com/assets/fonts/

vim include/defines.inc.php #zabbixweb

zabbix-get

root@zabbix-server ~]#zabbix_get  -s 10.3.10.139 -k "system.hostname"
dev-hello-market


不过使用zabbix_get时必须开启客户端被动模式,要求暴露客户端监听端口。

自动化监控--zabbix-get安装使用详解

第二 agent

agent on docker 监控zabbix on docker

#安装zabbix-agent监控主机代理
docker run --name zabbix-agent-onserver --add-host=dockerhost:`docker network inspect --format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' bridge` -p 10050:10050 -e ZBX_HOSTNAME="localhost" -e ZBX_SERVER_HOST=`docker network inspect --format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' bridge`  -e ZBX_SERVER_PORT=10051 -d zabbix/zabbix-agent:alpine-5.0-latest

命令分解和得出填写web的ip  172.17.0.1

 docker network inspect --format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' bridge
172.17.0.1

docker run --name zabbix-agent-onserver --add-host=dockerhost:172.17.0.1 -p 10050:10050 -e ZBX_HOSTNAME="localhost" -e ZBX_SERVER_HOST=172.17.0.1  -e ZBX_SERVER_PORT=10051 -d zabbix/zabbix-agent:alpine-5.0-latest

这个其实第一个网口 
Zabbix server	172.16.238.1: 10050  或者 填写  172.17.0.1  


root@ agetmp]# ifconfig 
br-33705d169fa7: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.238.1  netmask 255.255.255.0  broadcast 172.16.238.255
        ether 02:42:de:ce:32:f1  txqueuelen 0  (Ethernet)
        RX packets 7863  bytes 604307 (590.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8162  bytes 2526914 (2.4 MiB)
        TX errors 0  drop

解决的问题  监控server出现的问题

解决 Zabbix 系统告警 “Zabbix agent is not available (for 3m)“

Received empty response from Zabbix Agent at [172.16.0.42]. Assuming that agent dropped connection because of access permissions.

Zabbix(Docker版) Agent 配置

yum


#5.0 #centos7 快速安装和自动配置 Oct 14  2021
rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

#4.0 #centos7 快速安装和自动配置 2019年 8月23日 星期五 11时45分01秒 CST

#国外
rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm

#国内
https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm

手工直接添加  repo文件 ,如果有时 不小心 像上次删除了 reop文件 一样 ,搞半天 

cat <<EOF > /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - \$basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/\$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
 
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - \$basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/\$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
EOF

curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591 \
-o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
 
curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX \
-o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX



yum install zabbix-agent -y

yum install ntp  -y
timedatectl set-ntp true

HOSTNAME=prod-java-02

#config
sed -i "s/^Server=127.0.0.1/Server=172.16.1.9/ " /etc/zabbix/zabbix_agentd.conf

sed -i "s/^ServerActive=127.0.0.1/ServerActive=172.16.1.9/"  /etc/zabbix/zabbix_agentd.conf
sed  -i "s/^Hostname=Zabbix server/Hostname=test-market/"  /etc/zabbix/zabbix_agentd.conf



#这个用了HOSTNAME 变量  而上面的要指定hostname
sed  -i 's/127.0.0.1/23.67.81.95/g'  /etc/zabbix/zabbix_agentd.conf
sed  -i "s/Hostname=Zabbix server/Hostname=${HOSTNAME}/g"  /etc/zabbix/zabbix_agentd.conf
grep "^\s*[^# \t].*$" /etc/zabbix/zabbix_agentd.conf

systemctl  enable  zabbix-agent.service
systemctl restart zabbix-agent


2021
添加配置后 模板选择 templa /operate /  of linux by zabbix agent or active
可用性 ZBX变为绿才行




下面是老的信息 和解说

cat /etc/zabbix/zabbix_agentd.conf
Hostname=主机名
Server=zabbix server ip
LogFile= 可以不改

# failed to accept an incoming connection: connection from 127.0.0.1
##最好这样3个 如果是server 加上 ,127.0.0.1  
Server=10.6.1.181
ServerActive=10.6.1.181
Hostname=zabbix-client-1


#rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
#rpm -ivh http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm
#http://repo.zabbix.com/zabbix/2.0/rhel/5/x86_64/zabbix-release-2.0-1.el5.noarch.rpm


rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

 

agent on debian

#用系统的源 
 apt-get install zabbix-agent


#config 其实和yum的也一样 只是启动不一样而已
HOSTNAME=wiki
sed -i "s/^Server=127.0.0.1/Server=207.148.106.229/ " /etc/zabbix/zabbix_agentd.conf

sed -i "s/^ServerActive=127.0.0.1/ServerActive=207.148.106.229/"  /etc/zabbix/zabbix_agentd.conf
sed  -i "s/^Hostname=Zabbix server/Hostname=wiki/"  /etc/zabbix/zabbix_agentd.conf

grep "^\s*[^# \t].*$" /etc/zabbix/zabbix_agentd.conf

service zabbix-agent start


 zabbix_get -s 138.68.59.0 -k "system.hostname"


#用zbx的源
  https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-3+buster_all.deb        
dpkg -i zabbix-release_stretch_all.deb
# apt-get update

https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages/repository_installation

https://www.zabbix.com/documentation/4.0/zh/manual/installation/install_from_packages/rhel_centos#%E5%AE%89%E8%A3%85_agent


国内zabbix源总结

https://www.cnblogs.com/caidingyu/p/11423089.html

https://blog.cactifans.com/2019/01/21/Zabbix%E5%9B%BD%E5%86%85%E6%BA%90%E4%BD%BF%E7%94%A8/


zabbix-agent2


#rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

yum install zabbix-agent2

systemctl restart zabbix-agent2
 systemctl enable zabbix-agent2

https://www.zabbix.com/download?zabbix=5.0&os_distribution=centos&os_version=7&components=agent_2&db=&ws=

docker zabbix 5.0

官方教程 值得细品 https://www.zabbix.com/documentation/5.0/zh/manual/installation/containers

zbx dbmysql

https://github.com/evan886/zabbix/tree/main/docker-compose-zabbix/dbmysql
#不能超过os内存 最终解决办法是os内存要超过4G
 cannot initialize configuration cache: cannot get private shared memory of size 4294967296 for configuration cache: [12] Out of memory
 
    - ZBX_CACHESIZE=2096M
    #- ZBX_CACHESIZE=4096M

用 Zabbix 和 Docker 搭建监控平台


Docker Compose 快速搭建zabbix监控系统

我的没有 zabbix web ui 明天搞一下 暴露端口 8888 用于访问页面,10051 用于和 Zabbix-agent 通信;

Zabbix 5.0 LTS新功能

011.Docker Compose部署Zabbix实战

zabbix docker-compose 运行配置

zbx pgsql

https://github.com/evan886/zabbix/tree/main/docker-compose-zabbix/zbx5.0lts_dbpg

正常的docker-compose  端口是8081  clone不了就直接 web 下载zip 文件吧 默认用户 密码 Admin zabbix
The Zabbix database version does not match current requirements pg 版本要对应得上  我是一开始改了 5.2的为5.0的导致 要全下载为5.0LTS


centos7安装zabbix5.0+nginx+postgresql

debian10 zabbix5

Lnmp debian



Debian 10 Buster上安装和配置Zabbix 5.0


源码安装Zabbix5.0监控系统

Usage

5.0查看 Latest data -->右边 Graph


 Notice 添加主机要添加 模板  不然 在监控--主机那 图形没东西 

https://www.zabbix.com/documentation/current/manual/quickstart/host


zabbix将多台机器的数据聚合到一个图中

查看hostid

http://z.cn/hosts.php?form=update&hostid=10084 一种简单的zabbix客户端 主机hostid查看方法


项目实战——企业级Zabbix监控实战(一)

添加用户 和用户组

添加用户前 要添加用户组 然后在里面指定用户是哪个组 看到哪些项目

用户群组->权限  选择你的机器 然后 读写什么的至少要选择一个 然后包括子组 下面的勾 以及更新 按键 不然老不成功

zabbix监控之用户及用户组

zabbix之建立普通用户登陆web界面


zabbix4.4新建用户组和用户权限设置

登陆和配置用户

zabbix自定义key值

zabbix监控(一)自定义key值

zabbix 自定义监控项

zabbix自定义key监控mysql

【zabbix】自定义监控项key值

Zabbix配置Telegram告警



zabbix监控触发器与报警动作

https://www.zabbix.com/cn/integrations/telegram#tab:official1

配置zabbix+telegram告警

zabbix+telegram的API接口(告警)

Zabbix配置Telegram告警(无坑文档)

zabbix 用Telegram报警!!!

zabbix+telegram的API接口(告警)

故障及回顾

docker zabbix5.0时区问题 时间差5/8小时



timezone 问题导致 web显示的时间和天时对不上 

grep -r "timezone" /etc/php7/


/usr/share/zabbix # ps -ef | grep php 
   19 zabbix    0:00 {php-fpm7} php-fpm: master process (/etc/php7/php-fpm.conf)
   25 zabbix    0:05 {php-fpm7} php-fpm: pool zabbix
   26 zabbix    0:05 {php-fpm7} php-fpm: pool zabbix
   27 zabbix    0:05 {php-fpm7} php-fpm: pool zabbix
   28 zabbix    0:06 {php-fpm7} php-fpm: pool zabbix
   29 zabbix    0:06 {php-fpm7} php-fpm: pool zabbix
   30 zabbix    0:05 {php-fpm7} php-fpm: pool zabbix
   31 zabbix    0:05 {php-fpm7} php-fpm: pool zabbix
   32 zabbix    0:05 {php-fpm7} php-fpm: pool zabbix
   53 zabbix    0:05 {php-fpm7} php-fpm: pool zabbix
   54 zabbix    0:06 {php-fpm7} php-fpm: pool zabbix
   55 zabbix    0:05 {php-fpm7} php-fpm: pool zabbix
  389 root      0:00 grep php
/usr/share/zabbix # cat /etc/php7/php.ini | grep timezone 
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Shanghai
/usr/share/zabbix # tail    /etc/php7/php-fpm.d/zabbix.conf 
php_value[session.save_path]    = /var/lib/php/session

php_value[max_execution_time] = ${ZBX_MAXEXECUTIONTIME}
php_value[memory_limit] = ${ZBX_MEMORYLIMIT}
php_value[post_max_size] = ${ZBX_POSTMAXSIZE}
php_value[upload_max_filesize] = ${ZBX_UPLOADMAXFILESIZE}
php_value[max_input_time] = ${ZBX_MAXINPUTTIME}
php_value[max_input_vars] = 10000
;php_value[date.timezone] = ${PHP_TZ}
php_value[date.timezone] = Asia/Shanghai 
/usr/share/zabbix # 

cat  /etc/php7/php-fpm.d/zabbix.conf 
过来的时区变量不生效 所以在zabbix.conf 配置里面写死

;php_value[date.timezone] = ${PHP_TZ}
php_value[date.timezone] = Asia/Shanghai 


受这个启发  ,搞了几天呢 
zabbix5.0时区问题 时间差5/8小时

[root@localhost ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai

填坑之路!玩转 Docker + Zabbix4.x 中你可能遇到的问题


问题1.  zabbix server 没有打开 10051端口 前端图形没显示 

版本zabbix 2.2 

没有看到 10051 是因为  

DBPassword=‘123’ 改为 DBPassword=123


日志查看 
 tail  /tmp/zabbix_server.log

14659:20170525:171042.257 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: YES)


正确如下 
[root@ zabbix]# netstat  -nlpt 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:10051

经常报Zabbix agent on Zabbix server is unreachable for 5 minutes


我上次的处理是 重启 zbx server 就好了 

zabbix-compilation-dependencies


解决Zabbix使用一段时间后总报Zabbix Agent不可到达的问题

防火墙导致 zabbix监控大批量报警zabbix agent on **** unreachable for 5 minute

zabbix server is running | No.解决方法

zabbix 5 

根据日志报错排查
cat /var/log/zabbix/zabbix_server.log

zabbix进程查看
ps aux |grep zabbix

查看监听zabbix server---------zabbix agent    10050---10051端口
netstat -nplut |grep zabbix

登陆报错解决    zabbix server is running | No.

解决方法1

setsebool -P httpd_can_network_connect on   selinux 允许它通过httpd服务

关闭selinux

永久关闭vi /etc/selinux/config

#SELINUX=disabled

#SELINUXTYPE=targeted

临时关闭 setenforce 0 

关闭防火墙

永久关闭 chkconfig iptables off

临时生效 iptables -F

解决方法2

cd /etc/zabbix/web/

修改配置文件

vi zabbix.conf.php

修改lochlhost为 自己服务器的IP地址

修改$DB['SERVER']   = '192.168.30.6';

修改$ZBX_SERVER     = '192.168.30.6';

重启服务

service httpd restart

service zabbix-agent restart

service zabbix-server restart


zbx红红

Server ServerActive 两个都要写上

Zabbix server: Utilization of housekeeper internal processes, in %”

为了防止数据库持续增大,Zabbix有自动删除历史数据的机制,即housekeeper,而在频繁清理历史数据的时候,MySQL数据库可能出现性能降低的情况,此时就会告警。

一般来说,Zabbix都会监控Zabbix Server本身。如下所示,我们可以分析“Zabbix server: Utilization of housekeeper internal processes, in %”图形,通过分析,我们可以看到Zabbix housekeeper processes在10点32分的时候, housekeeper进程突然开始繁忙

Zabbix housekeeper processes more than 75% busy原因分析

参考

使用Docker Compose启动Zabbix 5.0的步骤

Docker Compose 快速搭建zabbix监控系统

Install Zabbix Monitoring Server and Agent on Debian

zabbix--5.0.2部署使用手册

zabbix 3.0使用教程

Zabbix 3.0 详解:从添加主机到发送报警通知

Zabbix监控系统 (3) 之 添加自定义监控项目、配置邮件告警、测试告警

http://blog.linuxchina.net/?p=1711

Zabbix 3.0 with apache安装笔记

【zabbix】自定义监控项key值


zabbix添加自定义py脚本

用 Zabbix 和 Docker 搭建监控平台