LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-09-2010, 12:22 PM   #1
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,461
Blog Entries: 6

Rep: Reputation: 51
Help with a script?


I have a monitoring script like snippet below:
Code:
sudo sh customer@IP "perl ./monitoring-script bust_page | /home/john/mailhim.pl
Now The issue is I have 10 Web and 10 DB Servers.
All I used to open different putty and run this command 20-times on the monitoring Server.This script which I run on Local Monitoring server, run on remote server, fetches the data and bring it back to local monitoring server and execute with local script called /home/john/mailhim.pl
As of now I do need to provide couple of 20 times and thats cumbersome when connectivity goes down.I follow up like this:

Code:
Putty Session-1
sudo sh customer@10.14.236.91"perl ./monitoring-script bust_page | /home/john/mailhim.pl
Putty Session- II
sudo sh customer@10.14.236.92 "perl ./monitoring-script bust_page | /home/john/mailhim.pl
.
.
.
sudo sh customer@10.14.236.120 "perl ./monitoring-script bust_page | /home/john/mailhim.pl
Guys, Can you help me with writing a single script which can execute at a single shot.

Last edited by your_shadow03; 01-09-2010 at 12:23 PM.
 
Old 01-09-2010, 12:37 PM   #2
GooseYArd
Member
 
Registered: Jul 2009
Location: Reston, VA
Distribution: Slackware, Ubuntu, RHEL
Posts: 183

Rep: Reputation: 46
there are a slew of tools that let you run a command on sets of servers at once via ssh.

http://freshmeat.net/projects/pssh/

http://tentakel.biskalar.de/

if you don't need them to run strictly in parallel, why not just use a for loop:

for octet in 91 92 93; do ssh foo@10.14.236.$octet:"remote command"; done

If you need to run these from the machine with putty, I would install Cygwin and just script it via bash with openssh instead of putty.
 
Old 01-09-2010, 12:48 PM   #3
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,461
Blog Entries: 6

Original Poster
Rep: Reputation: 51
What about the password?Will it ask for single time for password?
 
Old 01-09-2010, 07:46 PM   #4
donnied
Member
 
Registered: Oct 2006
Distribution: Debian x64
Posts: 198

Rep: Reputation: 30
Do you have ssh keys set-up?

http://www.debian-administration.org/articles/152

I like this python app for simultaneously controlling multiple ssh connections.
http://www.noah.org/wiki/Pexpect
 
Old 01-09-2010, 07:54 PM   #5
GooseYArd
Member
 
Registered: Jul 2009
Location: Reston, VA
Distribution: Slackware, Ubuntu, RHEL
Posts: 183

Rep: Reputation: 46
shadow: once you've followed donnied's advice and set up key auth for ssh, then you want to load the key you create into an ssh-agent. Any ssh connections you make once the agent is running won't require you to type any passwords- the decrypted key sits in the agent, and ssh communicates with the agent at login time to get the key.
 
Old 01-10-2010, 05:23 AM   #6
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,461
Blog Entries: 6

Original Poster
Rep: Reputation: 51
I don't have root credentials with the production server.
Can I use my user credentials for the same?
I have root access with the local Monitoring Server but not for production servers.
Can it be possible without copying anything to be monitored servers.
 
Old 01-10-2010, 08:38 AM   #7
GooseYArd
Member
 
Registered: Jul 2009
Location: Reston, VA
Distribution: Slackware, Ubuntu, RHEL
Posts: 183

Rep: Reputation: 46
Yes, the only thing that needs to be adjusted on the servers you are connecting to is to create an .ssh/authorized_keys file in the home directory of the user you connect as. As long as sshd is configured to do key auth (it almost always is), no other changes are necessary.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to execute a ssh script on Linux server from Windows through a bat script? wanna13e Programming 13 10-23-2009 03:41 AM
Runs Multiple shell script inside a main script using crontab srimal Linux - Newbie 4 10-22-2009 07:19 PM
How to get full path to script file inside script itself? And in case of sym links? maggus Linux - Newbie 3 05-28-2009 09:40 AM
MySQL Updates With Null When Perl Script Run From Shell Script ThisGuyIKnow Programming 6 08-12-2008 10:56 AM
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 12:33 PM


All times are GMT -5. The time now is 04:23 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration