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.
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.
#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.
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}'
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.
Distribution: CentOS, RHEL, Fedora, Debian, Ubuntu, LinuxMint, Kali Linux, Raspbian
Posts: 166
Rep:
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.
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)
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.