@@ -138,6 +138,87 @@ Has same arguments as generic configure service.
138138 output = device.configure_exclusive(' logging console disable' )
139139
140140
141+ monitor
142+ -------
143+
144+ The monitor service can be used with the `monitor interface ` command. You can
145+ also pass `action ` commands to execute while the monitor is running. For
146+ example `clear ` (lowercase) will send the key associated with the action as
147+ shown in the output, i.e. Clear="c" will send "c" for action "clear".
148+
149+ =============== ====================== ==================================================
150+ Argument Type Description
151+ =============== ====================== ==================================================
152+ command str monitor command to execute ('monitor' is optional)
153+ or action to send (e.g. 'clear')
154+ reply Dialog additional dialog
155+ timeout int (default 60 sec) timeout value for the overall interaction.
156+ =============== ====================== ==================================================
157+
158+ Example:
159+
160+ .. code-block :: python
161+
162+ rtr.monitor(' monitor interface GigabitEthernet0/0/0/0' )
163+
164+ # execute `monitor interface`
165+ rtr.monitor(' interface' )
166+
167+ # tail the output for 10 seconds
168+ rtr.monitor.tail(timeout = 10 )
169+
170+ output = rtr.monitor.stop()
171+
172+ # send an action to the device
173+ rtr.monitor(' clear' )
174+ rtr.monitor(' bytes' )
175+
176+
177+ monitor.get_buffer
178+ ~~~~~~~~~~~~~~~~~~
179+
180+ To get the output that has been buffered by the monitor service, you can use the `monitor.get_buffer `
181+ method. This will return all output from the start of the monitor command until the moment of execution
182+ of this service.
183+
184+ ===================== ====================== ===================================================
185+ Argument Type Description
186+ ===================== ====================== ===================================================
187+ truncate bool (default: False) If true, will truncate the current buffer.
188+ ===================== ====================== ===================================================
189+
190+ .. code-block :: python
191+
192+ output = rtr.monitor.get_buffer()
193+
194+
195+ monitor.tail
196+ ~~~~~~~~~~~~
197+
198+ The monitor.tail method can be used to monitor the output logging after the ``monitor `` service
199+ has been used to start the monitor.
200+
201+ ===================== ====================== ===================================================
202+ Argument Type Description
203+ ===================== ====================== ===================================================
204+ timeout int (seconds) maximum time to wait before returning output.
205+ ===================== ====================== ===================================================
206+
207+ .. code-block :: python
208+
209+ output = rtr.monitor.tail(timeout = 30 )
210+
211+
212+ monitor.stop
213+ ~~~~~~~~~~~~
214+
215+ Stop the monitor and return all output.
216+
217+ .. code-block :: python
218+
219+ output = rtr.monitor.stop()
220+
221+
141222 Sub-Plugins
142223-----------
143224
@@ -152,7 +233,7 @@ attach_console
152233""""""""""""""
153234
154235Service to attach to line card console/Standby RP to execute commands in. Returns a
155- router-like object to execute commands on using python context managers.This service is
236+ router-like object to execute commands on using python context managers.This service is
156237supported in HA as well.
157238
158239==================== ====================== ========================================
@@ -176,8 +257,8 @@ switchto
176257""""""""
177258
178259Service to switch the router console to any state that user needs in order to perform
179- his tests. The api becomes a no-op if the console is already at the state user wants
180- to reach. This service is supported in HA as well.
260+ his tests. The api becomes a no-op if the console is already at the state user wants
261+ to reach. This service is supported in HA as well.
181262
182263
183264The states available to switch to are :
@@ -197,7 +278,7 @@ timeout int (default in None) timeout in sec for executing c
197278==================== ====================== ========================================
198279
199280.. code-block :: python
200-
281+
201282 device.switchto(" xr_env" )
202283 ... . some commands that need to be run in xr_env state ... .
203- device.switchto(" enable" )
284+ device.switchto(" enable" )
0 commit comments