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