Collector/Output/Console/Alerts.pm

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Collector/Output/Socket/OpenTSDB.pm ↑ Summary Collector/Output/Console/Logs.pm »
1 package XAS::Collector::Output::Console::Alerts;
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 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 use XAS::Class
10 0 ▶ debug => 0,
Subroutine BEGIN: called CC=1 SCAR=2.6
11 version => $VERSION,
12 base => 'XAS::Collector::Output::Console::Base',
13 1 ;
14  
15 # --------------------------------------------------------------------
16 # Public Events
17 # --------------------------------------------------------------------
18  
19 sub store_data {
20 my ($self, $data, $ack, $input) = @_[OBJECT,ARG0...ARG2];
21  
22 my $buffer;
23 my $alias = $self->alias;
24 my $schema = $self->schema;
25  
26 $self->log->debug("$alias: entering store_data()");
27  
28 $buffer = sprintf('%s: hostname = %s; timestamp = %s; priority = %s; facility = %s; message = %s',
29 $alias, $data->{'hostname'}, $data->{'datetime'}, $data->{'priority'},
30 $data->{'facility'}, $data->{'message'}
31 );
32  
33 $self->log->debug($buffer);
34 $self->log->info(Dumper($data));
35 $self->log->info_msg('collector_processed', $alias, 1, $data->{'hostname'}, $data->{'datetime'});
36  
37 $poe_kernel->post($input, 'write_data', $ack);
38  
39 $self->log->debug("$alias: leaving store_notify()");
40  
41 }
42  
43 # --------------------------------------------------------------------
44 # Public Methods
45 # --------------------------------------------------------------------
46  
47 # --------------------------------------------------------------------
48 # Private Methods
49 # --------------------------------------------------------------------
50  
51 1;
52  
53 __END__
54  
55 =head1 NAME
56  
57 XAS::Collector::Output::Console::Alerts - Perl extension for the XAS Environment
58  
59 =head1 SYNOPSIS
60  
61 use XAS::Collector::Output::Console::Alerts;
62  
63 my $output = XAS::Collector::Output::Console::Alerts->new(
64 -alias => 'database-alerts',
65 );
66  
67 =head1 DESCRIPTION
68  
69 This module handles the xas-alerts packet type.
70  
71 =head1 METHODS
72  
73 =head2 new
74  
75 This module inherits from L<XAS::Collector::Output::Console::Base|XAS::Collector::Output::Console::Base>
76 and takes the same parameters.
77  
78 =head1 PUBLIC EVENTS
79  
80 =head2 store_data(OBJECT, ARG0, ARG1, ARG2)
81  
82 This event will dump the contain of xas-alerts packets to the console using
83 L<Data::Dumper|https://metacpan.org/pod/Data::Dumper>.
84  
85 =over 4
86  
87 =item B<OBJECT>
88  
89 A handle to the current object.
90  
91 =item B<ARG0>
92  
93 The data to be stored within the database.
94  
95 =item B<ARG1>
96  
97 The acknowledgement to send back to the message queue server.
98  
99 =item B<ARG2>
100  
101 The input to return the ack too.
102  
103 =back
104  
105 =head1 SEE ALSO
106  
107 =over 4
108  
109 =item L<XAS::Collector::Output::Console::Base|XAS::Collector::Output::Console::Base>
110  
111 =item L<XAS::Collector::Output::Console::Logs|XAS::Collector::Output::Console::Logs>
112  
113 =item L<XAS::Collector|XAS::Collector>
114  
115 =item L<XAS|XAS>
116  
117 =back
118  
119 =head1 AUTHOR
120  
121 Kevin Esteb, E<lt>kevin@kesteb.usE<gt>
122  
123 =head1 COPYRIGHT AND LICENSE
124  
125 Copyright (c) 2012-2015 Kevin L. Esteb
126  
127 This is free software; you can redistribute it and/or modify it under
128 the terms of the Artistic License 2.0. For details, see the full text
129 of the license at http://www.perlfoundation.org/artistic_license_2_0.
130  
131 =cut
« Collector/Output/Socket/OpenTSDB.pm ↑ Summary Collector/Output/Console/Logs.pm »