Skip to content
Snippets Groups Projects
Commit 38e5243c authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Added more detailed info to run the tool, used the linux-friendly older jq formatting

parent bd819875
No related branches found
No related tags found
No related merge requests found
......@@ -14,17 +14,46 @@ cat gwcert.bin | openssl x509 -outform PEM > gwcert.pem
Now download the network definition file:
```
bin/client getndf --gwhost "194.163.163.77:22840" --cert gwcert.pem > ndf.json
git clone https://git.xx.network/elixxir/client.git
cd client
export GOPRIVATE="gitlab.com/elixxir/*,gitlab.com/xx_network/*,git.xx.network/elixxir/*,git.xx.network/xx_network/*"
go mod tidy
go build -o ../xxclient main.go
cd ..
./xxclient getndf --gwhost "194.163.163.77:22840" --cert gwcert.pem > ndf.json
cat ndf.json
```
If it worked, you should see the ndf data.
Now we can generate our targets file:
```
jq '.Gateways.[].Address' ndf.json > nodes.txt
jq '.Gateways[].Address' ndf.json | sed 's/"//g' > nodes.txt
```
And you should see:
```
% head nodes.txt
66.94.126.88:22840
200.69.14.230:22840
185.218.125.248:22840
206.221.176.142:22840
135.181.226.128:22840
195.201.171.211:22840
gateway.xxnetwork.nl:22840
159.148.20.195:22840
94.130.10.38:22840
65.21.90.237:22840
...
```
Now we can run the stats command:
```
go run . stats --input_file nodes.txt
go mod tidy
go build ./...
go run main.go status --input_file nodes.txt > stats.json
python3 json2csv.py stats.json > stats.csv
```
#! /usr/bin/env python3
import json
import csv
import sys
def flatten(data, prefix=""):
result = {}
for k, v in data.items():
if isinstance(v, dict):
result.update(flatten(v, f"{prefix}{k}."))
else:
result[f"{prefix}{k}"] = v
return result
def main():
if len(sys.argv) < 2:
print("Error: Please provide an input JSON file")
sys.exit(1)
with open(sys.argv[1], "r") as f:
data = json.load(f)
# now we flatten the data
csvdata = [flatten(x) for x in data]
# write to csv
writer = csv.writer(sys.stdout)
writer.writerow(csvdata[0].keys())
for row in csvdata:
writer.writerow(row.values())
if __name__ == "__main__":
main()
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment