使用Zabbix + Python对Mysql监控

Python之Zabbix Zabbix api简介 部署zabbix Zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案 能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题 部署方式参见云计算监控课程,不再赘述 Zabbix api概述 Zabbix API允许你以编程方式检索和修改Zabbix的配置,并提供对历史数据的... 阅读详情

一、背景介绍

随着公司业务的变迁,公司的开发数据库以mysql为主了。mysql服务器层面的监控,例如CPU、内存、硬盘空间等就用zabbix自带的linux模板即可。数据库层面zabbix也自带了一个模板,但是它需要将mysql的密码写到my.cnf文件中,这样不安全,因此决定自己写一个。原先我写过一个用python去监控oracle的博客 使用zabbix监控oracle数据库 ,对于mysql的监控大同小异,只需要简单改改监控项即可。

二、监控方式

Zabbix服务端的环境为:CentOS 6.10, Zabbix 3.4.15, Python 3.6.8。被监控的mysql 版本为8.0.x。监控采用外部检查(External Check)的方式,即从zabbix服务端执行python脚本,去查询被监控的mysql信息。这种方式的好处是监控脚本放在zabbix服务端,后面想修改模板和脚本只需要在zabbix服务端修改一次即可,被监控端不用做任何操作,省心。

三、监控项规划

确定好了监控方式,接下来就开始对监控项进行规划。

1. os层

port:mysql端口是否正常监听,检测不到监听端口,报警

proc:mysqld进程是否存在,检测不到mysqld进程,报警

以上两个监控项通过zabbix agent采集信息(需要在被监控机安装zabbix-agent)

2. db层

主库和从库都包括的监控项:

readonly:是否只读,状态发生改变时报警

uptime:运行时间,uptime减少表示数据库发生了重启,报警

queries:检查qps

select: 查询的sql次数

update: 更新的sql次数

delete: 删除的sql次数

Zabbix实现邮件和钉钉实时告警(使用python脚本) 告警是监控的主要职能,是指将到达某一阈值事件的消息发送给用户,让用户在事件发生的时候即刻知道监控项处于不正常状态,从而让用户来决定是否采取相关措施。zabbix中,告警是由一系列的流程组成的,⾸首先是触发器到达阈值,接下是Active对事件信息进行处理,其中包括两部分:第一部分是发送消息,即将告警信息发送给用户;第二部分是执行命令,即将事件用命令进行处理,到达对事件故障⾃动尝试恢复的结果。 阅读详情

相关推荐

Zabbix动作执行Python脚本错误总结——应对大数据

在处理大数据时,Zabbix动作执行Python脚本可能会遇到内存不足、网络超时、代码逻辑错误和性能瓶颈等问题。通过设置虚拟内存、增加物理内存、优化网络连接、调试代码、加入异常处理和进行性能优化等方法,我们能够更好地应对这些问题,并确保脚本的正常执行。当然,在实际应用中,我们还需要根据具体情况进行进一步的调试和优化,以满足大数据处理的需求。当处理大数据时,可能会遇到性能瓶颈,导致脚本执行较慢或无法完成任务。为了解决这个问题,我们可以对脚本进行性能优化,例如使用并行处理、采用更高效的算法或者对代码进行精简。

2301_79366435的博客 399

ETL基础概念及要求详解

ETL即Extract(抽取)Transform(转换)Load(装载)的过程,如下图,同时也包括数据清洗的部分,是数据从源端到目标端的一个数据处理的过程,是构建数据仓库的重要一环,但不局限于构建数据仓库其他BI(商业智能)的设计和开发数据分析平台也经常用到ETL。

qq_43605229的博客 8942

KIBANA可视化管理界面说明

更说明转自https://blog.youkuaiyun.com/IT_ZRS/article/details/125496588 1 主要结构功能 使用浏览器访问 ip:5601 默认端口,进入首页 Discover:日志管理视图 主要进行搜索和查询 Visualize:统计视图 构建可视化的图表 Dashboard:仪表视图 将构建的图表组合形成图表盘 Timelion:时间轴视图 随着时间流逝的数据 APM:性能管理视图 应用程序的性能管理系统 Canvas:大屏展示

tian830937的专栏 7081

一文讲透什么是ADC/DAC中的DDC、DUC、采样率以及数据率等概念

摘要:ADC/DAC中的采样率与数据率概念不同,采样率是转换器的时钟速率,而数据率是数字输出的实际速率。抽取通过滤波降低数据速率,提升信噪比但牺牲带宽;内插则通过插零和滤波提高采样率,将镜像信号移远但增加延迟和功耗。JESD204B标准的高速转换器需平衡通道数与串行速率,内插/抽取技术是关键。文章还解析了DDC、DUC的应用及优缺点,为高速数据转换设计提供参考。(150字)

weixin_49761275的博客 4264

基于STM32F407的定时器以及定时器中断的实现

基于STM32F407的定时器以及定时器中断的实现

weixin_57941207的博客 5228

第2章: MMU Notifier 全局通知器的核心原理⭐

摘要 MMU Notifier机制是Linux内核中用于处理内存地址空间变化通知的关键框架。其设计遵循解耦与标准化、最小侵入性、高性能和安全性四大原则,采用三层架构实现上层应用、核心层与内存管理层的协作。框架提供两种通知模型:全局订阅的mmu_notifier和区间订阅的mmu_interval_notifier,分别适用于KVM虚拟化和GPU共享虚拟内存等不同场景。核心数据结构mmu_notifier_ops定义了设备驱动需要实现的回调函数集合,包括进程退出处理、页面老化管理、地址范围失效通知等功能。

图形/计算GPU的驱动与虚拟化技术分享园地 4550

【WRF-Chem第二期】WRF-Chem有关 namelist 详解

【WRF-Chem第二期】WRF-Chem有关 namelist 详解

WW、forever的博客 2155

2.0 电子凸轮 西门子1500电子凸轮使用研究1

本文研究了S7-1500T电子凸轮同步控制技术,通过仿真实验得出以下结论:1)通过比例系数可调整凸轮曲线形状;2)解除同步需调用从轴其他运动指令;3)详细阐述了凸轮同步的5个实施步骤。重点分析了三种同步类型(主值距离同步、动态参数同步和直接同步)的特点及应用场景,并探讨了缩放系数、偏移量等参数对凸轮曲线的影响。同时介绍了凸轮应用模式及常见异常处理方法,为工程应用提供了重要参考。

qq_34047402的博客 808

把 SM30 用顺:从表设计到权限与传输,全面掌握 SAP Table Maintenance Generator

摘要 SAP的Table Maintenance Generator(TMG)是为配置表维护需求设计的经典工具,能够生成标准化的维护对话框(SM30)。它支持单表、维护视图(多表关联)和视图簇(导航式维护)三种维护对象类型。使用TMG前需注意三个关键设置:1)表维护权限选项;2)交付类(决定数据传输行为);3)客户端字段配置。通过SE54/SE11生成维护对话框时,需选择维护类型(一步/两步)和记录例程(控制传输)。TMG生成的对象包含函数组、屏幕和处理模块,但部分标准框架不可修改。实际应用中,可通过参数事

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 176

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

上一篇: 使用 scipy.fft 进行Fourier Transform:Python 信号处理
下一篇: python绘图中的四个绘图技巧
Python_xiaowu
博客等级 码龄5年 3096粉丝 178原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值