Skip to content

Commit

Permalink
tap into ss2 run as module mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cherusk committed Nov 24, 2023
1 parent 4fe33d4 commit 19107c9
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions prometheus_ss_exporter/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,11 @@ def __init__(self):
self.args.all = False
self.args.unix = False

def _reset_io(self):
if sys.version_info[0] == 2:
import cStringIO
self.stream_sink = cStringIO.StringIO()
else:
self.stream_sink = io.StringIO()

def provide_tcp_stats(self):
_stdout = sys.stdout
sys.stdout = self.stream_sink

ss2.run(self.args)

# catch stdout
sys.stdout = _stdout
sk_stats_raw = self.stream_sink.getvalue()
ss2.RUN_AS_MODULE = True

self._reset_io()
sk_stats_raw = ss2.run(self.args)

sk_stats_parsed = dict(TCP=dict(flows=list()))
try:
Expand Down

0 comments on commit 19107c9

Please sign in to comment.