Python(Django)。存储 telnet 连接
我正在编写通过 telnet 与 cisco 交换机进行通信的 Web 界面。我想制作这样一个系统,每个交换机将存储一个 telnet 连接,并且每个脚本(Web 界面、cron 作业等)都可以访问它。这是为每个设备创建单个查询队列并防止多个并发 telnet 连接造成的巨大 cisco 处理器负载所必需的。 我怎样才能做到这一点?
更新
具有连接处理守护进程的选项很好,并且将以最佳方式工作。在脚本之间共享 telnet 连接对象可能难以实现和调试。但这个选项很有趣,因为接口仅由几个操作员和 cron 作业使用。
I am programming web interface which communicates with cisco switches via telnet. I want to make such system which will be storing one telnet connection per switch and every script (web interface, cron jobs, etc.) will have access to it. This is needed to make a single query queue for each device and prevent huge cisco processor load caused by several concurent telnet connections.
How do I can do this?
updated
Option with connection handling daemon is good and will work in the best way. Sharing telnet connection object between scripts may be difficult to implement and debug. But this option is interesting because interface is using only by couple of operators and cron jobs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常的方法是让一个进程在后台运行,以保持持久的 telnet 连接和排队等待的命令。
然后让前端脚本连接到它(例如,通过 unix 套接字)以对命令进行排队并异步获取结果。
但这可能有点矫枉过正。您预计有多少人同时使用交换机接口?仅针对 Web 部分的一种轻量级替代方案是将 telnet 连接对象保留在 Web 脚本中,并将 Web 服务器/网关配置为一次仅启动 Web 应用程序的一个实例。
The usual way would be to have a process running in the background that keeps hold of the persistent telnet connections and commands queued to go down them.
Then have the front-end scripts connect to it (eg. via a unix socket) to queue commands and get the results asynchronously.
But this might be overkill. How many people are you expecting to be using a switch interface concurrently? A lightweight alternative for just the web part of it would be to keep the telnet connection object in the web scripts, and configure the web server/gateway to only launch one instance of your webapp at once.