discover功能
- 思路
discover:找到mount挂载的盘目录
自动添加:将找到的目录添加到监控项中
1.部署lamp环境
安装zabbix 3.0以上,yum安装的版本有点低
- 解决方案:使用其他yum源
rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap wget ntpdate net-snmp*
2.:阿里云不支持25端口发邮件
- 解决方案:使用Python脚本ssl
#!/usr/bin/env python
# coding: utf-8
import smtplib,sys
from email.MIMEText import MIMEText
from email.Utils import formatdate
from email.Header import Header
def_encoding = 'utf-8'
if sys.getdefaultencoding() !=def_encoding:
reload(sys)
sys.setdefaultencoding(def_encoding)
def sendmail(toMail,subject,body):
smtpHost = 'smtp.qq.com'
smtpPort = '25'
sslPort = '465'
fromMail = 'test@qq.com'
toMail = 'test@qq.com'
username = 'test'
password = 'test'
# subject = u'hello'
# body = u'hello,this is a mail from ' + fromMail
encoding = 'utf-8'
mail=MIMEText(body,"plain",encoding)
mail['Subject'] = Header(subject, encoding)
# mail['Subject'] = subject
mail['From'] = fromMail
mail['To'] = toMail
mail['Date'] = formatdate()
mail["Accept-Language"] = "zh-CN"
mail["Accept-Charset"] = "ISO-8859-1,utf-8"
try:
#no ssl
# smtp = smtplib.SMTP(smtpHost,smtpPort)
# smtp.ehlo()
# smtp.login(username,password)
# ssl
smtp = smtplib.SMTP_SSL(smtpHost, sslPort)
smtp.ehlo()
smtp.login(username, password)
# print mail.as_string()
smtp.sendmail(fromMail, toMail, mail.as_string())
smtp.close()
print 'OK'
except Exception as e:
print e
if __name__ == "__main__":
sendmail(sys.argv[1], sys.argv[2], sys.argv[3])
这里自己有个邮箱账户什么的自己解决吧!
discover功能
- 自动发现
个人理解:
discover:找到mount挂载的盘目录
自动添加:将找到的目录添加到监控项中
监控sql server
PerfCounter = MSSQLLOCKS,"\SQLServer:Locks(_Total)\Number of Deadlocks/sec",15
PerfCounter = Lock_Timeouts,"\SQLServer:Locks(_Total)\Lock Timeouts/sec",15
PerfCounter = Lock_Requests,"\SQLServer:Locks(_Total)\Lock Requests/sec",15
类似,可百度PerfCounter
代理proxy安装
1.安装数据库
2.导入数据库数据,库名为zabbix_proxy,导入数据(和搭建server一样)
3.编译安装zabbix-server:./configure --sysconfdir=/usr/local/zabbix/ --enable-proxy --enable-agent --with-net-snmp --with-mysql --with-ssh2
4.导入数据库文件(只要一个就OK):mysql zabbix_proxy <schema.sql
5.修改zabbix_proxy.cnf配置文件
ProxyMode=0 ##默认参数值,proxy代理主动模式
Server=IP ##主动模式下,主动请求这个IP,获得监控配置信息
ServerPort=10051 ##proxy代理端口
Hostname=xxx ##这个要名字随便取,但是不能重复,web端设置时需要
然后就是db设置
6.启动代理:zabbix-proxy
7.web设置
首先要配置代理
然后将agent端放到代理下面:添加主机选择
image.png等他变绿
agent到proxy配置
server:配了了server端的IP,和proxy的IP
serveractive:配置的是proxy的ip+端口号
LogFile=/tmp/zabbix_agentd.log
Server=
ListenPort=10049
ServerActive=ip:10051
Hostname=MMMM_master
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix /usr/bin/mysql -N | awk '{print $$2}'
数据库监控
1.给数据库创建一个zabbix用户
grant REPLICATION CLIENT on *.* to 'zabbix'@'localhost' identified by '123456';
2.在my.cnf配置文件[client]写入信息
[client]
user=zabbix
password=123456
3.监控模块
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix /usr/bin/mysql -N | awk '{print $$2}'
UserParameter=mysql.ping,HOME=/var/lib/zabbix /usr/bin/mysqladmin ping | grep -c 'mysqld is alive'
UserParameter=db_status,echo "show slave status\G" | HOME=/var/lib/zabbix /usr/local/mysql/bin/mysql -N|grep -c Yes
UserParameter=db_time,echo "show slave status \G" | HOME=/var/lib/zabbix /usr/local/mysql/bin/mysql|grep Seconds_Behind_Master|awk '{print $2}'|awk '{sum += $1};END {print sum}'
这些是例子,前端添加模块就不写了,注意/usr/local/mysql/bin/mysql
路径
网友评论