#!/usr/bin/env python from xmlrpclib import * import getpass import subprocess import sys import socket import logging import logging.handlers def main(): numtry = 10 sysloger = logging.getLogger('sysloger') # logging levels = CRITICAL << ERROR << WARNING << INFO << DEBUG << NOTSET sysloger.setLevel(logging.WARNING) sysloger.addHandler(logging.handlers.SysLogHandler(address='/dev/log')) # #try connect with server for get remote ip and local ip # s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: s.connect(("server",4242)) except: sysloger.error('[lliurex-logger-client] : not connect with server on port 80') sys.exit(1) myip = s.getsockname()[0] serverip = s.getpeername()[0] s.close() sysloger.debug('[lliurex-logger-client] : acces to server with ip ' + serverip) server = ServerProxy ("http://"+serverip+":4242") auxtry = 0 while auxtry <= numtry : userlog = getpass.getuser() sysloger.info('[lliurex-logger-client] : Logout ...') sysloger.debug('[lliurex-logger-client] : user logout = '+userlog +' with ip = '+myip) executeresult = server.userlogout(getpass.getuser(),myip) if executeresult == "ok": sysloger.info('[lliurex-logout-client] : logout on '+ str(auxtry) +' try ') break sysloger.warning('[lliurex-logger-client] : Failed on logout on server with ip '+ serverip ) auxtry += 1 sysloger.error('[lliurex-logger-client] : attempts to overcome when user connect with server') if __name__ == '__main__': main()