#!/usr/bin/env python import py def show_info(hostname): if '.' not in hostname: hostname += '.merlinux.de' gw = py.execnet.SshGateway(hostname) channel = gw.remote_exec(""" import re, py try: out = py.process.cmdexec("sudo xm list") except py.process.cmdexec.Error, e: # probably no XEN system out = py.process.cmdexec("sudo vserver-stat") channel.send(out) out = py.process.cmdexec("sudo fdisk -l /dev/sda /dev/sdb /dev/hda /dev/hdb") lines = [] for line in out.split('\\n'): if line.find("Disk") != -1: lines.append(line) channel.send(lines) """) out = channel.receive() print "***", hostname, hetzner[hostname], "***" print out for line in channel.receive(): print line print hetzner = { 'h4.merlinux.de': '#11805 85.10.208.235', 'h2.merlinux.de': '#8733 88.198.18.230', 'h1.merlinux.de': '#8010 85.10.203.229', 'h5.merlinux.de': '#16663 85.10.203.226', } if __name__ == '__main__': hostnames = py.std.sys.argv[1:] if not hostnames: hostnames = ["h%d" % x for x in (1,2,4,5)] for hostname in hostnames: show_info(hostname)