mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-30 07:59:53 -08:00
Merge pull request #1939 from prometheus/rootmsg
Add a warning when node exporter runs as root
This commit is contained in:
commit
bf4f48a4a7
|
@ -8,7 +8,7 @@ repository:
|
||||||
build:
|
build:
|
||||||
binaries:
|
binaries:
|
||||||
- name: node_exporter
|
- name: node_exporter
|
||||||
flags: -a -tags 'netgo static_build'
|
flags: -a -tags 'netgo osusergo static_build'
|
||||||
ldflags: |
|
ldflags: |
|
||||||
-X github.com/prometheus/common/version.Version={{.Version}}
|
-X github.com/prometheus/common/version.Version={{.Version}}
|
||||||
-X github.com/prometheus/common/version.Revision={{.Revision}}
|
-X github.com/prometheus/common/version.Revision={{.Revision}}
|
||||||
|
|
|
@ -7,7 +7,7 @@ repository:
|
||||||
build:
|
build:
|
||||||
binaries:
|
binaries:
|
||||||
- name: node_exporter
|
- name: node_exporter
|
||||||
flags: -a -tags 'netgo static_build'
|
flags: -a -tags 'netgo osusergo static_build'
|
||||||
ldflags: |
|
ldflags: |
|
||||||
-X github.com/prometheus/common/version.Version={{.Version}}
|
-X github.com/prometheus/common/version.Version={{.Version}}
|
||||||
-X github.com/prometheus/common/version.Revision={{.Revision}}
|
-X github.com/prometheus/common/version.Revision={{.Revision}}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
|
"os/user"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/prometheus/common/promlog"
|
"github.com/prometheus/common/promlog"
|
||||||
|
@ -176,6 +177,9 @@ func main() {
|
||||||
}
|
}
|
||||||
level.Info(logger).Log("msg", "Starting node_exporter", "version", version.Info())
|
level.Info(logger).Log("msg", "Starting node_exporter", "version", version.Info())
|
||||||
level.Info(logger).Log("msg", "Build context", "build_context", version.BuildContext())
|
level.Info(logger).Log("msg", "Build context", "build_context", version.BuildContext())
|
||||||
|
if user, err := user.Current(); err == nil && user.Uid == "0" {
|
||||||
|
level.Warn(logger).Log("msg", "Node Exporter is running as root user. This exporter is designed to run as unpriviledged user, root is not required.")
|
||||||
|
}
|
||||||
|
|
||||||
http.Handle(*metricsPath, newHandler(!*disableExporterMetrics, *maxRequests, logger))
|
http.Handle(*metricsPath, newHandler(!*disableExporterMetrics, *maxRequests, logger))
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
Loading…
Reference in a new issue