Getting Data In

How to execute a py or sh by interface of Splunk

Lindaiyu
Path Finder

Hello,

I write a xxx.sh in the /splunk/etc/apps/my_apps/bin and by the commande line

./xxx.sh

to execute the code.

Could I add a bouton or something else in the interface of my app in Splunk
alt text

to trigger the xxx.sh.

Thank you very much
Hanzhi

0 Karma

vinitatsky
Communicator

http://answers.splunk.com/answers/25658/whats-the-point-of-custom-python-scripts.html

This is what I did
Put my custom python script in this folder
/var/sky/splunk/etc/system/bin

import csv
import sys
import splunk.Intersplunk
import string
(isgetinfo, sys.argv) = splunk.Intersplunk.isGetInfo(sys.argv)
if len(sys.argv) < 2:
splunk.Intersplunk.parseError("No arguments provided to custom script")

results = splunk.Intersplunk.readResults(None, None, True)
splunk.Intersplunk.outputResults(results)

Modify commands.conf file in below folder
/var/sky/splunk/etc/system/local

defaults for all external commands, exceptions are below in individual stanzas

type of script: 'python', 'perl'

TYPE = python

default FILENAME would be .py for python, .pl for perl and otherwise

is command streamable?

STREAMING = true

maximum data that can be passed to command (0 = no limit)

MAXINPUTS = 50000

end defaults

[customtest]
filename = customtest.py

To reload the setting run this URL in your browser (Just in case, if required)
https://SPLUNK_HOSTNAME:PORT/debug/refresh

And this is how we can use custom command in splunk
| customtest GETINFO [Inputparameters]

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...