<?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 trigger a script based on an alert and include those results in the email? in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/How-to-trigger-a-script-based-on-an-alert-and-include-those/m-p/179895#M3010</link>
    <description>&lt;P&gt;Let me be a little more specific:&lt;/P&gt;

&lt;P&gt;This is my search:&lt;BR /&gt;
index=apigateway host="servername" "java.io.IOException: Too many open files". &lt;/P&gt;

&lt;P&gt;This runs on a cron schedule of "every 10 minutes" and alerts when any results &amp;gt; 0 are found. &lt;BR /&gt;
I already setup all of the alert actions.&lt;BR /&gt;
I added the the check for "Run a script" and put the script into $SPLUNK_HOME/bin/scripts/&lt;/P&gt;

&lt;P&gt;The alert triggers and emails as it should BUT the results of the script are not included in the email. Only the results of the search.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Aug 2015 19:16:58 GMT</pubDate>
    <dc:creator>tkwaller</dc:creator>
    <dc:date>2015-08-18T19:16:58Z</dc:date>
    <item>
      <title>How to trigger a script based on an alert and include those results in the email?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-trigger-a-script-based-on-an-alert-and-include-those/m-p/179893#M3008</link>
      <description>&lt;P&gt;Hello &lt;/P&gt;

&lt;P&gt;I'm trying to find a way to trigger a script  based on an alert and include those results in the alert email.&lt;/P&gt;

&lt;P&gt;Basically:&lt;BR /&gt;
The alert looks for this error in the wso2carbon.log file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;java.io.IOException: Too many open files 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This triggers an alert to send email notifiacations. What I would like to do is have this alert run&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"echo there are "/usr/sbin/lsof | grep wso2am | wc -l" open wso2am files"
"echo there are "/usr/sbin/lsof | grep java | wc -l" open java files"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and include this in the email.&lt;/P&gt;

&lt;P&gt;What would be the best way to accomplish this?&lt;BR /&gt;
Thanks for the thoughts!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2015 16:42:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-trigger-a-script-based-on-an-alert-and-include-those/m-p/179893#M3008</guid>
      <dc:creator>tkwaller</dc:creator>
      <dc:date>2015-08-18T16:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger a script based on an alert and include those results in the email?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-trigger-a-script-based-on-an-alert-and-include-those/m-p/179894#M3009</link>
      <description>&lt;P&gt;Your search query should be -&lt;BR /&gt;
*** source=“&lt;EM&gt;wso2carbon.log&lt;/EM&gt;” “java.io.IOException: Too many open files” | stats count&lt;BR /&gt;
Alert config-&lt;BR /&gt;
Trigger Condition: Number of Results is &amp;gt; 0&lt;BR /&gt;
Actions: Send Email, List in Triggered Alerts and in the alert config put a check on run a script(select ur script), link to results and inline table results in the email&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2015 17:12:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-trigger-a-script-based-on-an-alert-and-include-those/m-p/179894#M3009</guid>
      <dc:creator>jensonthottian</dc:creator>
      <dc:date>2015-08-18T17:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger a script based on an alert and include those results in the email?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-trigger-a-script-based-on-an-alert-and-include-those/m-p/179895#M3010</link>
      <description>&lt;P&gt;Let me be a little more specific:&lt;/P&gt;

&lt;P&gt;This is my search:&lt;BR /&gt;
index=apigateway host="servername" "java.io.IOException: Too many open files". &lt;/P&gt;

&lt;P&gt;This runs on a cron schedule of "every 10 minutes" and alerts when any results &amp;gt; 0 are found. &lt;BR /&gt;
I already setup all of the alert actions.&lt;BR /&gt;
I added the the check for "Run a script" and put the script into $SPLUNK_HOME/bin/scripts/&lt;/P&gt;

&lt;P&gt;The alert triggers and emails as it should BUT the results of the script are not included in the email. Only the results of the search.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2015 19:16:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-trigger-a-script-based-on-an-alert-and-include-those/m-p/179895#M3010</guid>
      <dc:creator>tkwaller</dc:creator>
      <dc:date>2015-08-18T19:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger a script based on an alert and include those results in the email?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-trigger-a-script-based-on-an-alert-and-include-those/m-p/179896#M3011</link>
      <description>&lt;P&gt;I dont think you can have the results of your script as part of the original email alert. What you can do is to have an additional line of code in your script to have the output emailed to the DL you want but let me remind you that this will be a separate email altogether. &lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2015 19:29:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-trigger-a-script-based-on-an-alert-and-include-those/m-p/179896#M3011</guid>
      <dc:creator>jensonthottian</dc:creator>
      <dc:date>2015-08-18T19:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger a script based on an alert and include those results in the email?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-trigger-a-script-based-on-an-alert-and-include-those/m-p/179897#M3012</link>
      <description>&lt;P&gt;Thats what I was thinking but wasn't sure if there was another way.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2015 20:47:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-trigger-a-script-based-on-an-alert-and-include-those/m-p/179897#M3012</guid>
      <dc:creator>tkwaller</dc:creator>
      <dc:date>2015-08-18T20:47:12Z</dc:date>
    </item>
  </channel>
</rss>

