LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-04-2011, 07:40 AM   #1
sergani
LQ Newbie
 
Registered: Jan 2010
Distribution: Fedora, CentOS, OpenSuse, Oracle Enterprise Linux, MacOSX
Posts: 27

Rep: Reputation: 0
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.

Does anyone know of any ideas to achieve this?

Last edited by sergani; 09-04-2011 at 07:42 AM.
 
Old 09-04-2011, 09:27 AM   #2
lydiaXr
LQ Newbie
 
Registered: Jun 2011
Location: London
Distribution: FreeBSD, Ubuntu, Fedora
Posts: 15

Rep: Reputation: Disabled
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?
 
Old 09-04-2011, 11:09 AM   #3
sergani
LQ Newbie
 
Registered: Jan 2010
Distribution: Fedora, CentOS, OpenSuse, Oracle Enterprise Linux, MacOSX
Posts: 27

Original Poster
Rep: Reputation: 0
Hello lydiaXr,

Quote:
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.

Please let me know if you can help in anyway.

Thanks..
//M
 
Old 09-04-2011, 08:37 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Quote:
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.
 
Old 09-05-2011, 05:44 AM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,481

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
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.
 
Old 09-05-2011, 06:23 AM   #6
sergani
LQ Newbie
 
Registered: Jan 2010
Distribution: Fedora, CentOS, OpenSuse, Oracle Enterprise Linux, MacOSX
Posts: 27

Original Poster
Rep: Reputation: 0
Quote:
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.

Thanks..
//M
 
Old 09-05-2011, 06:43 AM   #7
sergani
LQ Newbie
 
Registered: Jan 2010
Distribution: Fedora, CentOS, OpenSuse, Oracle Enterprise Linux, MacOSX
Posts: 27

Original Poster
Rep: Reputation: 0
Quote:
Ouch; I hope you are kidding.. ;-)
LoL... not bad if you own the switch itself ;-)

Quote:
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 :-(
 
Old 09-06-2011, 03:38 AM   #8
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
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.
 
Old 09-06-2011, 07:40 AM   #9
sergani
LQ Newbie
 
Registered: Jan 2010
Distribution: Fedora, CentOS, OpenSuse, Oracle Enterprise Linux, MacOSX
Posts: 27

Original Poster
Rep: Reputation: 0
Quote:
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.

Thanks all, your help is very much appreciated.

//M
 
Old 10-04-2011, 04:04 AM   #10
sergani
LQ Newbie
 
Registered: Jan 2010
Distribution: Fedora, CentOS, OpenSuse, Oracle Enterprise Linux, MacOSX
Posts: 27

Original Poster
Rep: Reputation: 0
Hi all,

This is to conclude my search with the following:

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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
odbc (php output not displaying in web browser,but it displaying in terminal) manu@vssc Red Hat 1 06-29-2011 01:33 AM
trouble with VNC in gnome-rdp started through terminal via ssh (Xubuntu 7.10) sehku17 Linux - Software 2 05-01-2008 06:47 PM
multiple terminal windows for ssh in linux nasarlinux Linux - General 3 09-23-2005 08:13 AM
multiple outputs from xmms walrus_55 Linux - Software 0 10-20-2003 12:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration