<?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 Custom alert script failing in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Custom-alert-script-failing/m-p/463757#M8403</link>
    <description>&lt;P&gt;I have been following this example (&lt;A href="https://answers.splunk.com/answers/683820/why-is-the-custom-alert-script-failing-with-sendal.html" target="_blank"&gt;https://answers.splunk.com/answers/683820/why-is-the-custom-alert-script-failing-with-sendal.html&lt;/A&gt;) and encountered an error in the showconfiguration.py script.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;import pprint, json, sys

if __name__ == "__main__":
  if len(sys.argv) &amp;gt; 1 and sys.argv[1] = "--execute":
    f.open("/tmp/splunktest.txt", "w")
    f.write("Here's the info we get from splunk:")
    f.write(pprint.pprint(json.loads(sys.stdin.read())))
    f.close()
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Errors in log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; 04-02-2020 07:30:11.193 +0000 WARN  sendmodalert - action=showconfiguration - Alert action script returned error code=1
 04-02-2020 07:30:11.193 +0000 INFO  sendmodalert - action=showconfiguration - Alert action script completed in duration=11 ms with exit code=1
 04-02-2020 07:30:11.191 +0000 ERROR sendmodalert - action=showconfiguration STDERR -  SyntaxError: invalid syntax
 04-02-2020 07:30:11.191 +0000 ERROR sendmodalert - action=showconfiguration STDERR -                                           ^
 04-02-2020 07:30:11.191 +0000 ERROR sendmodalert - action=showconfiguration STDERR -      if len(sys.argv) &amp;gt; 1 and sys.argv[1] = "--execute":
 04-02-2020 07:30:11.191 +0000 ERROR sendmodalert - action=showconfiguration STDERR -    File "/opt/splunk/etc/apps/showconfiguration/bin/showconfiguration.py", line 4
 host = 6c83f2e55cd4source = /opt/splunk/var/log/splunk/splunkd.logsourcetype = splunkd
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 07 Jun 2020 18:20:46 GMT</pubDate>
    <dc:creator>pjohnson1</dc:creator>
    <dc:date>2020-06-07T18:20:46Z</dc:date>
    <item>
      <title>Custom alert script failing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-alert-script-failing/m-p/463757#M8403</link>
      <description>&lt;P&gt;I have been following this example (&lt;A href="https://answers.splunk.com/answers/683820/why-is-the-custom-alert-script-failing-with-sendal.html" target="_blank"&gt;https://answers.splunk.com/answers/683820/why-is-the-custom-alert-script-failing-with-sendal.html&lt;/A&gt;) and encountered an error in the showconfiguration.py script.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;import pprint, json, sys

if __name__ == "__main__":
  if len(sys.argv) &amp;gt; 1 and sys.argv[1] = "--execute":
    f.open("/tmp/splunktest.txt", "w")
    f.write("Here's the info we get from splunk:")
    f.write(pprint.pprint(json.loads(sys.stdin.read())))
    f.close()
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Errors in log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; 04-02-2020 07:30:11.193 +0000 WARN  sendmodalert - action=showconfiguration - Alert action script returned error code=1
 04-02-2020 07:30:11.193 +0000 INFO  sendmodalert - action=showconfiguration - Alert action script completed in duration=11 ms with exit code=1
 04-02-2020 07:30:11.191 +0000 ERROR sendmodalert - action=showconfiguration STDERR -  SyntaxError: invalid syntax
 04-02-2020 07:30:11.191 +0000 ERROR sendmodalert - action=showconfiguration STDERR -                                           ^
 04-02-2020 07:30:11.191 +0000 ERROR sendmodalert - action=showconfiguration STDERR -      if len(sys.argv) &amp;gt; 1 and sys.argv[1] = "--execute":
 04-02-2020 07:30:11.191 +0000 ERROR sendmodalert - action=showconfiguration STDERR -    File "/opt/splunk/etc/apps/showconfiguration/bin/showconfiguration.py", line 4
 host = 6c83f2e55cd4source = /opt/splunk/var/log/splunk/splunkd.logsourcetype = splunkd
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Jun 2020 18:20:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-alert-script-failing/m-p/463757#M8403</guid>
      <dc:creator>pjohnson1</dc:creator>
      <dc:date>2020-06-07T18:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: Custom alert script failing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-alert-script-failing/m-p/463758#M8404</link>
      <description>&lt;P&gt;There is a syntax error in your python script. Line number 4 should be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if len(sys.argv) &amp;gt; 1 and sys.argv[1] == "--execute":
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's better to use a python editor/IDE like IDLE or PyCharm to write your code so that you'll identify these errors before deploying to search heads.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 05:29:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-alert-script-failing/m-p/463758#M8404</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-04-03T05:29:54Z</dc:date>
    </item>
  </channel>
</rss>

