常見開源監控軟件php
[root@lijie-01 src]# ls !$ ls /etc/yum.repos.d/ CentOS7-Base-163.repo CentOS-fasttrack.repo CentOS-Vault.repo zabbix.repo CentOS-CR.repo CentOS-Media.repo epel.repo CentOS-Debuginfo.repo CentOS-Sources.repo epel-testing.repo [root@lijie-01 src]# cat /etc/yum.repos.d/zabbix.repo [zabbix] name=Zabbix Official Repository - $basearch baseurl=http://repo.zabbix.com/zabbix/3.2/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=http://repo.zabbix.com/non-supported/rhel/7/$basearch/ enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgcheck=1 [root@lijie-01 src]#
# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
其中zabbix-agent是客戶端軟件,zabbix-get是服務端上用的一個工具,這個工具是能夠經過命令行的形式得到客戶端上某些監控項目的數據,zabbix-server-mysql是安裝一些跟mysql相關的文件,zabbix-web是web UI,zabbix-web-mysql是安裝web和mysql相關的一些文件前端
做爲依賴被安裝: OpenIPMI-libs.x86_64 0:2.0.19-15.el7 OpenIPMI-modalias.x86_64 0:2.0.19-15.el7 apr.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7 dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7 fontpackages-filesystem.noarch 0:1.44-8.el7 fping.x86_64 0:3.10-4.el7 httpd.x86_64 0:2.4.6-67.el7.centos.6 httpd-tools.x86_64 0:2.4.6-67.el7.centos.6 iksemel.x86_64 0:1.4-6.el7 libX11.x86_64 0:1.6.5-1.el7 libX11-common.noarch 0:1.6.5-1.el7 libXau.x86_64 0:1.0.8-2.1.el7 libXpm.x86_64 0:3.5.12-1.el7 libxcb.x86_64 0:1.12-1.el7 libzip.x86_64 0:0.10.1-8.el7 mailcap.noarch 0:2.1.41-2.el7 php.x86_64 0:5.4.16-43.el7_4.1 php-bcmath.x86_64 0:5.4.16-43.el7_4.1 php-cli.x86_64 0:5.4.16-43.el7_4.1 php-common.x86_64 0:5.4.16-43.el7_4.1 php-gd.x86_64 0:5.4.16-43.el7_4.1 php-ldap.x86_64 0:5.4.16-43.el7_4.1 php-mbstring.x86_64 0:5.4.16-43.el7_4.1 php-mysql.x86_64 0:5.4.16-43.el7_4.1 php-pdo.x86_64 0:5.4.16-43.el7_4.1 php-xml.x86_64 0:5.4.16-43.el7_4.1 t1lib.x86_64 0:5.1.2-14.el7 unixODBC.x86_64 0:2.3.1-11.el7 完畢!
# systemctl start mysql
[root@lijie-01 src]# mysql -uroot -p112233 Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.6.36-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database zabbix character set utf8; Query OK, 1 row affected (0.01 sec) mysql>
mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by '112233'; Query OK, 0 rows affected (0.11 sec) mysql>
[root@lijie-01 src]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/ 切換到自帶數據所在目錄 [root@lijie-01 zabbix-server-mysql-3.2.11]# ls 能夠看到數據壓縮包 AUTHORS ChangeLog COPYING create.sql.gz NEWS README [root@lijie-01 zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz 解壓 [root@lijie-01 zabbix-server-mysql-3.2.11]# ls AUTHORS ChangeLog COPYING create.sql NEWS README [root@lijie-01 zabbix-server-mysql-3.2.11]# mysql -uroot -p112233 zabbix < create.sql 恢復數據到zabbix庫 Warning: Using a password on the command line interface can be insecure. [root@lijie-01 zabbix-server-mysql-3.2.11]# systemctl start zabbix-server 啓動zabbix服務 [root@lijie-01 zabbix-server-mysql-3.2.11]# systemctl start httpd^C
[root@lijie-01 zabbix-server-mysql-3.2.11]# ps aux |grep nginx 查看nginx是否佔用80端口 root 6716 0.0 0.0 112676 984 pts/0 S+ 17:15 0:00 grep --color=auto nginx [root@lijie-01 zabbix-server-mysql-3.2.11]# systemctl start httpd 啓動httpd服務 [root@lijie-01 zabbix-server-mysql-3.2.11]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@lijie-01 zabbix-server-mysql-3.2.11]#
[root@lijie-01 ~]# systemctl start zabbix-server [root@lijie-01 ~]# systemctl enable zabbix-server [root@lijie-01 zabbix-server-mysql-3.2.11]# systemctl disable nginx 禁止nginx啓動 nginx.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig nginx off [root@lijie-01 zabbix-server-mysql-3.2.11]# chkconfig nginx off [root@lijie-01 ~]# ps aux |grep zabbix zabbix 7388 2.0 0.2 254760 4168 ? S 00:16 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf zabbix 7391 0.0 0.1 254760 2520 ? S 00:16 0:00 /usr/sbin/zabbix_server: configuration syncer [waiting 60 sec for processes] zabbix 7392 0.0 0.1 254760 2732 ? S 00:16 0:00 /usr/sbin/zabbix_server: db watchdog [synced alerts config in 0.004178 sec, idle 60 sec] zabbix 7393 0.8 0.2 361704 5244 ? S 00:16 0:00 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000009 sec, idle 5 sec] zabbix 7394 1.1 0.2 361704 5244 ? S 00:16 0:00 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000010 sec, idle 5 sec] zabbix 7395 1.1 0.2 361704 5244 ? S 00:16 0:00 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000008 sec, idle 5 sec] zabbix 7396 1.1 0.2 361704 5244 ? S 00:16 0:00 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000247 sec, idle 5 sec] zabbix 7397 1.0 0.2 361704 5244 ? S 00:16 0:00 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000008 sec, idle 5 sec] zabbix 7398 1.4 0.2 361704 5244 ? S 00:16 0:00 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000008 sec, idle 5 sec] zabbix 7399 0.3 0.1 254760 3628 ? S 00:16 0:00 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection] zabbix 7400 0.1 0.1 254760 3624 ? S 00:16 0:00 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection] zabbix 7401 0.0 0.1 254760 3628 ? S 00:16 0:00 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection] zabbix 7402 0.0 0.1 254760 3628 ? S 00:16 0:00 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection] zabbix 7403 0.0 0.1 254760 3628 ? S 00:16 0:00 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection] zabbix 7407 0.0 0.1 257336 2660 ? S 00:16 0:00 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000004 sec, idle 5 sec] zabbix 7408 0.0 0.1 254760 2736 ? S 00:16 0:00 /usr/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.004105 sec, idle 30 sec] zabbix 7410 0.0 0.1 254760 2516 ? S 00:16 0:00 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes] zabbix 7411 0.0 0.1 254760 2736 ? S 00:16 0:00 /usr/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.000000 sec, 0 maintenances in 0.000000 sec, idle 21 sec] zabbix 7413 0.1 0.1 254760 2876 ? S 00:16 0:00 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.001905 sec, idle 5 sec] zabbix 7414 1.4 0.2 359120 5032 ? S 00:16 0:00 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.009963 sec, idle 60 sec] zabbix 7416 0.0 0.1 254760 2864 ? S 00:16 0:00 /usr/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000001 sec, idle 1 sec] zabbix 7418 0.0 0.1 254760 2864 ? S 00:16 0:00 /usr/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000003 sec, idle 1 sec] zabbix 7420 0.0 0.1 254760 2864 ? S 00:16 0:00 /usr/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000002 sec, idle 1 sec] zabbix 7422 0.0 0.1 254760 2864 ? S 00:16 0:00 /usr/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000002 sec, idle 1 sec] zabbix 7424 0.2 0.2 254760 3808 ? S 00:16 0:00 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.004486 sec, idle 3 sec] zabbix 7425 0.1 0.2 254760 3808 ? S 00:16 0:00 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000006 sec, idle 5 sec] zabbix 7426 0.0 0.1 254760 2628 ? S 00:16 0:00 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000009 sec, idle 1 sec] zabbix 7428 0.0 0.1 254760 2852 ? S 00:16 0:00 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.003621 sec, idle 5 sec] root 7439 0.0 0.0 112680 984 pts/1 S+ 00:16 0:00 grep --color=auto zabbix [root@lijie-01 ~]# netstat -lntp |grep zabbix tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 7388/zabbix_server tcp6 0 0 :::10051 :::* LISTEN 7388/zabbix_server [root@lijie-01 ~]#
忘記密碼咱們能夠直接進入mysql的zabbix庫users表中修改數據庫數據就能夠了mysql
[root@lijie-01 ~]# mysql -uroot -p112233 Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 464 Server version: 5.6.36-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use zabbix; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql>
mysql> update users set passwd=md5('112233') where alias='Admin'; Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0 Warnings: 0
這樣就更改了Admin用戶的密碼ios
# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
# yum install -y zabbix-agent
[root@lijie-02 src]# systemctl start zabbix-agent [root@lijie-02 src]# ps aux |grep zabbix zabbix 50606 0.0 0.0 82964 1272 ? S 01:46 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf zabbix 50607 0.0 0.0 82964 1432 ? S 01:46 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec] zabbix 50608 0.0 0.0 82964 1852 ? S 01:46 0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection] zabbix 50609 0.0 0.0 82964 1852 ? S 01:46 0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection] zabbix 50610 0.0 0.0 82964 1852 ? S 01:46 0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection] zabbix 50611 0.0 0.1 83096 2208 ? S 01:46 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec] root 50621 0.0 0.0 112680 980 pts/1 S+ 01:46 0:00 grep --color=auto zabbi [root@lijie-02 src]# netstat -lntp |grep zabbix 能夠看到監控的端口爲10050 tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 50606/zabbix_agentd tcp6 0 0 :::10050 :::* LISTEN 50606/zabbix_agentd
[root@lijie-02 src]# systemctl enable zabbix-agent Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service. [root@lijie-02 src]#