#!/usr/bin/python3 import sys import re import os from rrdtool import update as rrd_update # pylint: disable=no-name-in-module from addEvent import send_event SUBFOLDER = '' # print(datetime.datetime.now().strftime("%V")) re1 = re.compile(r"load average:\s?(\d{1,2}\.\d{1,2}),\s?(\d{1,2}\.\d{1,2}),\s?(\d{1,2}\.\d{1,2})") re2 = re.compile(r"\d+\.\d+") re3 = re.compile(r"\d+") root = 0 boot = 0 home = 0 opt = 0 tmp = 0 var = 0 for line in sys.stdin: if '/' in line: words = line.split() if words[-1] == '/': root = words[-2].replace('%', '') if words[-1] == '/mnt/hdrive': boot = words[-2].replace('%', '') if words[-1] == '/home': home = words[-2].replace('%', '') if words[-1] == '/opt': opt = words[-2].replace('%', '') if words[-1] == '/tmp': tmp = words[-2].replace('%', '') if words[-1] == '/var': var = words[-2].replace('%', '') # print("{0}:{1}:{2}:{3}:{4}:{5}".format(root, boot, home, opt, tmp, var)) ret = rrd_update(os.path.join(SUBFOLDER, 'disk.rrd'), 'N:{0}:{1}:{2}:{3}:{4}:{5}'.format(root, boot, home, opt, tmp, var)) if float(root) > 90.0: send_event("ERROR,disk,5,30,Unexpected high disk-usagefor the last few minutes: {}".format(root))