From 1a64deeb894dc95e2645a75771732c6cc53a79ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 4 Oct 2023 01:35:06 +0200 Subject: Squash changes containing private information There were a lot of changes since the previous commit, but a lot of them contained personnal information about users. All thos changes got stashed into a single commit (history is kept in a different place) and private information was moved in a separate private repository --- modules/private/monitoring/plugins/check_eriomem | 83 ------------------------ 1 file changed, 83 deletions(-) delete mode 100755 modules/private/monitoring/plugins/check_eriomem (limited to 'modules/private/monitoring/plugins/check_eriomem') diff --git a/modules/private/monitoring/plugins/check_eriomem b/modules/private/monitoring/plugins/check_eriomem deleted file mode 100755 index 880b88a..0000000 --- a/modules/private/monitoring/plugins/check_eriomem +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -import os -import sys -import getopt -import signal -from subprocess import Popen, PIPE - -STATE_OK = 0 -STATE_WARNING = 1 -STATE_CRITICAL = 2 -STATE_UNKNOWN = 3 - -keys = sys.argv[1].split(",") - -def to_args(k): - access, secret = k.split(":", 1) - return [ - "s3cmd", - '-c=/dev/null', - '--no-check-certificate', - '--access_key={}'.format(access), - '--secret_key={}'.format(secret), - '--host=e.eriomem.net', - '--host-bucket=%(bucket)s.e.eriomem.net', - 'du' - ] - -max_size = 1024*1024*1024*1024 -warning_percent = 99.75 -critical_percent = 99.95 - -def output(code, msg): - print(msg) - sys.exit(code) - -def main(): - def handler(signum, frame): - raise IOError - signal.signal(signal.SIGALRM, handler) - signal.alarm(60) - - try: - ps = [Popen(to_args(a), stdout=PIPE, stderr=PIPE) for a in keys] - outs = [p.communicate() for p in ps] - rets = [p.wait() for p in ps] - except IOError: - for p in ps: - os.kill(p.pid, signal.SIGTERM) - output(STATE_UNKNOWN, - "Eriomem UNKNOWN - Command timeout after 60 seconds!") - - signal.alarm(0) - - if sum(rets) == 0: - usages = [int(out[0].decode().split("\n")[-2].split()[0]) for out in outs] - usage = sum(usages) - use_percent = 100 * usage / max_size - if use_percent > critical_percent: - output(STATE_CRITICAL, - "Eriomem CRITICAL - bucket usage: %s (%s%%);| size=%s;;;;" % - (sizeof_fmt(usage), use_percent, sizeof_fmt(usage))) - elif use_percent > warning_percent: - output(STATE_WARNING, - "Eriomem WARNING - bucket usage: %s (%s%%);| size=%s;;;;" % - (sizeof_fmt(usage), use_percent, sizeof_fmt(usage))) - else: - output(STATE_OK, - "Eriomem OK - bucket usage: %s (%d%%);| size=%s;;;;" % - (sizeof_fmt(usage), use_percent, sizeof_fmt(usage))) - else: - messages = "\n".join([out[0].decode() + out[1].decode() for out in outs]) - output(STATE_UNKNOWN, - "Eriomem UNKNOWN - Error in command") - -def sizeof_fmt(num): - for unit in ['','ko','Mo','Go','To','Po','Eo','Zo']: - if abs(num) < 1024.0: - return "%3.1f%s" % (num, unit) - num /= 1024.0 - return "%.1f%s%s" % (num, 'Yo') - -if __name__ == '__main__': - main() -- cgit v1.2.3