Ping test detects LAN online hosts and offline hosts, and prints them out separately
and count their numbers.
#!/bin/bash
#
Declaring network addresses
Host_pre= "192.168.0"
Declaring the number of online hosts
Declare-i active_sum=0
Declaring the number of non-online hosts
Declare-i unactive_sum=0
The For loop performs a ping of the host test
For i in {1..254}; Do
If ping-c 1-w 1 "$host _pre. $i" &>/dev/null; Then
ECHO-E "33[32m [*] $host _c. $i is active. 33[0m "
Number of online hosts +1
active_sum= $active _sum+1
Else
Number of non-online hosts +1
Echo-e "33[31m [!] $host _pre. $i is unactive. 33[0m "
unactive_sum= $unactive _sum+1
Fi
Done
Print the number of online hosts
ECHO-E "33[32m Active Number: $active _sum 33[0m"
Number of non-online hosts printed
Echo-e "33[31m unactive number: $unactive _sum 33[0m"
Exit 0
This article is from the "Tea" blog, please be sure to keep this source http://runingday.blog.51cto.com/2154382/1670919
Ping Host Online Statistics script