Hi,
Newbie ( to the forum ) here....
Just started a new job.... Used to work for Sun Microsystems as a hardware engineer, now am trying to move more into Sys Admin/ Software ...
Never really needed scripting before, could always do what I wanted to do manually.
The new job is going to need better scripting skills than I currently have....
Anyway, been asked if I can come up with a script that checks what network ports are available on a box and which version of the OS is running .... So initial thoughts are
So that's my basic info collected ...... But.... There are 130 machines to login, run the script, collect the output, logout
Obviously this would all be better scripted .... But I've no idea how... Any ideas?
Yeah , I believe the machines are all Solaris boxes, some pretty old though maybe back to 2.5.1 mixed bag, Solaris 2.5.1, 8, 9 & 10
Cheers
Martin
---------- Post updated at 05:14 PM ---------- Previous update was at 05:12 PM ----------
I can't see how you could log on to the different boxes..... Wouldn't you need individual passwords etc.... In which case you may as well log on manually.... :0/
Pick a box or a desktop as home. Create ssh keys on the home box. Push the public ssh keys to 127 other boxes (this is the first and last bit of dog work)
How to: ssh-keygen: password-less SSH login
(Note: your remote and local home directories all have to be at least 755 permissions, your ~/.ssh directory 600)
At this point you now a need a file with the names of all of your servers.
Then on the home box (you have some script you want to run everywhere) you do this:
while read sname
do
scp -p -q /local/path/to/script ${sname}:/remote/path/to/script # park the script over there
ssh ${sname} '/remote/path/to/script' # run the script
done < list_of_servers.txt > my_report_from_127_servers.dat
Don't for get to chmod 755 your local script file BEFORE you run the above.
Create different versions of list_of_servers.txt to handle special runs that hit only some boxes. You can run any script anywhere (assuming you have privilege everywhere).
With that many hosts, installing ssh public key is the way to go. Pick a good host to use for your management host. Don't use your desktop. It may take sometime to do for the first time but after that, it will help you manage all the hosts much easier.
Looking at your script, "ifconfig -a" won't give you all the NIC ports on your server. It ONLY give you all the plumb (active) NIC's. To see all the NIC ports, including the inactive ones, you need to run "dladm show-dev".
instead of scp and ssh (-x?). You don't need to chmod your script and actually it will be downloaded each time from one location and not actually saved on the target server
Cheers polkan
That would need to be run from each machine wouldn't it? I suppose you could Cron it....
Looks nice and easy but I'm not sure how it'd work.
I run it from one (hub) machine that has ssh key authorized on the slave machines listed in the file "list.txt". Presuming "scripthostedat" is URL of the place the script I need to run hosted using http (for example, it can be anything wget can understand) exact command I need to run on the hub machine is:
for server in `cat list.txt`; do ssh $server -x "wget -O - scripthostedat | sh"; done
We was talking about about hundreds of servers - such a construction works good on hundreds items list on most *nixes out of box. But it can be easier to understand for not so professional