检测并重启脚本:checkAndRestart.sh

#!/bin/bash
nowpath=$(cd "$(dirname "$")";pwd)
source $nowpath/omcparam.properties
nowtime=`date --date='0 days ago' "+%Y%m%d%H%M%S"`
daytime=`date --date='0 days ago' "+%Y%m%d"` function log(){
echo $ >> $nowpath/logcheck_$daytime.log
} ## read params function checkConfigApps(){ arr=${apps//,/ } for app in $arr
do
local jarName;
local serviceName; if [[ "$app" =~ "=" ]];then
##
jarName=`echo $app | cut -d "=" -f `
serviceName=`echo $app | cut -d "=" -f `
else
jarName=$app
serviceName=$app
fi
if `isAppRunning $jarName` ;then
log "$serviceName is running."
else
log "$serviceName is not running, start"
start $serviceName
fi
done
} function start(){
systemctl start $
} function stop(){
## check if stop finished
if `isAppRunning $` ; then
local waitTime=
local runPort=`ps -ef|grep $|grep -v grep|awk '{print $2}'`
if [ "$runPort" != "" ];then
kill $runPort
fi
while `isAppRunning $`;do
waitTime=$((waitTime+)) if [ $waitTime -ge $maxAppStopTime ];then
log "stop time timeout, will forced closure"
kill - $runPort
else
sleep 1s
log "wait for $waitTime second"
fi
done
else
log "$1 has stop."
fi } function isAppRunning(){
runningPort=`ps -ef|grep $|grep -v grep|awk '{print $2}'`
if [ "$runningPort" != "" ];then
echo true
return
else
echo false
return
fi
} webConfigFile="/usr/local/tomcat_web/shared_loader/application.properties"
function checkTomcatWeb(){
local webUrl=`grep web.url $webConfigFile`
local url=`echo $webUrl | cut -d "=" -f `
local loginRet=`curl $url/login.jsp --speed-time $maxTimeToLoginPage --speed-limit `
local flag="/smallcell/sys/login/userLoad.htm"
if [[ "$loginRet" =~ "$flag" ]];then
log "tomcat_web is running normal."
else
log "can not visit login page, will restart tomcat_web"
stop tomcat_web
start tomcat_web
log "start tomcat_web, wait $maxTomcatWebStartTime seconds"
sleep 60s
fi
} log "****************************************$nowtime*********************************************"
checkTomcatWeb
checkConfigApps

设置crontab定时任务,每五分钟执行一次

*/ * * * * /work/checkomc/checkAndRestart.sh

配置:omcparam.properties

apps=tomcat_tr069
maxAppStopTime=
maxTimeToLoginPage=
maxTomcatWebStartTime=

PS:

