forked from gws/munin-plugin-couchdb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
couchdb_memory
executable file
·45 lines (37 loc) · 1.23 KB
/
couchdb_memory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env node
// Munin plugin for CouchDB database io
// Magic Markers for auto-configuration
// #%# family=auto
// #%# capabilities=autoconf suggest
var sys = require("sys")
, exec = require("child_process").exec
, mode = "fetch"
// could be "config" or "autoconf" mode
if (process.argv[2] !== undefined) mode = process.argv[2]
exec("free", function(err, data) {
var total = arguments[1].split("\n")[1].split(/\s+/)[1];
if (mode === 'config') {
sys.puts("graph_title CouchDB RAM usage")
sys.puts("graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit " + total)
sys.puts("graph_category couchdb")
sys.puts("memory_vsize.label virtual memory")
sys.puts("memory_vsize.draw AREA")
sys.puts("memory_rss.label real memory")
sys.puts("memory_rss.draw STACK")
} else {
var vsize = 0
, rss = 0
exec("ps -U couchdb -u couchdb u", function(err, data) {
data = data.split("\n")
data.shift()
data.pop()
data.forEach(function(line) {
var values = line.split(/\s+/)
vsize += parseInt(values[4])
rss += parseInt(values[5])
})
sys.puts("memory_vsize.value " + (vsize * 1024))
sys.puts("memory_rss.value " + (rss * 1024))
})
}
})