LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 06-16-2018, 11:26 PM   #1
aditya88
LQ Newbie
 
Registered: Jun 2018
Posts: 3

Rep: Reputation: Disabled
script


Hi, I have to collect some data from multiple servers by login individually on daily basis.I want a script through which I can fetch these data without putting the command in each node regularly.I have a common server from which I can access all the servers from where these data is required.Below is the command which I use.
Command
dsClassInfo | grep -i subscriber
Output
78 subscriber -1 3716242
79 subscriberSubdata -1 7431868
80 subscriberProfile -1 0
109 hlrSubscriber -1 0
122 virtualSubscriber -1 0

I want the count 78 subscriber
I have modified the command as below
Command
dsClassInfo | grep -i '78 subscriber ' | awk -F ' ' '{print $4}'
Output
3716242

Please help.Also I want to get count of each servers in email.
 
Old 06-17-2018, 05:48 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,512

Rep: Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657
#1 is this homework?

#2 I can think of a dozen possible approaches at first glance. I am a bit confused about your meaning when you say
Quote:
I can fetch these data without putting the command in each node regularly.
Do you mean without running your script regularly, not having a script on the rmeote servers, not running the command on the remote servers...
Please clarify.
 
Old 06-17-2018, 12:16 PM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,692

Rep: Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274
I would say we need more info, what you wrote is incomplete. Please give use more details, explain what is your input, what is the expected output and what is your problem (with your script).
Right now I can only say:
Code:
instead of
grep -i '78 subscriber ' | awk -F ' ' '{print $4}' 
you can write
awk -F ' ' '/78 subscriber / {print $4}'
 
Old 06-17-2018, 09:51 PM   #4
aditya88
LQ Newbie
 
Registered: Jun 2018
Posts: 3

Original Poster
Rep: Reputation: Disabled
script

Hi,actually I want to make a script which will automatically run in particular server in a particular time from where several multiple remote servers are accessible and the required data will directly go to the mail or the script can be run manually to get the data from those multiple remote servers.Now I run the command in each remote servers and accumulate the data to make the report.I want to reduce this daily job by making a script.

dsClassInfo | awk -F ' ' '/78 subscriber / {print $4}' command is helpful.My point is, instead of taking the output of these command by login each servers one by one, I want to run a script either automatically or manually by which I will get the output of all remote servers from a single server.

Please help me if it is possible and let me know if anything else is required.
 
Old 06-17-2018, 10:17 PM   #5
kaushalpatel1982
Member
 
Registered: Aug 2007
Location: INDIA
Distribution: CentOS, RHEL, Fedora, Debian, Ubuntu, LinuxMint, Kali Linux, Raspbian
Posts: 166

Rep: Reputation: 10
I assume that you are using SSH to take access to your remote servers.

You can run your command from the single server like :

Quote:
ssh user@ServerIPorDomainName -c "Your Command"
That will give you output on the console where you run the command but it will prompt the password of the user. You can configure passwordless ssh to automate your script.

Last edited by kaushalpatel1982; 06-17-2018 at 10:18 PM.
 
Old 06-18-2018, 06:17 AM   #6
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,512

Rep: Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657
If you ARE using ssh and you DO set up key based authentication (it is easy enough, and I recommend it), then I might suggest using on of the tools for automating multiple host sessions such as MPSSH. Once you have that output as you like it, it is just a matter of collecting and reformatting the output and feeding it to a mail client. (mail, mailx, mutt, etc. - any of them that can be used on the command line for a finger-free send should work)
 
Old 06-18-2018, 07:33 AM   #7
aditya88
LQ Newbie
 
Registered: Jun 2018
Posts: 3

Original Poster
Rep: Reputation: Disabled
yes i am using ssh for login.please help with the MPSSH tool and how i could get the output.
 
Old 06-19-2018, 05:37 AM   #8
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,512

Rep: Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657
Quote:
Originally Posted by aditya88 View Post
yes i am using ssh for login.please help with the MPSSH tool and how i could get the output.
What help do you need?
What Linux distro are you using, and what version?
Have you looked for ssh tools that automate running commands on multiple hosts (mpssh or others, there are several) in your repo?
 
  


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
Shell script/Perl Script to remove the string until it finds special character '_' pooppp Programming 10 07-17-2012 09:36 AM
Shell script/Perl Script to remove the string until it finds special character '_' pooppp Programming 1 07-13-2012 01:03 AM
Shell script, Perl script, command or utility to convert Binary to text Perseus Programming 26 07-12-2012 06:00 AM
[SOLVED] bash and xterm: how make apps started by and for a script persist when script terminates porphyry5 Linux - General 4 06-15-2011 01:27 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 08:40 AM

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

All times are GMT -5. The time now is 02:32 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