[root@localhost checkomc]# curl -h
Usage: curl [options...] <url>
Options: (H) means HTTP/HTTPS only, (F) means FTP only
--anyauth Pick "any" authentication method (H)
-a, --append Append to target file when uploading (F/SFTP)
--basic Use HTTP Basic Authentication (H)
--cacert FILE CA certificate to verify peer against (SSL)
--capath DIR CA directory to verify peer against (SSL)
-E, --cert CERT[:PASSWD] Client certificate file and password (SSL)
--cert-type TYPE Certificate file type (DER/PEM/ENG) (SSL)
--ciphers LIST SSL ciphers to use (SSL)
--compressed Request compressed response (using deflate or gzip)
-K, --config FILE Specify which config file to read
--connect-timeout SECONDS Maximum time allowed for connection
-C, --continue-at OFFSET Resumed transfer offset
-b, --cookie STRING/FILE String or file to read cookies from (H)
-c, --cookie-jar FILE Write cookies to this file after operation (H)
--create-dirs Create necessary local directory hierarchy
--crlf Convert LF to CRLF in upload
--crlfile FILE Get a CRL list in PEM format from the given file
-d, --data DATA HTTP POST data (H)
--data-ascii DATA HTTP POST ASCII data (H)
--data-binary DATA HTTP POST binary data (H)
--data-urlencode DATA HTTP POST data url encoded (H)
--delegation STRING GSS-API delegation permission
--digest Use HTTP Digest Authentication (H)
--disable-eprt Inhibit using EPRT or LPRT (F)
--disable-epsv Inhibit using EPSV (F)
-D, --dump-header FILE Write the headers to this file
--egd-file FILE EGD socket path for random data (SSL)
--engine ENGINGE Crypto engine (SSL). "--engine list" for list
-f, --fail Fail silently (no output at all) on HTTP errors (H)
-F, --form CONTENT Specify HTTP multipart POST data (H)
--form-string STRING Specify HTTP multipart POST data (H)
--ftp-account DATA Account data string (F)
--ftp-alternative-to-user COMMAND String to replace "USER [name]" (F)
--ftp-create-dirs Create the remote dirs if not present (F)
--ftp-method [MULTICWD/NOCWD/SINGLECWD] Control CWD usage (F)
--ftp-pasv Use PASV/EPSV instead of PORT (F)
-P, --ftp-port ADR Use PORT with given address instead of PASV (F)
--ftp-skip-pasv-ip Skip the IP address for PASV (F)
--ftp-pret Send PRET before PASV (for drftpd) (F)
--ftp-ssl-ccc Send CCC after authenticating (F)
--ftp-ssl-ccc-mode ACTIVE/PASSIVE Set CCC mode (F)
--ftp-ssl-control Require SSL/TLS for ftp login, clear for transfer (F)
-G, --get Send the -d data with a HTTP GET (H)
-g, --globoff Disable URL sequences and ranges using {} and []
-H, --header LINE Custom header to pass to server (H)
-I, --head Show document info only
-h, --help This help text
--hostpubmd5 MD5 Hex encoded MD5 string of the host public key. (SSH)
-, --http1. Use HTTP 1.0 (H)
--ignore-content-length Ignore the HTTP Content-Length header
-i, --include Include protocol headers in the output (H/F)
-k, --insecure Allow connections to SSL sites without certs (H)
--interface INTERFACE Specify network interface/address to use
-, --ipv4 Resolve name to IPv4 address
-, --ipv6 Resolve name to IPv6 address
-j, --junk-session-cookies Ignore session cookies read from file (H)
--keepalive-time SECONDS Interval between keepalive probes
--key KEY Private key file name (SSL/SSH)
--key-type TYPE Private key file type (DER/PEM/ENG) (SSL)
--krb LEVEL Enable Kerberos with specified security level (F)
--libcurl FILE Dump libcurl equivalent code of this command line
--limit-rate RATE Limit transfer speed to this rate
-l, --list-only List only names of an FTP directory (F)
--local-port RANGE Force use of these local port numbers
-L, --location Follow redirects (H)
--location-trusted like --location and send auth to other hosts (H)
-M, --manual Display the full manual
--mail-from FROM Mail from this address
--mail-rcpt TO Mail to this receiver(s)
--mail-auth AUTH Originator address of the original email
--max-filesize BYTES Maximum file size to download (H/F)
--max-redirs NUM Maximum number of redirects allowed (H)
-m, --max-time SECONDS Maximum time allowed for the transfer
--metalink Process given URLs as metalink XML file
--negotiate Use HTTP Negotiate Authentication (H)
-n, --netrc Must read .netrc for user name and password
--netrc-optional Use either .netrc or URL; overrides -n
--netrc-file FILE Set up the netrc filename to use
-N, --no-buffer Disable buffering of the output stream
--no-keepalive Disable keepalive use on the connection
--no-sessionid Disable SSL session-ID reusing (SSL)
--noproxy List of hosts which do not use proxy
--ntlm Use HTTP NTLM authentication (H)
-o, --output FILE Write output to <file> instead of stdout
--pass PASS Pass phrase for the private key (SSL/SSH)
--post301 Do not switch to GET after following a redirect (H)
--post302 Do not switch to GET after following a redirect (H)
--post303 Do not switch to GET after following a redirect (H)
-#, --progress-bar Display transfer progress as a progress bar
--proto PROTOCOLS Enable/disable specified protocols
--proto-redir PROTOCOLS Enable/disable specified protocols on redirect
-x, --proxy [PROTOCOL://]HOST[:PORT] Use proxy on given port
--proxy-anyauth Pick "any" proxy authentication method (H)
--proxy-basic Use Basic authentication on the proxy (H)
--proxy-digest Use Digest authentication on the proxy (H)
--proxy-negotiate Use Negotiate authentication on the proxy (H)
--proxy-ntlm Use NTLM authentication on the proxy (H)
-U, --proxy-user USER[:PASSWORD] Proxy user and password
--proxy1. HOST[:PORT] Use HTTP/1.0 proxy on given port
-p, --proxytunnel Operate through a HTTP proxy tunnel (using CONNECT)
--pubkey KEY Public key file name (SSH)
-Q, --quote CMD Send command(s) to server before transfer (F/SFTP)
--random-file FILE File for reading random data from (SSL)
-r, --range RANGE Retrieve only the bytes within a range
--raw Do HTTP "raw", without any transfer decoding (H)
-e, --referer Referer URL (H)
-J, --remote-header-name Use the header-provided filename (H)
-O, --remote-name Write output to a file named as the remote file
--remote-name-all Use the remote file name for all URLs
-R, --remote-time Set the remote file's time on the local output
-X, --request COMMAND Specify request command to use
--resolve HOST:PORT:ADDRESS Force resolve of HOST:PORT to ADDRESS
--retry NUM Retry request NUM times if transient problems occur
--retry-delay SECONDS When retrying, wait this many seconds between each
--retry-max-time SECONDS Retry only within this period
-S, --show-error Show error. With -s, make curl show errors when they occur
-s, --silent Silent mode. Don't output anything
--socks4 HOST[:PORT] SOCKS4 proxy on given host + port
--socks4a HOST[:PORT] SOCKS4a proxy on given host + port
--socks5 HOST[:PORT] SOCKS5 proxy on given host + port
--socks5-hostname HOST[:PORT] SOCKS5 proxy, pass host name to proxy
--socks5-gssapi-service NAME SOCKS5 proxy service name for gssapi
--socks5-gssapi-nec Compatibility with NEC SOCKS5 server
-Y, --speed-limit RATE Stop transfers below speed-limit for 'speed-time' secs
-y, --speed-time SECONDS Time for trig speed-limit abort. Defaults to
--ssl Try SSL/TLS (FTP, IMAP, POP3, SMTP)
--ssl-reqd Require SSL/TLS (FTP, IMAP, POP3, SMTP)
-, --sslv2 Use SSLv2 (SSL)
-, --sslv3 Use SSLv3 (SSL)
--ssl-allow-beast Allow security flaw to improve interop (SSL)
--stderr FILE Where to redirect stderr. - means stdout
--tcp-nodelay Use the TCP_NODELAY option
-t, --telnet-option OPT=VAL Set telnet option
--tftp-blksize VALUE Set TFTP BLKSIZE option (must be >)
-z, --time-cond TIME Transfer based on a time condition
-, --tlsv1 Use => TLSv1 (SSL)
--tlsv1. Use TLSv1. (SSL)
--tlsv1. Use TLSv1. (SSL)
--tlsv1. Use TLSv1. (SSL)
--trace FILE Write a debug trace to the given file
--trace-ascii FILE Like --trace but without the hex output
--trace-time Add time stamps to trace/verbose output
--tr-encoding Request compressed transfer encoding (H)
-T, --upload-file FILE Transfer FILE to destination
--url URL URL to work with
-B, --use-ascii Use ASCII/text transfer
-u, --user USER[:PASSWORD] Server user and password
--tlsuser USER TLS username
--tlspassword STRING TLS password
--tlsauthtype STRING TLS authentication type (default SRP)
-A, --user-agent STRING User-Agent to send to server (H)
-v, --verbose Make the operation more talkative
-V, --version Show version number and quit
-w, --write-out FORMAT What to output after completion
--xattr Store metadata in extended file attributes
-q If used as the first parameter disables .curlrc

查看curl帮助文档,对于本例中,只需要关注如下四个参数

--connect-timeout

--max-time

--speed-limit

--speed-time

前两个一起使用,或者后两个一起使用,本例中使用的为后两个一起使用

检测web界面不能访问后重启的更多相关文章

  1. hadoop 3.x 无法访问hdfs(50070,8088)的web界面

    1.启动hadoop.然后netstat -nltp|grep 50070,如果,没有找到进程,说明没有配置web界面的端口修改hdfs-site,xml中加上如下配置 再次启动后,netstat - ...

  2. tomcat配置根目录访问后,部署后第一次访问会出现tomcat的默认界面而非项目首页

    tomcat配置根目录访问后,部署后第一次访问会出现tomcat的默认界面而非项目首页,而重启后会正常,这个原因是因为在配置文件中有如下配置,造成项目加载两次 <Host name=" ...

  3. InfluxDB安装后web页面无法访问的解决方案

    本文属于<InfluxDB系列教程>文章系列,该系列共包括以下 16 部分: InfluxDB学习之InfluxDB的安装和简介 InfluxDB学习之InfluxDB的基本概念 Infl ...

  4. cloudera manager的7180 web界面访问不了的解决办法(图文详解)

    说在前面的话 我的机器是总共4台,分别为ubuntucmbigdata1.ubuntucmbigdata2.ubuntucmbigdata3和ubuntucmbigdata4.(注意啦,以下是针对Ub ...

  5. 网站运行一段时间后就无法访问,重启Tomcat才能恢复

    网站运行一段时间后就无法访问,重启Tomcat才能恢复出现这种情况,很可能是以下几种情况:1.超过数据库连接池上限2.并发数达到上限3.内存溢出具体还是需要通过打印的日志进行具体分析.解决方法1.如果 ...

  6. 【云计算】Docker集中化web界面管理平台shipyard

    Docker集中化web界面管理平台shipyard docker shipyard seanlook                        2015年01月05日发布             ...

  7. Docker集中化web界面管理平台-Shipyard部署记录

    Docker图形页面管理工具基本常用的有三种: DOCKER UI,Shipyard,Portainer.对比后发现,Shipyard最强大,其次是Portainer,最后是Docker ui.之前介 ...

  8. ganglia之web界面介绍

    转自:https://blog.csdn.net/lswnew/article/details/79175555 http://www.51niux.com/?id=83 第一篇文章讲述了gangli ...

  9. OpenWRT - WEB界面开发思路和基本方法

    想要对OpenWRT的WEB界面(*下称界面)进行修改.修改的目标是: 1.修改页面的样式,设计为企业的风格(stylesheet) 2.新建自己的功能,实现 访问页面后,用户就可以对配置文件(也就是 ...

随机推荐

  1. OKR与Scrum如何强强联手

    我们收到很多问题询问如何把OKR和其他框架结合起来使用,以便管理组织的人员.流程和活动. 软件开发公司最喜欢用的框架之一就是Scrum,Scrum是一个诞生于20世纪90年代的软件开发框架,我们公司内 ...

  2. Connection open error . Connection Timeout Expired. The timeout period elapsed during the post-login phase.

    是这样的,最近我在开发Api(重构),用的数据库是Sqlserver,使用的Orm是 SqlSugar(别问我为什么选这个,boss选的同时我也想支持国人写的东西,且文档也很全). 被催的是,写好了程 ...

  3. Python:正则表达式 re 模块

    正则是处理字符串最常用的方法,我们编码中到处可见正则的身影. 正则大同小异,python 中的正则跟其他语言相比略有差异: 1.替换字符串时,替换的字符串可以是一个函数 2.split 函数可以指定分 ...

  4. 【.NET Core项目实战-统一认证平台】第十五章 网关篇-使用二级缓存提升性能

    [.NET Core项目实战-统一认证平台]开篇及目录索引 一.背景 首先说声抱歉,可能是因为假期综合症(其实就是因为懒哈)的原因,已经很长时间没更新博客了,现在也调整的差不多了,准备还是以每周1-2 ...

  5. 第5章 支持和咨询选项 - Identity Server 4 中文文档(v1.0.0)

    我们为IdentityServer提供了多种免费和商业支持和咨询选项. 5.1 免费支持 免费支持是基于社区的,并使用公共论坛 5.1.1 StackOverflow StackOverflow 社区 ...

  6. C# ListBox实现显示插入最新的数据的方法

    在我们使用ListBox控件时,如果我们在里面不断的添加一条条数据,但是在我们添加的数据过多超过了ListBox显示的窗口时(此时会产生滑动条), 发现我们无法看到最新添加的数据.实现倒序显示此处有两 ...

  7. Android破解学习之路(九)—— 练手破解游戏集合

    1.魔塔50层 https://www.taptap.com/app/48859 选择需要购买的东西,之后在支付宝支付界面点击取消,即可支付成功 2.布布合丁丁 https://www.coolapk ...

  8. 3. 基于优先级的Queue(PriorityBlockingQueue)

    package com.gf.conn013; import java.util.Iterator; import java.util.concurrent.PriorityBlockingQueue ...

  9. SpringBoot究竟是如何跑起来的?

    摘要: 神奇的SpringBoot. 原文:SpringBoot 究竟是如何跑起来的? 作者:老钱 Fundebug经授权转载,版权归原作者所有. 不得不说 SpringBoot 太复杂了,我本来只想 ...

  10. 网络最大流算法—最高标号预流推进HLPP

    吐槽 这个算法.. 怎么说........ 学来也就是装装13吧.... 长得比EK丑 跑的比EK慢 写着比EK难 思想 大家先来猜一下这个算法的思想吧:joy: 看看人家的名字——最高标号预留推进 ...