mrtg 工作原理
1. 利用 snmp 返回数据
2. 利用 自定义脚本进行数据返回

example:
希望监控当前 mysql  query cache 使用中的内存大小.
默认状态下, mrtg 希望返回 4 条数据
1. 数据变量1 例如 input 流量
2. 数据变量2 例如 output 流量,
3. uptime
4. 对应目标名称, 例如主机名, ip 等资料

由于 query cache 不存在多变量返回, 则, 随便返回一个变量则可

脚本返回效果如下:

[root@station10 mrtg]# /etc/mrtg/mrtg-query.sh qcache_free_memory localhost
16460120               (当前使用率)
16460120               (可忽略)
18804 seconds          (uptime)
station10.cluster.com  (hostname)

mrtg.cfg 定义规则

全局定义, 如

workdir: /www/mrtg/mysql 
#网页与日志存放位置, 可分离, 如利用
#Imagedir: /www/mrtg/images
#Logdir: /www/mrtg/logs
#Htmldir: /www/mrtg/
#Refresh: 600
MaxAge: 7200
Language: chinese
EnableIPv6: no

 

图片输出自定义

target  <- 用于定义如何获得数据方法

1, 利用自定义 MIB 获得数据方法, 如

cacheRequestHitRatio.5&cacheRequestHitRatio.60:public@10.1.1.1:3401 (我的 squid 缓存命中率)

2. 利用 snmp 获得数据方法 如

.1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.6.0:public@10.1.1.1 (我的 CPU 信息)

3. 利用自定义脚本

/etc/mrtg/mrtg-query.sh qcache_free_memory localhost

注意: MIB, snmp 只获得需要的相关数据, 无法返回主机 UPTIME, 需要额外定义

常见语法:

WorkDir: /www/mrtg/mysql
EnableIPv6: no

Target[mysqlqcache]: `/etc/mrtg/mrtg-query.sh qcache_free_memory localhost`
MaxBytes[mysqlqcache]: 20000000
Options[mysqlqcache]:  nopercent,growright,gauge,noinfo
Title[mysqlqcache]: qcache size
PageTop[mysqlqcache]: <H1>10.1.1.10 Free Memory</H1>
YLegend[mysqlqcache]: memory free
ShortLegend[mysqlqcache]: m/s
Legend1[mysqlqcache]: aaaaaaa
Legend2[mysqlqcache]:
Legend3[mysqlqcache]:
Legend4[mysqlqcache]:
LegendI[mysqlqcache]: &nbsp;eee:
LegendO[mysqlqcache]:

注释:

target 能够返回数据
MaxBytes 定义最大返回数据大小
Options (最重要, 定义了数据类型)
title 图片标签, 任意字符
ShortLegend 量度单位
Legend1[mysqlqcache]:  target 中第一条返回数据值 (重要)
Legend2[mysqlqcache]:  target 中第二条返回数据值  (重要)
Legend3[mysqlqcache]:
Legend4[mysqlqcache]:
LegendI[mysqlqcache]: 图片中颜色数据注释 (不能够为空)
LegendO[mysqlqcache]: 图片中颜色数据注释 (不能够为空)

效果:

Options

growright

希望数据从右边出现, 默认从左出现

bits

以 BIT 作为单位, 不以 BYTES 作为单位

perminute

每分钟 (默认每秒).

perhour

每小时 (默认每秒)

noinfo

禁止 UPTIME 及主机名信息进行显示

nopercent

不显示百分比.

transparent

后台生成 GIF 图片.

integer

以整数打印.

dorelpercent

The relative percentage of IN-traffic to OUT-traffic is calculatedand displayed in the graph as an additional line.Note: Only a fixed scale is available (from 0 to 100%). Thereforeif IN-traffic is greater than OUT-traffic then 100% is displayed.If you suspect that your IN-traffic is not always less than or equalto your OUT-traffic you are urged to not use this options.Note: If you use this option in combination with theColoursoptions, a fifth colour-name colour-value pair is required there.

avgpeak

There are some ISPs who use the average Peak values to bill their customers.Using this option MRTG displays these values for each graph. The value isbuilt by averaging the max 5 minute traffic average for each 'step' shown inthe graph. For the Weekly graph this means that it builds the average of all2 hour intervals 5 minute peak values. (Confused? Thought so!)

