Hi,

I have the below code which runs on Server A, connects to a set of Servers, loops through the set of servers and gets IP addresses in range of 10.42.8 from it, then goes into each server in the IP and runs TSSI command.

function findworkers ()
    {
        knsw=$(kubectl get nodes -A -o name | grep worker)

        for knodew in $knsw;
        do
            podres=$( echo $knodew | cut -c 6- )
            echo "IP Addresses Found in $podres"
            ssh -q $podres arp -n | grep 10.42.8 | grep ether | awk '{print $1}'
            for rruaddr in $(ssh -q $podres arp -n | grep 10.42.8 | grep ether | awk '{print $1}')
                do
                ssh -q $podres ssh -q $rruaddr tssi
      done
    done
}

Which gives the below output.

IP Addresses Found in bai-ran-cluster-worker1
10.42.8.11
10.42.8.3
sh: tssi: not found
sh: tssi: not found

IP Addresses Found in bai-ran-cluster-worker2
10.42.8.30
10.42.8.24
TX 1 TSSI: 23.3428 dBm
TX 2 TSSI: -inf dBm
TX 3 TSSI: 22.8387 dBm
TX 4 TSSI: -inf dBm
TX 1 TSSI: -8.8506 dBm
TX 2 TSSI: -inf dBm
TX 3 TSSI: -10.0684 dBm
TX 4 TSSI: -inf dBm

As seen above what happens is it returns the result of TSSI command all together for all the IP addresses found.

I’m unable to figure out how to run TSSI for each IP so the expected output is

IP Addresses Found in bai-ran-cluster-worker2
10.42.8.30
TX 1 TSSI: 23.3428 dBm
TX 2 TSSI: -inf dBm
TX 3 TSSI: 22.8387 dBm
TX 4 TSSI: -inf dBm

10.42.8.24
TX 1 TSSI: -8.8506 dBm
TX 2 TSSI: -inf dBm
TX 3 TSSI: -10.0684 dBm
TX 4 TSSI: -inf dBm

Connection is as follows :

  • Server A (Single Server) - Can connect to Server B Set only
  • Server B Set (6 servers ) - Can connect to Server A and Server C Set
  • Server C Set (5-6 servers connected to each Server in Server B set) - Can connect to Server C Set, and cannot connect to Server A.

So the command ssh -q $podres ssh -q $rruaddr is for Server A to access each server in Server B Set and then access each server in Server C set and get the results.

Any thoughts on how to write this loop with the expected output ?

1 Spice up

Try using the full path name to the “tssi” command.

Or possibly replace


ssh -q $rruaddr tssi


with

ssh -q $rruaddr $(which tssi)

1 Spice up

couldn’t this be problematic if there is more than one tssi command? Like perhaps, one in /bin/tssi and one in /usr/bin/tssi? Or, archive copies in the system?

1 Spice up

It shouldn’t be problematic, but it might not work at all.

“which” will only return a command that is found in the current environment and I think it works via the setting of the PATH variable.

The " -a " option to “which” would return all “tssi” commands found in the environment. So if tryllz’s script isn’t finding it, the output of “which” (if any) is probably not going to be helpful.

“locate” or “find” is probably the better path for the issue with the 10.42.8.11 and .3 hosts.

It might even be that “tssi” is not installed on the host(s) with the problem.

1 Spice up