line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseFS::Server; |
2
|
2
|
|
|
2
|
|
90943
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
63
|
|
4
|
2
|
|
|
2
|
|
4496
|
use IO::Socket::INET; |
|
2
|
|
|
|
|
26477
|
|
|
2
|
|
|
|
|
17
|
|
5
|
2
|
|
|
2
|
|
2626
|
use Moo; |
|
2
|
|
|
|
|
18411
|
|
|
2
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'MooseFS'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has count => ( |
10
|
|
|
|
|
|
|
is => 'rw', |
11
|
|
|
|
|
|
|
default => sub { 0 } |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has list => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
default => sub { [] } |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has info => ( |
20
|
|
|
|
|
|
|
is => 'rw', |
21
|
|
|
|
|
|
|
default => sub { {} } |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub BUILD { |
25
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
26
|
0
|
|
|
|
|
|
my $s = $self->sock; |
27
|
0
|
|
|
|
|
|
print $s pack('(LL)>', 500, 0); |
28
|
0
|
|
|
|
|
|
my $header = $self->myrecv($s, 8); |
29
|
0
|
|
|
|
|
|
my ($cmd, $length) = unpack('(LL)>', $header); |
30
|
0
|
0
|
0
|
|
|
|
if ( $cmd == 501 and $length % 54 == 0 ) { |
31
|
0
|
|
|
|
|
|
my $data = $self->myrecv($s, $length); |
32
|
0
|
|
|
|
|
|
my $count = $length / 54; |
33
|
0
|
|
|
|
|
|
$self->count($count); |
34
|
0
|
|
|
|
|
|
for my $num ( 0 .. $count - 1 ) { |
35
|
0
|
|
|
|
|
|
my $d = substr($data, $num*54, 54); |
36
|
0
|
|
|
|
|
|
my ($v1, $v2, $v3, $ip1, $ip2, $ip3, $ip4, $port, $used, $total, $chunks, $tdused, $tdtotal, $tdchunks, $errcnt) = unpack('(SCCCCCCSQQLQQLL)>', $d); |
37
|
0
|
0
|
|
|
|
|
my $percent = $total > 0 ? ($used * 100)/$total : ''; |
38
|
0
|
0
|
|
|
|
|
my $tdpercent = $tdtotal > 0 ? ($tdused * 100)/$tdtotal : ''; |
39
|
0
|
|
|
|
|
|
my $ip = "$ip1.$ip2.$ip3.$ip4"; |
40
|
0
|
|
|
|
|
|
push @{$self->list}, $ip; |
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$self->info->{$ip} = { |
42
|
|
|
|
|
|
|
version => "$v1.$v2.$v3", |
43
|
|
|
|
|
|
|
port => $port, |
44
|
|
|
|
|
|
|
used => $used, |
45
|
|
|
|
|
|
|
total => $total, |
46
|
|
|
|
|
|
|
chunks => $chunks, |
47
|
|
|
|
|
|
|
percent_used => $percent, |
48
|
|
|
|
|
|
|
tdused => $tdused, |
49
|
|
|
|
|
|
|
tdtotal => $tdtotal, |
50
|
|
|
|
|
|
|
tdchunks => $tdchunks, |
51
|
|
|
|
|
|
|
tdpercent_used => $tdpercent, |
52
|
|
|
|
|
|
|
errcnt => $errcnt, |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |