Skip to content

Commit

Permalink
fix(go.d/mysql): handle Cpu_time in microseconds in v10.11.11+ (netda…
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyam8 authored Feb 20, 2025
1 parent 851a2a6 commit 4046b35
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/go/plugin/go.d/collector/mysql/collect_user_statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ func (c *Collector) collectUserStatistics(mx map[string]int64) error {
c.addUserStatisticsCharts(user)
}
case "Cpu_time":
if c.isMariaDB && c.version.GTE(semver.Version{Major: 11, Minor: 4, Patch: 5}) {
needsDivision := c.isMariaDB &&
((c.version.Major == 10 && c.version.GTE(semver.Version{Major: 10, Minor: 11, Patch: 11})) ||
c.version.GTE(semver.Version{Major: 11, Minor: 4, Patch: 5}))

key := strings.ToLower(prefix + column)
if needsDivision {
// TODO: theoretically should divide by 1e6 to convert to seconds,
// but empirically need 1e7 to match pre-11.4.5 values.
// Needs investigation - possible unit reporting inconsistency in MariaDB
mx[strings.ToLower(prefix+column)] = int64(parseFloat(value) / 1e7 * 1000)
mx[key] = int64(parseFloat(value) / 1e7 * 1000)
} else {
mx[strings.ToLower(prefix+column)] = int64(parseFloat(value) * 1000)
mx[key] = int64(parseFloat(value) * 1000)
}
case
"Total_connections",
Expand Down

0 comments on commit 4046b35

Please sign in to comment.