first commit
This commit is contained in:
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/python3
|
||||
import sys
|
||||
import re
|
||||
import datetime
|
||||
import os
|
||||
from rrdtool import update as rrd_update # pylint: disable=no-name-in-module
|
||||
|
||||
SUBFOLDER = ''
|
||||
#print(datetime.datetime.now().strftime("%V"))
|
||||
|
||||
# root@plex:/opt/monitor# free
|
||||
# total used free shared buff/cache available
|
||||
# Mem: 5904284 353696 190204 3524 5360384 5238048
|
||||
# Swap: 2097148 248064 1849084
|
||||
|
||||
|
||||
re3 = re.compile(r"\d+")
|
||||
|
||||
def save(filename, string):
|
||||
fo = open(os.path.join(SUBFOLDER, filename+'_'+datetime.datetime.now().strftime("%V"))+'.log', "a")
|
||||
fo.writelines( string + "\n" )
|
||||
fo.close()
|
||||
|
||||
for line in sys.stdin:
|
||||
if 'Mem:' in line:
|
||||
mems = re3.findall(line)
|
||||
# save('mem_', ";".join(mems))
|
||||
print('N:{0}:{1}:{2}:{3}'.format( mems[0], mems[2], mems[1], int(mems[0])-int(mems[5])))
|
||||
ret = rrd_update(os.path.join(SUBFOLDER, 'mem.rrd'), 'N:{0}:{1}:{2}:{3}'.format( mems[0], mems[2], mems[1], int(mems[0])-int(mems[5])) )
|
||||
|
||||
Reference in New Issue
Block a user