mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
[monit_parser] fix whitespace issues
This commit is contained in:
parent
207f801148
commit
0f24fe00eb
@ -17,7 +17,7 @@ def sanitize(s):
|
|||||||
out = str()
|
out = str()
|
||||||
for char in s:
|
for char in s:
|
||||||
if char.lower() in OK_CHARS:
|
if char.lower() in OK_CHARS:
|
||||||
out += char
|
out += char
|
||||||
return out
|
return out
|
||||||
|
|
||||||
procs = dict()
|
procs = dict()
|
||||||
@ -33,20 +33,20 @@ for line in output:
|
|||||||
m = re.match("^Process '(.*)'.*$", line)
|
m = re.match("^Process '(.*)'.*$", line)
|
||||||
if m:
|
if m:
|
||||||
cur_proc = sanitize(m.group(1))
|
cur_proc = sanitize(m.group(1))
|
||||||
try:
|
try:
|
||||||
procs[cur_proc]
|
procs[cur_proc]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
procs[cur_proc] = dict()
|
procs[cur_proc] = dict()
|
||||||
continue
|
continue
|
||||||
m = re.match(" memory kilobytes total\s+([0-9]+).*$", line)
|
m = re.match(" memory kilobytes total\s+([0-9]+).*$", line)
|
||||||
if m:
|
if m:
|
||||||
procs[cur_proc]["total_memory"] = m.group(1)
|
procs[cur_proc]["total_memory"] = m.group(1)
|
||||||
continue
|
continue
|
||||||
m = re.match(" cpu percent total\s+([.0-9]+)%.*$", line)
|
m = re.match(" cpu percent total\s+([.0-9]+)%.*$", line)
|
||||||
if m:
|
if m:
|
||||||
procs[cur_proc]["total_cpu"] = m.group(1)
|
procs[cur_proc]["total_cpu"] = m.group(1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == 'config':
|
if len(sys.argv) > 1 and sys.argv[1] == 'config':
|
||||||
print 'graph_title Per process stats from Monit'
|
print 'graph_title Per process stats from Monit'
|
||||||
print 'graph_vlabel numbers'
|
print 'graph_vlabel numbers'
|
||||||
@ -55,7 +55,7 @@ if len(sys.argv) > 1 and sys.argv[1] == 'config':
|
|||||||
for stat in procs[process]:
|
for stat in procs[process]:
|
||||||
print "monit_%s_%s.label %s.%s" % (process, stat, process, stat)
|
print "monit_%s_%s.label %s.%s" % (process, stat, process, stat)
|
||||||
if stat == 'total_memory':
|
if stat == 'total_memory':
|
||||||
print "monit_%s_%s.warning 1:" % (process, stat)
|
print "monit_%s_%s.warning 1:" % (process, stat)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
for process in procs:
|
for process in procs:
|
||||||
|
Loading…
Reference in New Issue
Block a user