Debian Codegraph @

docs/cli/exec.md

raw symbols SCIP
1 ---
2 title: Executing Commands on Devices
3 hide:
4 - tags
5 tags:
6 - CLI
7 ---
8
9 <!--
10 ~ Copyright (c) 2023-2026 Arista Networks, Inc.
11 ~ Use of this source code is governed by the Apache License 2.0
12 ~ that can be found in the LICENSE file.
13 -->
14
15 ANTA CLI provides a set of entrypoints to facilitate remote command execution on EOS devices.
16
17 ## EXEC command overview
18
19 ```bash
20 --8<-- "anta_exec_help.txt"
21 ```
22
23 ## Clear interfaces counters
24
25 This command clears interface counters on EOS devices specified in your inventory.
26
27 ### Command overview
28
29 ```bash
30 --8<-- "anta_exec_clearcounters_help.txt"
31 ```
32
33 !!! tip
34 `username`, `password`, `enable-password`, `enable`, `timeout` and `insecure` values are the same for all devices
35
36 ### Example
37
38 ```bash
39 anta exec clear-counters --tags SPINE
40 [20:19:13] INFO Connecting to devices... utils.py:43
41 INFO Clearing counters on remote devices... utils.py:46
42 INFO Cleared counters on DC1-SPINE2 (cEOSLab) utils.py:41
43 INFO Cleared counters on DC2-SPINE1 (cEOSLab) utils.py:41
44 INFO Cleared counters on DC1-SPINE1 (cEOSLab) utils.py:41
45 INFO Cleared counters on DC2-SPINE2 (cEOSLab)
46 ```
47
48 ## Collect a set of commands
49
50 This command collects all the commands specified in a commands-list file, which can be in either `json` or `text` format.
51
52 ### Command overview
53
54 ```bash
55 --8<-- "anta_exec_snapshot_help.txt"
56 ```
57
58 > `username`, `password`, `enable-password`, `enable`, `timeout` and `insecure` values are the same for all devices
59
60 The commands-list file should follow this structure:
61
62 ```yaml
63 ---
64 json_format:
65 - show version
66 text_format:
67 - show bfd peers
68 ```
69
70 ### Example
71
72 ```bash
73 anta exec snapshot --tags SPINE --commands-list ./commands.yaml --output ./
74 [20:25:15] INFO Connecting to devices... utils.py:78
75 INFO Collecting commands from remote devices utils.py:81
76 INFO Collected command 'show version' from device DC2-SPINE1 (cEOSLab) utils.py:76
77 INFO Collected command 'show version' from device DC2-SPINE2 (cEOSLab) utils.py:76
78 INFO Collected command 'show version' from device DC1-SPINE1 (cEOSLab) utils.py:76
79 INFO Collected command 'show version' from device DC1-SPINE2 (cEOSLab) utils.py:76
80 [20:25:16] INFO Collected command 'show bfd peers' from device DC2-SPINE2 (cEOSLab) utils.py:76
81 INFO Collected command 'show bfd peers' from device DC2-SPINE1 (cEOSLab) utils.py:76
82 INFO Collected command 'show bfd peers' from device DC1-SPINE1 (cEOSLab) utils.py:76
83 INFO Collected command 'show bfd peers' from device DC1-SPINE2 (cEOSLab)
84 ```
85
86 The results of the executed commands will be stored in the output directory specified during command execution:
87
88 ```bash
89 tree _2023-07-14_20_25_15
90 _2023-07-14_20_25_15
91 ├── DC1-SPINE1
92 │   ├── json
93 │   │   └── show version.json
94 │   └── text
95 │   └── show bfd peers.log
96 ├── DC1-SPINE2
97 │   ├── json
98 │   │   └── show version.json
99 │   └── text
100 │   └── show bfd peers.log
101 ├── DC2-SPINE1
102 │   ├── json
103 │   │   └── show version.json
104 │   └── text
105 │   └── show bfd peers.log
106 └── DC2-SPINE2
107 ├── json
108 │   └── show version.json
109 └── text
110 └── show bfd peers.log
111
112 12 directories, 8 files
113 ```
114
115 ## Get Scheduled tech-support
116
117 EOS offers a feature that automatically creates a tech-support archive every hour by default. These archives are stored under `/mnt/flash/schedule/tech-support`.
118
119 ```eos
120 leaf1#show schedule summary
121 Maximum concurrent jobs 1
122 Prepend host name to logfile: Yes
123 Name At Time Last Interval Timeout Max Max Logfile Location Status
124 Time (mins) (mins) Log Logs
125 Files Size
126 ----------------- ------------- ----------- -------------- ------------- ----------- ---------- --------------------------------- ------
127 tech-support now 08:37 60 30 100 - flash:schedule/tech-support/ Success
128
129
130 leaf1#bash ls /mnt/flash/schedule/tech-support
131 leaf1_tech-support_2023-03-09.1337.log.gz leaf1_tech-support_2023-03-10.0837.log.gz leaf1_tech-support_2023-03-11.0337.log.gz
132 ```
133
134 For Network Readiness for Use (NRFU) tests and to keep a comprehensive report of the system state before going live, ANTA provides a command-line interface that efficiently retrieves these files.
135
136 ### Command overview
137
138 ```bash
139 --8<-- "anta_exec_collecttechsupport_help.txt"
140 ```
141
142 !!! tip
143 `username`, `password`, `enable-password`, `enable`, `timeout` and `insecure` values are the same for all devices
144
145 When executed, this command fetches tech-support files and downloads them locally into a device-specific subfolder within the designated folder. You can specify the output folder with the `--output` option.
146
147 ANTA uses SCP to download files from devices and will not trust unknown SSH hosts by default. Add the SSH public keys of your devices to your `known_hosts` file or use the `anta --insecure` option to ignore SSH host keys validation.
148
149 The configuration `aaa authorization exec default` must be present on devices to be able to use SCP.
150
151 !!! warning
152 **Deprecation**
153
154 ANTA can automatically configure `aaa authorization exec default local` using the `anta exec collect-tech-support --configure` option but this option is deprecated and will be removed in ANTA 2.0.0.
155
156 If you require specific AAA configuration for `aaa authorization exec default`, like `aaa authorization exec default none` or `aaa authorization exec default group tacacs+`, you will need to configure it manually.
157
158 The `--latest` option allows retrieval of a specific number of the most recent tech-support files.
159
160 !!! warning
161 By default **all** the tech-support files present on the devices are retrieved.
162
163 ### Example
164
165 ```bash
166 anta --insecure exec collect-tech-support
167 [15:27:19] INFO Connecting to devices...
168 INFO Copying '/mnt/flash/schedule/tech-support/spine1_tech-support_2023-06-09.1315.log.gz' from device spine1 to 'tech-support/spine1' locally
169 INFO Copying '/mnt/flash/schedule/tech-support/leaf3_tech-support_2023-06-09.1315.log.gz' from device leaf3 to 'tech-support/leaf3' locally
170 INFO Copying '/mnt/flash/schedule/tech-support/leaf1_tech-support_2023-06-09.1315.log.gz' from device leaf1 to 'tech-support/leaf1' locally
171 INFO Copying '/mnt/flash/schedule/tech-support/leaf2_tech-support_2023-06-09.1315.log.gz' from device leaf2 to 'tech-support/leaf2' locally
172 INFO Copying '/mnt/flash/schedule/tech-support/spine2_tech-support_2023-06-09.1315.log.gz' from device spine2 to 'tech-support/spine2' locally
173 INFO Copying '/mnt/flash/schedule/tech-support/leaf4_tech-support_2023-06-09.1315.log.gz' from device leaf4 to 'tech-support/leaf4' locally
174 INFO Collected 1 scheduled tech-support from leaf2
175 INFO Collected 1 scheduled tech-support from spine2
176 INFO Collected 1 scheduled tech-support from leaf3
177 INFO Collected 1 scheduled tech-support from spine1
178 INFO Collected 1 scheduled tech-support from leaf1
179 INFO Collected 1 scheduled tech-support from leaf4
180 ```
181
182 The output folder structure is as follows:
183
184 ```bash
185 tree tech-support/
186 tech-support/
187 ├── leaf1
188 │   └── leaf1_tech-support_2023-06-09.1315.log.gz
189 ├── leaf2
190 │   └── leaf2_tech-support_2023-06-09.1315.log.gz
191 ├── leaf3
192 │   └── leaf3_tech-support_2023-06-09.1315.log.gz
193 ├── leaf4
194 │   └── leaf4_tech-support_2023-06-09.1315.log.gz
195 ├── spine1
196 │   └── spine1_tech-support_2023-06-09.1315.log.gz
197 └── spine2
198 └── spine2_tech-support_2023-06-09.1315.log.gz
199
200 6 directories, 6 files
201 ```
202
203 Each device has its own subdirectory containing the collected tech-support files.