Linux Bulk test Online host

Source: Internet
Author: User

A friend mentioned a demand, there are a number of applications of the host need to check whether the network is normal, of course, many methods, such as deployment and saltstack, directly check whether minions online, or you can use Python to get a simple script directly ping. Anyway, a lot of methods, this time I intend to use the shell to achieve a simple, of course, this is just a simple demo, you can add a lot of content, such as writing to log, can also be in-depth, get the host name, daily scheduled to send reports and so on. This is primarily a simple exercise for shell programming, a function call.

Test as follows

#!/bin/sh function demo_ping () {ping-c 1 172.16.1.${1} >/dev/null 2>&1 if [$? = = 0];then return 0 Else Return 1 fi}for i in ' seq 1 254 ';d o demo_ping $i if [$? = 0];then echo "Server of 172.16.1.${i} is on Lin E "Else echo" server of 172.16.1.${i} is offline "Fidone

Results

[Email protected]_slliang ~]# SH ping.sh

Server 172.16.1.1 is on line

Server 172.16.1.2 is offline

Server 172.16.1.3 is on line

Server 172.16.1.4 is on line

Server 172.16.1.5 is offline


This article is from "It small Angry green" blog, please make sure to keep this source http://slliang.blog.51cto.com/6959776/1897449

Linux Bulk test Online host

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.