Removed comments

This commit is contained in:
2024-06-22 17:14:30 +02:00
parent e2594bc66d
commit 2999b4b0ce

View File

@@ -1,15 +1,13 @@
import time import time
import splunklib.client as client import splunklib.client as client
import splunklib.results as results
import splunklib.binding as binding
from splunklib.results import JSONResultsReader from splunklib.results import JSONResultsReader
from splunklib.binding import HTTPError from splunklib.binding import HTTPError
def connectSplunk(): def connectSplunk():
HOST = "10.218.7.194" HOST = "10.218.7.194"
PORT = 8089 PORT = 8089
USERNAME = "" # Configurar variable de entorno USERNAME = "" # Configurar como variable de entorno
PASSWORD = "" # Configurar variable de entorno PASSWORD = "" # Configurar como variable de entorno
try: try:
service = client.connect(host=HOST, port=PORT, username=USERNAME, password=PASSWORD) service = client.connect(host=HOST, port=PORT, username=USERNAME, password=PASSWORD)
@@ -32,17 +30,15 @@ def searchOldClient(service):
return return
job = service.jobs.create(search) job = service.jobs.create(search)
# Wait for the job to complete
while not job.is_done(): while not job.is_done():
time.sleep(2) time.sleep(2)
# Retrieve and display the results
result_stream = job.results(output_mode='json') result_stream = job.results(output_mode='json')
results_reader = JSONResultsReader(result_stream) results_reader = JSONResultsReader(result_stream)
guids = list() guids = list()
for result in results_reader: for result in results_reader:
if isinstance(result, dict) and 'guid' in result: # Check if the result is a dictionary (a valid search result) if isinstance(result, dict) and 'guid' in result:
guids.append(result['guid']) guids.append(result['guid'])
return guids return guids