line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Linux::GetPidstat::Writer; |
2
|
14
|
|
|
14
|
|
103936
|
use 5.008001; |
|
14
|
|
|
|
|
44
|
|
3
|
14
|
|
|
14
|
|
60
|
use strict; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
276
|
|
4
|
14
|
|
|
14
|
|
70
|
use warnings; |
|
14
|
|
|
|
|
18
|
|
|
14
|
|
|
|
|
280
|
|
5
|
|
|
|
|
|
|
|
6
|
14
|
|
|
14
|
|
59
|
use Time::Piece; |
|
14
|
|
|
|
|
236
|
|
|
14
|
|
|
|
|
104
|
|
7
|
14
|
|
|
14
|
|
4105
|
use Linux::GetPidstat::Writer::File; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
333
|
|
8
|
14
|
|
|
14
|
|
3324
|
use Linux::GetPidstat::Writer::Mackerel; |
|
14
|
|
|
|
|
66
|
|
|
14
|
|
|
|
|
3918
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
21
|
|
|
21
|
0
|
23803
|
my ( $class, %opt ) = @_; |
12
|
21
|
|
|
|
|
159
|
bless \%opt, $class; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub output { |
16
|
20
|
|
|
20
|
0
|
2333
|
my ($self, $ret_pidstats) = @_; |
17
|
|
|
|
|
|
|
|
18
|
20
|
|
|
|
|
52
|
my $file; |
19
|
20
|
50
|
|
|
|
284
|
if (length $self->{res_file}) { |
20
|
|
|
|
|
|
|
$file = Linux::GetPidstat::Writer::File->new( |
21
|
|
|
|
|
|
|
res_file => $self->{res_file}, |
22
|
|
|
|
|
|
|
now => $self->{now}, |
23
|
|
|
|
|
|
|
dry_run => $self->{dry_run}, |
24
|
20
|
|
|
|
|
341
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
20
|
|
|
|
|
63
|
my $mackerel; |
28
|
20
|
100
|
|
|
|
79
|
if (length $self->{mackerel_metric_type}) { |
29
|
|
|
|
|
|
|
$mackerel = Linux::GetPidstat::Writer::Mackerel->new( |
30
|
|
|
|
|
|
|
mackerel_metric_type => $self->{mackerel_metric_type}, |
31
|
|
|
|
|
|
|
mackerel_api_key => $self->{mackerel_api_key}, |
32
|
|
|
|
|
|
|
mackerel_service_name => $self->{mackerel_service_name}, |
33
|
|
|
|
|
|
|
mackerel_metric_key_prefix => $self->{mackerel_metric_key_prefix}, |
34
|
|
|
|
|
|
|
mackerel_host_id => $self->{mackerel_host_id}, |
35
|
|
|
|
|
|
|
now => $self->{now}, |
36
|
|
|
|
|
|
|
dry_run => $self->{dry_run}, |
37
|
6
|
|
|
|
|
125
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# ex. backup_mysql => { cpu => 21.0 } |
41
|
20
|
|
|
|
|
123
|
while (my ($program_name, $s) = each %$ret_pidstats) { |
42
|
40
|
|
|
|
|
1914
|
while (my ($metric_name, $metric) = each %$s) { |
43
|
360
|
50
|
|
|
|
28617
|
if ($file) { |
44
|
360
|
|
|
|
|
960
|
$file->output($program_name, $metric_name, $metric); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
20
|
100
|
|
|
|
2113
|
if ($mackerel) { |
49
|
6
|
|
|
|
|
64
|
$mackerel->bulk_output($ret_pidstats); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |