line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseFS::Disk; |
2
|
1
|
|
|
1
|
|
50062
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
104
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
1826
|
use IO::Socket::INET; |
|
1
|
|
|
|
|
37703
|
|
|
1
|
|
|
|
|
13
|
|
5
|
1
|
|
|
1
|
|
2335
|
use Moo; |
|
1
|
|
|
|
|
25332
|
|
|
1
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'MooseFS::Server'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has HDtime => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
default => sub { 'max' } |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has HDperiod => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
default => sub { 'min' } |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub BUILD { |
20
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
21
|
0
|
|
|
|
|
|
my $inforef; |
22
|
0
|
|
|
|
|
|
for my $ip ( keys %{ $self->info } ) { |
|
0
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $port = $self->info->{$ip}->{port}; |
24
|
0
|
|
|
|
|
|
my $ns = IO::Socket::INET->new( |
25
|
|
|
|
|
|
|
PeerAddr => $ip, |
26
|
|
|
|
|
|
|
PeerPort => $port, |
27
|
|
|
|
|
|
|
Proto => 'tcp', |
28
|
|
|
|
|
|
|
); |
29
|
0
|
|
|
|
|
|
print $ns pack('(LL)>', 600, 0); |
30
|
0
|
|
|
|
|
|
my $nheader = $self->myrecv($ns, 8); |
31
|
0
|
|
|
|
|
|
my ($ncmd, $nlength) = unpack('(LL)>', $nheader); |
32
|
0
|
0
|
|
|
|
|
if ( $ncmd == 601 ) { |
33
|
0
|
|
|
|
|
|
my $data = $self->myrecv($ns, $nlength); |
34
|
0
|
|
|
|
|
|
while ( $nlength > 0 ) { |
35
|
0
|
|
|
|
|
|
my ($entrysize) = unpack("S>", substr($data, 0, 2)); |
36
|
0
|
|
|
|
|
|
my $entry = substr($data, 2, $entrysize); |
37
|
0
|
|
|
|
|
|
$data = substr($data, 2+$entrysize); |
38
|
0
|
|
|
|
|
|
$nlength -= 2 + $entrysize; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $plen = ord(substr($entry, 0, 1)); |
41
|
0
|
|
|
|
|
|
my $ip_path = sprintf "%s:%u:%s", $ip, $port, substr($entry, 1, $plen); |
42
|
0
|
|
|
|
|
|
my ($flags, $errchunkid, $errtime, $used, $total, $chunkscnt) = unpack("(CQLQQL)>", substr($entry, $plen+1, 33)); |
43
|
0
|
|
|
|
|
|
my ($rbytes, $wbytes, $usecreadsum, $usecwritesum, $usecfsyncsum, $rops, $wops, $fsyncops, $usecreadmax, $usecwritemax, $usecfsyncmax); |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if ($entrysize == $plen + 34 + 144 ) { |
|
|
0
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
if ($self->HDperiod eq 'min' ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
($rbytes, $wbytes, $usecreadsum, $usecwritesum, $rops, $wops, $usecreadmax, $usecwritemax) = unpack("(QQQQLLLL)>", substr($entry, $plen+34, 48)); |
49
|
|
|
|
|
|
|
} elsif ($self->HDperiod eq 'hour') { |
50
|
0
|
|
|
|
|
|
($rbytes, $wbytes, $usecreadsum, $usecwritesum, $rops, $wops, $usecreadmax, $usecwritemax) = unpack("(QQQQLLLL)>", substr($entry, $plen+34+48, 48)); |
51
|
|
|
|
|
|
|
} elsif ($self->HDperiod eq 'day') { |
52
|
0
|
|
|
|
|
|
($rbytes, $wbytes, $usecreadsum, $usecwritesum, $rops, $wops, $usecreadmax, $usecwritemax) = unpack("(QQQQLLLL)>", substr($entry, $plen+34+48+48, 48)); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} elsif ( $entrysize == $plen + 34 + 192 ) { |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
if ($self->HDperiod eq 'min' ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
($rbytes, $wbytes, $usecreadsum, $usecwritesum, $usecfsyncsum, $rops, $wops, $fsyncops, $usecreadmax, $usecwritemax, $usecfsyncmax) = unpack("(QQQQQLLLLLL)>", substr($entry, $plen+34, 64)); |
59
|
|
|
|
|
|
|
} elsif ($self->HDperiod eq 'hour') { |
60
|
0
|
|
|
|
|
|
($rbytes, $wbytes, $usecreadsum, $usecwritesum, $usecfsyncsum, $rops, $wops, $fsyncops, $usecreadmax, $usecwritemax, $usecfsyncmax) = unpack("(QQQQQLLLLLL)>", substr($entry, $plen+34+64, 64)); |
61
|
|
|
|
|
|
|
} elsif ($self->HDperiod eq 'day') { |
62
|
0
|
|
|
|
|
|
($rbytes, $wbytes, $usecreadsum, $usecwritesum, $usecfsyncsum, $rops, $wops, $fsyncops, $usecreadmax, $usecwritemax, $usecfsyncmax) = unpack("(QQQQQLLLLLL)>", substr($entry, $plen+34+64+64, 64)); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my ($rtime, $wtime, $fsynctime); |
68
|
0
|
0
|
|
|
|
|
if ($self->HDtime eq 'avg') { |
69
|
0
|
0
|
|
|
|
|
if ($rops > 0) { |
70
|
0
|
|
|
|
|
|
$rtime = $usecreadsum/$rops; |
71
|
|
|
|
|
|
|
} else { |
72
|
0
|
|
|
|
|
|
$rtime = 0; |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
if ($wops > 0) { |
76
|
0
|
|
|
|
|
|
$wtime = $usecwritesum/$wops; |
77
|
|
|
|
|
|
|
} else { |
78
|
0
|
|
|
|
|
|
$wtime = 0; |
79
|
|
|
|
|
|
|
}; |
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
if ($fsyncops > 0) { |
82
|
0
|
|
|
|
|
|
$fsynctime = $usecfsyncsum/$fsyncops; |
83
|
|
|
|
|
|
|
} else { |
84
|
0
|
|
|
|
|
|
$fsynctime = 0; |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
} else { |
87
|
0
|
|
|
|
|
|
$rtime = $usecreadmax; |
88
|
0
|
|
|
|
|
|
$wtime = $usecwritemax; |
89
|
0
|
|
|
|
|
|
$fsynctime = $usecfsyncmax; |
90
|
|
|
|
|
|
|
}; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $status; |
93
|
0
|
0
|
|
|
|
|
if ($flags == 1) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$status = 'marked for removal'; |
95
|
|
|
|
|
|
|
} elsif ($flags == 2) { |
96
|
0
|
|
|
|
|
|
$status = 'damaged'; |
97
|
|
|
|
|
|
|
} elsif ($flags == 3) { |
98
|
0
|
|
|
|
|
|
$status = 'damaged, marked for removal'; |
99
|
|
|
|
|
|
|
} else { |
100
|
0
|
|
|
|
|
|
$status = 'ok'; |
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
my $lerror; |
104
|
0
|
0
|
0
|
|
|
|
if ($errtime == 0 and $errchunkid == 0) { |
105
|
0
|
|
|
|
|
|
$lerror = 'no errors'; |
106
|
|
|
|
|
|
|
} else { |
107
|
0
|
|
|
|
|
|
$lerror = localtime($errtime); |
108
|
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
my $rbsize = $rops > 0 ? $rbytes / $rops : 0; |
111
|
0
|
0
|
|
|
|
|
my $wbsize = $wops > 0 ? $wbytes / $wops : 0; |
112
|
0
|
0
|
|
|
|
|
my $percent_used = $total > 0 ? ($used * 100.0) / $total : '-'; |
113
|
0
|
0
|
|
|
|
|
my $rbw = $usecreadsum > 0 ? $rbytes * 1000000 / $usecreadsum : 0; |
114
|
0
|
0
|
|
|
|
|
my $wbw = $usecwritesum + $usecfsyncsum > 0 ? $wbytes *1000000 / ($usecwritesum + $usecfsyncsum) : 0; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
$self->info->{$ip} = { |
117
|
|
|
|
|
|
|
ip_path => $ip_path, |
118
|
|
|
|
|
|
|
flags => $flags, |
119
|
|
|
|
|
|
|
errchunkid => $errchunkid, |
120
|
|
|
|
|
|
|
errtime => $errtime, |
121
|
|
|
|
|
|
|
used => $used, |
122
|
|
|
|
|
|
|
total => $total, |
123
|
|
|
|
|
|
|
chunkscount => $chunkscnt, |
124
|
|
|
|
|
|
|
rbw => $rbw, |
125
|
|
|
|
|
|
|
wbw => $wbw, |
126
|
|
|
|
|
|
|
rtime => $rtime, |
127
|
|
|
|
|
|
|
wtime => $wtime, |
128
|
|
|
|
|
|
|
fsynctime => $fsynctime, |
129
|
|
|
|
|
|
|
read_ops => $rops, |
130
|
|
|
|
|
|
|
write_ops => $wops, |
131
|
|
|
|
|
|
|
fsyncops => $fsyncops, |
132
|
|
|
|
|
|
|
read_bytes => $rbytes, |
133
|
|
|
|
|
|
|
write_bytes => $wbytes, |
134
|
|
|
|
|
|
|
usecreadsum => $usecreadsum, |
135
|
|
|
|
|
|
|
usecwritesum => $usecwritesum, |
136
|
|
|
|
|
|
|
status => $status, |
137
|
|
|
|
|
|
|
lerror => $lerror, |
138
|
|
|
|
|
|
|
rbsize => $rbsize, |
139
|
|
|
|
|
|
|
wbsize => $wbsize, |
140
|
|
|
|
|
|
|
percent_used => $percent_used, |
141
|
|
|
|
|
|
|
}; |
142
|
|
|
|
|
|
|
}; |
143
|
|
|
|
|
|
|
} |
144
|
0
|
|
|
|
|
|
close($ns); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |