Skip to content

Commit 68cb3e2

Browse files
committed
.
1 parent b631190 commit 68cb3e2

File tree

6 files changed

+59
-173
lines changed

6 files changed

+59
-173
lines changed

client_connect_listen.py

-73
This file was deleted.

client_connect_publish.py

-79
This file was deleted.

contrib/blockperf.env

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To have this file loaded in a bash session use
2+
# set -a && source blockperf.env
3+
#
4+
BLOCKPERF_NODE_CONFIG="/opt/cardano/cnode/files/config.json"
5+
BLOCKPERF_RELAY_PUBLIC_IP="35.158.252.71"
6+
#BLOCKPERF_RELAY_PUBLIC_PORT="3001"
7+
BLOCKPERF_OPERATOR="devmanuel"
8+
BLOCKPERF_CLIENT_CERT="/home/ubuntu/devmanuel-certificate.pem"
9+
BLOCKPERF_CLIENT_KEY="/home/ubuntu/devmanuel-private.key"
10+
BLOCKPERF_TOPIC_BASE="blockperf"
11+
BLOCKPERF_BROKER_URL="a12j2zhynbsgdv-ats.iot.eu-central-1.amazonaws.com"
12+
#BLOCKPERF_BROKER_PORT="8883"

contrib/blockperf.service

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Type=simple
77
Restart=always
88
RestartSec=20
99
User=ubuntu
10-
Environment=someenvfile
10+
Environment=/opt/cardano/cnode/blockperf/contrib/blockperf.env
1111
ExecStart=/opt/cardano/cnode/blockperf/venv/bin/blockperf run /opt/cardano/cnode/blockperf/blockperf.ini
1212
KillSignal=SIGINT
1313
SyslogIdentifier=blockperf

