App-ElasticSearch-Utilities
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
scripts/es-graphite-dynamic.pl view on Meta::CPAN
#!perl
# PODNAME: es-graphite-dynamic.pl
# ABSTRACT: Dynamically gather metrics and send to graphite
use strict;
use warnings;
use App::ElasticSearch::Utilities qw(es_connect);
use App::ElasticSearch::Utilities::Metrics;
use CLI::Helpers qw(:all);
use Getopt::Long qw(:config no_ignore_case no_ignore_case_always);
use IO::Socket::INET;
use Pod::Usage;
use Ref::Util qw(is_hashref is_arrayref);
#------------------------------------------------------------------------#
# Argument Collection
my %opt;
GetOptions(\%opt,
'ignore=s',
'carbon-base=s',
'carbon-proto=s',
'carbon-server=s',
'carbon-port=i',
'prefix=s',
'no-prefix',
'help|h',
'manual|m',
);
#------------------------------------------------------------------------#
# Documentations!
pod2usage(1) if $opt{help};
pod2usage(-exitstatus => 0, -verbose => 2) if $opt{manual};
#------------------------------------------------------------------------#
# Argument Sanitazation
# Ignore uninteresting metrics
my @_IGNORE = ();
push @_IGNORE, split(/,/, $opt{ignore}) if exists $opt{ignore};
my %_IGNORE = map { $_ => 1 } @_IGNORE;
# Merge options into config
my %cfg = (
'carbon-proto' => 'tcp',
'carbon-base' => 'general.es',
%opt,
);
#------------------------------------------------------------------------#
# Globals
my $TIME = time;
my $Fetcher = App::ElasticSearch::Utilities::Metrics->new(
connection => es_connect(),
%_IGNORE ? (
ignore => [ sort keys %_IGNORE ]
) : (),
);
#------------------------------------------------------------------------#
# Carbon Socket Creation
my $carbon_socket;
if( exists $cfg{'carbon-server'} and length $cfg{'carbon-server'} ) {
my %valid_protos = ( tcp => 1, udp => 1 );
die "invalid protocol specified: $cfg{'carbon-proto'}\n" unless exists $valid_protos{$cfg{'carbon-proto'}};
$carbon_socket = IO::Socket::INET->new(
PeerAddr => $cfg{'carbon-server'},
PeerPort => $cfg{'carbon-port'} || 2003,
Proto => $cfg{'carbon-proto'},
);
die "unable to connect to carbon server: $!" unless defined $carbon_socket && $carbon_socket->connected;
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 2.092 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-48ebf85a1963 )