Counter versus Gauge

本文介绍了MRTG监控工具中两种基本对象——计数器与仪表的工作原理及应用场景。计数器用于测量随时间递增的事件数量,如TCP连接;而仪表则用于监控波动的指标,例如并发会话数。正确配置这两种对象对于获取准确的数据至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

From: http://vegan.net/MRTG/countergauge.php

 

MRTG can graph two basic types of objects: Counters and gauges.

A counter is an object that returns an unsigned integer that grows over time (for an explanation on objects, check the concepts page). For example, for a counter object that tracks TCP connections, the number in the counter will increment by 1 every time a new connection is established. This number never gets smaller, it is always incrementing. MRTG polls a configured counter every 5 minutes, subtracts the last number it got, and divides it by the number of seconds in 5 minutes. This gives us a number, in instances per second, in which this event (TCP connection being opened) has occurred. Here is an example:

10:10am:  123394 connections 
10:15am: 138854 connections

138854 - 123394 = 15460 connections in the past 5 minutes

15460 connections / 300 seconds (in 5 minutes) = 52 connections per second
(rounded)

The number is rounded because MRTG only deals in positive integers.

A gauge is a different type of variable. A gauge integer will go up an down according the variable it tracks. For instance, concurrent TCP sessions on a given device is considered a gauge. There is no math done on a gauge object, it just takes the number polled and graphs that number.

Counters and gauges are good for measure different types of metrics. Concurrent sessions, for instance, can only really be measured by a gauge. At a specific moment in time, we are measuring how many active TCP sessions there are. Bandwidth is best measured by a counter. Every time a bit passes an interface, the interface counter is incremented. We can then use the formula above to calculate the average number of bits/s that occurred between those 5 minute intervals.

To put it simply, any item that we need in something per second, we need to have a counter. If we just need a variable graphed, then we need a gauge.

By default, MRTG will consider an object a counter. To set a particular MRTG target to be a gauge, you use the "Options[]: gauge" directive in the configuration file.

If you configure this wrong, MRTG will not graph the data correctly, and you may end up with some rather odd results.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值