Trying to set up the TA-connectivity app, and I get the following (I had to run 'dos2unix' on the .py scripts in order to run this on Linux):
#./pythonshell.py ping /opt/splunk/etc/apps/TA-connectivity/lookups/hosts.csv Traceback (most recent call last): File "/opt/splunk/etc/apps/TA-connectivity/bin/ping.py", line 177, in print x.get() File "/usr/lib64/python2.7/multiprocessing/pool.py", line 554, in get raise self._value ValueError: invalid literal for int() with base 10: '2 packets'
The error should be from the line within the script:
rtt = float(rex_stats.group('rtt')) / int(packet_no)
Is there a correction for this? Not very familiar with python scripting ...
The error message invalid literal for int() with base 10 would seem to indicate that you are passing a string that's not an integer to the int() function . In other words it's either empty, or has a character in it other than a digit.
You can solve this error by using Python isdigit() method to check whether the value is number or not. The returns True if all the characters are digits, otherwise False .
The other way to overcome this issue is to wrap your code inside a Python try...except block to handle this error.
Python2.x and Python3.x
Sometimes the difference between Python2.x and Python3.x that leads to this ValueError: invalid literal for int() with base 10 .
With Python2.x , int(str(3/2)) gives you "1". With Python3.x , the same gives you ("1.5"): ValueError: invalid literal for int() with base 10: "1.5".
I fixed some of the inconsistencies in the last update, and it should just work with any inputs you might have configured from v0.4. Do let me know if you find any other bugs, or would like any other feature added to this 🙂
I'll come test and come back to you in a week with an updated version. I might actually rewrite the multiprocessing bit.
Could you also specify which Splunk version and OS you tried this on?
Here's a fix. You'll need to edit line 121 of ping.py:
pattern_statistics = r'^(?P\d+\spackets)\stransmitted,\s(?:\d+)\sreceived,\s(?P\d+%)\spacket\sloss,\stime\s(?P\d+)ms'
Needs to be updated to this:
pattern_statistics = r'^(?P\d+)\spackets\stransmitted,\s(?:\d+)\sreceived,\s(?P\d+%)\spacket\sloss,\stime\s(?P\d+)ms'
Do let me know if it works for you, and I'll be sure to publish an update to the app which I'm currently testing.
I'm rewriting this as a modular input, but considering leaving or taking out multiprocessing since you would be able to define multiple inputs.