diff options
| author | 姜萍 <[email protected]> | 2022-05-29 17:59:26 +0800 |
|---|---|---|
| committer | 姜萍 <[email protected]> | 2022-05-29 17:59:26 +0800 |
| commit | 9f0f12ed28357ae167cb9aab3a614da0f8cd4bab (patch) | |
| tree | 0eac2d3fbfc11e7639b9a0254a8c24d8a43bd8f2 /sflow-rt/extras/tail_flows.py | |
initmaster
Diffstat (limited to 'sflow-rt/extras/tail_flows.py')
| -rwxr-xr-x | sflow-rt/extras/tail_flows.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sflow-rt/extras/tail_flows.py b/sflow-rt/extras/tail_flows.py new file mode 100755 index 0000000..faf6213 --- /dev/null +++ b/sflow-rt/extras/tail_flows.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +import requests +import signal + +def sig_handler(signal,frame): + exit(0) +signal.signal(signal.SIGINT, sig_handler) + +flowurl = 'http://localhost:8008/flows/json?maxFlows=10&timeout=60' +flowID = -1 +while 1 == 1: + r = requests.get(flowurl + "&flowID=" + str(flowID)) + if r.status_code != 200: break + flows = r.json() + if len(flows) == 0: continue + + flowID = flows[0]["flowID"] + flows.reverse() + for f in flows: + print(str(f['flowID']) + ',' + f['name'] + ',' + f['flowKeys'] + ',' + str(f['value']) + ',' + str(f['start']) + ',' + str(f['end']) + ',' + f['agent'] + ',' + str(f['dataSource'])) |
