I am trying to run a python script from Splunk which takes 3 arguments and then suppose to run calculations on those arguments and print the results into Splunk. But I am not getting any results back. There are about 100 events that I want to run the script on.
Splunk command:
... | script python amp2 macaddress timestamp numofaverages
Values of arguments:
macaddress=11:22:33:44:55:66
timestamp=123456789
numofaverages=1,2,3,4,5,6,7,8,9,10
Below is the python script I am trying to run.
import sys
mac=sys.argv[1]
time=sys.argv[2]
avg=sys.argv[3]
avg=avg.split(",")
avgmin=min(avg)
avgmax=max(avg)
count=len(avg)
try:
avg=map(float, avg)
avgmean=round((sum(avg)/count),2)
except (NameError, ValueError):
avgmin="min"
avgmax="max"
count="bin count"
avgmean="mean"
print(mac+","+time+","+avgmin+","+avgmax+","+str(avgmean)+","+str(count))
... View more