zabbix監控nginx mysql 服務新增
[[email protected] ~]# rpm -ivh nginx-1.8.0-1.el7.ngx.x86_64.rpm
[[email protected] ~]# cd /etc/nginx/
[[email protected] nginx]# cd conf.d/
[[email protected] conf.d]# vim default.conf
[[email protected] conf.d]# nginx -t
[[email protected] conf.d]# systemctl start nginx.service
[email protected] conf.d]# curl 127.0.0.1/status
[[email protected] conf.d]# cd /etc/zabbix/zabbix_agentd.d/
[[email protected] zabbix_agentd.d]# cp userparameter_mysql.conf userparameter_nginx.conf
[[email protected] zabbix_agentd.d]# curl -s http://127.0.0.1/status | grep Active | awk '{print $3}' ##獲得返回值即可
[[email protected] zabbix_agentd.d]# vim userparameter_nginx.conf
刪除其餘的UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active | awk '{print $3}'
[[email protected] zabbix_agentd.d]# systemctl restart zabbix-agent.service
test1:
[[email protected] 3.4]# rpm -ivh zabbix-get-3.4.6-1.el7.x86_64.rpm
[[email protected] 3.4]# zabbix_get -s 172.25.8.12 -p 10050 -k "nginx.active" ##有返回值即可
web介面
建立監控項
配置--主機--監控項--建立監控
建立圖形
配置--主機--圖形--建立圖形
新增自定義配置檔案
[[email protected] zabbix_agentd.d]# vim userparameter_nginx.conf
[[email protected] zabbix_agentd.d]# systemctl restart zabbix-agent.service
test1:
[[email protected] 3.4]# zabbix_get -s 172.25.8.12 -p 10050 -k "nginx.active"
1
[[email protected] 3.4]# zabbix_get -s 172.25.8.12 -p 10050 -k "nginx.accepts"
51
[[email protected] 3.4]# zabbix_get -s 172.25.8.12 -p 10050 -k "nginx.handled"
52
[[email protected] 3.4]# zabbix_get -s 172.25.8.12 -p 10050 -k "nginx.requests"
54
web:
監控向新增
圖形新增
預覽
mysql:
web
主機zabbix server新增模版
DBmysql
圖形檢視
[[email protected] 3.4]# mkdir /var/lib/zabbix
[[email protected] 3.4]# cd /var/lib/zabbix/
[[email protected] zabbix]# vim .my.cnf
[[email protected] zabbix]# systemctl restart zabbix-agent.service
percona
rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm
[[email protected] ~]# cd /var/lib/zabbix/percona/templates/
[[email protected] templates]# cp userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
[[email protected] templates]# cd /etc/zabbix/zabbix_agentd.d/
[[email protected] zabbix_agentd.d]# rpm -q php-mysql
[[email protected] zabbix_agentd.d]# cat userparameter_percona_mysql.conf | wc -l
cd /var/lib/zabbix/percona/scripts/
vim ss_get_mysql_stats.php.cnf
<?php
$mysql_user = 'root';
$mysql_pass = 'redhat';
[[email protected] zabbix_agentd.d]# mysqladmin -uroot password westos
[[email protected] zabbix_agentd.d]# mysql -uroot -pwestos
[[email protected] scripts]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
[[email protected] scripts]# cd /tmp/
[[email protected] tmp]# chown zabbix.zabbix localhost-mysql_cacti_stats.txt
[[email protected] tmp]# ll localhost-mysql_cacti_stats.txt
[[email protected] tmp]# cd /etc/zabbix/zabbix_agentd.d/
[[email protected] zabbix_agentd.d]# zabbix_get -s 127.0.0.1 -p 10050 -k 'MySQL.Key-read-requests'
web介面
在模版中匯入