Item 參數文檔php
https://www.zabbix.com/documentation/3.0/manual/config/items/itemtypes/zabbix_agenthtml
(1)查看全部的itemnode
[root@linux-node1 ~]# zabbix_agentd -pmysql
(2)查看 system.cpu.util[,idle]linux
文檔參數查看nginx
間隔時間1hgit
(3)測試itemgithub
[root@linux-node1 ~]# zabbix_get -s linux-node2.example.com -k agent.ping 1 [root@linux-node1 ~]# zabbix_get -s linux-node2.example.com -k system.hostname linux-node2.example.com [root@linux-node1 ~]# zabbix_get -s linux-node2.example.com -k system.cpu.switches 362173 [root@linux-node1 ~]# zabbix_get -s linux-node2.example.com -k system.cpu.util[,idle] 99.800067
全程在 node2上面web
1 取值方法: /etc/services文件的大小redis
[root@linux-node1 /etc/zabbix/zabbix_agentd.d]# stat -c %s /etc/services 670293
2 查看默認conf配置以及格式
[root@linux-node1 ~]# cd /etc/zabbix/zabbix_agentd.d/ [root@linux-node1 /etc/zabbix/zabbix_agentd.d]# ll total 4 -rw-r--r-- 1 root root 1531 May 27 08:33 userparameter_mysql.conf [root@linux-node1 /etc/zabbix/zabbix_agentd.d]# tail -2 userparameter_mysql.conf UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive UserParameter=mysql.version,mysql -V
3 添加自定義的 node2
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]# vim monitor_file.conf
UserParameter=monitor_file,stat -c %s /etc/services
4 重啓agent服務
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]# systemctl restart zabbix-agent [root@linux-node2 /etc/zabbix/zabbix_agentd.d]# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 4409/zabbix_agentd tcp6 0 0 :::10050 :::* LISTEN 4409/zabbix_agentd
5 在server上Test
[root@linux-node1 /etc/zabbix/zabbix_agentd.d]# zabbix_get -s linux-node2.example.com -k monitor_file 670293
6 網頁添加item
7 添加成功
8 查看數據
1 安裝httpd,啓動
[root@linux-node2 ~]# yum install httpd -y [root@linux-node2 ~]# systemctl enable httpd [root@linux-node2 ~]# systemctl restart httpd [root@linux-node2 ~]# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 192.168.194.132:80 0.0.0.0:* LISTEN 4676/httpd
2 添加item:監聽80端口
3 查看數據
[root@linux-node1 /etc/zabbix/zabbix_agentd.d]# systemctl restart httpd
1.定義數據
查看全部的
選擇
結果
2 技術出圖
[root@linux-node2 ~]# systemctl restart httpd
[root@linux-node2 ~]# systemctl stop httpd
3 技術出圖2
4 字體-解決中文亂碼
C:\Windows\Fonts
字體路徑查找
[root@linux-node1 ~]# cat /etc/httpd/conf.d/zabbix.conf
[root@linux-node1 ~]# cd /usr/share/zabbix/fonts/ [root@linux-node1 /usr/share/zabbix/fonts]# ll [root@linux-node1 /usr/share/zabbix/fonts]# ls graphfont.ttf STZHONGS.TTF [root@linux-node1 /usr/share/zabbix/fonts]# mv STZHONGS.TTF graphfont.ttf
5 Item數據解析
(1)數據格式定製
(2)存儲值 每秒一次
取值命令
[root@linux-node1 /usr/share/zabbix/fonts]
# zabbix_get -s 192.168.194.131 -k system.cpu.switches
48199769
文檔解釋
觸發器表達式
1 觸發了有什麼動做,發送郵件
2 如何發送郵件
https://www.zabbix.com/documentation/3.0/manual/installation/requirements
有郵件模塊smtp
3 發件人
4 收件人
5 test報警
重啓80端口
發送郵件
5 郵件內容自定義
https://www.zabbix.com/documentation/3.0/manual/appendix/macros/supported_by_location
日期:{DATE} 時間:{TIME} 主機:{HOST.NAME} 1. {ITEM.NAME1} ({HOST.NAME1}:{ITEM.KEY1}): {ITEM.VALUE1}
啓動httpd,中止httpd
6 報警聲音設置
https://blog.csdn.net/yanggd1987/article/details/80093310
http://www.javashuo.com/article/p-fhgopewn-gv.html
https://github.com/unixhot/Zabbix-Alert-WeChat
通常是腳本報警
查看報警目錄
查看報警代碼.py
阿里大魚
http://tool.chinaz.com/tools/urlencode.aspx
只能zabbix server上外網,其餘agent都不能上
1 命令行執行test
2 添加web監控
更新間隔時間 120s
模擬瀏覽器agent
返回狀態碼200
3 添加成功
[root@linux-node1 ~]# zabbix_server -R config_cache_reload
zabbix_server [20304]: command sent successfully
[root@linux-node1 ~]# zabbix_server -h
做業1:
登陸驗證 filter
退出驗證 filter
Authertication 是ssl認證登陸
驗證登陸能夠選擇,除了驗證碼不能夠
做業2:監控天氣
http://www.weather.com.cn/data/cityinfo/101160101.html
http://www.javashuo.com/article/p-ckpnihjx-hc.html
Nginx模板
https://gitee.com/tinee/zabbix-nginx-status
http://www.javashuo.com/article/p-ngjikycl-hg.html
https://cloud.tencent.com/developer/article/1400917
1 安裝
[root@linux-node2 ~]# yum list |grep nginx* nginx.x86_64 1:1.12.2-3.el7 @epel nginx-all-modules.noarch 1:1.12.2-3.el7 @epel [root@linux-node2 ~]# yum install -y nginx.x86_64 nginx-all-modules.noarch
2 配置文件,開啓nginx監控
[root@linux-node2 ~]# vim /etc/nginx/nginx.con location /ngx_status { stub_status on ; #開啓訪問功能stub_status功能 access_log off; #關閉訪問日誌 allow 192.168.194.0/24; #容許訪問的ip網段 allow 127.0.0.1; deny all; #拒絕除了容許的ip外的全部ip訪問 }
3 檢查語法,啓動
[root@linux-node2 ~]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@linux-node2 ~]# systemctl stop httpd [root@linux-node2 ~]# systemctl restart nginx 端口 [root@linux-node2 ~]# netstat -nltp 3581/redis-server 1 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 106182/nginx: maste
1 新建conf文件
# 參考系統自帶的 [root@linux-node2 /etc/zabbix/zabbix_agentd.d]# tail -2 userparameter_mysql.conf UserParameter=mysql.ping[*],HOME=/var/lib/zabbix mysqladmin -u$1 -p$2 ping | grep -c alive UserParameter=mysql.version,mysql -V
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]# vim nginx_monitor.conf UserParameter=nginx.status[*],/etc/zabix/zabbix_agentd.d/nginx_monitor.sh $1
配置文件的相對路徑
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]# vim /etc/zabbix/zabbix_agentd.conf
2 添加.sh 文件,網上百度
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]# vim nginx_monitor.sh
#!/bin/bash HOST="192.168.194.132" PORT="80" # 檢測nginx進程是否存在 function ping { /sbin/pidof nginx | wc -l } # 檢測nginx性能 function active { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep 'Active' | awk '{print $NF}' } function reading { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep 'Reading' | awk '{print $2}' } function writing { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep 'Writing' | awk '{print $4}' } function waiting { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep 'Waiting' | awk '{print $6}' } function accepts { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| awk NR==3 | awk '{print $1}' } function handled { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| awk NR==3 | awk '{print $2}' } function requests { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| awk NR==3 | awk '{print $3}' } # 執行function $1
執行權限
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]# chmod +x nginx_monitor.sh
4 導入網上的模板
模板文件,網上百度
zbx_nginx_templates.xml
<?xml version="1.0" encoding="UTF-8"?> <zabbix_export> <version>3.0</version> <date>2017-01-13T07:55:46Z</date> <groups> <group> <name>Templates</name> </group> </groups> <templates> <template> <template>Template App Nginx</template> <name>Template App Nginx</name> <description/> <groups> <group> <name>Templates</name> </group> </groups> <applications> <application> <name>Nginx</name> </application> </applications> <items> <item> <name>Nginx Accepted connections\min</name> <type>0</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>nginx.status[accepts]</key> <delay>60</delay> <history>90</history> <trends>365</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>2</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> </item> <item> <name>Nginx Active connections</name> <type>0</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>nginx.status[active]</key> <delay>60</delay> <history>90</history> <trends>365</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>0</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> </item> <item> <name>Nginx Handled connections\min</name> <type>0</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>nginx.status[handled]</key> <delay>60</delay> <history>90</history> <trends>365</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>2</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> </item> <item> <name>Nginx Proc_Num</name> <type>0</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>nginx.status[proc_num]</key> <delay>60</delay> <history>90</history> <trends>365</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>0</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> </item> <item> <name>Nginx Reading Connections</name> <type>0</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>nginx.status[reading]</key> <delay>60</delay> <history>90</history> <trends>365</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>0</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> </item> <item> <name>Nginx Requests\min</name> <type>0</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>nginx.status[requests]</key> <delay>60</delay> <history>90</history> <trends>365</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>2</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> </item> <item> <name>Nginx Waiting Connections</name> <type>0</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>nginx.status[waiting]</key> <delay>60</delay> <history>90</history> <trends>365</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>0</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> </item> <item> <name>Nginx Writing Connections</name> <type>0</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>nginx.status[writing]</key> <delay>60</delay> <history>90</history> <trends>365</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>0</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>Nginx</name> </application> </applications> <valuemap/> <logtimefmt/> </item> </items> <discovery_rules/> <macros/> <templates/> <screens/> </template> </templates> <triggers> <trigger> <expression>{Template App Nginx:nginx.status[proc_num].last()}=0</expression> <name>Nginx is down on {HOST.NAME}</name> <url/> <status>0</status> <priority>5</priority> <description/> <type>0</type> <dependencies/> </trigger> </triggers> <graphs> <graph> <name>Active connections</name> <width>900</width> <height>200</height> <yaxismin>0.0000</yaxismin> <yaxismax>100.0000</yaxismax> <show_work_period>1</show_work_period> <show_triggers>1</show_triggers> <type>0</type> <show_legend>1</show_legend> <show_3d>0</show_3d> <percent_left>0.0000</percent_left> <percent_right>0.0000</percent_right> <ymin_type_1>0</ymin_type_1> <ymax_type_1>0</ymax_type_1> <ymin_item_1>0</ymin_item_1> <ymax_item_1>0</ymax_item_1> <graph_items> <graph_item> <sortorder>0</sortorder> <drawtype>0</drawtype> <color>00C800</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template App Nginx</host> <key>nginx.status[active]</key> </item> </graph_item> <graph_item> <sortorder>1</sortorder> <drawtype>0</drawtype> <color>C80000</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template App Nginx</host> <key>nginx.status[waiting]</key> </item> </graph_item> </graph_items> </graph> <graph> <name>Nginx Connections\min</name> <width>900</width> <height>200</height> <yaxismin>0.0000</yaxismin> <yaxismax>100.0000</yaxismax> <show_work_period>1</show_work_period> <show_triggers>1</show_triggers> <type>0</type> <show_legend>1</show_legend> <show_3d>0</show_3d> <percent_left>0.0000</percent_left> <percent_right>0.0000</percent_right> <ymin_type_1>1</ymin_type_1> <ymax_type_1>0</ymax_type_1> <ymin_item_1>0</ymin_item_1> <ymax_item_1>0</ymax_item_1> <graph_items> <graph_item> <sortorder>0</sortorder> <drawtype>0</drawtype> <color>00C800</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template App Nginx</host> <key>nginx.status[accepts]</key> </item> </graph_item> <graph_item> <sortorder>1</sortorder> <drawtype>0</drawtype> <color>C80000</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template App Nginx</host> <key>nginx.status[handled]</key> </item> </graph_item> <graph_item> <sortorder>2</sortorder> <drawtype>0</drawtype> <color>0000C8</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template App Nginx</host> <key>nginx.status[requests]</key> </item> </graph_item> </graph_items> </graph> <graph> <name>Nginx Proc_Num</name> <width>900</width> <height>200</height> <yaxismin>0.0000</yaxismin> <yaxismax>100.0000</yaxismax> <show_work_period>1</show_work_period> <show_triggers>1</show_triggers> <type>0</type> <show_legend>1</show_legend> <show_3d>0</show_3d> <percent_left>0.0000</percent_left> <percent_right>0.0000</percent_right> <ymin_type_1>1</ymin_type_1> <ymax_type_1>0</ymax_type_1> <ymin_item_1>0</ymin_item_1> <ymax_item_1>0</ymax_item_1> <graph_items> <graph_item> <sortorder>0</sortorder> <drawtype>0</drawtype> <color>00C800</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Template App Nginx</host> <key>nginx.status[proc_num]</key> </item> </graph_item> </graph_items> </graph> </graphs> </zabbix_export>
導入
7個item,模板裏面
重啓agent
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]# systemctl restart zabbix-agent
Test測試
1 訪問網址test
2 server執行命令test
[root@linux-node1 ~]# zabbix_get -s 192.168.194.132 -k nginx.status[requests] 9 [root@linux-node1 ~]# zabbix_get -s 192.168.194.132 -k nginx.status[handled] 10
3 查看數據
講解
取第一個的時候,緩存一份
建立時間與 文件的建立時間比較
若是<60則不更新
1 安裝mariadb
[root@linux-node1 ~]# yum install mariadb-server -y^C
[root@linux-node1 ~]# systemctl start mariadb.service
2 取值驗證 test
[root@linux-node1 ~]# mysqladmin ping | grep -c alive 1 [root@linux-node2 /etc/zabbix/zabbix_agentd.d]# mysqladmin ping mysqld is alive
3 系統配置模板
監控mysql的,默認配置ok的
# 自帶的conf [root@linux-node2 ~]# cd /etc/zabbix/zabbix_agentd.d/ [root@linux-node2 /etc/zabbix/zabbix_agentd.d]# tail -2 userparameter_mysql.conf UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive UserParameter=mysql.version,mysql -V
4 新建host
5 查看data
查看日誌
[root@linux-node1 ~]# tail -f /var/log/zabbix/zabbix_server.log
Items
Latest data
6 配置文件,源碼剖析
如何取值,看配置文件
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]# vim userparameter_mysql.conf
$1的值
[root@linux-node2 ~]# echo "show global status where Variable_name='Com_begin';" | HOME=/var/lib/zabbix mysql -N
Com_begin 39038
兩個$$
第一個$表明 相對路徑
[root@linux-node2 ~]# vim /etc/zabbix/zabbix_agentd.conf
1 配置密碼
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]#
cp userparameter_mysql.conf userparameter_mysql.conf.bak
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]# vim userparameter_mysql.conf
2 Mysql受權 給 zabbix
MariaDB [(none)]> grant all on *.* to zabbix@'localhost' identified by 'zabbix'; Query OK, 0 rows affected (0.17 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.02 sec)
Test
重啓服務
3 刷新時間修改
某些item不能正常執行
刷新時間太長,改成30
Test這些item
[root@linux-node1 ~]# zabbix_get -s 192.168.194.132 -k mysql.status[Uptime]
1189
思想:
若是按照個新的mysql
Usermysql文件替換下,連接個模板,變量設置user pwd。
1.每一個agent的數據庫密碼不同,如何自動化,每一個文件都要配置?
Zabbix能夠自定義變量 宏
2.修改配置文件,使其生效
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]# vim userparameter_mysql.conf
* 能夠傳多個參數
$1 $2 $3
3.重啓agent,test
[root@linux-node2 /etc/zabbix/zabbix_agentd.d]# systemctl restart zabbix-agent
test執行命令
[root@linux-node1 ~]# zabbix_get -s 192.168.194.132 -k mysql.status[zabbix,zabbix,Uptime]
1471
4.修改模板,定義宏變量
定義變量
{$PASSWD}{$USER}
修改 template
Enable
5.修改item
有mysql.status,每一個item都要執行
{$USER},{$PASSWD},
完成
只須要修改模板,剩下的item都變了
使用變量了
6. test,不一樣用戶名密碼,均可以執行
修改密碼,從新受權
MariaDB [(none)]> grant all on *.* to monitor@'localhost' identified by '123456'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec)
修改 宏變量
查看data
http://www.javashuo.com/article/p-podpytqj-hm.html
http://www.javashuo.com/article/p-hvlccgig-ca.html
Percona Server由領先的MySQL諮詢公司Percona發佈。 Percona Server是一款獨立的數據庫產品,其能夠徹底與MySQL兼容,能夠在不更改代碼的狀況了下將存儲引擎更換成XtraDB 。
Percona團隊的最終聲明是「Percona Server是由Oracle發佈的最接近官方MySQL Enterprise發行版的版本」,所以與其餘更改了大量基本核心MySQL代碼的分支有所區別。 Percona Server的一個缺點是他們本身管理代碼,不接受外部開發人員的貢獻,以這種方式確保他們對產品中所包含功能的控制。
Percona提供了高性能XtraDB引擎,還提供PXC高可用解決方案,而且附帶了perconatoolkit等DBA管理工具箱
在node2 上面
安裝 percona
[root@linux-node2 ~]# rpm -ivh https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.8/binary/redhat/7/x86_64/percona-zabbix-templates-1.1.8-1.noarch.rpm
安裝完成會提示腳本和模板的位置
Scripts are installed to /var/lib/zabbix/percona/scripts Templates are installed to /var/lib/zabbix/percona/templates
安裝php
[root@linux-node2 ~]# yum install -y php php-mysql
(1)copy監控項配置到zabbix_agentd.d
[root@linux-node2 /var/lib/zabbix/percona/templates]# cp userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
(2)修改腳本
[root@linux-node2 /var/lib/zabbix/percona/scripts]# vim get_mysql_stats_wrapper.sh
[root@linux-node2 /var/lib/zabbix/percona/scripts]# vim ss_get_mysql_stats.php
腳本1
Mysql密碼
間隔300s,監控不要影響服務
腳本2
(3)重啓agent,test
[root@linux-node2 /var/lib/zabbix/percona/scripts]# systemctl restart zabbix-agent
Test,如何取值
[root@linux-node1 ~]# zabbix_get -s 192.168.194.132 -k MySQL.Open-files
21
(4)導入自帶模板
模板自帶(有問題),導入到桌面
[root@linux-node2 /var/lib/zabbix/percona/templates]# sz zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml
導入到zabbix
把上面scripts下面的xml文件拷貝到win主機上,而後導入,導入的時候會報錯
無底洞,不修改了
官方的是zabbix2.2 不兼容
(5)導入ok的模板
百度給的解決辦法是: 將模板導入到2.4環境中,而後再導出到3的環境中,不會報錯。百度上也提供了一個模板導入,
模板鏈接:
連接:https://pan.baidu.com/s/1HvoOGNqI9HYC9ymgi7HsDQ 提取碼:emsh
wget http://jaminzhang.github.io/soft-conf/Zabbix/zbx_percona_mysql_template.xml
直接用好的,網上下載
添加觸發器的時候,添加依賴
若是它報警了我就不報警了。
擴展:
報警依賴
優先監控路由器,再監控服務器
減小誤報
全部服務器都依賴交換機
交換機報警,其餘的就不報警了
學習監控的話,更多跟系統學習這些知識。
配置conf文件怎麼寫
觸發器怎麼設計
Item怎麼轉換,存儲的
Question1
檢查發件人設置
Question2
解決:
/etc/zabbix/zabbix_agentd.d
只能放conf文件,必須使用的