I went through the Network automation classes and able to do some scripts for most configuration and show output and take action based on the output etc.
Now I need to monitor the switch console and take an action when I see a message something like “BGP session went down”
Can someone please give some tips on how to do this, basically using paramiko wait for response from switch
I’m sure there are several ways to do this, but one that comes to mind involves the use of Embedded Event Manager (EEM) scripting in conjunction with Python.
EEM supports Python scripts. Python scripts can be executed as part of EEM actions in EEM applets.
This NetworkLessons note shows how to match a string within CLI output. You can then use the EEM script to call a Python script. This EEM/Python interaction is further described in this Cisco documentation:
If you want to do it natively within Python using Paramiko, take a look at this StackOverflow thread where a user searched for a particular string in the output of the CLI:
I hope this has been helpful!