Trouble displaying multiple SSH outputs in the same terminal
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Trouble displaying multiple SSH outputs in the same terminal
Hi all,
I have a case were I need to monitor the same thing on many different servers at the same time.
Currently I'm opening multiple terminals and running the same ssh command for ever server. So, I thought it might be best to use AWK to use just one terminal.
Ok, so basically I need to display a certain line from the output of a command on my remote servers, and since it's application-specific, I'll refer to it here as the command df.
I need to watch the output, so I do:
Code:
ssh -t user@ip "watch df -h | grep partition"
What I need to do, is to watch the same output for many servers, at the same time in the same window, so that they will be shown below each other.
Have you considered using a terminal emulator like 'Terminator'?
Have you looked into screen? While the output would all be in one terminal (sorta) you wouldn't be able to see it all at once.
Have you thought about maybe just logging that output to a single file that's in some networked directory available to all hosts and then just tail -F that file?
Have you considered using a terminal emulator like 'Terminator'?
No, not really. I'm on a Mac and use Fedora otherwise, so terminals are everywhere around me.
Quote:
Have you looked into screen? While the output would all be in one terminal (sorta) you wouldn't be able to see it all at once.
Again, nope.
Quote:
Have you thought about maybe just logging that output to a single file that's in some networked directory available to all hosts and then just tail -F that file?
Yes. But that wouldn't serve the purpose.
You see, I need not to log the output(s) into a single file, that's easy no problem.
One of my daily tasks is to sit and watch the number of calls going through our VOIP switches, and I have to do this over multiple servers.
Now, if it was one server, then BAAM!, easy. One terminal; one SSH session would do the job.
The problem is that it's not just one server, it's more. And currently I have to open a terminal window for each SSH session.
What I'm looking for is to write a simple script (if needed), that would contain the necessary set of commands that would initiate multiple SSH sessions at the same time, and display them on one open terminal screen.
One of my daily tasks is to sit and watch the number of calls going through our VOIP switches
Ouch; I hope you are kidding..
Anyway a quick n dirty soln is to write a shell script that fires off the ssh cmds into the background via '&'.
By default, the stdout & stderr (of each process) are still attached to the initiating terminal session, so all output should appear on the term for you.
Surely you would be MUCH better off setting up something like NAGIOS to monitor the relevant parameters, that way you can at least have a usable display and configurable alerts.
Surely you would be MUCH better off setting up something like NAGIOS to monitor the relevant parameters, that way you can at least have a usable display and configurable alerts.
Looks promising actually.
I'm not sure if it's going to give me what I need, but I'll definitely check it out in more details and put it to the test.
Will let you know if I need any further assistance.
Anyway a quick n dirty soln is to write a shell script that fires off the ssh cmds into the background via '&'.
By default, the stdout & stderr (of each process) are still attached to the initiating terminal session, so all output should appear on the term for you.
Yeah, tried that as well, but couldn't get the desired output :-(
You can address multiple server if you reverse the command order:
Code:
$ watch "ssh host1 ls; ssh host2 ls"
You can also put an empty echo between the ssh commands to separate the output.
Thanks Reuti, never thought about it before. But tried it now and unfortunately it doesn't give the desired output/effect.
Basically it has to login every time it's going to execute a command, and all my servers have an email alert in their bashrc files.
I installed Nagios last night, but still having problems with how to run custom commands on remote servers.
@TenTenths, can you help with this please? I'd like to have Nagios display certain outputs, not just the normal temp, disk space etc.. stuff. Or at least point me into the right direction if possible.
1- We wrote a script on the end servers that would be watched when logged in via SSH, so this is ok
2- We deployed Cacti (a wonderful graphing tool - awesome) for logging data and graphing them over time
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.