first commit
This commit is contained in:
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/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# uptime
|
||||
# 16:05:39 up 422 days, 1:05, 1 user, load average: 0.01, 0.03, 0.01
|
||||
|
||||
re2 = re.compile(r"\d+\.\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 'load average' in line:
|
||||
avgs = re2.findall(line)
|
||||
# print(";".join(avgs))
|
||||
ret = rrd_update(os.path.join(SUBFOLDER, 'load.rrd'), 'N:{0}:{1}:{2}'.format(avgs[0],avgs[1],avgs[2]))
|
||||
if float(avgs[2]) > 5.0:
|
||||
send_event("ERROR,avgs,3,7,Unexpected high average load15 for the last minutes: {}".format(avgs[2]))
|
||||
Reference in New Issue
Block a user