惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
Spread Privacy
Spread Privacy
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
腾讯CDC
P
Privacy International News Feed
Webroot Blog
Webroot Blog
J
Java Code Geeks
爱范儿
爱范儿
A
About on SuperTechFans
S
Secure Thoughts
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
DataBreaches.Net
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Security Latest
Security Latest
Forbes - Security
Forbes - Security
小众软件
小众软件
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threatpost
量子位
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
The Exploit Database - CXSecurity.com
Help Net Security
Help Net Security
V
Visual Studio Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 聂微东
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs

Rat's Blog - ping

SmartPing:一个服务器Ping值监测工具,带报警功能 - Rat's Blog uPing:一个简单的服务器Ping值监测小工具 - Rat's Blog mPing:一键测试服务器回程ping脚本 - Rat's Blog
一个基于Python3的VPS服务器在线监控脚本 - Rat's Blog
博主: Rat's · 2018-03-13 · via Rat's Blog - ping
  •  发布时间:
  •  15040 次浏览
  •   2 条评论
  •  1214 字数
  • 分类: 主机教程
  1.  首页
  2. 正文  
  3. 分享到:

简介

本脚本基于Python3写的,原理是通过监测端定时运行监测程序来ping被监测端的VPS,只进行一次ping操作,并对反馈回来的数据进行分析,一旦发现ping失败了,就通过server酱推送到微信上,通知VPS服务器已经断线了。

使用

本脚本需要配合server酱的sckey使用,没有的去http://sc.ftqq.com申请一个。

1、安装Python3
一般Ubuntu系统都是自带Python3CentosDebian系统使用以下脚本进行安装。

#检查系统是否有Python3
python3 -V

#安装Python3
#CentOS系统
wget https://www.moerats.com/usr/shell/Python3/CentOS_Python3.6.sh && sh CentOS_Python3.6.sh
#Debian系统
wget https://www.moerats.com/usr/shell/Python3/Debian_Python3.6.sh && sh Debian_Python3.6.sh

2、安装requests
运行命令:

pip3 install requests

3、下载并编辑脚本

#下载脚本
wget https://www.moerats.com/usr/shell/Python3/ping_jk.py
#编辑脚本
nano ping_jk.py

修改以下两个地方:

key = 'SCKEY'  #SCKEY替换成你自己的SCKEY
hostname = "xx.xx.xx.xx"  #换成你需要监控的VPS的IP

然后Ctrl+C保存并退出。

4、运行脚本

python3 ping_jk.py

请配合crontab定时任务使用,建议每15分钟运行一次,参考:Linux系统Crontab的安装及定时任务的命令详解

提示:如果想监控多个VPS服务器,把pingcontent那里重复一下就可以了。不会重复的多用几个同样脚本,命名不同的脚本名称,并在监控提示那里编辑好服务器信息用来区分就可以了。

脚本来源:Hostloc论坛


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/537/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。

Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。