Skip to content

Commit

Permalink
Check CPU metric - Fix memory metric to include text+data+stack
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier-heurtier committed Apr 12, 2020
1 parent 4fa80f9 commit 3bc4336
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion livemetrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@
if os.name=='posix':
def get_memory():
# Retrieve memory usage from /proc/self/statm
# text + data (data+stack)
try:
with open('/proc/self/statm','r') as f:
return int(f.read().split(' ')[0]) * os.sysconf('SC_PAGE_SIZE')
parts = f.read().split(' ')
return (int(parts[3])+int(parts[5])) * os.sysconf('SC_PAGE_SIZE')
except:
return 0

Expand Down
13 changes: 7 additions & 6 deletions tests/dashboard/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ rows:
type: status
- label: CPU
server: "{{server}}/metrics/gauges/cpu/count"
type: value
unit: "%o"
factor: "*1000"
color: green
type: gauge
unit: "%"
max: 100
gauge_color: green
color: "#C0F0C0"
- label: Memory
server: "{{server}}/metrics/gauges/memory/count"
type: gauge
Expand Down Expand Up @@ -62,7 +63,7 @@ rows:
type: value
unit: "/h"
factor: "*3600"
color: "#C0F0C0"
color: green
max: 25000
operator: min
precision: 1
Expand All @@ -71,7 +72,7 @@ rows:
type: value
unit: "/h"
factor: "*3600"
color: "#C0F0C0"
color: green
max: 25000
operator: max
precision: 2
Expand Down

0 comments on commit 3bc4336

Please sign in to comment.