UNPKG

767 Bapplication/x-perlView Raw
1#! /usr/bin/perl
2
3# example perl code for Etsy StatsD
4# Steve Sanbeg http://www.buzzfeed.com/stv
5# host and port are passed in as command line options, default to
6# localhost & 8125.
7
8use strict;
9use warnings;
10use Getopt::Long;
11use lib '.';
12use Etsy::StatsD;
13
14my %opt;
15
16GetOptions(\%opt, 'host=s', 'port=s', 'sample=f', 'time=f', 'increment', 'decrement', 'update=i') or die;
17
18my $bucket = shift or die "Need to provide a bucket";
19
20my $statsd = Etsy::StatsD->new($opt{host}, $opt{port}, $opt{rate});
21if ($opt{time}) {
22 $statsd->timing($bucket,$opt{time});
23}
24if ($opt{increment}) {
25 $statsd->increment($bucket);
26}
27if ($opt{update}) {
28 $statsd->update($bucket, $opt{update});
29}
30if ($opt{decrement}) {
31 $statsd->decrement($bucket);
32}
33