<?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 passing arguments to shell script alert action in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/passing-arguments-to-shell-script-alert-action/m-p/320619#M11015</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have an alert which results a host name and task name whenever certain task goes down on the servers. I want to run a script(.sh) alert action in Splunk web based on this  triggered alert, where that script would reset the status of that task to running. In doing so, I had to pass host name and task name as parameters to the shell script. I already have  a script  but have to pass parameters to it. How would I pass those particular parameters to that script? Detailed explanation would be kind enough. An example for this kind of script with parameters would be appreciated&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 05 Dec 2017 16:32:55 GMT</pubDate>
    <dc:creator>kumar28</dc:creator>
    <dc:date>2017-12-05T16:32:55Z</dc:date>
    <item>
      <title>passing arguments to shell script alert action</title>
      <link>https://community.splunk.com/t5/Alerting/passing-arguments-to-shell-script-alert-action/m-p/320619#M11015</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have an alert which results a host name and task name whenever certain task goes down on the servers. I want to run a script(.sh) alert action in Splunk web based on this  triggered alert, where that script would reset the status of that task to running. In doing so, I had to pass host name and task name as parameters to the shell script. I already have  a script  but have to pass parameters to it. How would I pass those particular parameters to that script? Detailed explanation would be kind enough. An example for this kind of script with parameters would be appreciated&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 16:32:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/passing-arguments-to-shell-script-alert-action/m-p/320619#M11015</guid>
      <dc:creator>kumar28</dc:creator>
      <dc:date>2017-12-05T16:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: passing arguments to shell script alert action</title>
      <link>https://community.splunk.com/t5/Alerting/passing-arguments-to-shell-script-alert-action/m-p/320620#M11016</link>
      <description>&lt;P&gt;Hi @kumar28,&lt;/P&gt;

&lt;P&gt;If you are using "Run a script" (alert action) then this feature has been deprecated since Splunk 6.3 and splunk introduced new feature &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.1/AdvancedDev/ModAlertsIntro"&gt;Custom Alert Action&lt;/A&gt; but "Run a script" (alert action) is still working.&lt;/P&gt;

&lt;P&gt;If you want to fetch parameter for "alert action" then please refer &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.1/Alert/Configuringscriptedalerts"&gt;http://docs.splunk.com/Documentation/Splunk/7.0.1/Alert/Configuringscriptedalerts&lt;/A&gt; &lt;/P&gt;

&lt;P&gt;Based on the documentation &lt;CODE&gt;$SPLUNK_ARG_8&lt;/CODE&gt; gives you filename with full path in which query result will be stored, it will be compressed (.gz) CSV file. Once you have this file you can &lt;CODE&gt;zcat&lt;/CODE&gt; command in linux to read content from compressed CSV file and you can implement your logic to read every row and required column value from that file.&lt;/P&gt;

&lt;P&gt;If you are trying to implement "Custom Alert Action" then you can use &lt;CODE&gt;read payload&lt;/CODE&gt; in your script to fetch payload value and from that payload you will able to find &lt;CODE&gt;results_file&lt;/CODE&gt; parameter which gives you filename with full path in which query result will be stored, it will be compressed (.gz) CSV file and then you can perform same logic which I explained above in "alert script".&lt;/P&gt;

&lt;P&gt;I hope this helps.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Harshil&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 03:21:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/passing-arguments-to-shell-script-alert-action/m-p/320620#M11016</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-12-06T03:21:11Z</dc:date>
    </item>
  </channel>
</rss>

