Counter versus Gauge

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.

你可能感兴趣的:(Counter versus Gauge)