linux服务监控脚本
- 配置需要监控的服务器
- 数组定义:host_ports=(host_name=host_port=uri_path)
host_name为容易识别的服务器名称
host_port为服务器ip和服务端口
uri_path为经济的请求路径 - 为脚本运行的服务器开放防火墙端口,内网ip和外网ip皆可,但要与host_port一致
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -s 121.45.111.17 --dport 8090 -j ACCEPT - 监控结果记录日志
- 先记录日期
echo `date +'%Y-%m-%d %H:%M:%S'` > $log - 选择notify_host,需要提供发送邮件的接口,所以前面定义数组时将有邮件接口的host放在前面,找到第一个运行正常的host即可作为notify_host
if [ -z $notify_host ]; thennotify_host=$host_portfi - 检查完后检查日志文件,大于1行则发邮件通知
curl http://$notify_host/admin/monitor.html?log=$log > /dev/null 2>&1 - crontab定时运行监控脚本
- crontab配置,每20分钟检查一次
*/20 * * * * /soft/monitor.sh >> /soft/logs/monitor-cron.log - 运行效果,测试时每两分钟检查一次

- 邮件通知

log_content=`cat $log` #post log_content to notify_host, cause it can't get file $log
curl -d "log=$log_content" http://$notify_host/admin/monitor.html > /dev/null 2>&1
附件列表
linux服务监控脚本的更多相关文章
- linux centos7 定时执行服务监控脚本
2021-08-25 1. 需求 在服务挂掉之后我们要怎么做才能保证服务在短时间内开启?可以编写脚本监控服务的状态,在服务挂掉后及时将其开启,并定时执行该脚本. 2. 脚本编写 思路:平常我们可以通过 ...
- Zabbix Linux http 监控脚本
说明:自定义监控脚本,监控内存是否启用主进程 创建文件:vim check_http.sh #!/bin/bash result=`ps -ef | grep httpd | grep -v grep ...
- linux 服务发布脚本升级,远程发布,指定拉取远程dev,test等分支代码
1.本地发布脚本 publish.sh #!/bin/sh currentDay=`date +%Y%m%d` currentTime=`date +%Y%m%d%H%M%S` tomcat1=/da ...
- Linux 负载监控脚本
#!/bin/bash Date=`echo $(date +%Y\-%m\-%d\ %H:%M:%S)`HostName=`hostname`IP=`ifconfig eth0 | grep &qu ...
- linux服务器监控脚本
#!/bin/bash #获取cpu使用率 cpuUsage=`top -n 1 | awk -F '[ %]+' 'NR==3 {print $2}'` #获取磁盘使用率 data_name=&qu ...
- linux网络监控脚本
http://www.51testing.com/html/92/77492-828434.html
- linux重启服务的脚本命令
最近做网站测试,每次测试完成都要重启服务,为此写了一个简单的shell脚本 linux服务重启shell脚本示例 2014年12月18日 linux服务重启脚本,如何实现linux服务的定时重启,可以 ...
- Linux 服务器系统监控脚本 Shell【转】
转自: Linux 服务器系统监控脚本 Shell - 今日头条(www.toutiao.com)http://www.toutiao.com/i6373134402163048961/ 本程序在Ce ...
- Linux简单Shell脚本监控MySQL、Apache Web和磁盘空间
Linux简单Shell脚本监控MySQL.Apache Web和磁盘空间 1. 目的或任务 当MySQL数据库.Apache Web服务器停止运行时,重新启动运行,并发送邮件通知: 当服务器磁盘的空 ...
随机推荐
- HDU3657Game(最大流)
这几天敲了几道最大流的问题,发现网络流真是模板算法啊.... 敲来敲去敲了几遍,基本每遍都敲得让人灰心,但同时也感受到了网络流的强大所在,这是我做网络流的第一题,,本以为看了一遍小白书的代码差不多理解 ...
- zendstudio 出现failed to create the java machine转
是因为配置java虚拟机内存太小 打开zend for eclipse 10.5时报了个错: failed to create the java virtual machine google了一下,解 ...
- websocket的php测试demo
<?php class WS { var $master; var $sockets = array(); var $debug = false; var $handshake = false; ...
- jquery easyui-linkButton获取和设置按钮text并且解决火狐不支持innerText的方法
<a href="javascript:test" id="btn" class="easyui-linkbutton" iconCl ...
- installshield basic msi 更新时覆盖不了上一个版本文件解决方案1
1.增加dll exe程序集的版本号 2.设置IS里文件的Set key file
- jQuery each,避免使用js for循环
What is the difference between $.each(selector) and $(selector).each(): http://stackoverflow.com/que ...
- sqlserver:同一数据库内负责表结构。
select * into 新表 from 旧表 where 1=2; ## where 表示要携带的数据,随便写个恒不等式就可以只复制表结构不携带数据.
- 关于request.getsession(true|false)
request.getSession(true):若存在会话则返回该会话,否则新建一个会话.request.getSession(false):若存在会话则返回该会话,否则返回NULL
- JSP中的TAG
http://blog.csdn.net/hongweigg/article/details/12006849 JSP标签有两种实现方法,一种是使用tag 文件,一种是使用tld文件. 1.使用tag ...
- 番茄钟App(Pomodoro Tracker)
最近为了学习Swift编程语言,写了一个番茄钟的App(Pomodoro Tracker).刚上线的1.2版本增加了Apple Watch的支持. iPhone版 Apple Watch版 如果你跟我 ...