1. 程式人生 > >centos7,監控httpd運行狀態

centos7,監控httpd運行狀態

centos7 linux httpd apache

#!/bin/bash
# 獲取運行狀態
http=$(systemctl status httpd | grep Active | awk ‘{print $2}‘)
# 判斷運行狀態
if [ "$http" != "active" ];then
# 運行狀態為失敗時嘗試重啟並發出重啟成功信息,如果運行失敗發出失敗警告!
systemctl restart httpd && echo "httpd Restart successfully" || echo "httpd Unable to restart"
exit 0
else
# 判斷如果運行狀態為正常發出正常信息
echo "httpd Normal operation"
exit 1
fi


centos7,監控httpd運行狀態