Skip to content

Instantly share code, notes, and snippets.

@alq666
Created August 17, 2012 18:04
Show Gist options
  • Save alq666/3381188 to your computer and use it in GitHub Desktop.
Save alq666/3381188 to your computer and use it in GitHub Desktop.
Determine how hosts are set
# on one triplet, e.g. s11.ams, s11.aus, s11.chi
# python hostname.py
import socket
import os
import pprint
print("socket, hostname")
print(socket.gethostname(), os.popen("hostname").read().strip(), [r for r in open("/etc/dd-agent/datadog.conf").readlines() if r.find("hostname:") > -1])
pprint.pprint(open("/etc/hosts").readlines())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment