简体   繁体   English

从远程服务器收集日志的最佳方法

[英]Best way to collect logs from a remote server

I need to run some commands on some remote Solaris/Linux servers and collect their output in a log file on my local server. 我需要在某些远程Solaris / Linux服务器上运行一些命令,并将它们的输出收集到本地服务器上的日志文件中。

Currently, I'm using a simple Expect script, residing on the local server to fire the commands on the target system. 当前,我正在使用一个简单的Expect脚本,该脚本位于本地服务器上,以在目标系统上触发命令。 I then redirect the output of the expect script to a log file, like this, 然后,我将Expect脚本的输出重定向到这样的日志文件中,

/usr/local/bin/expect script.exp >> logfile.txt

However, this is proving to be very unreliable as the connection to the server fluctuates a lot, leading to incomplete logs and hung scripts. 但是,事实证明这是非常不可靠的,因为与服务器的连接波动很大,从而导致日志不完整和脚本挂起。

Is there a better and more reliable way to go about this task? 有没有更好,更可靠的方法来执行此任务?

I have implemented fedorqui's answer, 我已经实现了fedorqui的答案,

  • Created a (shell) script that runs the required commands on the target servers. 创建了一个(外壳)脚本,该脚本在目标服务器上运行所需的命令。
  • Deployed this script to all servers. 将此脚本部署到所有服务器。
  • Executed this script via expect, from my local (central) server. 通过期望从我的本地(中央)服务器执行了此脚本。
  • Finally collected logs individually from each server after successful completion, and processed them. 最后,在成功完成之后,分别从每台服务器收集日志,并对其进行处理。

The solution has been working fine without a glitch till now. 到目前为止,该解决方案一直运行良好,没有出现故障。

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

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