web: Display current working directory on status-page

This commit is contained in:
Morten Siebuhr 2016-12-04 00:37:59 +01:00
parent a932c1a4b6
commit c5b17263a6
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> <th>Uptime</th>
<td>{{.Birth.UTC}}</td> <td>{{.Birth.UTC}}</td>
</tr> </tr>
<tr>
<th>Working Directory</th>
<td>{{.CWD}}</td>
</tr>
</tbody> </tbody>
</table> </table>

View file

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