summaryrefslogtreecommitdiff
path: root/docs/nfstrace.8.in
blob: 189ba6578e2d2d7d3c636e82edeb12c166c22829 (plain)
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
.\"
.\" nfstrace(8)
.\"
.\" Author: Alexey Costroma
.\"
.\" Copyright (c) 2014 EPAM Systems
.\"
.\" This file is part of Nfstrace.
.\"
.\" Nfstrace is free software: you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation, version 2 of the License.
.\"
.\" Nfstrace is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with Nfstrace.  If not, see <http://www.gnu.org/licenses/>.
.\"
.TH nfstrace 8 "@COMPILATION_DATE@" "version @NST_VERSION@"
.\" --------------------- NAME -----------------------------------
.SH NAME
.B nfstrace \- NFS and CIFS tracing/monitoring/capturing/analyzing tool
.\" --------------------- SYNOPSIS -------------------------------
.SH SYNOPSIS
.B nfstrace
[
.B \-m
.I drain|live|dump|stat
] [
.B \-i
.I interface
] [
.B \-f
.I filter
]
.br
         [
.B \-s
.I 1..65535
] [
.B \-t
.I Milliseconds
] [
.B \-b
.I MBytes
]
[
.B \-p
.I promisc 
] 
.br 
         [
.B \-d
.I in|out|inout
] [
.B \-a
.I path#opt1,opt2=val,...
] [
.B \-I
.I path
]
.br
         [
.B \-O
.I path
] [
.B \-C
.I 'shell command'
] [
.B \-D
.I MBytes
] [
.B \-E
.I interfaces|plugins
]
.br
         [
.B \-M
.I 1..4000
] [
.B \-Q
.I 1..65535
] [
.B \-T
.I true|false
] [
.B \-Z
.I username
] [
.B \-v
.I 0|1|2
]
.\" --------------------- DESCRIPTION ----------------------------
.SH DESCRIPTION
.B nfstrace
performs live Ethernet 1 Gbps – 10 Gbps packets capturing and helps to
determine NFS and CIFS procedures in raw network traffic. Furthermore, it performs
filtration, dumping, compression, statistical analysis, visualization and
provides the API for custom pluggable analysis modules.
.PP
.B nfstrace
captures raw packets from an Ethernet interface using libpcap interface
to Linux (LSF) or FreeBSD (BPF) implementations. At the moment it is assumed
that libpcap delivers correct TCP and UDP packets. Assembling of IP packets
from ethernet frames and IP packets defragmentation are performed in the
operating system's kernel.
.PP
The application has been tested on the workstations with integrated 1 Gbps NICs
(Ethernet 1000baseT/Full).
.PP
Currently
.B nfstrace
supports the following protocols:
.PP
    Ethernet > IPv4 | IPv6 > UDP | TCP > NFSv3 | NFSv4 | NFSv4.1 | CIFSv1 | CIFSv2
