zabbix是由 Alexei Vladishev开发的一种网络监视、管理系统,基于 Server-Client架构。可用于监视各类网络服务、服务器和网络机器等状态。php
使用各类 Database-end 如 MySQL, PostgreSQL, SQLite, Oracle 或 IBM DB2 储存资料。Server 端基于 C语言、Web 管理端frontend则是基于PHP所制做的。Zabbix可使用多种方式监视。能够只使用 Simple Check 不须要安装 Client 端,亦可基于 SMTP 或 HTTP ... 各类协定作死活监视。html
在客户端如 UNIX, Windows 中安装 Zabbix Agent 以后,可监视 CPU Load、网络使用情况、硬盘容量等各类状态。而就算没有安装 Agent 在监视对象中,Zabbix 也能够经由 SNMP、TCP、ICMP、利用 IPMI、SSH、telnet 对目标进行监视。mysql
另外,Zabbix 包含 XMPP 等各类 Item 警示功能。linux
zabbix官网: https://www.zabbix.comweb
zabbix主要由二个部分构成 zabbix server和 zabbix agent;
zabbix proxy是用来管理其余的agent,做为代理使用。sql
主机名 | 操做系统 | IP地址 | 服务名 |
---|---|---|---|
zabbix | centos7.4 | 192.168.96.70 | zabbix2.2.23 |
www | centos7.4 | 192.168.96.71 | zabbix-agent |
客户端 | windows 10 | 192.168.96.2 | 网页浏览器 |
百度网盘 密码:x1uy数据库
yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash php-bcmath php-mbstring
systemctl stop firewalld.service setenforce 0
vim /etc/httpd/conf/httpd.confvim
#设置域名 ServerName www.yun.com:80 #修改监听地址 Listen 192.168.96.70:80 #Listen 80 #添加主页类型index.php DirectoryIndex index.html index.php
vim /etc/php.iniwindows
#PRC:中国时区 date.timezone = PRC
systemctl enable httpd.service systemctl start httpd.service systemctl enable mariadb.service systemctl start mariadb.service
netstat -ntap | egrep '(80|3306)'
vim /var/www/html/index.phpcentos
<?php phpinfo(); ?>
http://192.168.96.70/index.php
mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): // 回车键 OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: //设置新密码 Re-enter new password: //确认密码 Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] n //是否移除anonymous用户 ... skipping. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n //是否容许root用户远程登陆 ... skipping. By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] n //是否移除test数据库 ... skipping. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y //从新加载数据表 ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
mysql -u root -p mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@'%' identified by '123123'; mysql>flush privileges;
vim /var/www/html/mysql.php
<?php $link=mysql_connect('192.168.96.70','zabbix','123123'); if($link) echo "<h1>Success!!</h1>"; else echo "Fail!!"; mysql_close(); ?>
> select user,host from mysql.user; #用户名称为空占用致使本地没法登陆远程可登陆 +--------+-----------+ | user | host | +--------+-----------+ | zabbix | % | | root | 127.0.0.1 | | root | ::1 | | | localhost | | root | localhost | | | zabbix | | root | zabbix | +--------+-----------+ > drop user ''@localhost; > drop user ''@zabbix; > flush privileges;
rpm -i https://repo.zabbix.com/zabbix/2.2/rhel/7/x86_64/zabbix-release-2.2-1.el7.noarch.rpm
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
cd /usr/share/doc/zabbix-server-mysql-2.2.23/create/ mysql -uzabbix -p zabbix < schema.sql mysql -uzabbix -p zabbix < images.sql mysql -uzabbix -p zabbix < data.sql
egrep -n '^'[a-Z] /etc/zabbix/zabbix_server.conf
39:LogFile=/var/log/zabbix/zabbix_server.log 50:LogFileSize=0 72:PidFile=/var/run/zabbix/zabbix_server.pid 91:DBName=zabbix 107:DBUser=zabbix 115:DBPassword=123123 124:DBSocket=/var/lib/mysql/mysql.sock 288:SNMPTrapperFile=/var/log/snmptt/snmptt.log 426:Timeout=3 468:AlertScriptsPath=/usr/lib/zabbix/alertscripts 478:ExternalScripts=/usr/lib/zabbix/externalscripts 512:LogSlowQueries=3000
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
vim /usr/share/zabbix/include/defines.inc.php #替换全文中全部graphfot为kaiti :%s/graphfont/kaiti/g
cp kaiti.ttf /usr/share/zabbix/fonts/
systemctl enable zabbix-server systemctl start zabbix-server
netstat -anpt | grep zabbix
systemctl restart httpd.service
http://192.168.96.70/zabbix/
zabbix以前已经安装好了zabbix—agent软件包,这里就不用再安装,直接进行设置
egrep -n '^'[a-Z] /etc/zabbix/zabbix_agentd.conf
13:PidFile=/var/run/zabbix/zabbix_agentd.pid 23:LogFile=/var/log/zabbix/zabbix_agentd.log 34:LogFileSize=0 85:Server=192.168.96.70 126:ServerActive=192.168.96.70 137:Hostname=zabbix 246:Include=/etc/zabbix/zabbix_agentd.d/
systemctl enable zabbix-agent.service systemctl restart zabbix-agent.service
netstat -anpt | grep zabbix
systemctl stop firewalld setenforce 0
rpm -i https://repo.zabbix.com/zabbix/2.2/rhel/7/x86_64/zabbix-release-2.2-1.el7.noarch.rpm
yum install -y zabbix-agent httpd
egrep -n '^'[a-Z] /etc/zabbix/zabbix_agentd.conf
13:PidFile=/var/run/zabbix/zabbix_agentd.pid 23:LogFile=/var/log/zabbix/zabbix_agentd.log 34:LogFileSize=0 85:Server=192.168.96.70 126:ServerActive=192.168.96.70 137:Hostname=www 246:Include=/etc/zabbix/zabbix_agentd.d/
systemctl enable zabbix-agent.service systemctl restart zabbix-agent.service systemctl enable httpd.service systemctl start httpd.service
netstat -anpt | grep zabbix_agent