Skip to content

Instantly share code, notes, and snippets.

@sobuildit
Last active August 26, 2020 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sobuildit/465d08272ea3213b5351e5be11002804 to your computer and use it in GitHub Desktop.
Save sobuildit/465d08272ea3213b5351e5be11002804 to your computer and use it in GitHub Desktop.
# one-time information grabs
cmd = "dpkg -l | awk '/openmediavault /{ print $3;} '"
omvpkg = subprocess.check_output(cmd, shell=True).decode("utf-8")
print("OMV Version: ", omvpkg)
# date / time
cmd = "date +\"%H:%M %d/%m/%Y\""
date = subprocess.check_output(cmd, shell=True).decode("utf-8")
print("Date: ", date)
# uptime
cmd = "uptime -p"
uptime = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "hostname"
hostname = subprocess.check_output(cmd, shell=True).decode("utf-8")
net_if_addrs = psutil.net_if_addrs()['eth0'][0]
IP = net_if_addrs.address
print("IP: ", IP)
netmask = net_if_addrs.netmask
print("Netmask: ", netmask)
cmd = "/sbin/route -n | awk '/UG/{ print $2;} '"
gateway = subprocess.check_output(cmd, shell=True).decode("utf-8")
print("Gateway: ", gateway)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment