请求提示:将文件从路由器记录到服务器的可能性

发布于 2024-12-28 02:20:25 字数 652 浏览 5 评论 0原文

情况是这样的:

我编写了一个 C 程序,在 WRT54GL 路由器(OpenWRT White Russian、Busybox 1.00、Dropbear 客户端 v0.49)上进行一些无线测量。请注意,我无法在路由器上使用更新版本的操作系统或安装其他软件包(仅允许脚本或小程序)。

到目前为止,我每 15 分钟通过
从路由器到服务器记录一次测量结果 cat 本地文件 | ssh target_address cat“>” 远程文件

我从我的 C 程序 (system()) 中为日志启动时创建或存在的每个日志文件调用 。我不喜欢的是,系统调用为每个调用打开一个新的 shell,从而导致一些开销。好处是,通过这种方式,数据被加密,并且因为我为每个文件都建立了连接,所以我可以直接从服务器获取每个文件的反馈,以便我可以从路由器中删除日志。 (从服务器上的路由器调用脚本然后返回日志记录值的其他方法不起作用,因为 dropbear ssh 客户端不支持此返回)。

那么我要求的是:什么是一种更优雅的方法来做到这一点并减少这种开销?到目前为止,我已经阅读了一些有关如何使用 TLS / TCP 套接字的教程(这样我就可以将加密的数据发送到服务器)。另一种可能性可能是 HTTP PUT 或 POST,但我不确定如何获得正在发送的数据的反馈。所以我想听听你们的意见以及你们将如何尝试解决这个问题。

此致

here is the situation:

I have written a C program doing some wireless measurements on a WRT54GL Router (OpenWRT White Russian, Busybox 1.00, Dropbear client v0.49). Please note that i can not use a more up to date version of the operating system on the router or install additional packages (just scripts or small programs are allowed).

Up to now, i log my measurements results every 15 minutes from the router to the server via a
cat localfile | ssh target_address cat ">" remotefile

which i call from my C program (system()) for every logfile which is created or present at the moment the log starts. What i don't like is, that the system call opens a new shell for every single call, causing some overhead. The good thing is that in this way the data is encrypted and because i do a connection for every file, i can directly get per file feedback from the server, so that i can remove the logs from the router. (Other approaches calling scripts from the router on the server, which then return values for the logging did not work, as the dropbear ssh client does not support this return).

So what i'm asking for: what could be a more elegant way to do so and to reduce this overhead ? By now, i've read a few tutorials about how to use TLS / TCP Sockets (so i can send the data encrypted to the server). Another possibility could be a HTTP PUT or POST, but there i am not sure how i could get feedback for the data being send. So i would just like to hear your oppions and how you guys would try to tackle this.

Best regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何必那么矫情 2025-01-04 02:20:25

既然您谈论的是日志文件,这听起来像是 syslog 协议的工作

我非常确定 OpenWRT 开箱即用地支持它。

Since you're talking about log files, this sounds like a job for the syslog protocol.

I am pretty sure OpenWRT supports it out of the box.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文