Hey
I am basically trying to write a pstree-like command except that it should follow processes across machines.
What I mean is that if I run this :
$ ssh $node sleep 1000
Then the command should display something like this :
ssh $node -- ($node) sleep 1000
And if I'm running :
$ ssh $node ssh $node sleep 1000
ssh $node---($node) ssh $node---($node) sleep 1000
And so on ...
My question is this : How can I map one ssh session on one machine to a spawned process on another machine ?
Local parent-child processes are not a problem, but how can I figure out which ssh command on one node that triggered another process on another node.
linux 2.6.18
only openSSH for "remote" stuff. Running OpenSSH_4.3p2 currently.
SSH access to all nodes of course (key based auth) so ps and netstat are available from all nodes.
Linux-only "hacks" are fine, does not need to be portable though that would be an added bonus of course.
The user will always be the same and my command/script is running as that user. That user is not root.
Does not have to be fast, only accurate.
The spontaneous solution would be to write a pstree
clone, that triggers on the command string "ssh
", figures out the source-port and then goes to the remote machine in question and figures out which one of sshd
's children that was spawned by this particular command.
But maybe there's a more clever way ? :P