Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BitBar plugin for showing host availability
#!/usr/local/bin/python3
import os
hosts = [
'google.com',
'microsoft.com'
]
header = []
menu = []
for host in hosts:
response = os.system("ping -c 1 -t 1 " + host + " > /dev/null 2>&1")
if response == 0:
menu.append('💚 ' + host)
header.append('💚')
else:
menu.append('💔 ' + host)
header.append('💔')
print(''.join(header))
print('---')
for entry in menu:
print(entry)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.