XDR is a binary protocol that is used by not only gmetric but also gmond itself to pass
metric packets from one instance to another. The XDR protocol can also be used to
insert metric packets into the metric stream by a third-party utility. In fact, gmetric is
a good example of how the XDR protocol can be used in this manner. gmetric, being
an external utility, uses the XDR protocol to submit metrics directly to a gmond instance
in the form of a binary packet. The metric information is submitted as a series of two
UDP packets: one containing metadata regarding the metric in question, and a second
packet containing the metric value. Table 5-3explains the lower-level format of XDR
integer and string values. See Table 5-4and Table 5-5for descriptions of the metadata
and value formats.
gmetric, gmond都是通过xdr协议发送监控的消息包的, 包含metadata, data packet.
详见 :
Types
Metadata packet :
Value packet :
Packets
[参考]
Type Representation
INT Integer values in XDR are represented as a series of four sequential 8-bit values that, taken together,
form a single 32-bit integer value. The value is ordered high byte to low byte.
STRING String values in XDR are represented as an integer XDR “length” value, being the length of the target
string followed by a series of characters forming the string. These values are padded to a string length
that is a multiple of 4 by 0 byte values. Null string values are represented as a zero-length value,
followed by four 0 bytes.
Metadata packet :
Name Type Value
Packet type INT “gmetadata_full”, represented as 128
Hostname STRING Source hostname for this metric. This should be represented in “spoof” form (IP address
+ “:” + hostname) if the packet represents spoofed data.
Metric name STRING Textual name of the metric presented. Any nonalphanumeric characters will be translated into underscore characters by gmond in modern versions of the monitoring core.
Spoof INT 1 if the packet is being spoofed, 0 if it is not a spoofed packet.
Type representation
STRING One of the following: unknown, string, uint16, int16, uint32, int32, float, double.
Metric name STRING Repetition of the earlier metric name field.
Units STRING Textual name of the units being used for this metric.
Slope INT ? 0: zero slope
? 1: positive slope (creates a COUNTER style metric)
? 2: negative slope
? 3: both (should be the default for most metrics)
? 4: unspecified
tmax INT Maximum time in seconds between gmetric values submitted. The minimum value of
this should be 60.
dmax INT Lifetime in seconds of this metric. 0 indicates an unlimited lifetime.
Extra data qualifier INT This “magic” value specifies how many repetitions of the two following values are in
the packet. Most packets contain at least a GROUP value, if not a SPOOF_NAME one.
This value can be 0 if there are no additional extra data values being passed.
Extra data name
(repeats)
STRING Additional data name to be submitted with this packet. Common keys are “GROUP”
and “SPOOF_NAME”.
Extra data value
(repeats)
STRING Corresponding value for extra data.
Value packet :
Name Type Value
Packet type INT 133 (128 + 5)
Hostname STRING Should match the hostname in the preceding metadata packet.
Metric name STRING Should match the metric name in the preceding metadata packet.
Spoof INT Should match the spoof value in the preceding metadata packet.
Format string STRING “%s”. Note: ideally, this should be the printf/scanf-style format of the value being
passed, but in reality, all are presently passed as string values, and are then converted
to their specified types by gmond.
Metric value STRING Reported metric value.
Packets
A metadata packet is an XDR packet that contains the definition of an individual metric.
Before a metric can be understood and viewed by the Ganglia monitoring system, its
metadata must have been communicated throughout the system by a metadata packet.
When an instance of gmond is started, the first thing it does is send a metadata packet
over the network for each metric for which it intends to provide a value. If the configuration directive, send_metadata_interval, is set to a positive value, the instance of
gmond will resend each metric’s metadata according to the interval value.
A value packet contains only enough information to communicate a metric value. In
order to reduce the amount of data that an instance of gmond produces, the actual metric values are communicated through a much smaller packet, which allows gmond
to communicate the much larger metric metadata on an as-needed basis while maintaining a very small footprint when communicating metric values.
[参考]