-
Notifications
You must be signed in to change notification settings - Fork 1
/
find_controller_services.py
50 lines (36 loc) · 1.89 KB
/
find_controller_services.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
41
42
43
44
45
46
47
48
49
50
__author__ = "Gaurang Shah"
__version__ = "1.0.0"
__maintainer__ = "Gaurang Shah"
__email__ = "[email protected]"
import requests
import os
from requests.packages.urllib3.exceptions import InsecureRequestWarning
import utils
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
OUTPUT_FILE = open("%s.out" % os.path.basename(__file__), "w+")
def _find_processor_schedule(group_id, group_name):
url = "https://%s:%s/nifi-api/process-groups/%s/processors" % (utils.NIFI_HOST, utils.NIFI_PORT, group_id)
header = {"Authorization": "Bearer %s" % utils.ACCESS_TOKEN}
r = requests.get(url, headers=header, verify=False)
resp = r.json()
processors = resp.get("processors")
for processor in processors:
component = processor.get("component")
config = component.get("config")
# if component.get("state") == "RUNNING" and config.get("schedulingStrategy") == "CRON_DRIVEN":
# print >>OUTPUT_FILE, "%s,%s,%s,%s" % (group_id, group_name, processor.get("id"), config.get("schedulingPeriod"))
if config.get("properties") and "Database Connection Pooling Service" in config.get("properties"):
print >>OUTPUT_FILE, "%s,%s,%s,%s" % (group_id, group_name, processor.get("id"), config.get("properties").get("Database Connection Pooling Service"))
def find_schedule(processor_groups):
for processor_group in processor_groups:
p = processor_group.get("processGroupStatusSnapshot")
if len(p.get("processGroupStatusSnapshots")) > 0:
find_schedule(p.get("processGroupStatusSnapshots"))
else:
_find_processor_schedule(p.get("id"), p.get("name"))
if __name__ == '__main__':
username, password = utils.read_credential_from_console()
token = utils.get_token(username, password)
utils.ACCESS_TOKEN = token
root_processor = utils.get_root_processor()
find_schedule(root_processor)