I wanted to write a script for expanding my Python knowledge. I ussually create small scripts to accommodate my “problems” or wishes.
If you want use it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import socket FQDN = [] ACC = [] ACC_FILE = open('/var/log/nginx/access.log') for LINE in ACC_FILE: ACC.append(LINE.split(' ')[0]) ACC.sort() ACC = set(ACC) for LINE in ACC: ADDR = socket.getfqdn(LINE) FQDN.append(ADDR) FQDN.sort() for SERVER in FQDN: print(SERVER) |