在 Windows 上同时监控多个日志文件(通过 ssh)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/106668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Simultaneously monitoring multiple log files (over ssh) on Windows?
提问by anjanb
I've used poderosa(a .NET terminal app) to monitor logs on multiple linux/solaris servers. This application is NOT getting currently maintained and I've had several problems with it.
我使用 poderosa(一个 .NET 终端应用程序)来监控多个 linux/solaris 服务器上的日志。这个应用程序目前没有得到维护,我遇到了几个问题。
I'm wondering what other users do to simultaneously monitor several logs in real-time(as in tail -f logfile). I would like to be able to tab/cascade several ssh tails.
我想知道其他用户如何同时实时监控多个日志(如 tail -f 日志文件)。我希望能够标记/级联几个 ssh 尾部。
thank you
谢谢你
采纳答案by Owen
You could use Putty Connection Managerto add tabs to PuTTy. Then SSH into the machine twice and tab back and forth.
您可以使用Putty 连接管理器向 PuTTy 添加选项卡。然后 SSH 两次进入机器并来回切换。
回答by zigdon
回答by zigdon
Ssh to one of the server, run screen on it. You can then split the screen into multiple windows, and each one of them do
SSH 连接到其中一台服务器,在其上运行 screen。然后你可以把屏幕分成多个窗口,每个窗口都做
ssh serverX tail -f /path/to/log/file
An incidental advantage to this method is that you don't have to restart the tails each time you connect - instead, you can just reattach to the running screen session.
这种方法的一个附带优势是您不必每次连接时都重新启动尾部 - 相反,您只需重新连接到正在运行的屏幕会话。
回答by dsm
From bash you can (save in ~/.bashrc
or something):
从 bash 你可以(保存~/.bashrc
或其他东西):
function create-follower () {
local _NAME=;
local _USER=;
local _HOST=;
local _PATH=;
if ! [ "${_NAME}" ]\
|| ! [ "${_USER}" ]\
|| ! [ "${_HOST}" ]\
|| ! [ "${_PATH}" ] ; then
{ echo "Cannot create log follower." ;
echo;
echo "Usage: create-follower NAME USER HOST LOG-FILE";
} >&2;
return 1 ;
fi ;
eval "function ${_NAME}(){ ssh ${_USER}@${_HOST} tail -f \"${_PATH}\" & }"
}
function activate-followers () {
if (( $# < 1 )) ; then
{ echo "You must specify at least one follower to use" ;
echo ;
echo "Usage:" ;
echo " activate-followers follower1 [follower2 ... followerN]";
} >&2;
return 1 ;
fi ;
for FOLLOW in "${@}" ; do
${FOLLOW} ;
done ;
wait;
}
function stop-followers () {
if [ "$(jobs)" ] ; then
kill -9 $(jobs | perl -pe 's/\[([0-9]+)\].*/%/') ;
fi ;
}
And then from your shell, define the logs you want to follow:
然后在你的 shell 中,定义你想要关注的日志:
[dsm@localhost:~]$ create-follower test1 user1 localhost /tmp/log-1.txt
[dsm@localhost:~]$ create-follower test2 user2 otherhost /tmp/log-2.txt
[dsm@localhost:~]$ create-follower test2 user3 remotebox /tmp/log-3.txt
Now, activate the followers:
现在,激活关注者:
[dsm@localhost:~]$ activate-followers test1 test2 test3
To get out of the function use CTRL+C
, and to stop the backgrounded processes use:
要退出函数使用CTRL+C
,并停止后台进程使用:
[dsm@localhost:~]$ stop-followers
NOTE 1: This assumes public key authentication has been set up for your boxes.
注意 1:这假设已为您的盒子设置了公钥身份验证。
NOTE 2: You will have to kill all the jobs that are left running after quitting the activate-followers function. You may want to do this manually as the function provided does a brute force kill on ALL backgrounded jobs
注意 2:在退出激活跟随功能后,您必须终止所有仍在运行的作业。您可能希望手动执行此操作,因为所提供的功能会对所有后台作业进行强力杀死
NOTE 3: This assumes a working unix-like environment, which you can get by installing cygwin
注意 3:这假设有一个类似 Unix 的工作环境,您可以通过安装 cygwin 获得
Who says you can't do lisp in shellscript ;-)
谁说你不能在 shellscript 中做 lisp ;-)
回答by Philippe Schweitzer
You can checkout in'side log.
您可以在侧边日志中结帐。
A Java tool I created, able to read local and distant log files using SSH. It is fairly simple to use.
我创建的一个 Java 工具,能够使用 SSH 读取本地和远程日志文件。使用起来相当简单。
Some more explanations: https://github.com/pschweitz/insidelog/wiki
更多解释:https: //github.com/pschweitz/insidelog/wiki
Just download the version corresponding to your operating system, or the native jar release executable within your Java Runtime (requires java 8_40 or higher):
只需下载与您的操作系统相对应的版本,或您的 Java 运行时中的本地 jar 发布可执行文件(需要 java 8_40 或更高版本):
https://github.com/pschweitz/insidelog/releases
https://github.com/pschweitz/insidelog/releases
You can find a complete documentation (embedded with and in Github's page as well)
您可以找到完整的文档(也嵌入在 Github 页面中)
回答by f4nt
If you actually needed to see both logs at the same time, and tabs were out of the question, you could install a perl script called LogResolveMerge.pl. It'll will merge two logs together, and dump the output to STDOUT. However, it will be resource intensive, and if your intention is to tail -f the logs, it likely won't be too effective.
如果您确实需要同时查看两个日志,并且无法使用选项卡,您可以安装一个名为 LogResolveMerge.pl 的 perl 脚本。它会将两个日志合并在一起,并将输出转储到 STDOUT。但是,这将是资源密集型的,如果您的意图是对日志进行 tail -f,它可能不会太有效。
回答by dwj
Two options that pop into my mind first.
我首先想到的两个选项。
Choose your favorite SSH app (putty, ssh in cygwin, etc) and log into the machine.
1. SSH for each log (lots of windows open on your machine or tabs depending on your app)
2. SSH once and use screen.
选择您最喜欢的 SSH 应用程序(putty、cygwin 中的 ssh 等)并登录到机器。
1. 对每个日志进行 SSH(根据您的应用程序在您的机器上打开许多窗口或选项卡)
2. SSH 一次并使用screen。