| 1 | package XAS::Collector::Output::Socket::OpenTSDB; | ||
| 2 | |||
| 3 | our $VERSION = '0.01'; | ||
| 4 | |||
| 5 | 1 | ▶ | use POE; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use Try::Tiny; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | use XAS::Class | ||
| 9 | 0 | ▶ | debug => 0, |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 10 | version => $VERSION, | ||
| 11 | base => 'XAS::Collector::Output::Socket::Base', | ||
| 12 | utils => 'trim', | ||
| 13 | 1 | ; | |
| 14 | |||
| 15 | #use Data::Dumper; | ||
| 16 | |||
| 17 | # ---------------------------------------------------------------------- | ||
| 18 | # Public Events | ||
| 19 | # ---------------------------------------------------------------------- | ||
| 20 | |||
| 21 | sub store_data { | ||
| 22 | my ($self, $data, $ack, $input) = @_[OBJECT, ARG0...ARG2]; | ||
| 23 | |||
| 24 | my $alias = $self->alias; | ||
| 25 | |||
| 26 | $self->log->debug("$alias: entering store_data()"); | ||
| 27 | |||
| 28 | try { | ||
| 29 | |||
| 30 | my $packet = sprintf("put %s", $data); | ||
| 31 | |||
| 32 | $poe_kernel->call($alias, 'write_data', $packet); | ||
| 33 | # $self->log->info_msg('send', $alias); | ||
| 34 | |||
| 35 | } catch { | ||
| 36 | |||
| 37 | my $ex = $_; | ||
| 38 | |||
| 39 | $self->log->debug(Dumper($data)); | ||
| 40 | $self->exception_handler($ex); | ||
| 41 | |||
| 42 | }; | ||
| 43 | |||
| 44 | $poe_kernel->post($input, 'write_data', $ack); | ||
| 45 | $self->log->debug("$alias: leaving store_data()"); | ||
| 46 | |||
| 47 | } | ||
| 48 | |||
| 49 | # ---------------------------------------------------------------------- | ||
| 50 | # Public Methods | ||
| 51 | # ---------------------------------------------------------------------- | ||
| 52 | |||
| 53 | # ---------------------------------------------------------------------- | ||
| 54 | # Private Methods | ||
| 55 | # ---------------------------------------------------------------------- | ||
| 56 | |||
| 57 | 1; | ||
| 58 | |||
| 59 | __END__ | ||
| 60 | |||
| 61 | =head1 NAME | ||
| 62 | |||
| 63 | XAS::Collector::Output::Socket::OpenTSDB - A class to interact with OpenTSDB | ||
| 64 | |||
| 65 | =head1 SYNOPSIS | ||
| 66 | |||
| 67 | use XAS::Collector::Output::Socket::OpenTSDB; | ||
| 68 | |||
| 69 | my $output = XAS::Collector::Output::Socket::OpenTSDB->new( | ||
| 70 | -alias => 'output-opentsdb', | ||
| 71 | ); | ||
| 72 | |||
| 73 | =head1 DESCRIPTION | ||
| 74 | |||
| 75 | This module will open and maintain a connection to a L<OpenTSDB|http://opentsdb.net/> server. | ||
| 76 | |||
| 77 | =head1 METHODS | ||
| 78 | |||
| 79 | =head2 new | ||
| 80 | |||
| 81 | This module inherits from L<XAS::Collector::Output::Socket::Base|XAS::Collector::Output::Socket::Base> | ||
| 82 | and takes the same parameters. | ||
| 83 | |||
| 84 | =head1 PUBLIC EVENTS | ||
| 85 | |||
| 86 | =head2 store_data(OBJECT, ARG0, ARG1, ARG2) | ||
| 87 | |||
| 88 | This event will trigger the sending of packets to a L<OpenTSDB|http://opentsdb.net/> instance. | ||
| 89 | |||
| 90 | =over 4 | ||
| 91 | |||
| 92 | =item B<OBJECT> | ||
| 93 | |||
| 94 | A handle to the current object. | ||
| 95 | |||
| 96 | =item B<ARG0> | ||
| 97 | |||
| 98 | The data to be stored within the database. | ||
| 99 | |||
| 100 | =item B<ARG1> | ||
| 101 | |||
| 102 | The acknowledgement to send back to the message queue server. | ||
| 103 | |||
| 104 | =item B<ARG2> | ||
| 105 | |||
| 106 | The input to return the ack too. | ||
| 107 | |||
| 108 | =back | ||
| 109 | |||
| 110 | =head1 SEE ALSO | ||
| 111 | |||
| 112 | =over 4 | ||
| 113 | |||
| 114 | =item L<XAS::Collector::Output::Socket::Base|XAS::Collector::Output::Socket::Base> | ||
| 115 | |||
| 116 | =item L<XAS::Collector::Output::Socket::Logstash|XAS::Collector::Output::Socket::Logstash> | ||
| 117 | |||
| 118 | =item L<XAS::Collector|XAS::Collector> | ||
| 119 | |||
| 120 | =item L<XAS|XAS> | ||
| 121 | |||
| 122 | =back | ||
| 123 | |||
| 124 | =head1 AUTHOR | ||
| 125 | |||
| 126 | Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt> | ||
| 127 | |||
| 128 | =head1 COPYRIGHT AND LICENSE | ||
| 129 | |||
| 130 | Copyright (c) 2012-2015 Kevin L. Esteb | ||
| 131 | |||
| 132 | This is free software; you can redistribute it and/or modify it under | ||
| 133 | the terms of the Artistic License 2.0. For details, see the full text | ||
| 134 | of the license at http://www.perlfoundation.org/artistic_license_2_0. | ||
| 135 | |||
| 136 | =cut | ||