diff --git a/cranslib/utils/autologout.py b/cranslib/utils/autologout.py deleted file mode 100755 index 20cc65dd..00000000 --- a/cranslib/utils/autologout.py +++ /dev/null @@ -1,47 +0,0 @@ -#! /usr/bin/env python - -import re -import commands -import sys -sys.path.append('/usr/scripts/') -import cranslib.utils.logs -import logging -LOGGER = logging.getLogger("crans.autologout") -LOGGER.addHandler(cranslib.utils.logs.CransFileHandler("autologout")) -LOGGER.setLevel(logging.WARNING) - -def run_autologout(): - LOGGER.debug("Starting autologout") - # pour chaque ligne du w - for w in commands.getoutput("w -h").split('\n') : - if not w : continue - # on splite - w = w.split() - - # on verifie que c'est une connection du bde - hosts = ['cableur.crans.org','cableuse.crans.org','venus.crans.org','kfet.crans.org'] - if w[2] not in [ h[0:16] for h in hosts ] : - continue - - # on verifie qu'on a depase le timeout - if re.match('^\d*\.\d*s$', w[4]) or re.match('^[0-4]:\d*m$', w[4]) : - continue - - # on reccuperre les processus s le tty - ps = commands.getoutput('ps auwwx | grep "%s" | head -n 1' % w[1] ).split() - - # on verrifie que c'est le bon user - if ps[0] != w[0] : - continue - - # on verifie qu'on a pas de tty - if ps[6] != '?' : - continue - - # on tue le process - commands.getoutput('kill %s' % ps[1] ) - LOGGER.info("%s a ete deconnecte" % ps[0]) - #print ps - -if __name__ == "__main__": - run_autologout()