Merge pull request #2248 from msiebuhr/cwd-in-status

web: Display current working directory on status-page
This commit is contained in:
Fabian Reinartz 2016-12-05 21:41:37 +01:00 committed by GitHub
commit 893390e0c6
3 changed files with 90 additions and 76 deletions

File diff suppressed because one or more lines are too long

View file

@ -9,6 +9,10 @@
<th>Uptime</th>
<td>{{.Birth.UTC}}</td>
</tr>
<tr>
<th>Working Directory</th>
<td>{{.CWD}}</td>
</tr>
</tbody>
</table>

View file

@ -71,6 +71,7 @@ type Handler struct {
configString string
versionInfo *PrometheusVersion
birth time.Time
cwd string
flagsMap map[string]string
externalLabels model.LabelSet
@ -127,6 +128,12 @@ func New(o *Options) *Handler {
return o.Context, nil
})
cwd, err := os.Getwd()
if err != nil {
cwd = "<error retrieving current working directory>"
}
h := &Handler{
router: router,
listenErrCh: make(chan error),
@ -135,6 +142,7 @@ func New(o *Options) *Handler {
options: o,
versionInfo: o.Version,
birth: time.Now(),
cwd: cwd,
flagsMap: o.Flags,
context: o.Context,
@ -327,10 +335,12 @@ func (h *Handler) graph(w http.ResponseWriter, r *http.Request) {
func (h *Handler) status(w http.ResponseWriter, r *http.Request) {
h.executeTemplate(w, "status.html", struct {
Birth time.Time
CWD string
Version *PrometheusVersion
Alertmanagers []string
}{
Birth: h.birth,
CWD: h.cwd,
Version: h.versionInfo,
Alertmanagers: h.notifier.Alertmanagers(),
})