src/blockperf/cli.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
logging.basicConfig(
1313
level=logging.DEBUG,
14-
filename='/home/ubuntu/src/blockperf/blockperf.log',
14+
filename='/opt/cardano/cnode/blockperf/blockperf.log',
1515
filemode='w',
1616
format="%(name)s %(threadName)s [%(asctime)s %(levelname)s] %(message)s",
1717
datefmt='%H:%M:%S'
@@ -24,20 +24,19 @@
2424
def main(verbose):
2525
"""Blockperf.py - Cardano-network block performance measurement and analysis.
2626
27-
This script is based off of blockperf.sh which collects certain metrics from
28-
the cardano-node and sends it to an aggregation services for further
29-
analysis.
27+
This script is based on blockperf.sh which collects data from the cardano-node
28+
and sends it to an aggregation services for further analysis.
3029
"""
3130
# dont print() but click.echo()
3231
click.echo("Main runs")
3332
pass
3433

3534

36-
@click.command("run", short_help="Runs blockperf with given configuration")
35+
@click.command("run", short_help="Runs blockperf")
3736
@click.argument(
38-
"config_file_path", required=True, type=click.Path(resolve_path=True, exists=True)
37+
"config_file_path", required=False, type=click.Path(resolve_path=True, exists=True)
3938
)
40-
def cmd_run(config_file_path):
39+
def cmd_run(config_file_path=None):
4140
"""Run blockperf with given configuration"""
4241
try:
4342
LOG.info("Start blockperf")

src/blockperf/config.py

+40-13
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
Why configparser? Because its simple. There is a blockperf.ini file in the
33
contrib/ folder which has all options and a short explanation of what they do.
44
"""
5-
from pathlib import Path
6-
from configparser import ConfigParser
7-
import os
85
import json
6+
import os
7+
from configparser import ConfigParser
8+
from pathlib import Path
9+
from typing import Union
910

1011

1112
class ConfigError(Exception):
@@ -15,9 +16,10 @@ class ConfigError(Exception):
1516
class AppConfig:
1617
config_parser: ConfigParser
1718

18-
def __init__(self, config: Path):
19+
def __init__(self, config: Union[Path, None]):
1920
self.config_parser = ConfigParser()
20-
self.config_parser.read(config)
21+
if config:
22+
self.config_parser.read(config)
2123

2224
# def validate_config(self):
2325
# node_config_folder = node_config_path.parent
@@ -75,33 +77,48 @@ def network_magic(self) -> int:
7577

7678
@property
7779
def relay_public_ip(self) -> str:
78-
relay_public_ip = self.config_parser.get("DEFAULT", "relay_public_ip")
80+
relay_public_ip = os.getenv(
81+
"BLOCKPERF_RELAY_PUBLIC_IP",
82+
self.config_parser.get("DEFAULT", "relay_public_ip", fallback=None)
83+
)
7984
if not relay_public_ip:
8085
raise ConfigError("'relay_public_ip' not set!")
8186
return relay_public_ip
8287

8388
@property
8489
def relay_public_port(self) -> int:
85-
relay_public_port = int(self.config_parser.get("DEFAULT", "relay_public_port", fallback=3001))
90+
relay_public_port = int(os.getenv(
91+
"BLOCKPERF_RELAY_PUBLIC_PORT",
92+
self.config_parser.get("DEFAULT", "relay_public_port", fallback=3001)
93+
))
8694
return relay_public_port
8795

8896
@property
8997
def client_cert(self) -> str:
90-
client_cert = self.config_parser.get("DEFAULT", "client_cert")
98+
client_cert = os.getenv(
99+
"BLOCKPERF_CLIENT_CERT",
100+
self.config_parser.get("DEFAULT", "client_cert", fallback=None)
101+
)
91102
if not client_cert:
92103
raise ConfigError("No client_cert set")
93104
return client_cert
94105

95106
@property
96107
def client_key(self) -> str:
97-
client_key = self.config_parser.get("DEFAULT", "client_key")
108+
client_key = os.getenv(
109+
"BLOCKPERF_CLIENT_KEY",
110+
self.config_parser.get("DEFAULT", "client_key", fallback=None)
111+
)
98112
if not client_key:
99113
raise ConfigError("No client_key set")
100114
return client_key
101115

102116
@property
103117
def operator(self) -> str:
104-
operator = self.config_parser.get("DEFAULT", "operator")
118+
operator = os.getenv(
119+
"BLOCKPERF_OPERATOR",
120+
self.config_parser.get("DEFAULT", "operator", fallback=None)
121+
)
105122
if not operator:
106123
raise ConfigError("No operator set")
107124
return operator
@@ -112,21 +129,31 @@ def lock_file(self) -> str:
112129

113130
@property
114131
def topic_base(self) -> str:
115-
return self.config_parser.get("DEFAULT", "topic_base", fallback="develop")
132+
topic_base = os.getenv(
133+
"BLOCKPERF_TOPIC_BASE",
134+
self.config_parser.get("DEFAULT", "topic_base", fallback="develop")
135+
)
136+
return topic_base
116137

117138
@property
118139
def mqtt_broker_url(self) -> str:
119-
return str(
140+
broker_url = os.getenv(
141+
"BLOCKPERF_BROKER_URL",
120142
self.config_parser.get(
121143
"DEFAULT",
122144
"mqtt_broker_url",
123145
fallback="a12j2zhynbsgdv-ats.iot.eu-central-1.amazonaws.com",
124146
)
125147
)
148+
return broker_url
126149

127150
@property
128151
def mqtt_broker_port(self) -> int:
129-
return int(self.config_parser.get("DEFAULT", "mqtt_broker_port", fallback=8883))
152+
broker_port = int(os.getenv(
153+
"BLOCKPERF_BROKER_PORT",
154+
self.config_parser.get("DEFAULT", "mqtt_broker_port", fallback=8883)
155+
))
156+
return broker_port
130157

131158
@property
132159
def enable_tracelogs(self) -> bool:

0 commit comments

Comments
 (0)