metrics: move currentFDs code to the metrics package

Updates #2784

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2021-09-02 11:14:14 -07:00
parent 5d800152d9
commit fc160f80ee
5 changed files with 59 additions and 9 deletions

View File

@@ -47,3 +47,10 @@ func (m *LabelMap) GetFloat(key string) *expvar.Float {
m.AddFloat(key, 0.0)
return m.Map.Get(key).(*expvar.Float)
}
// CurrentFDs reports how many file descriptors are currently open.
//
// It only works on Linux. It returns zero otherwise.
func CurrentFDs() int {
return currentFDs()
}