-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivemq-heapusage-check.py
40 lines (40 loc) · 1.17 KB
/
activemq-heapusage-check.py
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
40
#!/usr/bin/python
import requests
from requests.auth import HTTPBasicAuth
from requests.exceptions import ConnectionError
import sys
try:
data = requests.get('http://localhost:8161/api/jolokia/read/java.lang:type=Memory/HeapMemoryUsage/used', auth=HTTPBasicAuth('admin', 'admin'))
data = data.json()
heapusage = data['value']
except (ConnectionError, NameError):
with open('/var/log/activemq/activemq.log') as file:
log_data = file.read()
if 'slave' in log_data:
print('OK. This Host is in Slave Mode')
sys.exit(0)
else:
print('UNKNOWN')
sys.exit(3)
#print(heapusage)
if heapusage < 3000000000:
print('OK. Heap Utilization is at a healthy level ---- {}'.format(heapusage))
sys.exit(0)
elif 3000000000 <= heapusage < 3500000000:
print("WARNING. Heap Utilization is approaching 90% Utilizationi ---- {}".format(heapusage))
sys.exit(1)
elif heapusage >= 3500000000:
print("CRITICAL. Heap Utilization has exceeded 90% Utilization ---- {}".format(heapusage))
sys.exit(2)
else:
print('UNKNOWN')
sys.exit(3)