开发者社区> 问答> 正文

使用curl写了程序之后,在日志中查看日志中没有获取到返回值

写了一个监控tomcat程序。在日志中tomcatservicecode值是空的。
【代码】
Monitor()
{
echo "[info]开始监控tomcat...[$(date +'%F %H:%M:%S')]"
     if [[ $TomcatCount -gt 0 ]];then
        echo "[info]当前tomcat进程ID为:$TomcatID,继续检测页面..."
        #检测是否启动成功
        TomcatServiceCode=$(curl -s -o $GetPageInfo -m 10 --connect-timeout 10 $                                                                                                                                                             WebUrl -w %{http_code})
     if [ $TomcatServiceCode -eq 200 ];then
           echo "[info]页面返回码为:$TomcatServicCode,tomcat启动成功,页面正常..                                                                                                                                                             ."
        else
           echo "[error]tomcat页面出错,状态码为:$TomcatServicCode,错误日志已输                                                                                                                                                             出到$GetPageInfo"
           echo "[info]页面访问出错,开始重启tomcat"
           kill -9 $TomcatID
           sleep 3
           rm -rf $TomcatCache #清理tomcat缓存
           echo "[info]现在开始重启tomcat..."
           echo "[info]请稍后..."
         fi
       else
           echo "[error]tomcat 进程不存在!"
           echo "[info]获取信息TomcatID:$TomcatID"
           echo "[info]获取信息TomcatCount:$TomcatCount"
           echo "[info]tomcat开始自动重启"
           echo "[info]$StartTomcat,请稍后......"
           rm -rf $TomcatCache
           $StartTomcat
          fi

       echo "--------------------------------------"
}
【日志】
--------------------------------------
[info]开始监控tomcat...[2019-01-04 14:54:01]
[info]当前tomcat进程ID为:8112,继续检测页面...
[info]页面返回码为:,tomcat启动成功,页面正常...
--------------------------------------
[info]开始监控tomcat...[2019-01-04 14:55:01]
[info]当前tomcat进程ID为:8112,继续检测页面...
[info]页面返回码为:,tomcat启动成功,页面正常...
--------------------------------------
[info]开始监控tomcat...[2019-01-04 14:56:01]
[info]当前tomcat进程ID为:8112,继续检测页面...
[info]页面返回码为:,tomcat启动成功,页面正常...
-------------------------------------

展开
收起
1629942345221958 2019-01-04 14:56:44 918 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
PostgresChina2018_赖思超_PostgreSQL10_hash索引的WAL日志修改版final 立即下载
Kubernetes下日志实时采集、存储与计算实践 立即下载
日志数据采集与分析对接 立即下载