nagios: fine tune mail queue check on bastion01

Signed-off-by: Francois Andrieu <darknao@fedoraproject.org>
This commit is contained in:
Francois Andrieu 2020-08-15 10:25:43 +02:00
parent d203048115
commit 655d167750

View file

@ -13,8 +13,10 @@ parser.add_argument('-c', '--critical', dest='critical', type=int, default=50,
help="Critical threshold") help="Critical threshold")
parser.add_argument('-w', '--warning', dest='warning', type=int, default=20, parser.add_argument('-w', '--warning', dest='warning', type=int, default=20,
help="Warning threshold") help="Warning threshold")
parser.add_argument('-i', '--ignore', dest='ignore', type=int, default=5, parser.add_argument('-L', '--lower', dest='lower', type=int, default=5,
help="Ignore queues from the last X minutes (default: 5)") help="ignore queues ages lower than x minutes (default: 5)")
parser.add_argument('-H', '--higher', dest='higher', type=int, default=1440,
help="ignore queues ages higher than x minutes (default: 1440)")
args = parser.parse_args() args = parser.parse_args()
@ -30,7 +32,6 @@ mail_queue = 0
if args.domain == 'all': if args.domain == 'all':
mail_queue = len(output) mail_queue = len(output)
else: else:
for line in output: for line in output:
j = json.loads(line) j = json.loads(line)
if j["queue_name"] == 'active': if j["queue_name"] == 'active':
@ -38,7 +39,8 @@ else:
continue continue
queue_old = now - datetime.fromtimestamp(j["arrival_time"]) queue_old = now - datetime.fromtimestamp(j["arrival_time"])
if queue_old.total_seconds() / 60 < args.ignore: if (queue_old.total_seconds() / 60 < args.lower
or queue_old.total_seconds() / 60 > args.higher):
# Not old enough # Not old enough
continue continue