可以发邮件,播放音乐,发短信的shell脚本V1.2

简介:
今天又把原来写的脚本进行了修正处理:

早上9点之前,晚上10点之后,监控程序会发短信给相关人员,同时会对ps_autotest邮箱发邮件。其他时间是播放音乐和发邮件。
2.在tomcat被点住之后,系统会播放音乐和发邮件。

脚本内容如下:
脚本1:

#!/bin/bash
#website test scripts
while true;do
        for cycle_temp in `cat /opt/autotest/websit_url_links`
        do
                        temp=1                        
                        i=1
                        character_sign_1=10
                        character_sign_2=5
                                while [ ${i} -lt $character_sign_1 ]
                                do
                                                
                                        if lynx -connect_timeout=2 -dump `echo ${cycle_temp}` -accept_all_cookies|grep "true"
                                        then
                                                                let "temp=$temp+0"
                                        else
                                                                let "temp=$temp+1"
                                                                

                                        fi
                                        let "i=${i}+1"
                                        echo ${cycle_temp}
                                        sleep 5s
                                done
                                if [ ${temp} -gt $character_sign_2 ]
                        then
                            dateday=`date +%T`
                            datehour=`expr substr ${dateday} 1 2`
                            echo "${cycle_temp} has been down"
                            echo "${cycle_temp} has been offline,please attend it now!">/opt/autotest/test.txt
                            mail -s "website down mail" ps_autotest@****.com.cn</opt/autotest/test.txt
                            if[${hourtime}<9 && ${hourtime} <20]
                            then
                                mplayer /opt/autotest/love.mp3
                            
                            else
                            
                                for read_phone in `cat /opt/autotest/PS_MobilePone.txt`
                                do
                                echo -e "`echo $cycle_temp` 网站宕机,请及时处理!" |gnokii -sendsms `echo $read_phone`
                                done       
                            fi
                            rm -rf /opt/autotest/test.txt
                        fi
        done
        sleep 5m
done

脚本2:

---tomcat被点住的情况
#!/bin/sh
#no back date check program
while true;do
TIME=`ps -e -o pid -o etime -o args|grep http |grep lynx |awk '{print $2}' |awk -F: '{print $2}'`

if [ $TIME -gt 20 ]
        then
        mplayer /opt/autotest/love.mp3
        echo "`ps -e -o pid -o etime -o args|grep http |grep lynx |awk '{print $6}'`, Tomcat has been hitted.">/opt/autotest/test1.txt
                mail -s "website down mail" ps_autotest@****.com.cn</opt/autotest/test1.txt
                rm -rf /opt/autotest/test1.txt
fi
sleep 5s

done


本文转自guoli0813 51CTO博客,原文链接:http://blog.51cto.com/guoli0813/285463,如需转载请自行联系原作者

相关文章
|
3天前
|
Shell
蓝易云 - 简单shell脚本的编写教程
以上就是编写一个基本Shell脚本的步骤。当然,Shell脚本可以做的远不止这些,你可以使用变量,控制结构(如if语句和循环),以及各种Shell命令和功能来编写更复杂的脚本。
11 1
|
15天前
|
监控 Shell Linux
Linux的Shell脚本详解
Linux的Shell脚本详解
|
19天前
|
Shell
shell脚本
shell脚本
18 2
|
4天前
|
Shell 调度
Shell脚本中的if条件判断语句
Shell脚本中的if条件判断语句
|
4天前
|
Shell
蓝易云 - 简单shell脚本的编写教程
以上就是编写一个基本Shell脚本的步骤。当然,Shell脚本可以做的远不止这些,你可以使用变量,控制结构(如if语句和循环),以及各种Shell命令和功能来编写更复杂的脚本。
5 0
|
27天前
|
Ubuntu Java Linux
Linux centos7 ubuntu 一键安装Java JDK 脚本 shell 脚本
Linux centos7 ubuntu 一键安装Java JDK 脚本 shell 脚本
38 2
|
5天前
|
机器学习/深度学习 Unix Java
技术笔记:Linux之Shell脚本编程(一)
技术笔记:Linux之Shell脚本编程(一)
|
8天前
|
Shell
Shell脚本之条件语句if总结
Shell脚本之条件语句if总结
|
27天前
|
Ubuntu Shell Linux
linux shell 后台执行脚本的方法 脚本后台运行 后台运行程
linux shell 后台执行脚本的方法 脚本后台运行 后台运行程
16 0
|
27天前
|
监控 Shell Linux
shell linux中用shell写一个占用CPU的脚本
shell linux中用shell写一个占用CPU的脚本
28 0