Created
October 18, 2023 15:26
-
-
Save sanesai/77bfc275fda1259386466e9c067854d7 to your computer and use it in GitHub Desktop.
Test the connectivity
This file contains hidden or 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
import socket | |
def check_conn(): | |
conn_data = [ | |
('xyz.abc.int', '10.20.200.10', 443), | |
('abc.xyz.int', '10.20.200.12', 8080) | |
] | |
for name, host, port in conn_data: | |
s = socket.socket() | |
try: | |
s.settimeout(2) | |
s.connect((host, port)) | |
except Exception as e: | |
print(f"ERROR → {name} {host}:{port} → {e}") | |
s.close() | |
else: | |
print(f"OK → {name} {host}:{port}") | |
s.close() | |
if __name__ == '__main__': | |
check_conn() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment