简体   繁体   English

Python(Django)。 商店telnet连接

[英]Python (Django). Store telnet connection

I am programming web interface which communicates with cisco switches via telnet. 我正在编程Web界面,该界面通过telnet与Cisco交换机通信。 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. 我想制作一个这样的系统,该系统将为每个交换机存储一个telnet连接,并且每个脚本(Web界面,cron作业等)都可以访问它。 This is needed to make a single query queue for each device and prevent huge cisco processor load caused by several concurent telnet connections. 这对于为每个设备创建单个查询队列并防止由多个并发的telnet连接导致的巨大cisco处理器负载是必需的。 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. 在脚本之间共享telnet连接对象可能难以实现和调试。 But this option is interesting because interface is using only by couple of operators and cron jobs. 但是这个选项很有趣,因为接口仅由几个操作员和cron作业使用。

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. 通常的方法是让一个进程在后台运行,以保持持久的telnet连接和排队的命令断开连接。

Then have the front-end scripts connect to it (eg. via a unix socket) to queue commands and get the results asynchronously. 然后让前端脚本连接到它(例如,通过unix套接字)以排队命令并异步获取结果。

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. 仅用于Web部分的一种轻量级替代方法是将telnet连接对象保留在Web脚本中,并将Web服务器/网关配置为仅一次启动Web应用程序的一个实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM