可以发邮件,播放音乐,发短信的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,如需转载请自行联系原作者

相关文章
|
9天前
|
分布式计算 Hadoop Shell
使用shell脚本实现自动SSH互信功能
使用shell脚本实现自动SSH互信功能
22 1
|
9天前
|
Unix Shell Linux
轻松编写 AIX Shell 脚本
轻松编写 AIX Shell 脚本
15 1
|
9天前
|
监控 关系型数据库 Shell
Shell脚本入门:从基础到实践,轻松掌握Shell编程
Shell脚本入门:从基础到实践,轻松掌握Shell编程
|
9天前
|
关系型数据库 MySQL Shell
在Centos7中利用Shell脚本:实现MySQL的数据备份
在Centos7中利用Shell脚本:实现MySQL的数据备份
|
9天前
|
Shell Linux 编译器
C语言,Linux,静态库编写方法,makefile与shell脚本的关系。
总结:C语言在Linux上编写静态库时,通常会使用Makefile来管理编译和链接过程,以及Shell脚本来自动化构建任务。Makefile包含了编译规则和链接信息,而Shell脚本可以调用Makefile以及其他构建工具来构建项目。这种组合可以大大简化编译和构建过程,使代码更易于维护和分发。
31 5
|
9天前
|
Shell 程序员 数据安全/隐私保护
shell 脚本 if-else判断 和流程控制 (基本语法|基础命令)
shell 脚本 if-else判断 和流程控制 (基本语法|基础命令)
|
9天前
|
存储 Shell C语言
shell脚本 编程 变量 基本入门(详解)
shell脚本 编程 变量 基本入门(详解)
|
9天前
|
Shell Linux 编译器
C语言,Linux,静态库编写方法,makefile与shell脚本的关系。
总结:C语言在Linux上编写静态库时,通常会使用Makefile来管理编译和链接过程,以及Shell脚本来自动化构建任务。Makefile包含了编译规则和链接信息,而Shell脚本可以调用Makefile以及其他构建工具来构建项目。这种组合可以大大简化编译和构建过程,使代码更易于维护和分发。
17 3
|
9天前
|
弹性计算 运维 监控
|
9天前
|
存储 弹性计算 运维
自动化收集员工信息的Shell脚本
【4月更文挑战第30天】
14 0