Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from datetime import datetime
- import paramiko
- a1 = 'version3'
- a2 = 'version5'
- client = paramiko.SSHClient()
- client.set_missing_host_key_policy(paramiko.AutoAddPolicy)
- file = open('/etc/openvpn/client.addr', 'r')
- for line in file:
- timestamps = str(datetime.now())
- #print('Timestamp:', timestamps)
- info = {}
- info['ip'] = line.split(',')[1]
- info['mac'] = line.split(',')[0]
- def connector():
- ip_log = 'Connecting to IP: ' + info['ip']
- print(ip_log)
- client.connect(info['ip'], username='', port=22, password='', timeout=12)
- stdin1, stdout, stderr = client.exec_command('cat /proc/cpuinfo')
- data = stdout.read() + stderr.read()
- try:
- connector()
- if a1 in str(data):
- filename = open('log.txt', 'w')
- filename.write(info['mac'] + ' - version 3')
- if a2 in str(data):
- filename = open('log.txt', 'w')
- filename.write(info['mac'] + ' - version 5')
- except Exception as e:
- error_log = str(e)
- print('error_log')
- file.close()
Add Comment
Please, Sign In to add comment