func KernelMetrics() (L []*model.MetricValue) { maxFiles, err := nux.KernelMaxFiles() if err != nil { log.Println(err) return } L = append(L, GaugeValue("kernel.maxfiles", maxFiles)) maxProc, err := nux.KernelMaxProc() if err != nil { log.Println(err) return } L = append(L, GaugeValue("kernel.maxproc", maxProc)) allocateFiles, err := nux.KernelAllocateFiles() if err != nil { log.Println(err) return } L = append(L, GaugeValue("kernel.files.allocated", allocateFiles)) L = append(L, GaugeValue("kernel.files.left", maxFiles-allocateFiles)) return }
func configKernelRoutes() { http.HandleFunc("/proc/kernel/hostname", func(w http.ResponseWriter, r *http.Request) { data, err := g.Hostname() AutoRender(w, data, err) }) http.HandleFunc("/proc/kernel/maxproc", func(w http.ResponseWriter, r *http.Request) { data, err := nux.KernelMaxProc() AutoRender(w, data, err) }) http.HandleFunc("/proc/kernel/maxfiles", func(w http.ResponseWriter, r *http.Request) { data, err := nux.KernelMaxFiles() AutoRender(w, data, err) }) http.HandleFunc("/proc/kernel/version", func(w http.ResponseWriter, r *http.Request) { data, err := sys.CmdOutNoLn("uname", "-r") AutoRender(w, data, err) }) }