Wednesday, January 30, 2019

telnet python script using telnetlib

Advertisements

Daily we do a lot of stuff using telnet. Usually we log in to telnet using hostname and a port, then send actions and parameters and gets the response. We can do all these using an interactive terminal connection. Suppose we want to check something everyday and create an alert if something fails. In the post we will see how to check an Asterisk AMI Login using telnet actions and checking for errors. We will write a python script for automation and use this script with nagios to get alerts.


We will be using a python module named telentlib for this purpose. The logic is to connect to the host and port, send login action along with username and password. Get the response message, check the response message and lastly alert if something is wrong.

the source code can be found on the github How to check Asterisk AMI login via python telnetlib

No comments:

Post a Comment

Be nice. That's all.