This repository was archived by the owner on Dec 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathping-test-using-csv.py
More file actions
44 lines (37 loc) · 1.7 KB
/
ping-test-using-csv.py
File metadata and controls
44 lines (37 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
/* Developer: SahanaJayaram, email: sjayaramu@eplus.com */
"""
import csv
import os
import platform
plat = platform.system()
#server = "localhost" #example for single host
#servers = {"10.1.185.71", "10.1.185.66", "10.1.185.89"} # example of Host/IPaddress using Dictionary
# Import the list of hosts/servers/ipaddress from CSV file
with open('ipaddress-list.csv', 'r') as servers_list:
servers = csv.DictReader(servers_list)
for vm in servers_list:
print "---- Trying to Ping a Server with IPAddress ----", vm
# Check for Windows and Linux Platforms
if plat == "Windows":
response = os.system("ping -n 1 " + vm)
pass
elif plat == "Linux":
response = os.system("ping -c 1 -W 3 " + vm)
pass
# Check for response status code
if response == 0:
print "********************************************************************"
print(vm, 'is UP and reachable!')
print "********************************************************************"
print "\n"
elif response == 2 or 256 or 512:
print "********************************************************************"
print(vm, 'is DOWN and No response from Server!')
print "********************************************************************"
print "\n"
else:
print "*********************************************************************"
print(vm, 'is DOWN and Host Unreachable!')
print "*********************************************************************"
print "\n"