line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Async::Graphite; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.1_1'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Net::Async::Graphite - Request data from graphite |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Net::Async::Graphite; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $graphite = Net::Async::Graphite->new( |
14
|
|
|
|
|
|
|
endpoint => 'https://graphite.example.com/', |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Find (requires graphite-api) |
18
|
|
|
|
|
|
|
my $metrics = $graphite->metrics_asperl('foo.*.datum')->get; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Download |
21
|
|
|
|
|
|
|
my $data = $graphite->render_asperl('foo.*.datum')->get; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Draw |
24
|
|
|
|
|
|
|
my $png = $graphite->render(png => 'foo.*.datum')->get; |
25
|
|
|
|
|
|
|
# or my $png = $graphite->png('foo.*.datum')->get; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Draw with gnuplot (requires gnuplot) |
28
|
|
|
|
|
|
|
my $ascii = $graphite->plot('foo.*.datum')->get; |
29
|
|
|
|
|
|
|
print $ascii; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
An interface to Graphite's data-request APIs graphite-web and |
34
|
|
|
|
|
|
|
graphite-api (which include's graphite-web's /render API). |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Preliminary support exists in this version for most of the |
37
|
|
|
|
|
|
|
functionality of C, C, C and |
38
|
|
|
|
|
|
|
C which is described in detail in |
39
|
|
|
|
|
|
|
L. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
There is also support to pass the raw data obtained from C |
42
|
|
|
|
|
|
|
into gnuplot, which includes the ability to format it for terminal |
43
|
|
|
|
|
|
|
output. This support will probably be made optional at some point or |
44
|
|
|
|
|
|
|
maybe split into its own package. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 BUGS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
No attempt is made to configure a timeout for the HTTP request. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
See individual components for their bugs that I know about. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
3
|
|
389571
|
use v5.14; |
|
3
|
|
|
|
|
11
|
|
55
|
3
|
|
|
3
|
|
1227
|
use strictures 2; |
|
3
|
|
|
|
|
3825
|
|
|
3
|
|
|
|
|
111
|
|
56
|
3
|
|
|
3
|
|
1790
|
use Moo; |
|
3
|
|
|
|
|
26462
|
|
|
3
|
|
|
|
|
17
|
|
57
|
3
|
|
|
3
|
|
3556
|
use Carp; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
154
|
|
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
3
|
|
1153
|
use namespace::clean; |
|
3
|
|
|
|
|
28248
|
|
|
3
|
|
|
|
|
19
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 OBJECT |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Net::Async::Graphite is an object built from individual roles using |
64
|
|
|
|
|
|
|
L. It uses L internally to provide an asynchronous |
65
|
|
|
|
|
|
|
interface to the remote API and so all methods return a L |
66
|
|
|
|
|
|
|
object. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
If you don't know about L or don't want to, you must only |
69
|
|
|
|
|
|
|
remember to call C on the return value of any |
70
|
|
|
|
|
|
|
L method: |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $data_when_it_comes = $graphite->render('me.tr.ic'); |
73
|
|
|
|
|
|
|
...; # Later |
74
|
|
|
|
|
|
|
my $data_finally = $data_when_it_comes->get(); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# or |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $data_now = $graphite->render('me.tr.ic')->get(); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L's API consists of all of the methods, |
81
|
|
|
|
|
|
|
attributes and accessors defined in its roles (and theirs (and theirs |
82
|
|
|
|
|
|
|
(etc.))) which do not begin with an C<_>. Being perl you are welcome |
83
|
|
|
|
|
|
|
to use these private methods, and even dig around inside the object's |
84
|
|
|
|
|
|
|
guts if you wish, but they do not constitute any part of the stable[*] |
85
|
|
|
|
|
|
|
API. You are thus also welcome to deal with the ensuing breakage. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
[*] Hahaha. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L's functionality comes from these roles: |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item L |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Interface between perl and Graphite's APIs (C and |
96
|
|
|
|
|
|
|
C). Of most interest are: |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=begin comment |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
usename and password don't both need a description but then it looks silly. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=end comment |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=over |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item username |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Mixed in by L. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item password |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Mixed in by L. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item endpoint |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item metrics() |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item render() |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item find_target_from_spec() |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=back |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item L |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Render data in various ways after it has been downloaded. Note that |
127
|
|
|
|
|
|
|
Graphite's C API include its own drawing routines which are |
128
|
|
|
|
|
|
|
not related to or affected by this role. This role uses data obtained |
129
|
|
|
|
|
|
|
from C API call with C; the relationship ends |
130
|
|
|
|
|
|
|
there. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Of most interest are: |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item last_value() |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item plot() |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
with 'Net::Async::Graphite::API'; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
with 'Net::Async::Graphite::Draw'; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
I don't know if I want these. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=over |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item default_from |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item default_until |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Default values for C and C URI parameters. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
has default_from => is => rw => predicate => 1; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
has default_until => is => rw => predicate => 1; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
1; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=back |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 SEE ALSO |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
L |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
L |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
L |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
L |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 AUTHOR |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Matthew King |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |