Created
January 30, 2019 08:12
-
-
Save dettmering/49ae72611d0f63e87ceb86f1521ee88d to your computer and use it in GitHub Desktop.
BitBar plugin for showing host availability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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