<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to pass hostname to a custom alert script? in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282000#M5201</link>
    <description>&lt;P&gt;I attempted to add &lt;CODE&gt;$result.host$&lt;/CODE&gt;to the .bat and just have the script print it to a file. The script ran but it only printed "$result.host$" to the text document. I also tried the same but with % isntead of $ but that time it only printed Echo is on. Am I missing something? The script is placed in %SPLUNK_HOME%\bin\scripts.&lt;/P&gt;</description>
    <pubDate>Mon, 06 Jun 2016 18:33:09 GMT</pubDate>
    <dc:creator>jpolcari</dc:creator>
    <dc:date>2016-06-06T18:33:09Z</dc:date>
    <item>
      <title>How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/281996#M5197</link>
      <description>&lt;P&gt;I have an alert setup that finds an error which indicates that a service must be restarted. When the alert triggers, I would like for a script to run that restarts the service on the specific host that service failed on. I saw in the link below that you can pass custom arguments such as a fieldvalue. Is it possible to pass these arguments to a script? I'm interested in grabbing the hostname of the system so I can reference it in my script. This is a Windows environment so I would most likely be using a .bat file to restart the service.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.1/AdvancedDev/ModAlertsLog"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.1/AdvancedDev/ModAlertsLog&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2016 15:47:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/281996#M5197</guid>
      <dc:creator>jpolcari</dc:creator>
      <dc:date>2016-06-06T15:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/281997#M5198</link>
      <description>&lt;P&gt;Do you have host name (where the service failed) available as a field in your resultset? If you do, you can use &lt;CODE&gt;$result.&amp;lt;hostfieldname&amp;gt;$&lt;/CODE&gt; in your script.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2016 16:14:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/281997#M5198</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-06T16:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/281998#M5199</link>
      <description>&lt;P&gt;This is worth a bookmark too: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/Alert/Configuringscriptedalerts"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.2/Alert/Configuringscriptedalerts&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2016 16:20:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/281998#M5199</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-06-06T16:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/281999#M5200</link>
      <description>&lt;P&gt;Thank you, the host name is available. I'll give this a shot.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2016 17:25:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/281999#M5200</guid>
      <dc:creator>jpolcari</dc:creator>
      <dc:date>2016-06-06T17:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282000#M5201</link>
      <description>&lt;P&gt;I attempted to add &lt;CODE&gt;$result.host$&lt;/CODE&gt;to the .bat and just have the script print it to a file. The script ran but it only printed "$result.host$" to the text document. I also tried the same but with % isntead of $ but that time it only printed Echo is on. Am I missing something? The script is placed in %SPLUNK_HOME%\bin\scripts.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2016 18:33:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282000#M5201</guid>
      <dc:creator>jpolcari</dc:creator>
      <dc:date>2016-06-06T18:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282001#M5202</link>
      <description>&lt;P&gt;Still having some issues with this. Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 17:52:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282001#M5202</guid>
      <dc:creator>jpolcari</dc:creator>
      <dc:date>2016-06-14T17:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282002#M5203</link>
      <description>&lt;P&gt;I figured this out.  in order for these variables to be used from the resultset I had to declare these variables in the alert_actions.conf, then restart.  I then could add the information by calling the variable value with setting.get from the action script.&lt;/P&gt;

&lt;P&gt;alert_actions.conf&lt;BR /&gt;
param.results_team = $result.team$&lt;/P&gt;

&lt;P&gt;action.py&lt;BR /&gt;
team = settings.get('results_team')&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:13:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282002#M5203</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2020-09-29T13:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282003#M5204</link>
      <description>&lt;P&gt;Hi Cuyose,&lt;BR /&gt;
I am trying something similar to this and am having trouble getting the variable to pass across.  Do you mind sharing some more of the code in action.py so we can see how this is done?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 00:57:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282003#M5204</guid>
      <dc:creator>jashman</dc:creator>
      <dc:date>2017-12-05T00:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282004#M5205</link>
      <description>&lt;P&gt;any update?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 11:32:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282004#M5205</guid>
      <dc:creator>alvaro_garcia</dc:creator>
      <dc:date>2017-12-20T11:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282005#M5206</link>
      <description>&lt;P&gt;Any update ?&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 07:27:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282005#M5206</guid>
      <dc:creator>AniPrag</dc:creator>
      <dc:date>2018-08-05T07:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282006#M5207</link>
      <description>&lt;P&gt;Any update&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 11:55:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282006#M5207</guid>
      <dc:creator>AniPrag</dc:creator>
      <dc:date>2018-08-05T11:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282007#M5208</link>
      <description>&lt;P&gt;did you get any answer&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 11:57:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282007#M5208</guid>
      <dc:creator>AniPrag</dc:creator>
      <dc:date>2018-08-05T11:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282008#M5209</link>
      <description>&lt;P&gt;Since Cuyose’s script was executing on a full splunk server (not a UF/LWF), Cuyose had python at hid disposal and didn’t use a .bat file.  Instead he used python and the documentation found here to create a custom alert action.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.1.2/AdvancedDev/ModAlertsIntro"&gt;http://docs.splunk.com/Documentation/Splunk/7.1.2/AdvancedDev/ModAlertsIntro&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;To do this with a batch script, you have to use the results gzip tar file and your own code to pull fields out.&lt;/P&gt;

&lt;P&gt;The tar.gz is explained here: &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.1.2/Alert/Configuringscriptedalerts"&gt;https://docs.splunk.com/Documentation/Splunk/7.1.2/Alert/Configuringscriptedalerts&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You’re wasting  your time doing this in batch scripts if you ask me... you should be doing a python mod alert or SPL command.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 12:22:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282008#M5209</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-08-05T12:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282009#M5210</link>
      <description>&lt;P&gt;Thanks for responding, However the problem is not resolved yet&lt;BR /&gt;
In alert_actions.conf ($Splunk_Home$\etc\system\local) file i am adding below &lt;BR /&gt;
param.name = $result.HostName$&lt;BR /&gt;
 but its showing invalid stanza and i am calling the same in script as shown below&lt;BR /&gt;
hostname=settings.get(name)&lt;/P&gt;

&lt;P&gt;but still the stanze problem is not done..&lt;BR /&gt;
m i doing some thing wrong...&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:47:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282009#M5210</guid>
      <dc:creator>AniPrag</dc:creator>
      <dc:date>2020-09-29T20:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282010#M5211</link>
      <description>&lt;P&gt;My apologies, I thought the original poster answered their own question.  &lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 14:14:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282010#M5211</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-08-05T14:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass hostname to a custom alert script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282011#M5212</link>
      <description>&lt;P&gt;If you want help I suggest you post your own question and show the code you’re using too.  We can’t troubleshoot two issues on one thread as these may be very different custom code problems.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 14:16:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-pass-hostname-to-a-custom-alert-script/m-p/282011#M5212</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-08-05T14:16:01Z</dc:date>
    </item>
  </channel>
</rss>

