在 CentOS 上监控 Jenkins 状态,通常可以从系统服务层面、应用层面和第三方监控工具三个维度来做。下面按常用程度给你梳理一套实用方案。
systemctl status jenkins
常见状态:
active (running):正常运行inactive (dead):已停止failed:启动失败systemctl enable jenkins
systemctl restart jenkins
ps -ef | grep jenkins
# 或
pgrep -af jenkins
ss -lntp | grep 8080
# 或
netstat -lntp | grep 8080
/var/log/jenkins/jenkins.log
tail -f /var/log/jenkins/jenkins.log
OutOfMemoryErrorSEVEREFailed to startConnection refusedhttp://<IP>:8080/metrics/currentUser/
需要先安装 Metrics Plugin
curl -s http://localhost:8080/login
返回 HTML 即服务可用
java -jar jenkins-cli.jar -s http://localhost:8080/ who-am-i
#!/bin/bash
URL="http://localhost:8080/login"
if ! curl -s --max-time 5 $URL > /dev/null; then
echo "Jenkins is down, restarting..."
systemctl restart jenkins
fi
加入定时任务:
crontab -e
*/5 * * * * /opt/check_jenkins.sh
top
htop
关注:
df -h
df -i
prometheus-metrics-plugin/prometheus/ 接口-Xmx)如果你愿意,我可以:
你现在是测试环境还是生产环境?