duncs / clusterssh

Cluster SSH - Cluster Admin Via SSH
https://github.com/duncs/clusterssh/wiki
896 stars 79 forks source link

using cssh to generate multiple terms, each with a diff initial launch cmd #104

Open deehill opened 6 years ago

deehill commented 6 years ago

Trying to figure out how/if cssh can be used to generate multiple terms with different launch actions

/etc/clusters testcluster7 -a '-t screen -r crawl1Session' crawl_user@159.203.188.67

cssh testcluster7 Doesn't work as cssh doesn't appear to be able to handle options

cssh -a '-t screen -r crawl1Session' crawl_user@159.203.188.67 This works, generates a term running the "screen -r crawl1Session cmd..

I could run separate cssh cmds from the local cmdline but the resulting cssh terms don't "tile" as they're unique processes.

Thoughts/Comments??

zabbix112 commented 6 years ago

in your configure file you can set up many different commands to open certain server windows. I use mine for patching. I would set it up when I type, cssh prod1 will bring up just the first set of servers in a cluster. I would also set it up with cssh dev, cssh test, cssh stage, or cssh prod. Its all in the configure file. it will error until you have it setup right.

deehill commented 6 years ago

Hi zabbix112

As far as I can tell the /etc/clusters config file allows you to set up the different user@hosts and you can even group them in as many different ways as you choose.

However, I have yet to be able to set up a process where I can pass an action to a user@host within the /etc/clusters file.

from the cmd line this works cssh --title '252' -a "-t screen -r crawl3Session" crawl_user@159.203.188.67

If you can show me a /etc/clusters file that allows you to have something like group1 -a "vi /tmp/cat " user1@host1 -a "vi /tmp/dog" user1@host1

and run it from the cmdline as cssh group1

so you then see two terms get displayed I'd lie to see it.

I can't figure out how to get an action (or separate actions) to work in the /etc/clusters file

zabbix112 commented 6 years ago

Deehill, Now here is the part where I dont know if I use it different from everyone else but I never touch the /etc/clusters config file I leave it alone.

So when you installed it did you install it as root and or under the rood dir?

if so do ls -la and you will see something .clusterssh file... cd to .clusterssh and then do a ls and it will show you a config file. Here is the bread and butter of the file. Here is where I do all my commands.

Oh also you need to download ximg "its what I use if you have something different" now I say ximg is cause I have to work off a corporate windows laptop and then this allows me to create multiple windows of each server I am working on.

let me know if any of this helps.

deehill commented 6 years ago

hey...

Installed as root .. yum install ....

in the root dir ~/.csshrc which is consistent with what I've seen from other people

Are you telling me you can do something like (even from the cmdline)

cssh -a "vi /tmp/cat" user1@1.2.3.4 -a "vi /tmp/dog" user2@1.2.3.4

and you then have 2 windows displayed in the same/single cssh process with one editing the tm/cat file and the other editing the tmp/dog file...

If I could get this to work.. that would be great as it would show how to initiate multiple terms with different actions passed in

deehill commented 6 years ago

now...

cssh -a "vi /home/crawl_user/cssh1.php" crawl_user@159.203.188.67 crawl_user@159.203.188.67

works,, as it kicks off two windows each of which edits the same file...

but the above isn't the same as this..

cssh -a "vi /home/crawl_user/cssh1.php" crawl_user@159.203.188.67 -a "vi /home/crawl_user/cssh2222.php" crawl_user@159.203.188.67

which edits a different file in each window. (and which doesn't work!) but this is what I need

duncs commented 6 years ago

What version of ClusterSSH are you using? The $HOME/.csshrc file is consistent with version 3, $HOME/.clusterssh/ directory is version 4

TomGudman commented 5 years ago

I think the feature @deehill is after is the equivalent of --hosts in csshX (the MacOSX version) which I need as well.

Ref: https://github.com/brockgr/csshx/blob/533b2626b5812cf9e1b7ff69589d6c98f4375d19/csshX#L2893-L2897