Monitoring Splunk

How to run a script only on one search head in a SH cluster, preferably the captain?

RDumbeck
Explorer

i have a script that is currently executing on all search heads.  Is there a way to execute on only the current captain?

I need only one of my search heads to return results. 

Labels (1)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

Depends on what you mean "run a script". If you want to use OS-level CLI to chose just one node to run the script on, just do "splunk show shcluster-status" and check which node is the captain. Then run only on that node. If you want to run it directly from Splunk's search window by means of | script command, it will only be run on one node (the one you're connected to in case of interactive search or any node it will get scheduled to by scheduler in case of scheduled searches).

So what's the use case?

View solution in original post

0 Karma

hrawat
Splunk Employee
Splunk Employee

Did you tied( if it's one of the input types mentioned) ?

run_only_one= <boolean>
* Determines if a scripted or modular inputs runs on one search head
  in SHC.

 

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Depends on what you mean "run a script". If you want to use OS-level CLI to chose just one node to run the script on, just do "splunk show shcluster-status" and check which node is the captain. Then run only on that node. If you want to run it directly from Splunk's search window by means of | script command, it will only be run on one node (the one you're connected to in case of interactive search or any node it will get scheduled to by scheduler in case of scheduled searches).

So what's the use case?

0 Karma

RDumbeck
Explorer

This is a scripted input that is set to run every minute.   I was hoping there was a setting for the input in inputs.conf that would cause this behavior, but this will work.  Thanks for the info. 

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Well... there is another thing to consider with inputs - why would you want to run your inputs on the search-head? You typically set up a HF for this (for scripted input even a UF should do). And why, oh why, would you distribute such input to all SHC members??? That's counterintuitive - first you want to create several separate instances of your input, then you want to disable almost all of them. Seems pointless.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @RDumbeck ,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @RDumbeck,

if you associate the script execution to an Alert, managed by the Search Head Cluster, your script will be executed only one time.

I used this solution to send SNMP traps to an external system.

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Fueling your curiosity with new Splunk ILT and eLearning courses

At Splunk Education, we’re driven by curiosity—both ours and yours! That’s why we’re committed to delivering ...

Splunk AI Assistant for SPL 1.1.0 | Now Personalized to Your Environment for Greater ...

Splunk AI Assistant for SPL has transformed how users interact with Splunk, making it easier than ever to ...

Unleash Unified Security and Observability with Splunk Cloud Platform

     Now Available on Microsoft AzureOn Demand Now Step boldly into the AI revolution with enhanced security ...