一、概述
最近发现办公室有一个感测器网关,偶尔会掉线,重启之后,就正常了。
手动操作过程如下:
#telnet 10.212.82.90
Trying 10.212.82.90...
Connected to10.212.82.90.
Escape characteris '^]'.
(none) login: root
Password:
Please make sure that what you're doing! If you aren't administrator, please Don't do anything! :)
#ps
PID USER VSZ STAT COMMAND1 root 1124S init2root 0 SW [kthreadd]3 root 0 SW [ksoftirqd/0]4 root 3888 S /usr/app/bin/app
说明:先telnet进去,输入用户名和密码之后,执行ps命令。如果有/usr/app/bin/app进程,说明设备正常,否则就需要重启。
但是手动操作比较麻烦,需要使用python登录网关设备,检测是否正常。
二、Telnet对象
Telnet.read_until(expected, timeout=None) : #读取连接服务器后显示的内容,直到遇到同expected相同的字节串。或者等待时间大于timeout时直接向下运行。
Telnet.read_very_eager() : 读取从上次IO阻断到现在所有的内容,返回的是字节串,需要进行decode()编码。如果连接