gauge

从 TARGET 返回值, 并把返回值作为 '当前状态' 测量结果, 而不作为递增计数器, 该参数常用语 磁盘空间, 进程负载, 温度及类似监控

absolute

This is for counter type data sources which reset their value when they areread. This means that rateup does not have to build the difference betweenthe current and the last value read from the data source. The value obtained isstill divided by the elapsed time between the current and the last reading, which makesit different from the 'gauge' option. Useful for external data gatherers.

derive

If you are using rrdtool as logger/grapher you can use a third type of datasource. Derive is like counter, except that it is not required to go UP allthe time. It is useful for situations where the change of some value should begraphed.

unknaszero

Log unknown data as zero instead of the default behaviour of repeating thelast value seen. Be careful with this, often a flat line in the graph ismuch more obvious than a line at 0.

withzeroes

Normally we ignore all values which are zero when calculating the averagetransfer rate on a line. If this is not desirable use this option.

noborder

If you are using rateup to log data, MRTG will create the graph images.Normally these images have a shaded border around them. If you do not want theborder to be drawn, enable this option. This option has no effect if you arenot using rateup.

noarrow

As with the option above, this effects rateup graph generation only. Normallyrateup will generate graphs with a small arrow showing the direction of thedata. If you do not want this arrow to be drawn, enable this option. Thisoption has no effect if you are not using rateup.

noi

When using rateup for graph generation, you can use this option to stop rateupdrawing a graph for the 'I' or first variable. This also removes entries forthis variable in the HTML page MRTG generates, and will remove the peaks forthis variable if they are enabled. This allows you to hide this data, or canbe very useful if you are only graphing one line of data rather than two.This option is not destructive - any data received for the the variablecontinued to be logged, it just isn't shown.

noo

Same as above, except relating to the 'O' or second variable.

nobanner

When using rateup for graph generation, this option disables MRTG adding theMRTG banner to the HTML pages it generates.

nolegend

When using rateup for graph generation, this option will stop MRTG from creatinga legend at the bottom of the HTML pages it generates.

printrouter

When using rateup for graph generation, this option will print the routername in the graph it generates. This option is overridden by the value ofPNGTitle if one is given

pngdate

When using rateup for graph generation, this option will print atimestamp in the graph it generates, including a timezone if one is specifiedby the 'Timezone' parameter. This is aequivalent to setting TimeStrPost[x]: RU

logscale

The logscale option causes rateup to display the data with the Y axisscaled logarithmically. Doing so allows the normal traffic to occupythe majority of the vertical range, while still showing any spikes attheir full height.

logscale displays all the available data and will always producewell-behaved graphs. People often consider a logarithmically scaled graphcounterintuitive, however, and thus hard to interpret.

expscale

The expscale option causes rateup to display the data with the Y axisscaled exponentially. Doing so emphasizes small changes at the top ofthe scale; this can be useful when graphing values that fluctuate bya small amount near the top of the scale, such as line voltage.

expscale is essentially the inverse of logscale.

secondmean

The secondmean option sets the maximum value on the graph to the meanof the data greater than the mean of all data. This produces a graphthat focuses more on the typical data, while clipping large peaks.

Using secondmean will give a more intutive linearlyscaled graph, but can result in a uselessly high or low scale in somerare situations (specifically, when the data includes a large portionof values far from the actual mean)

If a target includes both logscale and secondmean in the options, thesecondmean takes precedence.

