Skip to content

Commit

Permalink
Merge pull request #209 from linuxmaniac/vseva/208
Browse files Browse the repository at this point in the history
tools/view_stats.py: exit properly when no info is on Redis
  • Loading branch information
nickvsnetworking authored Oct 21, 2024
2 parents 030dc72 + b2a08f3 commit 2ce7945
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/view_stats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#This utility prints PyHSS stats stored in Redis
# This utility prints PyHSS stats stored in Redis
import yaml
import sys
with open(sys.path[0] + '/../config.yaml') as stream:
Expand All @@ -15,12 +15,13 @@

print("\n\nDiameter Peers:")
ActivePeerDict = r.get('ActivePeerDict')
if len(ActivePeerDict) == 0:
if ActivePeerDict is None or len(ActivePeerDict) == 0:
print("No connected peers.")
sys.exit()
ActivePeerDict = json.loads(ActivePeerDict)

for keys in ActivePeerDict:
print(keys)
for subkeys in ActivePeerDict[keys]:
print("\t" + str(subkeys) + ": \t" + str(ActivePeerDict[keys][subkeys]))
print('\n')
print('\n')

0 comments on commit 2ce7945

Please sign in to comment.