Hi bloodstrife
after you put your script into etc/apps/YourApp/bin folder and placed the commands.conf into etc/apps/YourApp/default folder, restart Splunk and switch to YourApp. There simply enter the following search command:
| CurrentTime
and this will run your command.
But I tested your script and the output is none. Here is a quick and dirty rewrite to get it printing current time in csv like output that Splunk likes:
import time;
mytime = time.localtime(time.time())
print "my_year ,my_mon ,my_mday ,my_hour ,my_min ,my_sec ,my_wday ,my_yday"
print "%s, %s, %s ,%s ,%s ,%s ,%s ,%s" % (mytime.tm_year, mytime.tm_mon, mytime.tm_mday, mytime.tm_hour, mytime.tm_min, mytime.tm_sec, mytime.tm_wday, mytime.tm_yday)
I'm pretty sure there are better ways to do this in python 😉
But nevertheless hope that helps ....
Cheers, MuS
... View more