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.
hello all,
i need to take the output "df -h" from 200 servers having same password. any idea on how i can get it as i dont understand how to write the correct script.
First you ought to fix the arrangement there so that the passwords are not the same. Then take a look at using client SSH certificates (not just keys) for authentication. Then after that, look at basic shell scripting and loops using while or for. How are you going to identify the servers? Do you have a list of names or IP addresses? What have you tried so far?
hello all,
i need to take the output "df -h" from 200 servers having same password. any idea on how i can get it as i dont understand how to write the correct script.
Lots of ideas, and there are lots of ways to do this. So post what you've written/done/tried and tell us where you're stuck, and we'll be happy to help.
You would use expect. Expect is a simple scripting language that can "login" and execute things like you are typing. The syntax is pretty vague, but it is easy to debug.
Yes, if you used public key authentication or took the time to install any time of management/auditing tool this would be easy.
I set up the config for mpssh to do such a thing. In my case every one of about 900 servers had different passwords, but I had pushed ssh keys out to them over several months time as part of an access and upgrade cycle.
There are better management tools available, and for the space information one might even leverage SNMP if it is available and configured on all nodes.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,818
Rep:
Quote:
Originally Posted by poonam2108
hello all,
i need to take the output "df -h" from 200 servers having same password. any idea on how i can get it as i dont understand how to write the correct script.
Start with the basics:
How would you get the output of that command from a single server?
How would you go through a list of servers in a script? (Say if their hostnames or IP addresses were stored in a file.)
Then, once you can do those two things, how might you combine those two activities into a script to go through the list of servers and issue 'df -h' on each?
Small steps.
(Personally, I'd say that this is a job for Ansible. An inventory file with information for the 200 servers and a playbook that has a primary task that issues "df -h" should do the trick but... that's probably not within the scope of the assignment.)
I would use a script for a small number of servers, perhaps a dozen. A utility like MPSSH for larger numbers, perhaps up to 50. For any arbitrary larger number of hosts something of a moniter application like NAGIOS or ZABBIX, or a manager like Ansible, will serve better and scale properly. They also give you additional reports, monitor reports over time to detect trends, and cover network connectivity and connection nodes if you set that up properly.
If your number of servers is large and potentially growing, there is no reason to use a quick-n-dirty solution that you will have to reinvent forever.
@wpeckham brings up a very(!) important point: Unless this is just a 'homework problem,' the first question that you should ask yourself is ... "hasn't 'this' been done before?" Undoubtedly it has, no matter what "'this'" is.
Quote:
Actum Ne Agas: "Do Not Do A Thing Already Done."
In this grand "open-source world," a tremendous number of very-generous people have "already done" an amazing number of things ... sometimes having spent more than a year developing it ... and then they shared(!) it.
Of course it is "instinctive" to jump directly between "this is what I have to do" and "this is the first thing that comes to my mind as a way for me(!) to solve it." But, in the present day, you really need to break yourself of that "instinct."
Last edited by sundialsvcs; 10-11-2022 at 03:36 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.