.PP
.B nfstrace
can operate in four different modes:
.RS 3
.PP
\- online analysis
.RB ( \-\-mode=live ):
performs online capturing, filtration and live analysis of detected NFS
procedures using a pluggable analysis module or prints out them to
.B stdout
.RB ( \-T
or
.B \-\-trace
options);
.PP
\- online dumping
.RB ( \-\-mode=dump ):
performs online traffic capturing, filtration and dumping to the output file
(specified with
.B \-O
or
.B \-\-ofile
options);
.PP
\- offline analysis
.RB ( \-\-mode=stat ):
performs offline filtration of the
.B .pcap
file that contains previously captured traces and performs analysis using a
pluggable analysis module or prints found NFS procedures to
.B stdout
.RB ( \-T
or
.B \-\-trace
options);
.PP
\- offline dumping
.RB ( \-\-mode=drain ):
performs a reading of traffic from the
.B .pcap
file (specified with
.B \-I
or
.B \-\-ifile
options), filtration, dumping to the output
.B .pcap
file (specified with
.B \-O
or
.B \-\-ofile
options) and removing all the packets that are not related to NFS procedures.
.RE
.PP
.B nfstrace
uses libpcap file format for input and output files so any external tool
(e.g.
.BR Wireshark )
can be used in order to inspect filtered traces.
.PP
Since nfstrace internally uses libpcap that provides a portable interface to the
native system API for capturing network traffic, filtration is
performed in the operating system's kernel.
.B nfstrace
provides a special option
.RB ( \-f
or
.BR \-\-filtration )
for specifying custom filters in BPF syntax (see
.BR pcap-filter (7)).
.PP
The default BPF filter in
.B nfstrace
is
.BR "'port 2049 or port 445'" ,
which means that each packet that is delivered to user-space from the kernel
satisfies the following conditions: it has IPv4 or IPv6 header and it has TCP
and UDP header with source or destination port number equals to 2049 (default
NFS port) or 445 (default CIFS port).
.PP
The reality is that this filter is very heavy and support of IPv6 is
experimental, so if you want to reach faster filtration of IPv4-only traffic we
suggest to use the following BPF filter:
.RS 4
.B 'ip and port 2049 or port 445'.
.RE
.\" --------------------- OPTIONS --------------------------------
.SH OPTIONS
.B nfstrace
can usually be run without arguments: in this case default arguments will be
used.
.TP
.BI "\-m, \-\-mode=" live|dump|drain|stat
Set the running mode (see the description above)
.RB (default:\  live ).
.TP
.BI "\-i, \-\-interface=" INTERFACE
Listen interface, it is required for live and dump modes
.RB (default:\  "searches for the lowest numbered, configured up interface"
.BR "(except loopback)" ).
.TP
.BI "\-f, \-\-filtration=" filter
Specify the packet filter in BPF syntax; for the expression syntax, see
.BR pcap-filter (7)
.RB (default:\  "'port 2049 or port 445'" ).
.TP
.BI "\-s, \-\-snaplen=" 1..65535
Set the max length of captured raw packet (bigger packets will be truncated).
Can be used only for UDP
.RB (default:\  65535 ).
.TP
.BI "\-t, \-\-timeout=" milliseconds
Set the read timeout that will be used while capturing
.RB (default:\  100 ).
.TP
.BI "\-b, \-\-bsize=" MBytes
Set the size of the operating system capture buffer in MBytes; note that this
option is crucial for capturing performance
.RB (default:\  20 ).
.TP
.BI "\-p, \-\-promisc"
Put the capturing interface into promiscuous mode
.RB (default:\  true ).
.TP
.BI "\-d, \-\-direction=" in|out|inout
Set the direction for which packets will be captured
.RB (default:\  inout ).
.TP
.BI "\-a, \-\-analysis=" PATH#opt1,opt2=val,...
Specify the path to an analysis module and set its options (if any).
.TP
.BI "\-I, \-\-ifile=" PATH
Specify the input file for stat mode,
.B '-'
means
.B stdin
.RB (default:\  nfstrace-{filter}.pcap ).
.TP
.BI "\-O, \-\-ofile=" PATH
Specify the output file for dump mode,
.B '-'
means
.B stdout
.RB (default:\  nfstrace-{filter}.pcap ).
.TP
.BI \-\-log= PATH
Specify the log file
.RB (default:\  nfstrace.log.{timestamp} ).
.TP
.BI "\-C, \-\-command=" "'shell command'"
Execute command for each dumped file.
.TP
.BI "\-D, \-\-dump-size=" MBytes
Set the size of the dumping file portion,
.B 0
means no limit
.RB (default:\  0 ).
.TP
.BI "\-E, \-\-enum=" interfaces|plugins
Enumerate all available network interfaces and and/or all available plugins,
then exit; please note that interfaces can't be listed unless nfstrace was built
against the recent version of libpcap that supports the
.B pcap_findalldevs()
function
.RB (default:\  none ).
.TP
.BI "\-M, \-\-msg-header=" 1..4000
Truncate RPC messages to this limit (specified in bytes) before passing to a
pluggable analysis module
.RB (default:\  512 ).
.TP
.BI "\-Q, \-\-qcapacity=" 1..65535
Set the initial capacity of the queue with RPC messages
.RB (default:\  4096 ).
.TP
.BI "\-T, \-\-trace"
Print collected NFSv3 or NFSv4 procedures, true if no modules were passed with
.B -a
option.
.TP
.BI "\-Z, \-\-droproot=" username
Drop root privileges after opening the capture device.
.TP
.BI "\-v, \-\-verbose=" 0|1|2
Specify verbosity level
.RB (default:\  1 ).
.TP
.BI "\-h, \-\-help"
Print help message and usage for modules passed with
.B \-a
option, then exit.
.\" --------------------- ANALYSIS MODULES -----------------------
.SH ANALYSIS MODULES
.SS Operation Breakdown Analyzer
Operation Breakdown (OB) analyzer calculates average frequency of NFS and CIFS
procedures and computes standard deviation of latency.
.PP
.RS 4
.PP
.B $ nfstrace -a libbreakdown.so -h
.br
.B nfstrace 0.4.0 (Release)
.br
.B built on Linux-3.16.1-1-generic
.br
.B by C++ compiler GNU 4.9.1
.br
.B Usage: ./nfstrace [OPTIONS]...
.br
.PP
Usage example:
.RS 4
.PP
.B $ nfstrace \-m stat \-a libreakdown.so
.RE
.PP
Breakdown analyzer produces
.B .dat
file in the current directory for each detected NFS session that can be
visualized using
.B nst.sh
and
.B breakdown_nfsv3.plt
or
.B breakdown_nfsv4.plt
(according to NFS version).
.RS 4
.PP
.B $ nst.sh \-a breakdown_nfsv4.plt \-d . \-p 'breakdown_10.6.137.47:903*.dat'
.RE
.SS Watch
Watch plugin mimics old
.B nfswatch
utility: it monitors NFS and CIFS traffic and displays it in terminal using ncurses. It
supports NFSv3, NFSv4, NFSv41, CIFSv1 and CIFSv2.
.PP
By default watch plugin will update its screen every second, you can specify
another timeout in milliseconds:
.RS 4
.PP
.B $ nfstrace -a libwatch.so#2000
.RE
.SS JSON Analyzer
JSON analyzer calculates a total amount of each supported application protocol
operation. It accepts TCP-connections on particular TCP-endpoint (host:port),
sends a respective JSON to the TCP-client and closes connection. Suggested to
be used in
.B live
mode.
.PP
.B Available options
.RS 4
.TP
.BI "host=" hostname
Network interface to listen (default is to listen all interfaces)
.TP
.BI "port=" port
IP-port to bind to
.RB (default:\  8888 )
.TP
.BI "workers=" workers
Amount of worker threads
.RB (default:\  10 )
.TP
.BI "duration=" duration
Max serving duration in milliseconds
.RB (default:\  500 )
.TP
.BI "backlog=" backlog
Listen backlog
.RB (default:\  15 )
.RE
.PP
.B Example of use
.RS 4
.PP
Start
.B nfstrace
in one console:
.RS 4
.PP
.B $ sudo nfstrace -i eth0 -a analyzers/libjson.so#host=localhost
.br
\[char46]..
.RE
.PP
Make a TCP-request to
.B nfstrace
in another console to fetch current statistics:
.RS 4
.PP
.B $ telnet localhost 8888
.br
Trying 127.0.0.1...
.br
Connected to localhost.
.br
Escape character is '^]'.
.br
{
.br
.RS 2
"nfs_v3":{
.br
.RS 2
"null":32,
.br
"getattr":4582,
.br
\[char46]..
.RE
},
.RE
.RS 2
"nfs_v4":{
.br
.RS 2
\[char46]..
.RE
},
.br
\[char46]..
.RE
}Connection closed by foreign host.
.RE
.RE
.\" --------------------- EXAMPLES -------------------------------
.SH EXAMPLES
.SS Available options
The following command demonstrates available options of the application and
plugged analysis modules (attached with
.B \-\-analysis
or
.B -a
options). Note that you can pass more than one module here.
.RS 4
.PP
.B nfstrace \-\-help \-\-analysis=libjson.so
.RE
.SS Online tracing
The following command will run
.B nfstrace
in online analysis mode (specified with
.B \-\-mode
or
.B \-m
options) without a pluggable analysis module. It will capture NFS and CIFS traffic
transferred over TCP or UDP with source or destination port number equals to
2049 and will simply print them out to
.B stdout
.RB ( \-T
or
.B \-\-trace
options). Capturing ends when
.B nfstrace
receives
.B SIGINT
(Control-C).
.PP
Note that capturing from network interface requires superuser privileges.
.PP
.RS 4
.B nfstrace \-\-mode=live \-\-filtration='ip and port 2049' \-\-trace
.RE
.SS Online analysis
The following command demonstrates running
.B nfstrace
in online analysis mode.  Just like in the previous example it will capture NFS and CIFS
traffic transferred over TCP or UDP with source or destination port number
equals to 2049 and then it will perform Operation Breakdown analysis using
pluggable analysis module
.B libbreakdown.so.
.PP
.RS 4
.B nfstrace \-m live \-f 'ip and port 2049' \-\-analysis=libbreakdown.so
.RE
.SS Online dumping and offline analysis
The following example demonstrates running
.B nfstrace
in online dumping and offline analysis modes.
.PP
At first
.B nfstrace
will capture NFS traffic transferred over TCP or UDP with source or destination
port number equals to 2049 and will dump captured packets to
.B dump.pcap
file (specified with
.B \-\-ofile
or
.B \-O
options).
.PP
At the second run
.B nfstrace
will perform offline Operation Breakdown analysis using pluggable analysis
module
.B libbreakdown.so.
.PP
.RS 4
.B # Dump captured packets to dump.pcap
.br
.B nfstrace \-m dump \-f 'ip and port 2049' \-\-ofile=dump.pcap
.br
.PP
.B # Analyse dump.pcap using libbreakdown.so
.br
.B nfstrace \-m stat \-\-ifile=dump.pcap \-a libbreakdown.so
.RE
.SS Online dumping, compression and offline analysis
The following example demonstrates running
.B nfstrace
in online dumping and offline analysis modes. Since dump file can easily
exhaust disk space, compression makes sense.
.PP
At first
.B nfstrace
will capture NFS traffic transferred over TCP or UDP with source or destination
port number equals to 2049 and will dump captured packets to
.B dump.pcap
file.
.PP
Note that compression is done by the external tool (executed in script passed
with
.B \-\-command
or
.B \-C
options) and it will be executed when capturing is done. The output file can
be inspected using some external tool.
.PP
At the second run
.B nfstrace
will perform offline analysis. Again, the external tool
.RB ( bzcat
in this example) is used in order to decompress previously saved dump.
.B nfstrace
will read
.B stdin
(note the
.B \-I –
option) and perform offline analysis using Operation Breakdown analyzer.
.PP
.RS 4
.B # Dump captured procedures to dump.pcap file.
.br
.B # Compress output using bzip2 when capturing ends.
.br
.B nfstrace \-m dump \-f 'ip and port 2049' \-O dump.pcap \-\-command 'bzip2 \-f \-9'
.PP
.B # Extract dump.pcap from dump.pcap.bz2 to stdin.
.br
.B # Read stdin and analyze data with libbreakdown.so module.
.br
.B bzcat dump.pcap.bz2 | nfstrace -m stat \-I \- \-a libbreakdown.so
.RE
.SS Online dumping with file limit, compression and offline analysis
This example is similar to the previous one except one thing: output dump file
can be very huge and cause problems in some situations, so
.B nfstrace
provides the ability to split it into parts.
.PP
At first
.B nfstrace
will be invoked in online dumping mode. Everything is similar to the previous
example except
.B -D
.RB ( \-\-dump-size )
option: it specifies the size limit in MBytes, so dump file will be split
according to this value.
.PP
At the second run
.B nfstrace
will perform offline analysis of captured packets using Operation Breakdown
analyzer.
.PP
Please note that only the first dump file has the pcap header.
.PP
.RS 4
.B # Dump captured procedures multiple files and compress them.
.br
.B nfstrace \-m dump \-f 'ip and port 2049' \-O dump.pcap \-D 1 \-C "bzip2 \-f \-9"
.PP
.B # get list of parts in the right order:
.br
.B #    dump.pcap.bz2
.br
.B #    dump.pcap-1.bz2
.br
.B #    dump.pcap-2.bz2
.br
.B parts=$(ls dump.pcap*.bz2 | sort \-n \-t \- \-k 2)
.PP
.B # Extract dump.pcap from main dump.pcap.bz2 and parts to stdin.
.br
.B # Read stdin and analyze data with libbreakdown.so module.
.br
.B bzcat $parts | nfstrace \-\-mode=stat \-I \- \-\-analysis=libbreakdown.so
.RE
.SS Visualization
This example demonstrates the ability to plot graphical representation of data
collected by Operation Breakdown analyzer.
.PP
.B nst.sh
is a shell script that collects data generated by analyzers and passes it to
gnuplot script specified with
.B -a
option.
.PP
.B breakdown.plt
is a gnuplot script that understands output data format of Operation Breakdown
analyzer and generates
.B .png
files with plots.
.PP
Note that
.B gnuplot
must be installed.
.PP
.RS 4
.B # Extract dump.pcap from dump.pcap.bz2 to stdin.
.br
.B # Read stdin and analyze data with libbreakdown.so module.
.br
.B bzcat trace.pcap.bz2 | nfstrace \-m stat \-I \- \-a libbreakdown.so
.PP
.B # Generate plot according to *.dat files generated by
.br
.B # libbreakdown.so analyzer.
.br
.B nst.sh \-a breakdown.plt \-d . \-p 'breakdown*.dat' \-v
.\" --------------------- FILES ----------------------------------
.SH FILES
.TP
API headers
.B @CMAKE_INSTALL_PREFIX@/include/nfstrace/api/
.TP
Pluggable Analysis Modules (PAMs)
.B @CMAKE_INSTALL_PREFIX@/lib/nfstrace/
.\" ---------------------- BUGS ----------------------------------
.SH BUGS
.P
Any problems, bugs, questions, desirable enhancements, etc.
should be sent to
.B <nfstrace@epam.com>
.\" -------------------- AUTHORS ---------------------------------
.SH AUTHORS
Vitali Adamenka
.B <Vitali_Adamenka@epam.com>
.PP
Yauheni Azaranka
.B <Yauheni_Azaranka@epam.com>
.PP
Alexey Costroma
.B <Alexey_Costroma@epam.com>
.PP
Dzianis Huznou
.B <Dzianis_Huznou@epam.com>
.PP
Pavel Karneliuk
.B <Pavel_Karneliuk@epam.com>
.PP
Andrey Kuznetsov
.B <Andrey_Kuznetsov@epam.com>
.PP
Mikhail Litvinets
.B <Mikhail_Litvinets@epam.com>
.PP
Ilya Storozhilov
.B <Ilya_Storozhilov@epam.com>
.\" -------------------- SEE ALSO --------------------------------
.SH SEE ALSO
.BR bpf (4),
.BR pcap (3),
.BR nfsstat (8),
.BR pcap-filter (7).