nagios: fine tune mail queue check on bastion01
Signed-off-by: Francois Andrieu <darknao@fedoraproject.org>
This commit is contained in:
parent
d203048115
commit
655d167750
1 changed files with 23 additions and 21 deletions
|
@ -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()
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,40 +30,40 @@ 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:
|
||||||
|
j = json.loads(line)
|
||||||
|
if j["queue_name"] == 'active':
|
||||||
|
# Ignore Active queue
|
||||||
|
continue
|
||||||
|
|
||||||
for line in output:
|
queue_old = now - datetime.fromtimestamp(j["arrival_time"])
|
||||||
j = json.loads(line)
|
if (queue_old.total_seconds() / 60 < args.lower
|
||||||
if j["queue_name"] == 'active':
|
or queue_old.total_seconds() / 60 > args.higher):
|
||||||
# Ignore Active queue
|
# Not old enough
|
||||||
continue
|
continue
|
||||||
|
|
||||||
queue_old = now - datetime.fromtimestamp(j["arrival_time"])
|
for recipient in j['recipients']:
|
||||||
if queue_old.total_seconds() / 60 < args.ignore:
|
if recipient['address'].endswith(args.domain):
|
||||||
# Not old enough
|
mail_queue += 1
|
||||||
continue
|
break
|
||||||
|
|
||||||
for recipient in j['recipients']:
|
|
||||||
if recipient['address'].endswith(args.domain):
|
|
||||||
mail_queue += 1
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
ret_val = 0
|
ret_val = 0
|
||||||
msg = ("OK: Queue length for %s destination < %s (%s)"
|
msg = ("OK: Queue length for %s destination < %s (%s)"
|
||||||
% (args.domain, args.warning, mail_queue))
|
% (args.domain, args.warning, mail_queue))
|
||||||
|
|
||||||
if mail_queue > args.warning:
|
if mail_queue > args.warning:
|
||||||
msg = ("WARNING: Queue length for %s destination > %s (%s)"
|
msg = ("WARNING: Queue length for %s destination > %s (%s)"
|
||||||
% (args.domain, args.warning, mail_queue))
|
% (args.domain, args.warning, mail_queue))
|
||||||
ret_val = 1
|
ret_val = 1
|
||||||
|
|
||||||
if mail_queue > args.critical:
|
if mail_queue > args.critical:
|
||||||
msg = ("CRITICAL: Queue length for %s destination > %s (%s)"
|
msg = ("CRITICAL: Queue length for %s destination > %s (%s)"
|
||||||
% (args.domain, args.critical, mail_queue))
|
% (args.domain, args.critical, mail_queue))
|
||||||
ret_val = 2
|
ret_val = 2
|
||||||
|
|
||||||
|
|
||||||
print(msg)
|
print(msg)
|
||||||
sys.exit(ret_val)
|
sys.exit(ret_val)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue