Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[shell] write ping packets and arp monitoring and send text messages through shell

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Host IP:10.100.8.79

Host Gateway: 10.100.8.1

Host IP:10.100.8.78 of the other party

Ping each other's IP from the local machine, and use the arp tool to parse the local gateway

Click (here) to collapse or open

#! / bin/bashNOW= "`date +% Y%m%d-%H:%M:% S`" PHONES=15134567893IP=10.100.8.78GATEWAY=10.100.30.1#ping failed SMS content content1= "host is failed" # arp host gateway failed SMS content content2= "GW is failed" # ping log path LogFile= "/ tmp/ ping`date" +% Y%m%d-%H-%M-%S "`.log" # ping the other host 100packets and input the result Log out to ping-c100 $IP & > $LogFile# with if Else statement to determine whether ping is proficient, if ["$?" = = "0"] Thenecho "$NOW $IP is ok" > > $LogFileelseecho "$NOW $IP is down" > > $LogFile & / usr/bin/curl-d "phones=$PHONES&content= $NOW $IP $content"content-type: application/x-www-form-urlencoded;charset=UTF-8"http:// SMS Gateway: 8080" fi# Delimiter echo "=" > > $LogFile#arp own gateway arp $GATEWAY & > > $LogFilenum=$ (cat $LogFile | grep eth0 | wc-l) if ["$num" = "0"] Thenecho "$NOW $GATEWAY is down" > > $LogFile & / usr/bin/curl-d "phones=$PHONES&content= $NOW $GATEWAY $content1"content-type: application/x-www-form-urlencoded;charset=UTF-8"http:// SMS Gateway: 8080" fi

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report