自定义 mrtg 数据相关推荐

  1. R语言ggplot2可视化:可视化箱图、在箱图中添加抖动数据点(Dot + Box Plot)、自定义抖动数据点的大小、颜色、数据点分布在箱图中间、添加主标题、副标题、题注信息

    R语言ggplot2可视化:可视化箱图.在箱图中添加抖动数据点(Dot + Box Plot).自定义抖动数据点的大小.颜色.数据点分布在箱图中间.添加主标题.副标题.题注信息 目录

  2. R语言ggplot2可视化:自定义函数在箱图(boxplot)上添加分组样本个数(count)、分组均值(mean)、箱体填充色自定义、数据标签色彩自定义

    R语言ggplot2可视化:自定义函数在箱图(boxplot)上添加分组样本个数(count).分组均值(mean).箱体填充色自定义.数据标签色彩自定义 目录

  3. plotly自定义股票数据绘图

    plotly自定义股票数据绘图 # import plotly as py import plotly.graph_objs as go from datetime import datetime# ...

  4. asp.net core系列 47 Identity 自定义用户数据

    一.概述 接着上篇的WebAppIdentityDemo项目,将自定义用户数据添加到Identity DB,自定义扩展的用户数据类应继承IdentityUser类, 文件名为Areas / Ident ...

  5. 【若依(ruoyi)】自定义的数据选择对话框

    前言 若依(ruoyi): v4.3 mysql:5.7.31 自定义的数据选择对话框的开发说明 在"若依(ruoyi)"中,数据选择对话框可以分为2类: 树表数据的选择对话框,比 ...

  6. ROS 学习笔记(三):自定义服务数据srv+server+client 示例运行

    ROS 学习笔记(三):自定义服务数据srv+Server+Client 示例运行 一.自定义服务数据: 1.向功能包添加自定义服务文件(AddTwoInts.srv) cd ~/catkin_ws/ ...

  7. Flex Gumbo中如何自定义HSlider数据Tip样式的例子

    接下来的Flex Gumbo中如何通过skinClass样式,自定义HSlider数据Tip样式. 下面是main.mxml:<?xml version="1.0" enco ...

  8. 7.ROS编程学习:自定义服务数据c++调用

    目录 一.准备工作--配置vscode 二.服务端创建 1.创建文件demo01_server.cpp 2.服务端的CMakeList.txt配置 3.测试服务端 三.客户端实现 1.创建domo01 ...

  9. 【转载】CodeWarrior IDE使用tips之prm链接文件详解(自定义存储器分区以及自定义RAM数据初始化与在RAM中运行函数)...

    CodeWarrior IDE使用tips之prm链接文件详解(自定义存储器分区以及自定义RAM数据初始化与在RAM中运行函数) 2017-08-19 胡恩伟 汽车电子expert成长之路 内容提要 ...

最新文章

  1. r语言聚类分析_技术贴 | R语言pheatmap聚类分析和热图
  2. python SSL error: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) 解决方法
  3. python条形图间距-python matplotlib做对比条形图
  4. android cursor 实例化,为什么Cursor放到带参数带返回值方法里就报错?
  5. Java学习笔记(二):String
  6. linux on android分区,android 分区大小 地址查看
  7. 正则表达式只能写数字_正则表达式真的很骚,可惜你不会写
  8. 模拟组合键 postmessage ctrl+v_《模拟江湖》:TapTap热门榜单第一,测试版评分8.0的汉家松鼠工作室新作...
  9. mysql case 2个返回值_MySQL函数简介 2
  10. mysql绿色版安装及授权连接
  11. python编程(类变量和实例变量)
  12. LAMP+Zabbix课程总结
  13. Respond.js让IE6-8支持CSS3 Media Query
  14. 数据库SQL语句解析
  15. xamarin android pdf,Xamarin 中的Android资源及使用.pdf
  16. oc实时渲染的图如何导出_VR批量渲染如何同时保存通道图?「渲云渲染」
  17. @Transaction注解详解
  18. DOORS入门教程系列:基本概念介绍(一)
  19. wmv格式+java_Java调用ffmepg+mencoder视频格式转换(*)
  20. stream_kws_cnn

热门文章

  1. 面试|应聘Java开发工程师的基本要求是什么?
  2. 智联招聘让人非常反感的一个功能:自动委托投递!
  3. 关于视频网站盈利模式的设想
  4. 使用Swagger自动生成接口文档
  5. Developing a Large Scale Application with a Single Page Application (S
  6. LVOOP(二)、面向对象概念演示
  7. 如何在互联网存量时代做电商?
  8. 网络RJ45水晶头制作(图解)
  9. mysql 数据库视图,Mysql数据库中的视图
  10. 0715今日歌单 One Last Kiss, 耗尽