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_log.py | |
initmaster
Diffstat (limited to 'sflow-rt/extras/tail_log.py')
| -rwxr-xr-x | sflow-rt/extras/tail_log.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sflow-rt/extras/tail_log.py b/sflow-rt/extras/tail_log.py new file mode 100755 index 0000000..7d29efb --- /dev/null +++ b/sflow-rt/extras/tail_log.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) + +eventurl = 'http://localhost:8008/events/json?maxEvents=10&timeout=60' +eventID = -1 +while 1 == 1: + r = requests.get(eventurl + "&eventID=" + str(eventID)) + if r.status_code != 200: break + events = r.json() + if len(events) == 0: continue + + eventID = events[0]["eventID"] + events.reverse() + for e in events: + print(str(e['eventID']) + ',' + str(e['timestamp']) + ',' + e['thresholdID'] + ',' + e['metric'] + ',' + str(e['threshold']) + ',' + str(e['value']) + ',' + e['agent'] + ',' + e['dataSource']) |
