Skip to content

Commit

Permalink
Collect slab memory usage also in Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdevan committed Apr 9, 2020
1 parent b6c1153 commit bd8d798
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion collector/system_linux.go
Expand Up @@ -123,8 +123,10 @@ func (c *collector) getMemory() {
c.result.System.MemFree = memInfo["MemFree:"]
c.result.System.MemBuffers = memInfo["Buffers:"]
c.result.System.MemCached = memInfo["Cached:"]
c.result.System.MemSlab = memInfo["Slab:"]
c.result.System.MemUsed = memInfo["MemTotal:"] - c.result.System.MemFree -
c.result.System.MemBuffers - c.result.System.MemCached
c.result.System.MemBuffers - c.result.System.MemCached -
c.result.System.MemSlab

// Swap
if val, ok := memInfo["SwapTotal:"]; ok {
Expand Down
4 changes: 3 additions & 1 deletion model.go
Expand Up @@ -19,7 +19,7 @@ package pgmetrics
// ModelSchemaVersion is the schema version of the "Model" data structure
// defined below. It is in the "semver" notation. Version history:
// 1.8 - AWS RDS/EnhancedMonitoring metrics, index defn,
// backend type counts, user agent
// backend type counts, slab memory (linux), user agent
// 1.7 - query execution plans, autovacuum, deadlocks, table acl
// 1.6 - added highest WAL segment number
// 1.5 - add PID to replication_outgoing entries
Expand Down Expand Up @@ -224,6 +224,8 @@ type SystemMetrics struct {
SwapUsed int64 `json:"swapused"` // used swap memory in bytes, 0 if no swap
SwapFree int64 `json:"swapfree"` // free swap memory in bytes, 0 if no swap
Hostname string `json:"hostname"` // hostname from the OS
// following fields present only in schema 1.8 and later
MemSlab int64 `json:"memslab"` // RAM used for slab in bytes
}

type Backend struct {
Expand Down

0 comments on commit bd8d798

Please sign in to comment.