{"id":176,"date":"2018-09-03T20:53:27","date_gmt":"2018-09-03T19:53:27","guid":{"rendered":"http:\/\/www.project34.net\/?p=176"},"modified":"2023-10-26T21:21:37","modified_gmt":"2023-10-26T20:21:37","slug":"retrieve-fqdn-from-ip-numbers-in-nginx-access-log","status":"publish","type":"post","link":"https:\/\/www.project34.net\/index.php\/2018\/09\/03\/retrieve-fqdn-from-ip-numbers-in-nginx-access-log\/","title":{"rendered":"Retrieve FQDN from IP numbers in Nginx access log"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I wanted to write a script for&nbsp;expanding my Python knowledge.&nbsp;I ussually create small scripts to accommodate my &#8220;problems&#8221; or wishes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want use it:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">import socket\n\nFQDN = []\nACC = []\n\nACC_FILE = open('\/var\/log\/nginx\/access.log')\nfor LINE in ACC_FILE:\n        ACC.append(LINE.split(' ')[0])\n\nACC.sort()\nACC = set(ACC)\nfor LINE in ACC:\n        ADDR = socket.getfqdn(LINE)\n        FQDN.append(ADDR)\n\nFQDN.sort()\nfor SERVER in FQDN:\n        print(SERVER)\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I wanted to write a script for&nbsp;expanding my Python knowledge.&nbsp;I ussually create small scripts to accommodate my &#8220;problems&#8221; or wishes. If you want use it:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"class_list":["post-176","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/www.project34.net\/index.php\/wp-json\/wp\/v2\/posts\/176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.project34.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.project34.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.project34.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.project34.net\/index.php\/wp-json\/wp\/v2\/comments?post=176"}],"version-history":[{"count":2,"href":"https:\/\/www.project34.net\/index.php\/wp-json\/wp\/v2\/posts\/176\/revisions"}],"predecessor-version":[{"id":337,"href":"https:\/\/www.project34.net\/index.php\/wp-json\/wp\/v2\/posts\/176\/revisions\/337"}],"wp:attachment":[{"href":"https:\/\/www.project34.net\/index.php\/wp-json\/wp\/v2\/media?parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.project34.net\/index.php\/wp-json\/wp\/v2\/categories?post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.project34.net\/index.php\/wp-json\/wp\/v2\/tags?post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}