Splunk Dev

Looking for an example generating custom script that execute OS command



I am looking for a simple example of custom generating search command that
executes OS command and show the result of execution.

I don't have much knowledge of Python SDK, but I want to start from an simple example.

Thank you, and any commend would be appreciated.

0 Karma


Its better if you do this in a separate/new app.

In local directory of app, create commands.conf (if it is already not there).

In bin directory of app create command_cachecheck.py
import os,re,csv
import sys
os.system("data \" +%c\" ")
command = 'vmstat -s'

Restart searchhead and give proper permissions.

In SH get the results by searching |cachecheck.

Get Updates on the Splunk Community!

2024 Splunk Career Impact Survey | Earn a $20 gift card for participating!

Hear ye, hear ye! The time has come again for Splunk's annual Career Impact Survey!  We need your help by ...

Optimize Cloud Monitoring

  TECH TALKS Optimize Cloud Monitoring Tuesday, August 13, 2024  |  11:00AM–12:00PM PST   Register to ...

What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...