Skip to content

Commit d5afbeb

Browse files
committed
update help and docs
1 parent 63a698a commit d5afbeb

File tree

6 files changed

+344
-201
lines changed

6 files changed

+344
-201
lines changed

commands/netobserv

Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/bash
22
source "./scripts/functions.sh"
3+
source "./scripts/help.sh"
34
source "./scripts/dependencies_check.sh"
45

56
set +u
7+
68
# e2e skips inputs
79
if [ -z "${isE2E+x}" ]; then isE2E=false; fi
810
# keep capture state
@@ -46,7 +48,22 @@ maxTime="5m"
4648
# max bytes (default: 50MB)
4749
maxBytes=50000000
4850

49-
function flows() {
51+
if [[ ! "$*" =~ ^(.*)help|version(.*) ]]; then
52+
required_yq_version="v0.0.0"
53+
supported_archs=""
54+
check_dependencies "$required_yq_version" "$supported_archs"
55+
fi
56+
57+
case "$1" in
58+
*help)
59+
help
60+
exit 0
61+
;;
62+
*version)
63+
version "$version"
64+
exit 0
65+
;;
66+
*flows)
5067
case "$2" in
5168
"help")
5269
flows_usage
@@ -59,9 +76,8 @@ function flows() {
5976
command="flows"
6077
;;
6178
esac
62-
}
63-
64-
function packets() {
79+
;;
80+
*packets)
6581
case "$2" in
6682
"help")
6783
packets_usage
@@ -74,9 +90,8 @@ function packets() {
7490
command="packets"
7591
;;
7692
esac
77-
}
78-
79-
function metrics() {
93+
;;
94+
*metrics)
8095
case "$2" in
8196
"help")
8297
metrics_usage
@@ -89,74 +104,58 @@ function metrics() {
89104
command="metrics"
90105
;;
91106
esac
92-
}
93-
94-
if [[ ! "$*" =~ ^(.*)help|version(.*) ]]; then
95-
required_yq_version="v0.0.0"
96-
supported_archs=""
97-
check_dependencies "$required_yq_version" "$supported_archs"
98-
fi
99-
100-
case "$1" in
101-
"help")
102-
# display Help
103-
echo
104-
echo "Netobserv allows you to capture flow, packets and metrics from your cluster."
105-
echo "Find more information at: https://github.com/netobserv/network-observability-cli/"
106-
echo
107-
echo "Syntax: netobserv [flows|packets|metrics|follow|stop|copy|cleanup|version] [options]"
108-
echo
109-
echo "commands:"
110-
echo " flows Capture flows information in JSON format using collector pod."
111-
echo " Options:"
112-
flows_usage
113-
echo " packets Capture packets information in pcap format using collector pod."
114-
echo " Options:"
115-
packets_usage
116-
echo " metrics Capture metrics information in Prometheus using a ServiceMonitor (OCP cluster only)."
117-
echo " Options:"
118-
metrics_usage
119-
echo " follow Follow collector logs when running in background."
120-
echo " stop Stop collection by removing agent daemonset."
121-
echo " copy Copy collector generated files locally."
122-
echo " cleanup Remove netobserv components and configurations."
123-
echo " version Print software version."
124-
echo
125-
exit 0
126107
;;
127-
"version")
128-
# display version
129-
echo "Netobserv CLI version $version"
130-
exit 0
131-
;;
132-
"flows")
133-
flows $*
134-
;;
135-
"packets")
136-
packets $*
137-
;;
138-
"metrics")
139-
metrics $*
140-
;;
141-
"follow")
142-
# run follow command
143-
follow
144-
exit 0
108+
*follow)
109+
case "$2" in
110+
"help")
111+
follow_usage
112+
exit 0
113+
;;
114+
*)
115+
# run follow command
116+
follow
117+
exit 0
118+
;;
119+
esac
145120
;;
146-
"stop")
147-
# run deleteDaemonset command
148-
deleteDaemonset
149-
exit 0
121+
*stop)
122+
case "$2" in
123+
"help")
124+
stop_usage
125+
exit 0
126+
;;
127+
*)
128+
# run deleteDaemonset command
129+
deleteDaemonset
130+
exit 0
131+
;;
132+
esac
150133
;;
151-
"copy")
152-
# run copy output command
153-
copyOutput
154-
exit 0
134+
*copy)
135+
case "$2" in
136+
"help")
137+
copy_usage
138+
exit 0
139+
;;
140+
*)
141+
# run copy output command
142+
copyOutput
143+
exit 0
144+
;;
145+
esac
155146
;;
156-
"cleanup")
157-
# run cleanup command
158-
cleanup
159-
exit 0
147+
*cleanup)
148+
case "$2" in
149+
"help")
150+
cleanup_usage
151+
exit 0
152+
;;
153+
*)
154+
# run cleanup command
155+
cleanup
156+
exit 0
157+
;;
158+
esac
160159
;;
161160
*)
162161
echo "Unknown command $1. Use 'netobserv help' to display options"

