mirror of
https://github.com/sched-ext/scx.git
synced 2024-11-28 21:50:23 +00:00
Merge pull request #516 from sched-ext/htejun/scx_stats
scx_stats/scripts/scxstats_to_openmetrics: Retry connection
This commit is contained in:
commit
c0b4deb9ec
@ -90,21 +90,7 @@ def update_om_metrics(resp, omid, labels, meta_db, om_metrics):
|
||||
else:
|
||||
dbg(f'skpping {k_omid}')
|
||||
|
||||
def main():
|
||||
global verbose
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='scxstats_to_openmetrics',
|
||||
description='Read from scx_stats server and output in OpenMetrics format')
|
||||
parser.add_argument('-i', '--intv', metavar='SECS', type=float, default='2.0',
|
||||
help='Polling interval (default: %(default)s)')
|
||||
parser.add_argument('-v', '--verbose', action='count')
|
||||
parser.add_argument('-p', '--path', metavar='PATH', default='/var/run/scx/root/stats',
|
||||
help='UNIX domain socket path to connect to (default: %(default)s)')
|
||||
|
||||
args = parser.parse_args()
|
||||
verbose = args.verbose
|
||||
|
||||
def connect_and_monitor(args):
|
||||
# Connect to the stats server.
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
sock.connect(args.path)
|
||||
@ -160,4 +146,29 @@ def main():
|
||||
|
||||
time.sleep(args.intv)
|
||||
|
||||
def main():
|
||||
global verbose
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='scxstats_to_openmetrics',
|
||||
description='Read from scx_stats server and output in OpenMetrics format')
|
||||
parser.add_argument('-i', '--intv', metavar='SECS', type=float, default='2.0',
|
||||
help='Polling interval (default: %(default)s)')
|
||||
parser.add_argument('-v', '--verbose', action='count')
|
||||
parser.add_argument('-p', '--path', metavar='PATH', default='/var/run/scx/root/stats',
|
||||
help='UNIX domain socket path to connect to (default: %(default)s)')
|
||||
|
||||
args = parser.parse_args()
|
||||
verbose = args.verbose
|
||||
last_e = None
|
||||
|
||||
while True:
|
||||
try:
|
||||
connect_and_monitor(args)
|
||||
except Exception as e:
|
||||
if type(e) is not type(last_e):
|
||||
info(f'{e}, retrying...')
|
||||
last_e = e
|
||||
time.sleep(1)
|
||||
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user