diff --git a/removeOldClientsDS.py b/removeOldClientsDS.py index 9c20b8b..06ccc32 100644 --- a/removeOldClientsDS.py +++ b/removeOldClientsDS.py @@ -1,15 +1,13 @@ import time import splunklib.client as client -import splunklib.results as results -import splunklib.binding as binding from splunklib.results import JSONResultsReader from splunklib.binding import HTTPError def connectSplunk(): HOST = "10.218.7.194" PORT = 8089 - USERNAME = "" # Configurar variable de entorno - PASSWORD = "" # Configurar variable de entorno + USERNAME = "" # Configurar como variable de entorno + PASSWORD = "" # Configurar como variable de entorno try: service = client.connect(host=HOST, port=PORT, username=USERNAME, password=PASSWORD) @@ -32,17 +30,15 @@ def searchOldClient(service): return job = service.jobs.create(search) - # Wait for the job to complete while not job.is_done(): time.sleep(2) - # Retrieve and display the results result_stream = job.results(output_mode='json') results_reader = JSONResultsReader(result_stream) guids = list() 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']) return guids