分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

Shell脚本——监控web服务

发布时间:2023-09-06 01:47责任编辑:白小东关键词:暂无标签
1.监控端口

#!/bin/bash

##############################################################

# File Name: web.sh

# Version: V7.4

# Author: feng yu

# Organization: http://blog.51cto.com/13520761

# Created Time : 2018-03-27 15:05:09

# Description:

##############################################################

if [ $(netstat -lntup | grep -w  80| awk -F "[ :]+" 'NR==1{print $5}') = 80 ];then

    echo "Nginx is Running"

else

    echo "Nginx is Stopped"

    mail -s "Nginx is stop" q@163.com < nginx is stop

fi


2.监控进程(注意:监控进程,脚本名不要写服务名)

#!/bin/bash

##############################################################

# File Name: web1.sh

# Version: V7.4

# Author: feng yu

# Organization: http://blog.51cto.com/13520761

# Created Time : 2018-03-27 15:30:56

# Description:

##############################################################

if [ $(ps -ef | grep nginx |wc -l) -gt 0 ];then

    echo "Nginx is Running"

else

    echo "Nginx is stopped"

    mail -s "nginx is stop" q@163.com < nginx is stop

fi


3.返回值

#!/bin/bash

##############################################################

# File Name: web2.sh

# Version: V7.4

# Author: feng yu

# Organization: http://blog.51cto.com/13520761

# Created Time : 2018-03-27 16:01:40

# Description:

##############################################################

num=$(curl -I www.baidu.com -s -w %{http_code} -o /dev/null)

if [ $num = 200 ];then

    echo "网页正常"

else

    echo "$num"

    mail -s "网页异常" q@163.com < 网页异常,$num

fi


Shell脚本——监控web服务

原文地址:http://blog.51cto.com/13520761/2091656

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved