[bornes.py] corrections
* échappement correct des commandes * possibilité d'utiliser des areas darcs-hash:20091018233758-bd074-8601fa332e20a74b01df218afa6283d50673c4d3.gz
This commit is contained in:
parent
d98b44e915
commit
af51c9177f
1 changed files with 13 additions and 7 deletions
|
@ -38,7 +38,7 @@ def bornes():
|
|||
|
||||
def ssh_exec(host, cmd):
|
||||
"""Execute une commande en ssh sur une machine et renvoie le résultat"""
|
||||
(stdin, stdout, stderr) = os.popen3("ssh -T -x -o BatchMode=yes -o ConnectTimeout=5 -o StrictHostKeyChecking=no %(host)s exec %(cmd)s" % locals())
|
||||
(stdin, stdout, stderr) = os.popen3("ssh -T -x -o BatchMode=yes -o ConnectTimeout=5 -o StrictHostKeyChecking=no %(host)s %(cmd)s" % locals())
|
||||
stdin.close()
|
||||
stderr.close()
|
||||
return stdout
|
||||
|
@ -110,7 +110,7 @@ def bornes_uptime():
|
|||
output.close()
|
||||
return results
|
||||
|
||||
def munin(config, cmd=None, process=(lambda x: x), results=None, buckets=None):
|
||||
def munin(config, cmd=None, process=(lambda x: x), results=None, buckets=None, stack=None):
|
||||
"""plugin munin"""
|
||||
|
||||
if 'autoconf' in sys.argv:
|
||||
|
@ -122,11 +122,17 @@ def munin(config, cmd=None, process=(lambda x: x), results=None, buckets=None):
|
|||
if 'config' in sys.argv:
|
||||
print config
|
||||
if buckets:
|
||||
for val, lbl in buckets.iteritems():
|
||||
for i, (val, lbl) in enumerate(buckets.items()):
|
||||
print "%s.label %s" % (lbl, val)
|
||||
if stack:
|
||||
if i == 0: print "%s.draw %s" % (lbl, stack)
|
||||
else: print "%s.draw STACK" % lbl
|
||||
else:
|
||||
for borne in names:
|
||||
for i, borne in enumerate(names):
|
||||
print "%s.label %s" % (borne, borne)
|
||||
if stack:
|
||||
if i == 0: print "%s.draw %s" % (borne, stack)
|
||||
else: print "%s.draw STACK" % borne
|
||||
sys.exit(0)
|
||||
|
||||
if not results:
|
||||
|
@ -162,7 +168,7 @@ def main():
|
|||
names = bornes()
|
||||
outputs = {}
|
||||
for name in names:
|
||||
outputs[name] = ssh_exec(name+".wifi", options.cmd)
|
||||
outputs[name] = ssh_exec(name+".wifi", commands.mkarg(options.cmd))
|
||||
|
||||
# On attend que tous les fils qu'on a lancé terminent, avec une petite
|
||||
# animation si la sortie est un terminal:
|
||||
|
@ -215,12 +221,12 @@ graph_vlabel uptime in days"""
|
|||
config = """graph_title Clients connectés
|
||||
graph_args --base 1000 -l 0
|
||||
graph_vlabel Clients connectés"""
|
||||
munin(config, results=bornes_clients())
|
||||
munin(config, results=bornes_clients(), stack="AREA")
|
||||
elif plugin == 'canal':
|
||||
config = """graph_title Canaux utilisés
|
||||
graph_args --base 1000 -l 0"""
|
||||
buckets = {'1': 'un', '2': 'deux', '3': 'trois', '4': 'quatre',
|
||||
'5': 'cinq', '6': 'siz', '7': 'sept', '8': 'huit',
|
||||
'5': 'cinq', '6': 'six', '7': 'sept', '8': 'huit',
|
||||
'9': 'neuf', '10': 'dix', '11': 'onze', '12': 'douze',
|
||||
'13': 'treize', '14': 'quatorze', '0': 'echec' }
|
||||
munin(config, results=bornes_canal(), buckets= buckets)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue