02:添加自定義監控項和修改字符集(解決亂碼狀況)

1、監控遠程主機上的系統文件大小(內部狀況):

需求:監控遠程node1系統文件:/etc/services(其它以此類推)node

步驟:先在客戶端上添加相關監控項,再在web界面上添加次監控項(這裏要注意的是:客戶端和web界面上的鍵值必須保持一致python

一、在node1上的/etc/zabbix/zabbix_agentd.d/目錄下添加一個monitor_file.conf文件並重啓agent,內容以下:mysql

[root@node1 ~]# cat /etc/zabbix/zabbix_agentd.d/monitor_file.conf 
UserParameter=monitor_file,stat -c %s /etc/services
[root@node1 ~]# systemctl restart zabbix-agent.service 

二、在web界面上依次點擊:配置 ----> 主機  ----> node1(監控項)----> 建立監控項 ,具體狀況以下:web

2、監控遠程主機上的80端口是否開啓(對外提供的服務):

主要步驟是:先確認遠程主機上確實對外提供了某端口,再在web界面上添加相關監控項sql

 一、node1上裝上http並啓動該服務:shell

# yum install httpd -y
# systemctl enable httpd.service
# systemctl start httpd.service

二、web界面上添加相關監控項,具體狀況以下下圖(這裏監控遠程主機上httpd的80端口):windows

上述是對一臺主機的內部、外部監控大概方法(也就這樣了,對不對)bash

3、監控MySQL主從複製狀態

主要步驟是:字體

一、在node1上的/etc/zabbix/zabbix_agentd.d/目錄下添加一個replication.conf文件並重啓agent,內容以下fetch

UserParameter=mysql.replication,/etc/zabbix/zabbix_agentd.d/check_slave.py

添加監控腳本,這裏提供兩種:

python(推薦):

[root@node1 zabbix_agentd.d]# cat check_slave.py 
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import MySQLdb
#import pymysql

#'''
#使用show slave status命令獲取主從複製狀態,
#判斷下面兩個線程是不是 Yes
#    Slave_IO_Running: Yes
#    Slave_SQL_Running: Yes
#都爲Yes輸出0,不然輸出1
#'''
hostname = "127.0.0.1"
username = "root"
password = "你帳號的密碼"
port = 3306

#con = pymysql.connect(host=hostname, port=port, user=username, passwd=password)
con = MySQLdb.connect(host=hostname, port=port, user=username, passwd=password)
cur = con.cursor()
cur.execute('show slave status;')
status = cur.fetchall()

#for item in status:
#    print(item)

if status[0][10] and status[0][11] == "Yes":
    print(1)
else:
    print(0)

con.close()
[root@node1 zabbix_agentd.d]#

shell腳本:

[root@node1 tmp]# cat mysql_slave_check.sh 
#/bin/bash
mysql -uroot -p'你的帳號密碼' -e "show slave status \G;" 2>/dev/null| grep -E 'Slave_IO_Running: Yes|Slave_SQL_Running: Yes' | grep -c Yes
[root@node1 tmp]# 

二、web界面上添加相關監控項——和上述相似,這裏就不寫了(請原諒)

4、解決亂碼問題

一、上傳windows上找的你本身喜歡的字體,上傳到zabbix服務端的:/usr/share/zabbix/assets/fonts/ 目錄下,並更名爲:graphfont.ttf;因爲我這裏已經改了,就貼個圖吧:

二、刷新web界面吧,應該發現已經正常了:

三個小點,先這樣

相關文章
相關標籤/搜索