forked from rucio/rucio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_activemq_queue
executable file
·39 lines (30 loc) · 1.05 KB
/
check_activemq_queue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
# Copyright European Organization for Nuclear Research (CERN) 2013
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Authors:
# - Thomas Beermann, <thomas.beermann@cern.ch>, 2014
'''
Probe to check if an ActiveMQ queue is above a certain threshold.
'''
from sys import argv, exit
from requests import get
# Exit statuses
OK, WARNING, CRITICAL, UNKNOWN = 0, 1, 2, 3
if __name__ == "__main__":
broker = argv[1]
destination = argv[2]
threshold = int(argv[3])
url = """http://%s:61004/j4p/read/org.apache.activemq:type=Broker,brokerName=atlas_%s,destinationType=Queue,destinationName=%s/QueueSize""" % (broker, broker, destination)
r = get(url)
if r.status_code != 200:
exit(UNKNOWN)
current = r.json()['value']
if current > (2 * threshold):
exit(CRITICAL)
elif current > threshold:
exit(WARNING)
exit(OK)