docs/netobserv_cli.adoc

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// Automatically generated by './scripts/generate-doc.sh'. Do not edit, or make the NETOBSERV team aware of the editions.
22
:_mod-docs-content-type: REFERENCE
3+
34
[id="network-observability-cli-usage_{context}"]
45
= Network Observability CLI usage
56

6-
You can use the The Network Observability CLI (`oc netobserv`) to pass command line arguments to capture flow data and packet data for further analysis, enable Network Observability Operator features or pass configuration options to the eBPF agent and flowlogs-pipeline.
7+
You can use the The Network Observability CLI (`oc netobserv`) to pass command line arguments to capture flows data and packets data for further analysis, enable Network Observability Operator features or pass configuration options to the eBPF agent and `flowlogs-pipeline`.
8+
9+
[id=cli-syntax_{context}]
710
== Syntax
811
The basic syntax for `oc netobserv` commands:
912

@@ -14,15 +17,24 @@ $ oc netobserv [<command>] [<feature_option>] [<command_options>] <1>
1417
----
1518
<1> Feature options can only be used with the `oc netobserv flows` command. They cannot be used with the `oc netobserv packets` command.
1619

20+
[id=cli-basic-commands_{context}]
1721
== Basic commands
1822
[cols="3a,8a",options="header"]
1923
.Basic commands
2024
|===
2125
| Command | Description
2226
| flows
23-
| Capture flows information. For subcommands, see the "Flow capture subcommands" table.
27+
| Capture flows information. For subcommands, see the "Flows capture options" table.
2428
| packets
25-
| Capture packets data. For subcommands, see the "Packet capture subcommand" table.
29+
| Capture packets data. For subcommands, see the "Packets capture options" table.
30+
| metrics
31+
| Capture metrics data. For subcommands, see the "Metrics capture options" table.
32+
| follow
33+
| Follow collector logs when running in background.
34+
| stop
35+
| Stop collection by removing agent daemonset.
36+
| copy
37+
| Copy collector generated files locally.
2638
| cleanup
2739
| Remove the Network Observability CLI components.
2840
| version
@@ -31,8 +43,10 @@ $ oc netobserv [<command>] [<feature_option>] [<command_options>] <1>
3143
| Show help.
3244
|===
3345

46+
[id=cli-reference-flows-capture-options_{context}]
3447
== Flows capture options
35-
Flow capture has mandatory commands as well as additional options, such as enabling extra features about packet drops, DNS latencies, Round-trip time, and filtering.
48+
flows capture has mandatory commands as well as additional options, such as enabling extra features about packet drops, DNS latencies, Round-trip time, and filtering.
49+
3650
.`oc netobserv flows` syntax
3751
[source,terminal]
3852
----
@@ -52,7 +66,6 @@ $ oc netobserv flows [<feature_option>] [<command_options>]
5266
|--background| run in background | false
5367
|--copy| copy the output files locally | prompt
5468
|--node-selector| capture on specific nodes | n/a
55-
|--enable_filter| enable flow filter | false
5669
|--direction| filter direction | n/a
5770
|--cidr| filter CIDR | 0.0.0.0/0
5871
|--protocol| filter protocol | n/a
@@ -71,17 +84,19 @@ $ oc netobserv flows [<feature_option>] [<command_options>]
7184
|--icmp_code| filter ICMP code | n/a
7285
|--peer_ip| filter peer IP | n/a
7386
|--drops| filter flows with only dropped packets | false
74-
|--regexes| filter flows using regex | n/a
87+
|--regexes| filter flows using regular expression | n/a
7588
|--interfaces| interfaces to monitor | n/a
7689
|===
7790

78-
.Example running flow capture on TCP protocol and port 49051 with PacketDrop and RTT features enabled:
91+
.Example running flows capture on TCP protocol and port 49051 with PacketDrop and RTT features enabled:
7992
[source,terminal]
8093
----
8194
$ oc netobserv flows --enable_pktdrop=true --enable_rtt=true --enable_filter=true --action=Accept --cidr=0.0.0.0/0 --protocol=TCP --port=49051
8295
----
96+
[id=cli-reference-packet-capture-options_{context}]
8397
== Packets capture options
84-
You can filter packet capture data as same as flow capture using the filters. However, the features are not available here.
98+
You can filter packets capture data as same as flows capture using the filters.
99+
Note that the features, such as packets drop, dns, rtt, and network events, are only available for flows and metrics capture.
85100

86101
.`oc netobserv packets` syntax
87102
[source,terminal]
@@ -97,7 +112,6 @@ $ oc netobserv packets [<option>]
97112
|--background| run in background | false
98113
|--copy| copy the output files locally | prompt
99114
|--node-selector| capture on specific nodes | n/a
100-
|--enable_filter| enable flow filter | false
101115
|--direction| filter direction | n/a
102116
|--cidr| filter CIDR | 0.0.0.0/0
103117
|--protocol| filter protocol | n/a
@@ -116,16 +130,17 @@ $ oc netobserv packets [<option>]
116130
|--icmp_code| filter ICMP code | n/a
117131
|--peer_ip| filter peer IP | n/a
118132
|--drops| filter flows with only dropped packets | false
119-
|--regexes| filter flows using regex | n/a
133+
|--regexes| filter flows using regular expression | n/a
120134
|===
121135

122-
.Example running packet capture on TCP protocol and port 49051:
136+
.Example running packets capture on TCP protocol and port 49051:
123137
[source,terminal]
124138
----
125139
$ oc netobserv packets --action=Accept --cidr=0.0.0.0/0 --protocol=TCP --port=49051
126140
----
141+
[id=cli-reference-metrics-capture-options_{context}]
127142
== Metrics capture options
128-
You can enable features and use filters on metrics capture as same as flow capture. The generated graphs will fill accordingly.
143+
You can enable features and use filters on metrics capture, the same as flows capture. The generated graphs fill accordingly in the dashboard.
129144

130145
.`oc netobserv metrics` syntax
131146
[source,terminal]
@@ -141,7 +156,6 @@ $ oc netobserv metrics [<option>]
141156
|--enable_network_events| enable Network events monitoring | false
142157
|--get-subnets| get subnets informations | false
143158
|--node-selector| capture on specific nodes | n/a
144-
|--enable_filter| enable flow filter | false
145159
|--direction| filter direction | n/a
146160
|--cidr| filter CIDR | 0.0.0.0/0
147161
|--protocol| filter protocol | n/a
@@ -160,7 +174,7 @@ $ oc netobserv metrics [<option>]
160174
|--icmp_code| filter ICMP code | n/a
161175
|--peer_ip| filter peer IP | n/a
162176
|--drops| filter flows with only dropped packets | false
163-
|--regexes| filter flows using regex | n/a
177+
|--regexes| filter flows using regular expression | n/a
164178
|--interfaces| interfaces to monitor | n/a
165179
|===
166180

0 commit comments

Comments
 (0)