mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
ET Pro Telemetry, spread traffic
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
PLUGIN_NAME= etpro-telemetry
|
||||
PLUGIN_VERSION= 1.0
|
||||
PLUGIN_REVISION= 1
|
||||
PLUGIN_VERSION= 1.1
|
||||
#PLUGIN_REVISION= 1
|
||||
PLUGIN_COMMENT= ET Pro Telemetry Edition
|
||||
PLUGIN_MAINTAINER= ad@opnsense.org
|
||||
PLUGIN_WWW= https://docs.opnsense.org/manual/etpro_telemetry.html
|
||||
|
||||
@@ -30,6 +30,8 @@ import sys
|
||||
import argparse
|
||||
import requests
|
||||
import syslog
|
||||
import time
|
||||
import random
|
||||
import urllib3
|
||||
import telemetry
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
@@ -46,6 +48,10 @@ parser.add_argument('-c', '--config',
|
||||
help='rule downloader configuration',
|
||||
default="/usr/local/etc/suricata/rule-updater.config"
|
||||
)
|
||||
parser.add_argument('-D', '--direct',
|
||||
help='do not sleep before send (disable traffic spread)',
|
||||
action="store_true",
|
||||
default=False)
|
||||
args = parser.parse_args()
|
||||
|
||||
exit_code = -1
|
||||
@@ -55,6 +61,9 @@ if cnf.token is not None:
|
||||
if args.insecure:
|
||||
params['verify'] = False
|
||||
try:
|
||||
# spread traffic to remote host, usual cron interval is 30 minutes
|
||||
if not args.direct:
|
||||
time.sleep(random.randint(0, 1800))
|
||||
r = requests.head(args.endpoint, **params)
|
||||
if r.status_code == 200:
|
||||
# expected result, set exit code
|
||||
|
||||
@@ -31,6 +31,7 @@ import os
|
||||
import argparse
|
||||
import requests
|
||||
import time
|
||||
import random
|
||||
import syslog
|
||||
import urllib3
|
||||
import ujson
|
||||
@@ -51,6 +52,10 @@ parser.add_argument('-l', '--log', help='log directory containing eve.json files
|
||||
parser.add_argument('-s', '--state', help='persistent state (and lock) filename',
|
||||
default="/usr/local/var/run/et_telemetry.state")
|
||||
parser.add_argument('-d', '--days', help='Maximum number of days to look back on initial run', type=int, default=2)
|
||||
parser.add_argument('-D', '--direct',
|
||||
help='do not sleep before send (disable traffic spread)',
|
||||
action="store_true",
|
||||
default=False)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
@@ -79,6 +84,9 @@ if not telemetry_state.is_running():
|
||||
row_count, time.time() - send_start_time, max_timestamp
|
||||
)
|
||||
)
|
||||
# spread traffic to remote host, usual cron interval is 1 minute
|
||||
if not args.direct:
|
||||
time.sleep(random.randint(0, 60))
|
||||
for push_data in event_collector:
|
||||
params = {
|
||||
'timeout': 5,
|
||||
|
||||
Reference in New Issue
Block a user