Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make dump function true json #744

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
edd8224
make dump function true json
Rehouma63 Aug 10, 2023
deba5da
almost done
Rehouma63 Aug 11, 2023
f0f72fb
done but weird error when validating whith jsonlint.com
Rehouma63 Aug 11, 2023
b90c1dd
l
Rehouma63 Aug 14, 2023
698fd42
s
Rehouma63 Aug 14, 2023
af68415
Fixed config, still working on the other issue...
Rehouma63 Aug 14, 2023
7454306
Json valid using jsonformatter.org, jsonlint returns a Error: Duplica…
Rehouma63 Aug 15, 2023
7268b21
make dump function true json
Rehouma63 Aug 10, 2023
9db5050
almost done
Rehouma63 Aug 11, 2023
35f6a56
done but weird error when validating whith jsonlint.com
Rehouma63 Aug 11, 2023
588d195
l
Rehouma63 Aug 14, 2023
d3d939e
s
Rehouma63 Aug 14, 2023
efd7248
Fixed config, still working on the other issue...
Rehouma63 Aug 14, 2023
21a98ef
Json valid using jsonformatter.org, jsonlint returns a Error: Duplica…
Rehouma63 Aug 15, 2023
33c63a6
Merge branch 'v03_issue634' of https://github.com/MetPX/Sarracenia in…
petersilva Aug 17, 2023
5e620da
missing instances
Rehouma63 Aug 17, 2023
3d99df6
Merge branch 'v03_issue634' of https://github.com/MetPX/Sarracenia in…
petersilva Aug 17, 2023
0bd4413
remove trash
petersilva Aug 17, 2023
4d58c76
saving changes, need to restart pc ...
Rehouma63 Aug 17, 2023
7f09097
almost done, saving changes just in case ...
Rehouma63 Aug 17, 2023
c92903d
Fix duplicate Key error, added URL field in nbroker summaries and mad…
Rehouma63 Aug 18, 2023
21b0824
this was a temporary file put in the repo by mistake. needs to go.
petersilva Aug 18, 2023
8eab9fd
removed last commas alone on lines, and adjusted some spacing.
petersilva Aug 18, 2023
1fea06f
one last stray comma on a line by itself.
petersilva Aug 18, 2023
789192d
re-writing the pid stuff a bit more pythonic.
petersilva Aug 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions kk
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{



"Processes" : {


}


,"Configs" : {


"cpost": {
},
"cpump": {
},
"flow": {
},
"poll": {
},
"post": {
},
"report": {
},
"sarra": {
},
"sender": {
},
"shovel": {
},
"subscribe": {
"hpfx_amis" : {"status": "stopped", "options": {"omitted": "use show"}, "instances": 5, "credentials": ["omitted"]} },
"watch": {
},
"winnow": {
}

},"States": {


"cpost": {
"NONE" : {"instance_pids": {}, "queueName": null, "status": "removed", "has_state": false, "noVip": null}
}
,
"cpump": {
"NONE" : {"instance_pids": {}, "queueName": null, "status": "removed", "has_state": false, "noVip": null}
}
,
"flow": {
}
,
"poll": {
}
,
"post": {
}
,
"report": {
}
,
"sarra": {
}
,
"sender": {
}
,
"shovel": {
}
,
"subscribe": {
"web_hungry" : {"instance_pids": {}, "queueName": "q_anonymous_subscribe.web_hungry.72994649.59972887", "status": "removed", "has_state": false, "noVip": null}
,
"hpfx_amis" : {"instance_pids": {}, "queueName": "q_anonymous_subscribe.hpfx_amis.63551780.29192638", "has_state": false, "noVip": null, "instance_metrics": {"0": {"flow": {"stop_requested": true, "last_housekeeping": 1692238144.4784622, "transferConnected": true, "transferConnectStart": 1692238148.0347462, "transferConnectTime": 2.8959105014801025, "transferRxBytes": 1356, "transferTxBytes": 0, "transferRxFiles": 7, "transferTxFiles": 0, "msgRate": 2.6889130204653346, "current_sleep": 0.8}, "gather.message": {"connected": true, "disconnectLast": 0, "disconnectTime": 0, "disconnectCount": 0, "rxByteCount": 970, "rxGoodCount": 7, "rxBadCount": 0, "txByteCount": 0, "txGoodCount": 0, "txBadCount": 0}, "retry": {"msgs_in_download_retry": 0, "msgs_in_post_retry": 0}, "log": {"lagMax": 3.1565592288970947, "lagTotal": 9.28438425064087, "lagMessageCount": 7, "rejectCount": 0}, "sarracenia.transfer": {"byteRateInstant": 1223338.6666666667}, "status": {"mtime": 1692238148.0295062}}}, "metrics": {"byteRate": 0, "rejectCount": 0, "last_housekeeping": 0, "rxByteCount": 0, "rxGoodCount": 0, "rxBadCount": 0, "txByteCount": 0, "txGoodCount": 0, "txBadCount": 0, "lagMax": 0, "lagTotal": 0, "lagMessageCount": 0, "disconnectTime": 0, "transferConnectTime": 0, "transferRxBytes": 0, "transferRxFiles": 0, "transferTxBytes": 0, "transferTxFiles": 0, "msgs_in_post_retry": 0, "msgs_in_download_retry": 0}, "missing_instances": [], "hung_instances": [], "resource_usage": {"uss": 0, "rss": 0, "vms": 0, "user_cpu": 0.0, "system_cpu": 0.0}}
,
"tsunami" : {"instance_pids": {}, "queueName": "q_anonymous_subscribe.tsunami.44130742.58093304", "status": "removed", "has_state": false, "noVip": null}
,
"flow_demo" : {"instance_pids": {}, "queueName": "q_anonymous.subscriber_test2", "status": "removed", "has_state": false, "noVip": null, "instance_metrics": {"0": {"flow": {"stop_requested": true, "last_housekeeping": 1687202619.4086704, "transferConnected": true, "transferConnectStart": 1687202619.9445, "transferConnectTime": 0.5186672210693359, "transferRxBytes": 46361, "transferTxBytes": 0, "transferRxFiles": 5, "transferTxFiles": 0, "msgRate": 11.200466429742907, "current_sleep": 0.1}, "gather.message": {"connected": true, "disconnectLast": 0, "disconnectTime": 0, "disconnectCount": 0, "rxByteCount": 730, "rxGoodCount": 5, "rxBadCount": 0, "txByteCount": 0, "txGoodCount": 0, "txBadCount": 0}, "retry": {"msgs_in_download_retry": 0, "msgs_in_post_retry": 0}, "log": {"lagMax": 1499.9188470840454, "lagTotal": 7498.568261861801, "lagMessageCount": 5, "rejectCount": 0}, "sarracenia.transfer": {"byteRateInstant": 2696338.285714286}, "status": {"mtime": 1687202619.9406805}}}}
}
,
"watch": {
}
,
"winnow": {
}
},


"Bindings": {



"host":{
"localhost": {


"exchanges": { },
"queues": {

}
},
"hpfx.collab.science.gc.ca": {


"exchanges": { "xpublic": ["q_anonymous_subscribe.hpfx_amis.63551780.29192638"] },
"queues": {
"q_anonymous_subscribe.hpfx_amis.63551780.29192638": "['subscribe/hpfx_amis']"
}
}}
},
"nbroker summaries": {



"broker": {
"localhost":{

"URL": "admin: amqp://bunnymaster@localhost",
"exchanges": [ ],"queues": []
},
"hpfx.collab.science.gc.ca":{

"URL": "admin: none",
"exchanges": [ "xpublic-1" ],"queues": ["q_anonymous_subscribe.hpfx_amis.63551780.29192638-1" ]
}}
},

"Missing instances" : [


]
}

