autologout pour les connections du bde au bout de 5 minutes
darcs-hash:20050803220512-4ec08-fd850b7b776ac5c34817a4306b6b718d582f2893.gz
This commit is contained in:
parent
7e8e989114
commit
7a02db5395
1 changed files with 32 additions and 0 deletions
32
autologout.py
Executable file
32
autologout.py
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
|
|
||||||
|
import sre, commands
|
||||||
|
|
||||||
|
# pour chaque ligne du w
|
||||||
|
for w in commands.getoutput("w -h").split('\n') :
|
||||||
|
|
||||||
|
# on splite
|
||||||
|
w = sre.split(' *', w)
|
||||||
|
|
||||||
|
# on verifie que c'est une connection du bde
|
||||||
|
if w[2] != 'bde.crans.org' :
|
||||||
|
continue
|
||||||
|
|
||||||
|
# on verifie qu'on a depase le timeout
|
||||||
|
if sre.match('^\d*\.\d*s$',w[4]) or sre.match('^[0-4]:\d*$',w[4]) :
|
||||||
|
continue
|
||||||
|
|
||||||
|
# on reccuperre les processus s le tty
|
||||||
|
ps = sre.split(' *', commands.getoutput('ps auwwx | grep "%s" | head -n 1' % w[1] ) )
|
||||||
|
|
||||||
|
# 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] )
|
||||||
|
print ps
|
Loading…
Add table
Add a link
Reference in a new issue