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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
#
# Adjusts the testnet monitor dashboard for the specified release channel
#
import sys
import json
if len(sys.argv) != 3:
    print('Error: Dashboard or Channel not specified')
    sys.exit(1)
dashboard_json = sys.argv[1]
channel = sys.argv[2]
if channel not in ['edge', 'beta', 'stable']:
    print('Error: Unknown channel:', channel)
    sys.exit(2)
with open(dashboard_json, 'r') as read_file:
    data = json.load(read_file)
if channel == 'stable':
    # Stable dashboard only allows the user to select between the stable
    # testnet databases
    data['title'] = 'Testnet Monitor'
    data['uid'] = 'testnet'
    data['templating']['list'] = [{'allValue': None,
                                   'current': {'text': 'testnet',
                                               'value': 'testnet'},
                                   'hide': 1,
                                   'includeAll': False,
                                   'label': 'Testnet',
                                   'multi': False,
                                   'name': 'testnet',
                                   'options': [{'selected': False,
                                                'text': 'testnet',
                                                'value': 'testnet'},
                                               {'selected': True,
                                                'text': 'testnet-perf',
                                                'value': 'testnet-perf'}],
                                   'query': 'testnet,testnet-perf',
                                   'type': 'custom'}]
else:
    # Non-stable dashboard only allows the user to select between all testnet
    # databases
    data['title'] = 'Testnet Monitor ({})'.format(channel)
    data['uid'] = 'testnet-' + channel
    data['templating']['list'] = [{'allValue': None,
                                   'current': {'text': 'testnet',
                                               'value': 'testnet'},
                                   'datasource': 'Solana Metrics (read-only)',
                                   'hide': 1,
                                   'includeAll': False,
                                   'label': 'Testnet',
                                   'multi': False,
                                   'name': 'testnet',
                                   'options': [],
                                   'query': 'show databases',
                                   'refresh': 1,
                                   'regex': 'testnet.*',
                                   'sort': 1,
                                   'tagValuesQuery': '',
                                   'tags': [],
                                   'tagsQuery': '',
                                   'type': 'query',
                                   'useTags': False},
                                   {'allValue': None,
                                    'datasource': 'Solana Metrics (read-only)',
                                    'hide': 0,
                                    'includeAll': True,
                                    'label': 'HostID',
                                    'multi': False,
                                    'name': 'hostid',
                                    'options': [],
                                    'query': 'SELECT DISTINCT(\"host_id\") FROM \"$testnet\".\"autogen\".\"counter-fullnode-new\" ',
                                    'refresh': 2,
                                    'regex': '',
                                    'sort': 1,
                                    'tagValuesQuery': '',
                                    'tags': [],
                                    'tagsQuery': '',
                                    'type': 'query',
                                    'useTags': False}]
with open(dashboard_json, 'w') as write_file:
    json.dump(data, write_file, indent=2)