in moneo.py [0:0]
def pssh(cmd, hosts_file, timeout=300, max_threads=16, user=None):
pssh_cmd = 'pssh'
os_type = shell_cmd('awk -F= \'/^NAME/{print $2}\' /etc/os-release', 45)
if 'Ubuntu' in os_type: # Ubuntu uses parallel-ssh while centos/AlmaLinux use pssh
pssh_cmd = 'parallel-ssh'
if user:
pssh_cmd = pssh_cmd + " --user={}".format(user)
pssh_cmd = pssh_cmd + \
" -x '-o StrictHostKeyChecking=no' -i -t 0 -p {} -h {} 'sudo {}' ".format(max_threads, hosts_file, cmd)
out = shell_cmd(pssh_cmd, timeout)
if 'FAILURE' in out:
raise Exception("Pssh command failed on one or more hosts with command {}, Output: {}".format(pssh_cmd, out))
return out