The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Ganglia::Gmetric::PP - Pure Perl emitter/parser of Ganglia gmetric monitoring packets

SYNOPSIS

    my $gmetric = Ganglia::Gmetric::PP->new(host => 'localhost', port => 8649);
    $gmetric->send($type, $name, $value, $units, $slope, $tmax, $dmax);

DESCRIPTION

This module constructs Ganglia packets in the manner of the gmetric program and sends them via UDP to a gmond. Additionally it can receive and/or parse gmetric packets which is useful for constructing proxies. Though written in pure Perl with no non-core dependencies, it tries to be fast.

FUNCTIONS

  • $gmetric = Ganglia::Gmetric::PP->new(host => $host, port => $port)

    Constructs a new object which sends gmetric packets to the specified host and UDP port. If omitted, they default to localhost and 8649, respectively.

  • $gmond = Ganglia::Gmetric::PP->new(listen_host => $host, listen_port => $port)

    Constructs a new object which receives gmetric packets (e.g. in a gmond replacement). If the $gmetric will be used for receiving packets, listen_host and listen_port may be specified as well.

  • $gmetric->send($type, $name, $value, $units, $slope, $tmax, $dmax)

    Sends a Ganglia message. The parameters are:

    • $type

      The type of data being sent. Must be one of these importable constants:

      • GANGLIA_VALUE_STRING

      • GANGLIA_VALUE_UNSIGNED_CHAR

      • GANGLIA_VALUE_CHAR

      • GANGLIA_VALUE_UNSIGNED_SHORT

      • GANGLIA_VALUE_SHORT

      • GANGLIA_VALUE_UNSIGNED_INT

      • GANGLIA_VALUE_INT

      • GANGLIA_VALUE_FLOAT

      • GANGLIA_VALUE_DOUBLE

    • $name

      The name of the metric.

    • $value

      The current value of the metric.

    • $units

      A string describing the units of measure for the metric.

    • $slope

      A description of how the metric tends to change over time. Must be one of these importable constants:

      • GANGLIA_SLOPE_ZERO

        Data is fixed, mostly unchanging.

      • GANGLIA_SLOPE_POSITIVE

        Value is always increasing (counter).

      • GANGLIA_SLOPE_NEGATIVE

        Value is always decreasing.

      • GANGLIA_SLOPE_BOTH

        Value can be anything.

    • $tmax

      The maximum time in seconds between gmetric calls.

    • $dmax

      The lifetime in seconds of this metric.

  • @metric = $gmetric->receive()

    Waits for a single gmetric packet on the UDP listen port and returns the parsed metric (see parse).

  • @metric = Ganglia::Gmetric::PP->parse($packet_data)

    Parses a gmetric packet, which is typically received by a UDP server.

    The elements returned match the arguments to send:

        ($type, $name, $value, $units, $slope, $tmax, $dmax) = @metric;

    This function may die if the given data does not resemble a gmetric packet.

AUTHOR

Adam Thomason, <athomason@cpan.org<gt>

COPYRIGHT AND LICENSE

Copyright (C) 2007-2009 by Six Apart, <cpan@sixapart.com>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.