Skip to content

Instantly share code, notes, and snippets.

@paulmey
Created November 7, 2022 10:35
Show Gist options
  • Save paulmey/58f5e3f87446ed9d147a64388c00b5f7 to your computer and use it in GitHub Desktop.
Save paulmey/58f5e3f87446ed9d147a64388c00b5f7 to your computer and use it in GitHub Desktop.
Dstat plugins
class dstat_plugin(dstat):
"""
Committed memory usage
Displays the committed memory.
"""
def __init__(self):
self.name = 'commit memory usage'
self.nick = ('limit', 'committed', 'perc')
self.vars = ('CommitLimit', 'Committed_AS', 'Committed_perc')
self.types = ('b', 'b', 'p')
self.scales = (1024, 1024, None)
self.open('/proc/meminfo')
def extract(self):
for l in self.splitlines():
if len(l) < 2: continue
name = l[0].split(':')[0]
if name in self.vars:
self.val[name] = long(l[1]) * 1024.0
self.val['Committed_perc'] = (self.val['Committed_AS']*100)/self.val['CommitLimit']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment