Net::Graphite(3) User Contributed Perl Documentation Net::Graphite(3) NAME Net::Graphite - Interface to Graphite SYNOPSIS use Net::Graphite; my $graphite = Net::Graphite->new( # except for host, these hopefully have reasonable defaults, so are optional host => '127.0.0.1', port => 2003, trace => 0, # if true, copy what's sent to STDERR proto => 'tcp', # can be 'udp' timeout => 1, # timeout of socket connect in seconds fire_and_forget => 0, # if true, ignore sending errors return_connect_error => 0, # if true, forward connect error to caller flush_limit => 0, # if true, send after this many metrics are ready path => 'foo.bar.baz', # optional, use when sending single values transformer => sub { my $data = shift; ...; return $plaintext }, ); # to check for connection error (when return_connect_error => 1) do: die "connection error: $!" unless $graphite->connect; # send a single value, # need to set path in the call to new # or call $graphite->path('some.path') beforehand $graphite->send(6); # default time is "now" -OR- # send a metric with named parameters $graphite->send( path => 'foo.bar.baz', value => 6, time => time(), # time defaults to "now" ); -OR- # send text with one line per metric, following the plaintext protocol $graphite->send(data => $string_with_one_line_per_metric); -OR- # send a data structure, # here using the default transformer for Hash of Hash: epoch => key => key .... => value $graphite->send(path => 'foo', data => $hash); # example of hash structure: 1234567890 => { bar => { db1 => 3, db2 => 7, db3 => 2, .... }, baz => 42, }, would be: foo.bar.db1 = 3 foo.bar.db2 = 7 foo.bar.db3 = 2 foo.baz = 42 -OR- # send a data structure, providing your own plaintext transformer # (the callback's only arg is the data structure, return a text string one metric on each line) $graphite->send(data => $whatever, transformer => \&make_whatever_into_plaintext); DESCRIPTION Interface to Graphite which doesn't depend on AnyEvent. INSTANCE METHODS close Explicitly close the socket to the graphite server. Not normally needed, because the socket will close when the $graphite object goes out of scope. connect Get an open a socket to the graphite server, either the currently connected one or, if not already connected, a new one. Not normally needed. flush Explicitly flush (send) the buffer of metrics. Not normally needed ("->send" flushes at the end already). flush_limit In case you send a very large hash (for example) of metrics, building up the internal data structure that gets sent can consume a lot of memory. The flush_limit allows instead for sending after this many metrics have accumulated. path Set the default path (corresponds to 'path' argument to new), for use when sending single values. send Normally all you need to use. See the SYNOPSIS. (FIXME) transformer If you pass a 'data' argument to send, use this coderef to transform from the data structure to plaintext. The coderef receives the data structure as its only parameter. There are default transformers for certain reftypes. SEE ALSO AnyEvent::Graphite <http://graphite.readthedocs.org/> AUTHOR Scott Lanning <slanning AT cpan.org> perl v5.16.3 2020-04-13 Net::Graphite(3)
Generated by $Id: phpMan.php,v 4.55 2007/09/05 04:42:51 chedong Exp $ Author: Che Dong
On Apache
Under GNU General Public License
2024-04-27 03:11 @18.217.228.35 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)