line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Measure::Everything::Adapter::InfluxDB::File; |
2
|
1
|
|
|
1
|
|
728
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.000'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Write stats formatted as InfluxDB lines into a file |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
3
|
use Config; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
10
|
1
|
|
|
1
|
|
3
|
use Fcntl qw/:flock/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
177
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
7
|
use base qw(Measure::Everything::Adapter::Base); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
142
|
|
13
|
1
|
|
|
1
|
|
581
|
use InfluxDB::LineProtocol qw(data2line); |
|
1
|
|
|
|
|
2898
|
|
|
1
|
|
|
|
|
207
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $HAS_FLOCK = $Config{d_flock} || $Config{d_fcntl_can_lock} || $Config{d_lockf}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
19
|
0
|
|
|
|
|
|
my $file = $self->{file}; |
20
|
0
|
0
|
|
|
|
|
open( $self->{fh}, ">>", $file ) |
21
|
|
|
|
|
|
|
or die "cannot open '$file' for append: $!"; |
22
|
0
|
|
|
|
|
|
$self->{fh}->autoflush(1); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub write { |
26
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
27
|
0
|
|
|
|
|
|
my $line = data2line(@_); |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
flock($self->{fh}, LOCK_EX) if $HAS_FLOCK; |
30
|
0
|
|
|
|
|
|
$self->{fh}->print($line."\n"); |
31
|
0
|
0
|
|
|
|
|
flock($self->{fh}, LOCK_UN) if $HAS_FLOCK; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |