Ping Host Online Statistics script

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.