forked from pcpiela/collectl-lustre
-
Notifications
You must be signed in to change notification settings - Fork 3
/
lustreClient.ph
executable file
·1620 lines (1424 loc) · 57.6 KB
/
lustreClient.ph
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# copyright, 2014 Terascala, Inc. All rights reserved
#
# lustreClient may be copied only under the terms of either the
# Artistic License or the GNU General Public License
# Lustre Client Data Collector
use strict;
# Allow reference to collectl variables, but be CAREFUL as these should be treated as readonly
our ($miniFiller, $rate, $SEP, $datetime, $intSecs, $totSecs, $showColFlag);
our ($firstPass, $debug, $filename, $playback, $ioSizeFlag, $verboseFlag);
our ($OneKB, $OneMB, $OneGB, $TenGB);
our ($miniDateTime, $options, $FS, $Host, $XCFlag, $interval, $count);
our ($sameColsFlag, $subsys, $ReqDir);
require "$ReqDir/LustreSingleton.pm";
use lib "$ReqDir";
use LustreCommon;
# Global to this module
my $lustOpts = undef;
my $lustOptsOnly = undef;
my $lustre_singleton = new LustreSingleton();
my $lustre_version = $lustre_singleton->getVersion();
my $METRIC = {value => 0, last => 0};
my $printMsg = $debug & 16384;
my $lustreCltDirtyHitsTot = 0;
my $lustreCltDirtyMissTot = 0;
my $lustreCltReadTot = 0;
my $lustreCltReadKBTot = 0;
my $lustreCltWriteTot = 0;
my $lustreCltWriteKBTot = 0;
my $lustreCltOpenTot = 0;
my $lustreCltCloseTot = 0;
my $lustreCltSeekTot = 0;
my $lustreCltFsyncTot = 0;
my $lustreCltSetattrTot = 0;
my $lustreCltGetattrTot = 0;
my $lustreCltRAPendingTot = 0;
my $lustreCltRAHitsTot = 0;
my $lustreCltRAMissesTot = 0;
my $lustreCltRANotConTot = 0; # Summed over filesystems
my $lustreCltRAMisWinTot = 0;
my $lustreCltRAFailGrabTot = 0;
my $lustreCltRAFailLockTot = 0;
my $lustreCltRAReadDiscTot = 0;
my $lustreCltRAZeroLenTot = 0;
my $lustreCltRAZeroWinTot = 0;
my $lustreCltRA2EofTot = 0;
my $lustreCltRAHitMaxTot = 0;
my $lustreCltRAWrongTot = 0;
my $lustreCltReadKBTOT = 0;
my $lustreCltReadTOT = 0;
my $lustreCltWriteKBTOT = 0;
my $lustreCltWriteTOT = 0;
my $lustreCltRAHitsTOT = 0;
my $lustreCltRAMissesTOT = 0;
my $limLusKBS = 100;
my $limLusReints = 1000;
my $cltFlag = 0;
my $reportCltFlag = 0;
my @clientFSNames = ();
my $clientFSNamesStr = '';
my $numClientFS = 0; # Number of client filesystems
my $FSWidth = 0;
my $ostWidth = 0;
my @clientOstNames = ();
my $clientOstNamesStr = '';
my $numClientOsts = 0; # Number of active OSTs
my %clientFSData = (); # Filesystem performance data indexed by filesystem name
my %clientOstData = (); # OST performance data indexed by FSName.OST
my %clientOstRpcReadData = ();
my %clientOstRpcWriteData = ();
my @clientRpcReadTot = []; # indexed by buffer number
my @clientRpcWriteTot = []; # indexed by buffer number
# Global to count how many buckets there are for brw_stats
my @brwBuckets = [];
my $numBrwBuckets = scalar(@brwBuckets);
logmsg('I', "Lustre version $lustre_version") if $printMsg;
sub createClientFS {
my $fs = {dir => '',
commonName => '',
dirty_pages_hits => {%{$METRIC}},
dirty_pages_misses => {%{$METRIC}},
read => {%{$METRIC}},
readKB => {%{$METRIC}},
write => {%{$METRIC}},
writeKB => {%{$METRIC}},
open => {%{$METRIC}},
close => {%{$METRIC}},
seek => {%{$METRIC}},
fsync => {%{$METRIC}},
setattr => {%{$METRIC}},
getattr => {%{$METRIC}},
ra_pending => {%{$METRIC}},
ra_hits => {%{$METRIC}},
ra_misses => {%{$METRIC}},
ra_notcon => {%{$METRIC}},
ra_miswin => {%{$METRIC}},
ra_failgrab => {%{$METRIC}},
ra_faillock => {%{$METRIC}},
ra_readdisc => {%{$METRIC}},
ra_zerowin => {%{$METRIC}},
ra_zerolen => {%{$METRIC}},
ra_2EofMax => {%{$METRIC}},
ra_hitmax => {%{$METRIC}},
ra_wrong => {%{$METRIC}}};
return $fs;
}
sub createClientOst {
my $clientOst = {fsName => '',
ostName => '',
dir => '',
lun_read => {%{$METRIC}},
lun_readKB => {%{$METRIC}},
lun_write => {%{$METRIC}},
lun_writeKB => {%{$METRIC}}};
return $clientOst;
}
sub lustreCheckClient {
my @saveClientFSNames = @clientFSNames;
my $saveClientFSNamesStr = $clientFSNamesStr;
# Get Filesystem Names
$FSWidth = 0;
@clientFSNames = ();
$numClientFS = 0;
my %clientFSNamesHash = ();
my @lustreFS = glob("/proc/fs/lustre/llite/*");
foreach my $dir (@lustreFS) {
# in newer versions of lustre, the fs name was dropped from uuid,
# so look here instead which does exist in earlier versions too,
# but we didn't look there sooner because uuid is still used in
# other cases and I wanted to be consistent.
my $commonName = cat("$dir/lov/common_name");
chomp $commonName;
my $fsName = (split(/-clilov-/, $commonName))[0];
# we use the dirname for finding 'stats' and fsname for printing.
# we may need the common name to make osts back to filesystems
my $dirname = basename($dir);
$clientFSNamesHash{$fsName} = $fsName;
push(@clientFSNames, $fsName);
logmsg(
'I',
"Found filesystem $fsName, dir = $dirname, commonName = $commonName")
if $printMsg;
$numClientFS++;
$clientFSData{$fsName} = createClientFS()
if !exists($clientFSData{$fsName});
$clientFSData{$fsName}{dir} = $dirname;
$clientFSData{$fsName}{commonName} = $commonName;
$FSWidth = length($fsName) if $FSWidth < length($fsName);
$cltFlag = $reportCltFlag = 1;
}
$clientFSNamesStr = join(' ', @clientFSNames);
$FSWidth++;
my $changed = $clientFSNamesStr ne $saveClientFSNamesStr;
# Remove any nonexistent filesystems
if ($changed) {
foreach my $fsName (@saveClientFSNames) {
delete $clientFSData{$fsName} if !exists($clientFSNamesHash{$fsName});
}
my $comment = ($filename eq '') ? '#' : '';
my $text = "Lustre CLT FSs Changed -- Old: $saveClientFSNamesStr New: $clientFSNamesStr";
logmsg('W', "${comment}$text") if !$firstPass;
print "$text\n" if $firstPass && $printMsg;
}
# Only For '--lustopts B/O' Get OST Names
if ($cltFlag && $lustOpts =~ /[BO]/) {
# we first need to get a list of all the OST uuids for
# all the filesystems, noting the 1 passed to cat()
# tells it to read until EOF
my %clientOstMappings;
foreach my $fsName (@clientFSNames) {
my $obds =
cat("/proc/fs/lustre/lov/$clientFSData{$fsName}{commonName}/target_obd",
1);
logmsg('I', "Processing OSTS: fsName = $fsName, commonName = $clientFSData{$fsName}{commonName}, obds = $obds") if $printMsg;
foreach my $obd (split(/\n/, $obds)) {
my ($uuid, $state) = (split(/\s+/, $obd))[1, 2];
logmsg('I', "obd = $obd, uuid = $uuid, state = $state") if $printMsg;
next if $state ne 'ACTIVE';
$clientOstMappings{$uuid} = $fsName;
}
}
my @saveClientOstNames = @clientOstNames;
my $saveClientOstNamesStr = $clientOstNamesStr;
@clientOstNames = ();
$numClientOsts = 0;
my %clientOstNamesHash = ();
my @lustreDirs = glob("/proc/fs/lustre/osc/*");
foreach my $dir (@lustreDirs) {
# Since we're looking for OST subdirectories, ignore anything not
# a directory which for now is limted to 'num_refs', but who
# knows what the future will hold. As for the 'MNT' test, I think
# that only applied to older versions of lustre, certainlu tp HP-SFS.
next if !-d $dir; # currently only the 'num_refs' file
# Looks like if you're on a 1.6.4.3 system (and perhaps earlier)
# that is both a client as well as an MDS, you'll see MDS
# specific directories with names like - lustre-OST0000-osc,
# whereas lustre-OST0000-osc-000001012e950400 is the
# client directory we want, so...
next if $dir =~ /\-osc$/;
logmsg('I', "Processing osc dir $dir") if $printMsg;
# if ost closed (this happens when new filesystems get created),
# ignore it. note that newer versions of lustre added a sstate
# and sets it to DEACTIVATED
my ($uuid, $state, $sstate) = split(/\s+/, cat("$dir/ost_server_uuid"));
logmsg('I', "uuid = $uuid, state = $state, sstate = $sstate")
if $printMsg;
next if $state =~ /CLOSED|DISCONN/ || $sstate =~ /DEACT/;
# uuids look something like 'xxx-ost_UUID' and you can actully
# have a - or _ following the xxx so drop the beginning/end
# this way in case an embedded _ in ost name itself.
my $ostName = $uuid;
$ostName =~ s/.*[-](OST.*)_UUID/$1/;
my $fsName = $clientOstMappings{$uuid};
logmsg('I', "ostName = $ostName, fsName = $fsName") if $printMsg;
$ostWidth = length($ostName) if $ostWidth < length($ostName);
my $ostFullName = "$fsName.$ostName";
$clientOstNamesHash{$ostFullName} = $ostFullName;
push(@clientOstNames, $ostFullName);
$numClientOsts++;
if (!exists($clientOstData{$ostFullName})) {
logmsg('I', "Adding client OST $ostFullName") if $printMsg;
$clientOstData{$ostFullName} = createClientOst();
for (my $j = 0; $j < $numBrwBuckets; $j++) {
$clientOstRpcReadData{$ostFullName}[$j] = {%{$METRIC}};
$clientOstRpcWriteData{$ostFullName}[$j] = {%{$METRIC}};
}
}
$clientOstData{$ostFullName}{fsName} = $fsName;
$clientOstData{$ostFullName}{ostName} = $ostName;
$clientOstData{$ostFullName}{dir} = $dir;
}
$clientOstNamesStr = join(' ', @clientOstNames);
# Remove any nonexistent OSTs
if ($clientOstNamesStr ne $saveClientOstNamesStr) {
foreach my $ostFullName (@saveClientOstNames) {
if (!exists($clientOstNamesHash{$ostFullName})) {
logmsg('I', "Deleting client OST $ostFullName") if $printMsg;
delete $clientOstData{$ostFullName};
delete $clientOstRpcReadData{$ostFullName};
delete $clientOstRpcWriteData{$ostFullName};
}
}
}
$ostWidth = 3 if $ostWidth < 3;
my $clientOstNamesChanged = $clientOstNamesStr ne $saveClientOstNamesStr;
$changed = $changed || $clientOstNamesChanged;
# Change info is important even when not logging except during
# initialization
if ($clientOstNamesChanged) {
my $comment = ($filename eq '') ? '#' : '';
my $text = "Lustre CLT OSTs Changed -- Old: $saveClientOstNamesStr New: $clientOstNamesStr";
logmsg('W', "${comment}$text") if !$firstPass;
print "$text\n" if $firstPass && $printMsg;
}
}
return $changed ? 1 : 0;
}
sub getClientLliteStats {
my ($fsName, $fsdir) = @_;
my $tag = "LLITE:$fsName";
my $proc = "/proc/fs/lustre/llite/$fsdir/stats";
return(0) if (!open PROC, "<$proc");
while (my $line = <PROC>) {
if (($line =~ /^dirty/) ||
($line =~ /^read/) ||
($line =~ /^write/) ||
($line =~ /^open/) ||
($line =~ /^close/) ||
($line =~ /^seek/) ||
($line =~ /^fsync/) ||
($line =~ /^getattr/) ||
($line =~ /^getxattr/) ||
($line =~ /^setattr/) ||
($line =~ /^setxattr/) ||
($line =~ /^statfs/)) {
record(2, "$tag $line");
}
}
close PROC;
return(1);
}
sub getClientReadAheadStats {
my ($fsName, $fsdir) = @_;
my $tag = "LLITE_RA:$fsName";
my $proc = "/proc/fs/lustre/llite/$fsdir/read_ahead_stats";
return(0) if (!open PROC, "<$proc");
while (my $line = <PROC>) {
record(2, "$tag $line");
}
close PROC;
return(1);
}
sub getClientRpcStats {
my ($ostName, $ostdir) = @_;
my $tag = "LLITE_RPC:$ostName";
my $proc = "$ostdir/rpc_stats";
return(0) if (!open PROC, "<$proc");
# Skip to beginning of rpcdata
while (my $line = <PROC>) {
last if (index($line, "pages per rpc") == 0);
}
my $index = 0;
while (my $line = <PROC>) {
last if $line=~/^\s+$/;
record(2, "$tag:$index $line");
$index++;
}
close PROC;
return(1);
}
sub getClientOstStats {
my ($ostName, $ostdir) = @_;
my $tag = "LLDET:$ostName";
my $proc = "$ostdir/stats";
return(0) if (!open PROC, "<$proc");
while (my $line = <PROC>) {
if (($line=~/^read_bytes/) ||
($line=~/^write_bytes/)) {
record(2, "$tag $line");
}
}
close PROC;
return(1);
}
sub lustreGetClientStats {
foreach my $fsName (@clientFSNames) {
# For vanilla -sl we only need read/write info, but lets grab metadata file
# we're at it. In the case of --lustopts R, we also want readahead stats
getClientLliteStats($fsName, $clientFSData{$fsName}{dir});
getClientReadAheadStats($fsName, $clientFSData{$fsName}{dir})
if $lustOpts =~ /R/;
}
# RPC stats are optional for both clients and servers
if ($lustOpts =~ /B/) {
foreach my $ostName (@clientOstNames) {
getClientRpcStats($ostName, $clientOstData{$ostName}{dir});
}
}
# Client OST detail data
if ($lustOpts =~ /O/) {
foreach my $ostName (@clientOstNames) {
getClientOstStats($ostName, $clientOstData{$ostName}{dir});
}
}
return(1);
}
sub lustreClientInit {
my $impOptsref = shift;
my $impKeyref = shift;
error("You must remove the -sl or -sL option to use this plugin")
if ($subsys =~ /l/i);
$lustOpts = ${$impOptsref};
error('Valid lustre options are: s d B M O R')
if defined($lustOpts) && $lustOpts !~ /^[sdBMOR]*$/;
$lustOpts = 's' if !defined($lustOpts);
${impOptsref} = $lustOpts;
error("Lustre does not appear to be installed on this host")
if (!defined $lustre_version);
error("Lustre versions earlier than 1.8.0 are not currently supported")
if ($lustre_version lt '1.8.0');
print "lustreClientInit: options: $lustOpts\n" if $printMsg;
${$impKeyref} = 'LLITE|LLDET';
error("You cannot mix Lustre option 'O' with 'M' or 'R'")
if $lustOpts =~ /O/ && $lustOpts =~ /[MR]/;
error("You cannot mix Lustre option 'B' with 'M'")
if $lustOpts =~ /B/ && $lustOpts =~ /M/;
error("You cannot mix Lustre option 'B' with 'R'")
if $lustOpts =~ /B/ && $lustOpts =~ /R/;
@brwBuckets = (1,2,4,8,16,32,64,128,256);
$numBrwBuckets = scalar(@brwBuckets);
lustreCheckClient();
error("Lustre option O only applies to client detail data")
if $lustOpts =~ /O/ && (!$cltFlag || $lustOpts !~ /d/);
# Force if not already specified, but ONLY for details
$lustOpts .= 'O'
if $cltFlag && $lustOpts =~ /d/ && $lustOpts =~ /B/ && $lustOpts !~ /O/;
$verboseFlag = 1 if $lustOpts =~ /[BM]/;
$lustOptsOnly = $lustOpts;
$lustOptsOnly =~ s/[ds]//;
return(1);
}
sub lustreClientUpdateHeader {
my $lineref = shift;
${$lineref} .=
"# Lustre Client Data Collector: Version 1.0, Lustre version: $lustre_version\n";
}
sub lustreClientGetData {
lustreGetClientStats() if ($numClientFS > 0);
}
sub lustreClientInitInterval {
# Check to see if any services changed and if they did, we may need
# a new logfile as well.
newLog($filename, "", "", "", "", "")
if lustreCheckClient() && $filename ne '';
$sameColsFlag = 0 if length($lustOptsOnly) > 1;
$lustreCltDirtyHitsTot = 0;
$lustreCltDirtyMissTot = 0;
$lustreCltReadTot = 0;
$lustreCltReadKBTot = 0;
$lustreCltWriteTot = 0;
$lustreCltWriteKBTot = 0;
$lustreCltOpenTot = 0;
$lustreCltCloseTot = 0;
$lustreCltSeekTot = 0;
$lustreCltFsyncTot = 0;
$lustreCltSetattrTot = 0;
$lustreCltGetattrTot = 0;
$lustreCltRAPendingTot = 0;
$lustreCltRAHitsTot = 0;
$lustreCltRAMissesTot = 0;
$lustreCltRANotConTot = 0;
$lustreCltRAMisWinTot = 0;
$lustreCltRAFailGrabTot = 0;
$lustreCltRAFailLockTot = 0;
$lustreCltRAReadDiscTot = 0;
$lustreCltRAZeroLenTot = 0;
$lustreCltRAZeroWinTot = 0;
$lustreCltRA2EofTot = 0;
$lustreCltRAHitMaxTot = 0;
$lustreCltRAWrongTot = 0;
for (my $i = 0; $i <= $numBrwBuckets; $i++) {
$clientRpcReadTot[$i] = 0;
$clientRpcWriteTot[$i] = 0;
}
}
sub lustreClientAnalyze {
my $type = shift;
my $dataref = shift;
my $data = ${$dataref};
logmsg('I', "lustreClientAnalyze: type: $type, data: $data") if $printMsg;
if ($type =~ /LLITE:(.+)/) {
my $fsName = $1;
my ($metric, $ops, $value) = (split(/\s+/, $data))[0, 1, 6];
my $attrId = undef;
my $tot = undef;
if ($metric =~ /dirty_pages_hits/) {
my $attrId = 'dirty_pages_hits';
$tot = \$lustreCltDirtyHitsTot;
} elsif ($metric =~ /dirty_pages_misses/) {
$attrId = 'dirty_pages_misses';
$tot = \$lustreCltDirtyMissTot;
} elsif ($metric =~ /read_bytes/) {
$attrId = 'read';
$tot = \$lustreCltReadTot;
$value = 0 if !defined($value);
my $readKB = $clientFSData{$fsName}{readKB};
$readKB->{value} = LustreCommon::delta($value, $readKB->{last}) / $OneKB;
$readKB->{last} = $value;
$lustreCltReadKBTot += $readKB->{value};
} elsif ($metric =~ /write_bytes/) {
$attrId = 'write';
$tot = \$lustreCltWriteTot;
$value = 0 if !defined($value);
my $writeKB = $clientFSData{$fsName}{writeKB};
$writeKB->{value} = LustreCommon::delta($value, $writeKB->{last}) / $OneKB;
$writeKB->{last} = $value;
$lustreCltWriteKBTot += $writeKB->{value};
} elsif ($metric =~ /open/) {
$attrId = 'open';
$tot = \$lustreCltOpenTot;
} elsif ($metric =~ /close/) {
$attrId = 'close';
$tot = \$lustreCltCloseTot;
} elsif ($metric =~ /seek/) {
$attrId = 'seek';
$tot = \$lustreCltSeekTot;
} elsif ($metric =~ /fsync/) {
$attrId = 'fsync';
$tot = \$lustreCltFsyncTot;
} elsif ($metric =~ /setattr/) {
$attrId = 'setattr';
$tot = \$lustreCltSetattrTot;
} elsif ($metric =~ /getattr/) {
$attrId = 'getattr';
$tot = \$lustreCltGetattrTot;
}
if (defined($attrId) && defined($ops)) {
my $attr = $clientFSData{$fsName}{$attrId};
my $value = LustreCommon::delta($ops, $attr->{last});
$attr->{value} = $value;
$attr->{last} = $ops;
${$tot} += $value if defined($tot);
}
} elsif ($type =~ /LLITE_RA:(.+)/) {
my $fsName = $1;
my $attrId = undef;
my $tot = undef;
my $ops = undef;
if ($data =~ /^pending.* (\d+)/) {
# This is NOT a counter but a meter
my $pending = $clientFSData{$fsName}{ra_pending};
$pending->{value} = $1;
$lustreCltRAPendingTot += $pending->{value};
} elsif ($data =~ /^hits.* (\d+)/) {
$ops = $1;
$attrId = 'ra_hits';
$tot = \$lustreCltRAHitsTot;
} elsif ($data =~ /^misses.* (\d+)/) {
$ops = $1;
$attrId = 'ra_misses';
$tot = \$lustreCltRAMissesTot;
} elsif ($data =~ /^readpage.* (\d+)/) {
$ops = $1;
$attrId = 'ra_notcon';
$tot = \$lustreCltRANotConTot;
} elsif ($data =~ /^miss inside.* (\d+)/) {
$ops = $1;
$attrId = 'ra_miswin';
$tot = \$lustreCltRAMisWinTot;
} elsif ($data =~ /^failed grab.* (\d+)/) {
$ops = $1;
$attrId = 'ra_failgrab';
$tot = \$lustreCltRAFailGrabTot;
} elsif ($data =~ /^failed lock.* (\d+)/) {
$ops = $1;
$attrId = 'ra_faillock';
$tot = \$lustreCltRAFailLockTot;
} elsif ($data =~ /^read but.* (\d+)/) {
$ops = $1;
$attrId = 'ra_readdisc';
$tot = \$lustreCltRAReadDiscTot;
} elsif ($data =~ /^zero length.* (\d+)/) {
$ops = $1;
$attrId = 'ra_zerolen';
$tot = \$lustreCltRAZeroLenTot;
} elsif ($data =~ /^zero size.* (\d+)/) {
$ops = $1;
$attrId = 'ra_zerowin';
$tot = \$lustreCltRAZeroWinTot;
} elsif ($data =~ /^read-ahead.* (\d+)/) {
$ops = $1;
$attrId = 'ra_2EofMax';
$tot = \$lustreCltRA2EofTot;
} elsif ($data =~ /^hit max.* (\d+)/) {
$ops = $1;
$attrId = 'ra_hitmax';
$tot = \$lustreCltRAHitMaxTot;
} elsif ($data =~ /^wrong.* (\d+)/) {
$ops = $1;
$attrId = 'ra_wrong';
$tot = \$lustreCltRAWrongTot;
}
if (defined($attrId) && defined($ops)) {
my $attr = $clientFSData{$fsName}{$attrId};
my $value = LustreCommon::delta($ops, $attr->{last});
$attr->{value} = $value;
$attr->{last} = $ops;
${$tot} += $value if defined($tot);
}
} elsif ($type =~ /LLITE_RPC:(.+):(\d+)/) {
my $ostName = $1;
my $bufNum = $2;
my ($reads, $writes) = (split(/\s+/, $data))[1, 5];
my $attr = $clientOstRpcReadData{$ostName}[$bufNum];
$attr->{value} = LustreCommon::delta($reads, $attr->{last});
$attr->{last} = $reads;
$clientRpcReadTot[$bufNum] += $attr->{value};
$attr = $clientOstRpcWriteData{$ostName}[$bufNum];
$attr->{value} = LustreCommon::delta($writes, $attr->{last});
$attr->{last} = $writes;
$clientRpcWriteTot[$bufNum] += $attr->{value};
} elsif ($type =~ /LLDET:(.*)/) {
my $ostName = $1;
my ($metric, $ops, $value) = (split(/\s+/, $data))[0, 1, 6];
if ($metric =~ /^read_bytes|ost_r/) {
my $attr = $clientOstData{$ostName}{lun_read};
$attr->{value} = LustreCommon::delta($ops, $attr->{last});
$attr->{last} = $ops;
if (defined($value)) { # not always defined
$attr = $clientOstData{$ostName}{lun_readKB};
$attr->{value} = LustreCommon::delta($value, $attr->{last}) / $OneKB;
$attr->{last} = $value;
}
} elsif ($metric =~ /^write_bytes|ost_w/) {
my $attr = $clientOstData{$ostName}{lun_write};
$attr->{value} = LustreCommon::delta($ops, $attr->{last});
$attr->{last} = $ops;
if (defined($value)) { # not always defined
$attr = $clientOstData{$ostName}{lun_writeKB};
$attr->{value} = LustreCommon::delta($value, $attr->{last}) / $OneKB;
$attr->{last} = $value;
}
}
}
}
# This and the 'print' routines should be self explanitory as they pretty much simply
# return a string in the appropriate format for collectl to dispose of.
sub lustreClientPrintBrief {
my $type = shift;
my $lineref = shift;
if ($type == 1) { # header line 1
if ($lustOpts =~ /s/ && $reportCltFlag) {
${$lineref} .= "<--------Lustre Client-------->"
if !$ioSizeFlag && $lustOpts !~ /R/;
${$lineref} .= "<---------------Lustre Client--------------->"
if !$ioSizeFlag && $lustOpts =~ /R/;
${$lineref} .= "<-------------Lustre Client------------->"
if $ioSizeFlag && $lustOpts !~ /R/;
${$lineref} .= "<--------------------Lustre Client-------------------->"
if $ioSizeFlag && $lustOpts =~ /R/;
}
} elsif ($type == 2) { # header line 2
if ($lustOpts =~ /s/ && $reportCltFlag) {
${$lineref} .= " KBRead Reads KBWrite Writes" if !$ioSizeFlag;
${$lineref} .= " KBRead Reads Size KBWrite Writes Size"
if $ioSizeFlag;
${$lineref} .= " Hits Misses" if $lustOpts =~ /R/;
}
} elsif ($type == 3) { # data
if ($lustOpts =~ /s/ && $reportCltFlag) {
if (!$ioSizeFlag) {
${$lineref} .=
sprintf("%7s %6s %7s %6s",
cvt($lustreCltReadKBTot / $intSecs, 7, 0, 1),
cvt($lustreCltReadTot / $intSecs),
cvt($lustreCltWriteKBTot / $intSecs, 7, 0, 1),
cvt($lustreCltWriteTot / $intSecs, 6));
} else {
${$lineref} .=
sprintf("%7s %6s %4s %7s %6s %4s",
cvt($lustreCltReadKBTot / $intSecs, 7, 0, 1),
cvt($lustreCltReadTot / $intSecs),
$lustreCltReadTot ? cvt($lustreCltReadKBTot / $lustreCltReadTot, 4, 0, 1) : 0,
cvt($lustreCltWriteKBTot / $intSecs, 7, 0, 1),
cvt($lustreCltWriteTot / $intSecs, 6),
$lustreCltWriteTot ? cvt($lustreCltWriteKBTot / $lustreCltWriteTot, 4, 0, 1) : 0);
}
# Add in cache hits/misses if --lustopts R
${$lineref} .=
sprintf(" %6d %6d",
$lustreCltRAHitsTot,
$lustreCltRAMissesTot) if $lustOpts =~ /R/;
}
} elsif ($type == 4) { # reset 'total' counters
$lustreCltReadKBTOT = 0;
$lustreCltReadTOT = 0;
$lustreCltWriteKBTOT = 0;
$lustreCltWriteTOT = 0;
$lustreCltRAHitsTOT = 0;
$lustreCltRAMissesTOT = 0;
} elsif ($type == 5) { # increment 'total' counters
if ($numClientFS) {
$lustreCltReadTOT += $lustreCltReadTot;
$lustreCltReadKBTOT += $lustreCltReadKBTot;
$lustreCltWriteTOT += $lustreCltWriteTot;
$lustreCltWriteKBTOT += $lustreCltWriteKBTot;
$lustreCltRAHitsTOT += $lustreCltRAHitsTot;
$lustreCltRAMissesTOT += $lustreCltRAMissesTot;
}
} elsif ($type == 6) { # print 'total' counters
# Since this never goes over a socket we can just do a simple print.
if ($lustOpts =~ /s/ && $reportCltFlag) {
if (!$ioSizeFlag) {
printf "%7s %6s %7s %6s",
cvt($lustreCltReadKBTOT / $totSecs, 7, 0, 1),
cvt($lustreCltReadTOT / $totSecs, 6),
cvt($lustreCltWriteKBTOT / $totSecs, 7, 0, 1),
cvt($lustreCltWriteTOT / $totSecs, 6);
} else {
printf "%7s %6s %4s %7s %6s %4s",
cvt($lustreCltReadKBTOT / $totSecs, 7, 0, 1),
cvt($lustreCltReadTOT / $totSecs, 6),
$lustreCltReadTOT ? cvt($lustreCltReadKBTOT / $lustreCltReadTOT,
4, 0, 1) : 0,
cvt($lustreCltWriteKBTOT / $totSecs, 7, 0, 1),
cvt($lustreCltWriteTOT / $totSecs, 6),
$lustreCltWriteTOT ? cvt($lustreCltWriteKBTOT / $lustreCltWriteTOT,
4, 0, 1) : 0;
}
printf " %6s %6s",
cvt($lustreCltRAHitsTOT / $totSecs, 6),
cvt($lustreCltRAMissesTOT / $totSecs, 6) if $lustOpts =~ /R/;
}
}
}
sub lustreClientPrintVerbose {
my $printHeader = shift;
my $homeFlag = shift;
my $lineref = shift;
# Note that last line of verbose data (if any) still sitting in $$lineref
my $line = ${$lineref} = '';
# NOTE - there are a number of different types of formats here and
# we're always going to include reads/writes with all of them!
if ($lustOpts =~ /s/ && $reportCltFlag) {
# If time for common header, do it...
if ($printHeader) {
my $line = '';
$line .= "\n" if !$homeFlag;
$line .= "# LUSTRE CLIENT SUMMARY ($rate)";
$line .= ":" if $lustOpts =~ /[BMR]/;
$line .= " RPC-BUFFERS (pages)" if $lustOpts =~ /B/;
$line .= " METADATA" if $lustOpts =~ /M/;
$line .= " READAHEAD" if $lustOpts =~ /R/;
$line .= "\n";
${$lineref} .= $line;
}
# If exception processing must be above minimum
if ($options !~ /x/ ||
$lustreCltReadKBTot / $intSecs >= $limLusKBS ||
$lustreCltWriteKBTot / $intSecs >= $limLusKBS) {
if ($lustOpts !~ /[BMR]/) {
${$lineref} .= "#$miniDateTime KBRead Reads SizeKB KBWrite Writes SizeKB\n" if $printHeader;
exit if $showColFlag;
my $line = sprintf("$datetime %7d %6d %6d %7d %6d %6d\n",
$lustreCltReadKBTot / $intSecs,
$lustreCltReadTot / $intSecs,
$lustreCltReadTot ?
int($lustreCltReadKBTot / $lustreCltReadTot) : 0,
$lustreCltWriteKBTot / $intSecs,
$lustreCltWriteTot / $intSecs,
$lustreCltWriteTot ?
int($lustreCltWriteKBTot / $lustreCltWriteTot) : 0);
${$lineref} .= $line;
}
if ($lustOpts =~ /B/) {
if ($printHeader) {
my $temp = '';
foreach my $i (@brwBuckets) {
$temp .= sprintf(" %3dP", $i);
}
${$lineref} .= "#${miniDateTime}RdK Rds$temp WrtK Wrts$temp\n";
exit if $showColFlag;
}
my $line = "$datetime";
$line .= sprintf("%4s %4s",
cvt($lustreCltReadKBTot / $intSecs, 4, 0, 1),
cvt($lustreCltReadTot / $intSecs));
for (my $i = 0; $i < $numBrwBuckets; $i++) {
$line .= sprintf(" %4s", cvt($clientRpcReadTot[$i] / $intSecs));
}
$line .= sprintf(" %4s %4s",
cvt($lustreCltWriteKBTot / $intSecs, 4, 0, 1),
cvt($lustreCltWriteTot / $intSecs));
for (my $i = 0; $i < $numBrwBuckets; $i++) {
$line .= sprintf(" %4s", cvt($clientRpcWriteTot[$i] / $intSecs));
}
$line .= "\n";
${$lineref} .= $line;
}
if ($lustOpts =~ /M/) {
${$lineref} .= "#$miniDateTime KBRead Reads KBWrite Writes Open Close GAttr SAttr Seek Fsync DrtHit DrtMis\n" if $printHeader;
exit if $showColFlag;
my $line = sprintf("$datetime %7d %6d %7d %6d %5d %5d %5d %5d %5d %5d %6d %6d\n",
$lustreCltReadKBTot / $intSecs,
$lustreCltReadTot / $intSecs,
$lustreCltWriteKBTot / $intSecs,
$lustreCltWriteTot / $intSecs,
$lustreCltOpenTot / $intSecs,
$lustreCltCloseTot / $intSecs,
$lustreCltGetattrTot / $intSecs,
$lustreCltSetattrTot / $intSecs,
$lustreCltSeekTot / $intSecs,
$lustreCltFsyncTot / $intSecs,
$lustreCltDirtyHitsTot / $intSecs,
$lustreCltDirtyMissTot / $intSecs);
${$lineref} .= $line;
}
if ($lustOpts =~ /R/) {
${$lineref} .= "#$miniDateTime KBRead Reads KBWrite Writes Pend Hits Misses NotCon MisWin FalGrb LckFal Discrd ZFile ZerWin RA2Eof HitMax Wrong\n" if $printHeader;
exit if $showColFlag;
my $line = sprintf("$datetime %7d %6d %7d %6d %5d %5d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d\n",
$lustreCltReadKBTot / $intSecs,
$lustreCltReadTot / $intSecs,
$lustreCltWriteKBTot / $intSecs,
$lustreCltWriteTot / $intSecs,
$lustreCltRAPendingTot / $intSecs,
$lustreCltRAHitsTot / $intSecs,
$lustreCltRAMissesTot / $intSecs,
$lustreCltRANotConTot / $intSecs,
$lustreCltRAMisWinTot / $intSecs,
$lustreCltRAFailGrabTot / $intSecs,
$lustreCltRAFailLockTot / $intSecs,
$lustreCltRAReadDiscTot / $intSecs,
$lustreCltRAZeroLenTot / $intSecs,
$lustreCltRAZeroWinTot / $intSecs,
$lustreCltRA2EofTot / $intSecs,
$lustreCltRAHitMaxTot / $intSecs,
$lustreCltRAWrongTot / $intSecs);
${$lineref} .= $line;
}
}
}
# NOTE -- there are 2 levels of details, both with and without --lustopts O
if ($lustOpts =~ /d/ && $reportCltFlag) {
my $fill1 = '';
my $temp = '';
if ($printHeader) {
# we need to build filesystem header, and when no date/time make it even 1
# char less.
$temp = "Filsys" . ' 'x$FSWidth;
$temp = substr($temp, 0, $FSWidth);
$temp = substr($temp, 0, $FSWidth - 2) . ' ' if $miniFiller eq '';
# When doing dates/time, we also need to shift first field over 1
# to the left;
$fill1 = '';
if ($miniFiller ne '') {
$fill1 = substr($miniDateTime, 0, length($miniFiller) - 1);
}
my $line = '';
$line .= "\n" if !$homeFlag;
$line .= "# LUSTRE CLIENT DETAIL ($rate)";
$line .= ":" if $lustOpts =~ /[BMR]/;
$line .= " RPC-BUFFERS (pages)" if $lustOpts =~ /B/;
$line .= " METADATA" if $lustOpts =~ /M/;
$line .= " READAHEAD" if $lustOpts =~ /R/;
$line .= "\n";
${$lineref} .= $line;
}
if ($lustOpts =~ /O/) {
# Never for M or R
if ($lustOpts !~ /B/) {
my $fill2 = ' 'x($ostWidth - 3);
${$lineref} .= "#$fill1$temp Ost$fill2 KBRead Reads SizeKB KBWrite Writes SizeKB\n" if $printHeader;
exit if $showColFlag;
foreach my $ostName (@clientOstNames) {
my $ost = $clientOstData{$ostName};
my $line =
sprintf("$datetime%-${FSWidth}s %-${ostWidth}s %7d %6d %6d %7d %6d %6d\n",
$ost->{fsName},
$ost->{ostName},
$ost->{lun_readKB}{value} / $intSecs,
$ost->{lun_read}{value} /$intSecs,
$ost->{lun_read}{value} ?
$ost->{lun_readKB}{value} / $ost->{lun_read}{value} : 0,
$ost->{lun_writeKB}{value} / $intSecs,
$ost->{lun_write}{value} /$intSecs,
$ost->{lun_write}{value} ?
$ost->{lun_writeKB}{value} / $ost->{lun_write}{value} : 0);
${$lineref} .= $line;
}
}
if ($lustOpts =~ /B/) {
my $fill2 = ' 'x($ostWidth - 3);
if ($printHeader) {
my $temp2 = ' 'x(length("$fill1$temp Ost$fill2 "));
my $temp3 = '';
foreach my $i (@brwBuckets) {
$temp3 .= sprintf(" %3dP", $i);
}
${$lineref} .= "#$fill1$temp Ost$fill2 RdK Rds$temp3 WrtK Wrts$temp3\n";
}
for my $ostName (@clientOstNames) {
my $ost = $clientOstData{$ostName};
my $line = sprintf("$datetime%-${FSWidth}s %-${ostWidth}s",
$ost->{fsName},
$ost->{ostName});
$line .= sprintf("%4s %4s",
cvt($ost->{lun_readKB}{value} / $intSecs, 4,0,1),
cvt($ost->{lun_read}{value} / $intSecs));
for (my $i = 0; $i < $numBrwBuckets; $i++) {
$line .= sprintf(
" %4s",
cvt($clientOstRpcReadData{$ostName}[$i]{value} / $intSecs));
}
$line .= sprintf(" %4s %4s",
cvt($ost->{lun_writeKB}{value} / $intSecs, 4,0,1),
cvt($ost->{lun_write}{value} / $intSecs));
for (my $i = 0; $i < $numBrwBuckets; $i++) {
$line .= sprintf(
" %4s",
cvt($clientOstRpcWriteData{$ostName}[$i]{value} / $intSecs));
}
$line .= "\n";
${$lineref} .= $line;
}
}
} else {
my $commonLine =
"#$fill1$temp KBRead Reads SizeKB KBWrite Writes SizeKB";
if ($lustOpts !~ /[MR]/) {
${$lineref} .= "$commonLine\n" if $printHeader;
exit if $showColFlag;
for my $fsName (@clientFSNames) {
my $fs = $clientFSData{$fsName};
my $line =