zabbix 安装和使用
1.利用zabbix 源安装
增加zabbix源
1 | rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm |
安装zabbix服务端
1 | yum --enablerepo=zabbix install zabbix-server-mysql zabbix-web-mysql |
2 | yum --enablerepo=zabbix install zabbix-get |
安装zabbix客户端1
yum --enablerepo=zabbix install zabbix-agent
安装mysql
1 | yum install mariadb-server |
2 | systemctl enable mariadb |
3 | systemctl start mariadb |
配置mysql
1 | mysql -u root |
2 | >update mysql.user set password=password('zabbix') ; |
3 | >flush privilges |
4 | >create database zabbix character set utf8 collate utf8_bin; |
5 | >grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; |
导入数据库
1 | zcat /usr/share/doc/zabbix-server-mysql-3.2.*/create.sql.gz | mysql -uzabbix -p zabbix |
zabbix配置
1 | # vi /etc/zabbix/zabbix_server.conf |
2 | DBHost=localhost |
3 | DBName=zabbix |
4 | DBUser=zabbix |
5 | DBPassword=<password> |
启动
1 | # systemctl start zabbix-server |
2 | # systemctl enable zabbix-server |
3 | # systemctl start zabbix-agent |
4 | # systemctl enable zabbix-agent |
PHP配置
1 | vi /etc/httpd/conf.d/zabbix.conf |
2 | |
3 | php_value max_execution_time 300 |
4 | php_value memory_limit 128M |
5 | php_value post_max_size 16M |
6 | php_value upload_max_filesize 2M |
7 | php_value max_input_time 300 |
8 | php_value always_populate_raw_post_data -1 |
9 | php_value date.timezone Asia/Shanghai #这个很重要 |
中文乱码
下载支持中文的字体如simsum.ttf 进入目录替换cd /usr/share/zabbix/fonts
1 | mv simsun.ttf graphfont.ttf |
安装agent
1 | rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm |
2 | yum --enablerepo=zabbix install zabbix-agent -y |
设置
1 | cat <<EOF>>/etc/zabbix/zabbix_agentd.conf |
2 | Hostname=172.16.16.134#填写监控主机的信息 |
3 | Server=172.16.16.136 |
4 | ServerActive=172.16.16.136 |
5 | EOF |
1 | systemctl enable zabbix-agent |
2 | systemctl start zabbix-agent |
在服务器端测试
1 | zabbix_get -s 172.16.16.135 -p 10050 -k "system.uptime" |
如果测试不通,请检查日志/var/log/zabbix/zabbix_server.log