Explore "limit_maxbytes" and "bytes" individually

This commit is contained in:
Maksim Naumov
2015-06-23 09:44:39 +02:00
parent 039fc80ed7
commit b86d789abe
2 changed files with 3 additions and 22 deletions

View File

@@ -30,6 +30,8 @@ var sendAsIs = []string{
"get_hits",
"get_misses",
"evictions",
"limit_maxbytes",
"bytes",
}
// SampleConfig returns sample configuration message
@@ -122,25 +124,9 @@ func (m *Memcached) gatherServer(address string, acc plugins.Accumulator) error
}
}
}
// Usage
acc.Add("usage", m.calcUsage(values), tags)
return nil
}
func (m *Memcached) calcUsage(values map[string]string) float64 {
maxBytes, maxOk := values["limit_maxbytes"]
bytes, bytesOk := values["bytes"]
if maxOk && bytesOk {
if fMax, errMax := strconv.ParseFloat(maxBytes, 64); errMax == nil && fMax > 0 {
if fBytes, errBytes := strconv.ParseFloat(bytes, 64); errBytes == nil {
return fBytes / fMax
}
}
}
return 0
}
func init() {
plugins.Add("memcached", func() plugins.Plugin {
return &Memcached{}