Getting Data In

Python Script Optimization

a_m_s
Explorer

To all the python masters out there :: Python Execution Time Optimization using multi-threading.

I have a python script which takes a list of 1000 IP from a file and does port monitoring 3389 and 22 respectively using the os module of python . It is taking as of now 40 minutes to run.

The requirement is to run the same scripted input within 10 minutes.

 

I have tried multi threading but the output is not sequential so I am not able to ingest...

Tags (2)
0 Karma

Zane
Explorer

Can we consider using socket packages and using the correct "try except" and timeout for filtering, which may be faster? Alternatively, asynchrony can be used, but most importantly, each event must have a timestamp

Tags (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

1. It's not really a Splunk question - it's about your Python scripting.

2. What do you mean by "the output is not sequential so I'm not able to ingest"? You have timestamps on the events so Splunk should be able to line up the events properly.

3. You can't beat maths. You do the checks sequentially, have some percentage of "dead" hosts and have relatively long default TCP SYN timeout - it's bound to take some time. You could try adjusting your timeouts to make it fail faster.

0 Karma
Get Updates on the Splunk Community!

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...