line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Measure::Everything::Adapter::InfluxDB::File; |
2
|
1
|
|
|
1
|
|
606
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
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
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
10
|
1
|
|
|
1
|
|
4
|
use Fcntl qw/:flock/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
113
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use base qw(Measure::Everything::Adapter::Base); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
69
|
|
13
|
1
|
|
|
1
|
|
378
|
use InfluxDB::LineProtocol qw(data2line); |
|
1
|
|
|
|
|
3868
|
|
|
1
|
|
|
|
|
6
|
|
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__ |