Binary file added sarracenia/kk
Binary file not shown.
128 changes: 83 additions & 45 deletions sarracenia/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2139,46 +2139,76 @@ def stop(self):
print('\t%s: %s' % (p, self.procs[p]['cmdline'][0:5]))
return 1

def dump(self):
def dump(self):
""" Printing all running processes, configs, states

:return:
"""
print('{\n')
print('\n\n"Processes" : { \n\n')
for pid in self.procs:
print('\t%s: %s' % (pid, json.dumps(self.procs[pid], sort_keys=True, indent=4) ))
#print('\t%s: %s' % (pid, self.procs[pid] ))

print('},\n\n\"Configs\" : {\n\n')
for c in self.configs:
#procs_length = len(self.procs)
#for index,pid in enumerate(self.procs):
# print('\t\"%s\": %s' % (pid, json.dumps(self.procs[pid], sort_keys=True, indent=4)), end='')
# if procs_length-1 > index:
# print(',')

print(','.join( map( lambda pid: f'"{pid}": {json.dumps(self.procs[pid], sort_keys=True, indent=1)}' , self.procs.keys() ) ))
print('},')

print('\n\n"Configs\" : {\n\n')
configLength = len(self.configs)
for indexConfig,c in enumerate(self.configs):
lengthSelfConfigC = len(self.configs[c])
print('\t\"%s\": { ' % c)
for cfg in self.configs[c]:
for indexC,cfg in enumerate(self.configs[c]):
self.configs[c][cfg]['options']={ 'omitted': 'use show' }
self.configs[c][cfg]['credentials']=[ 'omitted' ]
print('\t\t\"%s\" : { %s }, ' % (cfg, json.dumps(self.configs[c][cfg])))
print("\t\t}")
print('\t\t\"%s\" : %s ' % (cfg, json.dumps(self.configs[c][cfg])),end="")
if lengthSelfConfigC-1 > indexC:
print(',')
print('}',end="")
if configLength-1 > indexConfig or configLength == 0:
print(',')

