#!/bin/bash
#writen by Jerry
for i in `seq 1 255`;
do
{
ping 192.168.51.$i -c 2 >> /dev/null 2>&1 # ping ping
tai=$(echo $?)
if [ $tai == 0 ];
then
echo -e "\033[1;32m 192.168.51.$i is online \033[0m" # online
else
echo -e "\033[1;35m 192.168.51.$i is offline \033[0m" #
fi
}&
done
wait
echo "all Finished!"
python
#!/usr/bin/python
#Written By jerry
#date 2018-03-20
import subprocess
import threading
def ping(host):
result = subprocess.call(
'ping -c2 %s &> /dev/null' % host,
shell=True
)
if result == 0:
print "%s:up" % host
else:
print "%s:down" % host
if __name__ == '__main__':
ips = ['192.168.12.%s' % i for i in range(1, 255)]
for ip in ips:
t = threading.Thread(target=ping, args=(ip,))
t.start()