Jenkins正常运行时间-自上次重启以来已持续多长时间 [英] Jenkins uptime - how long since last restart

查看:160
本文介绍了Jenkins正常运行时间-自上次重启以来已持续多长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以查看Jenkins实例/主服务器运行了多长时间?

Is it possible to see how long a Jenkins instance/master has been running?

我尝试在"Manage Jenkins"中环顾四周,但在那里找不到.我知道我可以登录并在计算机上检查进程,但是可以在Jenkins Web UI中进行吗?

I've tried looking around in "Manage Jenkins" but can't find it there. I know I could log in and check the process on the machine, but is it possible to do it in Jenkins web UI?

此网址在重新启动时显示为白线...但不是那么直观.

This URL shows a white line when it was restarted... but it's not that intuitive.

<jenkins-url>/monitoring?part=graph&graph=usedMemory&period=mois

推荐答案

您可以通过以下方法在Jenkins Web-ui上运行groovy脚本:管理Jenkins>脚本控制台,并使用Jenkins API.如果您想知道Jenkins已经运行了多少天:

You can run groovy script on Jenkins web-ui from: Manage Jenkins > Script Console, and use Jenkins API. If you want to know how many days Jenkins has been running:

import java.util.concurrent.TimeUnit
long lastRestarted = Jenkins.instance.toComputer().getConnectTime()
long now =  System.currentTimeMillis()
println TimeUnit.MILLISECONDS.toDays(now - lastRestarted)

主计算机的

getConnectTime()应该是重新启动的时间. http://javadoc.jenkins.io/hudson/model/Computer.html #getConnectTime()

getConnectTime() of the master computer should be the time when it restarted. http://javadoc.jenkins.io/hudson/model/Computer.html#getConnectTime()

这篇关于Jenkins正常运行时间-自上次重启以来已持续多长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