print('},\n\n"States": { \n\n')
for c in self.states:
lengthSelfStates = len(self.states)
for indexSelfStates,c in enumerate(self.states):
print('\t\"%s\": { ' % c)
for cfg in self.states[c]:
print('\t\t\"%s\" : { %s },' % (cfg, json.dumps(self.states[c][cfg])))
print( "\t}" )

print('}\n\n"Bindings": { \n\n')

for h in self.brokers:
print("\n\"host\": { \"%s\": { " % h)
print("\n\"exchanges\": { ")
for x in self.brokers[h]['exchanges']:
print("\t\"%s\": { %s }," % (x, json.dumps(self.brokers[h]['exchanges'][x])))
print("},\n\"queues\": {")
for q in self.brokers[h]['queues']:
print("\t\"%s\": { %s }, " % (q, self.brokers[h]['queues'][q]))
print( "}},\n" )

print(',\n\"nbroker summaries": {\n\n')
for h in self.brokers:
lengthC = len(self.states[c])
for indexC,cfg in enumerate(self.states[c]):
print('\t\t\"%s\" : %s ' % (cfg, json.dumps(self.states[c][cfg])))
if lengthC -1 > indexC:
print(',')
print( "\t}", end="")
if lengthSelfStates -1 > indexSelfStates:
print(',')
print('},')

print('\n\n"Bindings": { \n\n')
lengthSelfBrokers = len(self.brokers)
print("\n\"host\":{\n\t", end="")
for indexSelfBrokers,h in enumerate(self.brokers):
print("\"%s\": { \n" % h)
print("\n\t\t\"exchanges\": { ", end="")
lengthExchange = len(self.brokers[h]['exchanges'])
for indexExchange,x in enumerate(self.brokers[h]['exchanges']):
print("\"%s\": %s " % (x, json.dumps(self.brokers[h]['exchanges'][x])), end="")
if lengthExchange -1 > indexExchange:
print(',')
print("},\n\t\t\"queues\": {")
lengthBrokersQueues = len(self.brokers[h]['queues'])
for indexBrokerQueues,q in enumerate(self.brokers[h]['queues']):
print("\t\"%s\": \"%s\" " % (q, self.brokers[h]['queues'][q]), end="")
if lengthBrokersQueues -1 > indexBrokerQueues:
print(',')
print( " \n}\n}",end="")
if lengthSelfBrokers - 1 > indexSelfBrokers:
print(',')

print('}\n},\n"nbroker summaries": {\n\n')
lengthSelfBroker = len(self.brokers)
print('\n\"broker\": {')
for indexSelfBroker,h in enumerate(self.brokers):
if 'admin' in self.brokers[h]:
admin_url = self.brokers[h]['admin'].url
admin_urlstr = "%s://%s@%s" % ( admin_url.scheme, \
Expand All @@ -2188,22 +2218,31 @@ def dump(self):
a = 'admin: %s' % admin_urlstr
else:
a = 'admin: none'
print('\n\"broker\": { \"%s\":\"%s\" }' % (h, a))
print('\n\"exchanges\": [ ', end='')
for x in self.exchange_summary[h]:
print("\"%s-%d\", " % (x, self.exchange_summary[h][x]), end='')
print(']')
print('\n\"queues\": [', end='')
for q in self.brokers[h]['queues']:
print("\"%s-%d\", " % (q, len(self.brokers[h]['queues'][q])),
end='')
print(']')

print('}\n\n\"Missing instances\" : { \n\n')
for instance in self.missing:
print('\"%s\":{' % (h))

print('\n\"URL\": \"%s\",\n\"exchanges\": [ ' %(a), end='')
lengthExchangeSummary = len(self.exchange_summary[h])
for indexSummary,x in enumerate(self.exchange_summary[h]):
print("\"%s-%d\" " % (x, self.exchange_summary[h][x]), end='')
if lengthExchangeSummary -1 > indexSummary:
print(',')
print('],"queues\": [', end="")
lengthBrokersQueues = len(self.brokers[h]['queues'])
for indexBrokersSummary,q in enumerate(self.brokers[h]['queues']):
print("\"%s-%d\" " % (q, len(self.brokers[h]["queues"][q])),end="")
if lengthBrokersQueues -1 > indexBrokersSummary:
print(',')
print(']\n}', end="")
if lengthSelfBroker -1 > indexSelfBroker:
print(',')
print('}\n},\n\n\"Missing instances\" : [\n\n')
lengthMissing = len(self.missing)
for indexMissing,instance in enumerate(self.missing):
(c, cfg, i) = instance
print('\t\t\"%s\" : \"%s %d\",' % (c, cfg, i))
print('\t\t}')
print('\t\t\"%s/%s_%d\"' % (c, cfg, i),end="")
if lengthMissing - 1 > indexMissing:
print(',')
print('] }')

def status(self):
""" v3 Printing prettier statuses for each component/configs found
Expand Down Expand Up @@ -2774,7 +2813,6 @@ def main():
gs.disable()

if action == 'dump':
print('dumping: ', end='', flush=True)
gs.dump()

if action == 'edit':
Expand Down