一 、系统环境
- CentOS 7.9
- zabbix-4.0.33.tar.gz
- 模板下载:https://share.zabbix.com/
1.1 源码安装
下载源码包:
wget https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.33.tar.gz
添加zabbix用户
groupadd --system zabbix useradd --system -g zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix or groupadd --system zabbix useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
安装依赖:
yum -y install telnet net-tools python-paramiko dejavu-sans-fonts python-setuptools python-devel sendmail mailx net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasnl-devel pll-kit-devel OpenIPMI unixODBC libevent-devel mysql-devel libxml2-devel libssh2-devel OpenIPMI-devel openldap-devel curl-devel unixODBC-devel wget gcc gcc-c++ go
编译安装:agent
./configure --prefix=/usr/local/zabbix \ --enable-server --enable-agent --enable-agent2 \ --with-mysql --with-net-snmp \ --with-libcurl --with-openipmi\ --with-libxml2 --enable-proxy
编译安装enable-agent2
go: github.com/dustin/[email protected]: Get "https://proxy.golang.org/github.com/dustin/gomemcached/@v/v0.0.0-20160817010731-a2284a01c143.mod": dial tcp 172.217.160.113:443: connect: connection refused make[2]: *** [build] Error 1 make[2]: Leaving directory `/root/zabbix-5.0.24/src/go' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/root/zabbix-5.0.24/src' make: *** [all-recursive] Error 1
解决方法 配置GO国内代理
go env -w GOPROXY=https://goproxy.cn
输出
Configuration: Detected OS: linux-gnu Install path: /usr/local/zabbix Compilation arch: linux Compiler: cc Compiler flags: -g -O2 Library-specific flags: database: -I/usr/local/mariadb/include/mysql -I/usr/local/mariadb/include/mysql/mysql libXML2: -I/usr/include/libxml2 unixODBC: -I/usr/include Net-SNMP: -I/usr/local/include -I/usr/lib64/perl5/CORE -I. -I/usr/include OpenIPMI: -I/usr/include libssh2: -I/usr/include LDAP: -I/usr/include iconv: -I/usr/include Enable server: yes Server details: With database: MySQL WEB Monitoring: cURL SSL certificates: /usr/local/zabbix/share/zabbix/ssl/certs SSL keys: /usr/local/zabbix/share/zabbix/ssl/keys Native Jabber: no SNMP: yes IPMI: yes SSH: yes (libssh2) TLS: no ODBC: yes Linker flags: -L/usr/local/mariadb/lib/ -L/usr/lib64 -L/usr/lib64 -L/usr/lib -L/usr/lib -L/usr/lib -rdynamic -L/usr/lib Libraries: -lmariadb -lxml2 -lodbc -lnetsnmp -lssh2 -lOpenIPMI -lOpenIPMIposix -lz -lpthread -levent -lldap -llber -lcurl -lm -ldl -lresolv -lpcre Configuration file: /usr/local/zabbix/etc/zabbix_server.conf External scripts: /usr/local/zabbix/share/zabbix/externalscripts Alert scripts: /usr/local/zabbix/share/zabbix/alertscripts Modules: /usr/local/zabbix/lib/modules Enable proxy: yes Proxy details: With database: MySQL WEB Monitoring: cURL SSL certificates: /usr/local/zabbix/share/zabbix/ssl/certs SSL keys: /usr/local/zabbix/share/zabbix/ssl/keys SNMP: yes IPMI: yes SSH: yes (libssh2) TLS: no ODBC: yes Linker flags: -L/usr/local/mariadb/lib/ -L/usr/lib64 -L/usr/lib64 -L/usr/lib -L/usr/lib -L/usr/lib -rdynamic -L/usr/lib Libraries: -lmariadb -lxml2 -lodbc -lnetsnmp -lssh2 -lOpenIPMI -lOpenIPMIposix -lz -lpthread -levent -lldap -llber -lcurl -lm -ldl -lresolv -lpcre Configuration file: /usr/local/zabbix/etc/zabbix_proxy.conf External scripts: /usr/local/zabbix/share/zabbix/externalscripts Modules: /usr/local/zabbix/lib/modules Enable agent: yes Agent details: TLS: no Linker flags: -L/usr/lib -rdynamic -L/usr/lib Libraries: -lz -lpthread -lldap -llber -lcurl -lm -ldl -lresolv -lpcre Configuration file: /usr/local/zabbix/etc/zabbix_agentd.conf Modules: /usr/local/zabbix/lib/modules Enable Java gateway: yes Java gateway details: Java compiler: javac Java archiver: jar LDAP support: yes IPv6 support: no
- Now run 'make install' *
- *
- Thank you for using Zabbix! *
安装
make && make install
zabbix 目录
[root@C20210910156669 zabbix-4.0.33]# tree /usr/local/zabbix/ /usr/local/zabbix/ ├── bin │ ├── zabbix_get │ └── zabbix_sender ├── etc │ ├── zabbix_agentd.conf │ ├── zabbix_agentd.conf.d │ ├── zabbix_proxy.conf │ ├── zabbix_proxy.conf.d │ ├── zabbix_server.conf │ └── zabbix_server.conf.d ├── lib │ └── modules ├── sbin │ ├── zabbix_agentd │ ├── zabbix_java │ │ ├── bin │ │ │ └── zabbix-java-gateway-4.0.33.jar │ │ ├── lib │ │ │ ├── android-json-4.3_r3.1.jar │ │ │ ├── logback-classic-1.2.3.jar │ │ │ ├── logback-console.xml │ │ │ ├── logback-core-1.2.3.jar │ │ │ ├── logback.xml │ │ │ └── slf4j-api-1.7.30.jar │ │ ├── settings.sh │ │ ├── shutdown.sh │ │ └── startup.sh │ ├── zabbix_proxy │ └── zabbix_server └── share ├── man │ ├── man1 │ │ ├── zabbix_get.1 │ │ └── zabbix_sender.1 │ └── man8 │ ├── zabbix_agentd.8 │ ├── zabbix_proxy.8 │ └── zabbix_server.8 └── zabbix ├── alertscripts └── externalscripts
二、数据库:
安装数据库
yum install -y mariadb-server
启动数据库
systemctl start mariadb.service
数据库启动状态
systemctl status mariadb.service
输出
● mariadb.service - LSB: start and stop MariaDB Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled) Active: active (exited) since Fri 2021-09-17 03:14:03 CST; 2 days ago Docs: man:systemd-sysv-generator(8) Sep 17 03:14:01 C20210910156669 systemd[1]: Starting LSB: start and stop MariaDB... Sep 17 03:14:02 C20210910156669 mysqld[817]: Starting MariaDB.210917 03:14:02 mysqld_safe Loggin...g'. Sep 17 03:14:02 C20210910156669 mysqld[817]: 210917 03:14:02 mysqld_safe Starting mariadbd daemo...adb Sep 17 03:14:03 C20210910156669 mysqld[817]: [ OK ] Sep 17 03:14:03 C20210910156669 systemd[1]: Started LSB: start and stop MariaDB. Hint: Some lines were ellipsized, use -l to show in full.
创建数据库
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.002 sec)
用户授权
MariaDB [(none)]> GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'zabbix'; Query OK, 0 rows affected (0.009 sec) or mysql -uroot -p<password> create database zabbix character set utf8 collate utf8_bin; create user 'zabbix'@'localhost' identified by '<password>'; grant all privileges on zabbix.* to 'zabbix'@'localhost';
导入zabbix表结构
mysql -uzaUser -ppassword zabbix < schema.sql mysql -uzaUser -ppassword zabbix < image.sql mysql -uzaUser -ppassword zabbix < data.sql
Mariadb 10 导入报错
mysql -uzaUser -ppassword zabbix < schema.sql ERROR 1118 (42000) at line 1278: Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.
编辑 my.cnf
innodb_strict_mode = 0 添加到 [mysqld]中,后重启mariadb
编辑 zabbix_server.conf
[root@C20210910156669 etc]# grep -Ev "^#|^$" zabbix_server.conf LogFile=/tmp/zabbix_server.log DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix DBSocket=/tmp/mysql.sock DBPort=3306 Timeout=4 LogSlowQueries=3000 AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts
编辑 php.ini文件 先决条件 最低要求 描述 PHP 版本 5.4.0 - PHP memory_limit 选项 128MB 位于 php.ini:memory_limit = 128M PHP post_max_size 选项 16MB 位于 php.ini:post_max_size = 16M PHP upload_max_filesize 选项 2MB 位于 php.ini:upload_max_filesize = 2M PHP max_execution_time 选项 300 seconds (此值允许为 0 和 -1 ) 位于 php.ini:max_execution_time = 300 PHP max_input_time 选项 300 seconds (此值允许为 0 和 -1) 位于 php.ini:max_input_time = 300 PHP session.auto_start 选项 必须禁用此值 In php.ini:session.auto_start = 0 数据库支持 其中之一: MySQL,、Oracle、PostgreSQL、IBM DB2 必须安装下列模块中的一种:mysql、oci8、pgsql、ibm_db2 bcmath php-bcmath - mbstring php-mbstring - PHP mbstring.func_overload选项 必须禁用此值 位于 php.ini:mbstring.func_overload = 0 PHP always_populate_raw_post_data option 必须禁用此值 只适用于 PHP 5.6.0 或更高的版本。位于 php.ini:always_populate_raw_post_data = -1 sockets - php-net-socket 用于支持用户脚本。 gd 2.0 或更高 php-gd. PHP GD 扩展必须支持 PNG 图像 (--with-png-dir),、JPEG (--with-jpeg-dir) 图像和 FreeType 2 (--with-freetype-dir). libxml 2.6.15 php-xml or php5-dom xmlwriter - php-xmlwriter xmlreader - php-xmlreader ctype - php-ctype session - php-session gettext php-gettext 从 Zabbix 2.2.1 起,PHP gettext 扩展不是安装 Zabbix 的强制性要求。如果 gettext 没有安装,前端也可以照常运行,但翻译将不可用。
三、zabbix登录异常
[Tips]
解决方法
修改 php.ini
cgi.fix_pathinfo=0
修改为:
cgi.fix_pathinfo=1
四、获取Windows 监控资源
C:\>typeperf
缺少参数:
缺少参数: -cf
缺少参数: -q [object]
缺少参数: -qx [object]
typeperf -qx > typeperf.txt
五、监控Windows Server
编辑zabbix_agent.conf 添加自定义监控项
# Mandatory: no
# Default:
# UserParameter=
PerfCounter=UserPerfCounterdiskBytesRead,"\LogicalDisk(C:)\Disk Read Bytes/sec",3
PerfCounter=UserPerfCounterdiskBytesWrite,"\LogicalDisk(C:)\Disk Write Bytes/sec",3
学习下,感谢分享.....