line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nagios::Passive::Role::Tempfile; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
3102
|
use Moo::Role; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
33
|
|
4
|
3
|
|
|
3
|
|
1639
|
use MooX::late; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
29
|
|
5
|
3
|
|
|
3
|
|
588
|
use File::Temp; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
599
|
|
6
|
3
|
|
|
3
|
|
26
|
use Fcntl qw/:DEFAULT :flock/; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
2522
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
requires 'checkresults_dir'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'tempfile' => ( is => 'ro', isa => 'File::Temp', lazy_build => 1); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _build_tempfile { |
13
|
1
|
|
|
1
|
|
18
|
my $self = shift; |
14
|
1
|
|
|
|
|
22
|
my $fh = File::Temp->new( |
15
|
|
|
|
|
|
|
TEMPLATE => "cXXXXXX", |
16
|
|
|
|
|
|
|
DIR => $self->checkresults_dir, |
17
|
|
|
|
|
|
|
); |
18
|
1
|
|
|
|
|
871
|
$fh->unlink_on_destroy(0); |
19
|
1
|
|
|
|
|
40
|
return $fh; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _touch_file { |
23
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
24
|
1
|
|
|
|
|
24
|
my $fh = $self->tempfile; |
25
|
1
|
|
|
|
|
15
|
my $file = $fh->filename.".ok"; |
26
|
1
|
50
|
|
|
|
100
|
sysopen my $t,$file,O_WRONLY|O_CREAT|O_NONBLOCK|O_NOCTTY |
27
|
|
|
|
|
|
|
or croak("Can't create $file : $!"); |
28
|
1
|
50
|
|
|
|
18
|
close $t or croak("Can't close $file : $!"); |
29
|
1
|
|
|
|
|
11
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |