-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathceph_w.m
264 lines (224 loc) · 8.91 KB
/
ceph_w.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
%% this file is to parse the "ceph -w" output
%% how to use: run "ceph -w" to get the output (either copy from screen or use ">>"), and then change the filename below correspondingly.
%% configuration area
% file to be parsed
filename='E:\Dropbox\Report\ceph\shell\results\filestore_fill_test_cleanup_ceph_w.txt';
% total number of PGs; will be calcuated automatially later
pg_num=1024;
% reserved parameters
% rep_num=2; ec_num=3; % =m+k
% node_num=4;
% in case that the batch write testing file is not synchozed with ceph_w, we shall add a shift value.
% time_shift=0.467
% need to pre-define the status you are interested. --> will write a script to automatically include all status later.
pg_status={'active+clean','active+clean+scrubbing','active+clean+inconsistent','peering','active+clean+scrubbing+deep','stale+active+clean','stale+peering','stale+remapped','down+peering','down+remapped+peering','stale+activating+undersized+degraded','active+recovering+degraded','stale+active+undersized+degraded','stale+active+recovery_wait+degraded','stale+active+recovery_wait+undersized+degraded','active+recovery_wait+degraded','stale+activating+degraded'};
fid=fopen(filename);
if fid<0
'error in openning the file...'
break;
end
tline=fgetl(fid);
pg_status_num=size(pg_status,2);
pg_record=zeros(100000,pg_status_num);
time_record=zeros(100000,1);
use_record=zeros(100000,6);
pg_inc=10000;
i=0; line_cont=1;
while ischar(tline)
% may add a line to omit [WRN]
% get the status string
idx0=strfind(tline,':');
idx1=strfind(tline,';');
idx6=strfind(tline,'/');
if (size(idx0,2)>1) & (size(idx1,2)>=1) & (size(idx6,2)>=1)
idx4=strfind(tline,',');
str_len=size(tline,2);
i=i+1;
% collect the time information
time_str=tline(1:26); % may change 26 for different format; % '2016-10-30 08:01:57.507576';
time_record(i)=datenum(time_str,'yyyy-mm-dd HH:MM:SS.FFF');
% collect the data usage information
idx5=find(idx4>idx1(1),1,'first');
usage_str=tline(idx1(1)+1:idx4(idx5)-1);
use_record(i,1)=sscanf(usage_str,'%d%*s'); % data usage
if ~isempty(strfind(usage_str,'kB'))
use_record(i,1)=use_record(i,1)/1024^2;
elseif ~isempty(strfind(usage_str,'MB'))
use_record(i,1)=use_record(i,1)/1024;
elseif ~isempty(strfind(usage_str,'GB'))
% the following code is temprary to connect two "ceph -s"
if (use_record(i-1,1)>=18990) && (use_record(i,1)<18990)
use_record(i,1)=use_record(i,1)+18990;
end
end
usage_str2=tline(idx4(idx5)+1:idx4(idx5+1)-1);
use_record(i,2)=sscanf(usage_str2,'%d%*s'); % total usage
idx7=find(idx4<idx6(1),1,'last');
usage_str3 =tline(idx4(idx7)+1:str_len); %avaible / total
use_record(i,3:4)=sscanf(usage_str3,'%d GB / %d GB avail');
if i==1
total_size=use_record(i,4);
end
% collect the status information
status_str=tline(idx0(4)+1:idx1(1)-1);
idx2=strfind(status_str,',');
if isempty(idx2)
status_term_num=1;
else
status_term_num=size(idx2,2)+1;
end
status_str_vec={};
if status_term_num>1
% separate the string
for k=1:status_term_num
if k==1
status_str_vec{k}=status_str(1:idx2(k)-1);
elseif k<status_term_num
status_str_vec{k}=status_str((idx2(k-1)+1):(idx2(k)-1));
else
status_str_vec{k}=status_str((idx2(k-1)+1):size(status_str,2));
end
end
end
% check which status
% for convenience, we may also check status_str_vec with another
% "for" loop
for j=1:pg_status_num
idx3=strfind(status_str,pg_status{j});
if ~isempty(idx3)
if status_term_num==1
temp_value=sscanf(status_str,'%d %*s');
else
% find the exactly matched string
find_right_str=0;
for ll=1:size(idx3,2)
% there are 3 cases: first, between, and last;
if (status_str(idx3(ll)-1)==' ')
if idx3(ll)+size(pg_status{j},2)>size(status_str,2)
find_right_str=1;
elseif (status_str(idx3(ll)+size(pg_status{j},2))==',')
find_right_str=1;
else
find_right_str=0;
end
if find_right_str==1
if idx2>idx3(ll)
% the first string
temp_value=sscanf(status_str,'%d %*s');
else
[a,b]=find(idx2<idx3(ll),1,'last');
temp_value=sscanf(status_str(idx2(b)+1:idx3(ll)),'%d %*s');
break;
end
end
end
end
end
pg_record(i,j)=temp_value(1);
end
end
%% collect the transmission & operation speed
if size(idx1,2)>1
so_str=tline(idx1(2)+1:str_len);
use_record(i,5)=sscanf(so_str,'%d');
if ~isempty(strfind(so_str,'kB'))
use_record(i,5)=use_record(i,5)/1024;
elseif ~isempty(strfind(so_str,'MB'))
% use_record(i,1)=use_record(i,1)/1024;
% not consider GB
end
idx10=strfind(so_str,',');
o_str=so_str(idx10+1:size(so_str,2));
use_record(i,6)=sscanf(o_str,'%d');
else
use_record(i,5)=NaN;
use_record(i,6)=NaN;
end
end
tline=fgetl(fid); line_cont=line_cont+1;
if mod(line_cont,5000)==0
disp(['processed ', int2str(line_cont), ' lines']);
end
end
fclose(fid)
pg_record=pg_record(1:i,:);
non_zero_status=[];
for jj=1:pg_status_num
idx_t=find(pg_record(:,jj)>0);
if ~isempty(idx_t)
non_zero_status=[non_zero_status,jj];
end
end
% pg_record(:,1)=pg_num-sum(pg_record(:,2:pg_status_num),2);
time_record=time_record(1:i);
time_record(:)=(time_record(:)-time_record(1))*24; time_record=time_record+time_shift;
use_record=use_record(1:i,:);
figure;hold on; grid on;
stp={'-r',':b','--y','-.g','-k',':c','--m','-b','k:','y-','g:','r:','b--','k--','b-.','r-.','y-.'};
% for i=1:pg_status_num
% plot(time_record,pg_record(:,i),stp{i});
% end
for i=1:size(non_zero_status,2)
plot(time_record,pg_record(:,non_zero_status(i)),stp{i});
end
xlabel('time (hours)');
ylabel('PG number');
legend(pg_status{non_zero_status},'Location','NorthEastOutside');
title(['PG status changes (total' int2str(pg_num) ')']);
figure;
hold on; grid on;
for i=1:2
plot(time_record,use_record(:,i),stp{i});
end
xlabel('time (hours)');
ylabel('usage (GB)');
legend('data', 'overall')
title(['storage usage change (total ' int2str(total_size) 'GB)'])
figure;
hold on; grid on;
for i=1:2
plot(time_record,use_record(:,i)/total_size,stp{i});
end
xlabel('time (hours)');
ylabel('usage %');
legend('data used', 'total used')
title(['storage usage change (total ' int2str(total_size) 'GB)'])
figure;
hold on; grid on;
xx=use_record(:,2)-2*use_record(:,1);
plot(time_record,xx);
xlabel('time (hours)');
ylabel('usage (GB)');
legend('metadata')
title(['storage usage other than data (total ' int2str(total_size) 'GB)'])
figure;
hold on; grid on;
for i=1:2
plot(time_record,use_record(:,i+2),stp{i});
end
xlabel('time (hours)');
ylabel('usage (GB)');
legend('avaiable', 'overall')
title(['storage available change (total ' int2str(total_size) 'GB)'])
figure
hold on; grid on;
[AX,H1,H2] = plotyy(time_record,use_record(:,5),time_record,use_record(:,6));
set(get(AX(1),'Ylabel'),'String','Througput (MBPS)')
set(get(AX(2),'Ylabel'),'String','Operation/s')
xlabel('Time (hours)')
title(['Observation via Ceph -w'])
set(H1,'LineStyle','o')
set(H2,'LineStyle','*')
figure
grid on;
plot(time_record,use_record(:,5),'o');
ylabel('Througput (MBPS)')
xlabel('Time (hours)')
title(['Observation via Ceph -w'])
figure
grid on;
plot(time_record,use_record(:,6),'o');
ylabel('Operation/s')
xlabel('Time (hours)')
title(['Observation via Ceph -w'])