<?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>question how to test custom ambari alert in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198213#M160264</link>
    <description>&lt;P&gt;I uset hdp 2.4 and ambari 2.2.1.1&lt;/P&gt;&lt;P&gt;I had custom an ambari alert and test on my test servers.&lt;/P&gt;&lt;P&gt;But when I copy it on mysql product environment, one server seems every thing is ok,and the other is show me :&lt;/P&gt;&lt;PRE&gt;'NoneType' object has no attribute 'modules' &lt;/PRE&gt;&lt;P&gt;So, I try to the monitor script writen in pytthon.&lt;/P&gt;&lt;P&gt;When I run python monitor.py, it shows ok,but on the ambari-agent,it still wrong.&lt;/P&gt;&lt;P&gt;So is there a way to test the script and debug the monitor script??&lt;/P&gt;</description>
    <pubDate>Wed, 20 Sep 2017 19:30:14 GMT</pubDate>
    <dc:creator>darkz1984</dc:creator>
    <dc:date>2017-09-20T19:30:14Z</dc:date>
    <item>
      <title>how to test custom ambari alert</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198213#M160264</link>
      <description>&lt;P&gt;I uset hdp 2.4 and ambari 2.2.1.1&lt;/P&gt;&lt;P&gt;I had custom an ambari alert and test on my test servers.&lt;/P&gt;&lt;P&gt;But when I copy it on mysql product environment, one server seems every thing is ok,and the other is show me :&lt;/P&gt;&lt;PRE&gt;'NoneType' object has no attribute 'modules' &lt;/PRE&gt;&lt;P&gt;So, I try to the monitor script writen in pytthon.&lt;/P&gt;&lt;P&gt;When I run python monitor.py, it shows ok,but on the ambari-agent,it still wrong.&lt;/P&gt;&lt;P&gt;So is there a way to test the script and debug the monitor script??&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 19:30:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198213#M160264</guid>
      <dc:creator>darkz1984</dc:creator>
      <dc:date>2017-09-20T19:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to test custom ambari alert</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198214#M160265</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3653/darkz1984-1.html" nodeid="3653"&gt;@darkz yu&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The error that you posted indicates some issue with your "monitor.py" python script.&lt;/P&gt;&lt;PRE&gt;'NoneType'object has no attribute 'modules'&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;Please try running that script manually to see if it works or causes the same error?   Please make sure that it uses the PYTHONPATH  that your ambari agent is using.&lt;/P&gt;&lt;PRE&gt;# python monitor.py&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;For example the pythonpath i use as following:&lt;/P&gt;&lt;PRE&gt;export PYTHONPATH=/usr/lib/python2.6/site-packages:/usr/lib/python2.6/site-packages/ambari_commons:/usr/lib/python2.6/site-packages:/usr/lib/python2.6/site-packages:/usr/lib/python2.6/site-packages/ambari_commons:/usr/lib/python2.6/site-packages::/usr/lib/python2.6/site-packages:/usr/lib/python2.6/site-packages/ambari_agent:/usr/lib/python2.6/site-packages&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 19:32:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198214#M160265</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-09-20T19:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to test custom ambari alert</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198215#M160266</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3653/darkz1984-1.html" nodeid="3653"&gt;@darkz yu&lt;BR /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also will it be possible if you can share your monitor.py script.&lt;BR /&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3653/darkz1984-1.html" nodeid="3653"&gt;&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 19:36:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198215#M160266</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-09-20T19:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to test custom ambari alert</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198216#M160267</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3653/darkz1984-1.html" nodeid="3653"&gt;@darkz yu&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Where exactly are you putting your custom alert script?  Is it the following location?&lt;/P&gt;&lt;PRE&gt;/var/lib/ambari-server/resources/host_scripts&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;I have written a similar article on this customization:  &lt;A href="https://community.hortonworks.com/articles/38149/how-to-create-and-register-custom-ambari-alerts.html" target="_blank"&gt;https://community.hortonworks.com/articles/38149/how-to-create-and-register-custom-ambari-alerts.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Above link will give some idea about how to run the alert manually using &lt;STRONG&gt; "?run_now=true" &lt;/STRONG&gt;something like following:&lt;/P&gt;&lt;PRE&gt;# curl -u admin:admin -i -H 'X-Requested-By:ambari' -X PUT  &lt;A href="http://node1.example.com:8080/api/v1/clusters/ClusterDemo/alert_definitions/151?run_now=true" target="_blank"&gt;http://node1.example.com:8080/api/v1/clusters/ClusterDemo/alert_definitions/151?run_now=true&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 20:23:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198216#M160267</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-09-20T20:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to test custom ambari alert</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198217#M160268</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3418/jsensharma.html" nodeid="3418"&gt;@Jay SenSharma&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I know how to deploy a custom monitor and how to start it.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;But it runs ok on one server but failed on the other one.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I had change the code to simple logic:&lt;/P&gt;&lt;P&gt;such as:&lt;/P&gt;&lt;PRE&gt;def execute():
	try:
		return 'OK', 'no errors'
	exception:
		return 'UNKNOW', 'UNKNOW data'
&lt;/PRE&gt;&lt;P&gt;it still shows me :&lt;/P&gt;&lt;PRE&gt;'NoneType' object has no attribute 'modules' 
&lt;/PRE&gt;&lt;P&gt;And I surely that I can run the monitor.py manaual correctly.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 08:38:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198217#M160268</guid>
      <dc:creator>darkz1984</dc:creator>
      <dc:date>2017-09-21T08:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to test custom ambari alert</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198218#M160269</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3653/darkz1984-1.html" nodeid="3653"&gt;@darkz yu&lt;BR /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There is a typo in UNKNOWN  word,    Although it might not be causing the issue. &lt;/P&gt;&lt;PRE&gt;return 'UNKNOW','UNKNOW data'&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;Can you please share the steps that you followed like Where have you placed the script and the sample script, alerts.json. The Ambari Version,  I will try the same at my end.  &lt;BR /&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3653/darkz1984-1.html" nodeid="3653"&gt;&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 08:42:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198218#M160269</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-09-21T08:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to test custom ambari alert</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198219#M160270</link>
      <description>&lt;P&gt;I add the script call time to label, and I found there no time return.I will post the script soon&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 10:53:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198219#M160270</guid>
      <dc:creator>darkz1984</dc:creator>
      <dc:date>2017-09-21T10:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to test custom ambari alert</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198220#M160271</link>
      <description>&lt;P&gt;&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/40443-test.zip"&gt;test.zip&lt;/A&gt;&lt;/P&gt;&lt;P&gt;this the code I run on two server&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 10:58:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198220#M160271</guid>
      <dc:creator>darkz1984</dc:creator>
      <dc:date>2017-09-21T10:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to test custom ambari alert</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198221#M160272</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3653/darkz1984-1.html" nodeid="3653" target="_blank"&gt;@darkz yu&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This is the step that i followed:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1). Copied the "flume_monitor.py" script to ambari server "/var/lib/ambari-server/resources/host_scripts" location.&lt;/P&gt;&lt;PRE&gt;# scp  /Users/jsensharma/Downloads/40443-test/flume_monitor.py   root@amb25101:/var/lib/ambari-server/resources/host_scripts&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;2). Now i pushed the alert definition to my ambari cluster.&lt;/P&gt;&lt;PRE&gt;# curl -u admin:admin -i -H 'X-Requested-By:ambari' -X POST -d @/Users/jsensharma/Downloads/40443-test/flume_monitor.json  &lt;A href="http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/alert_definitions" target="_blank" rel="nofollow noopener noreferrer"&gt;http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/alert_definitions&lt;/A&gt;

HTTP/1.1 100 Continue
HTTP/1.1 201 Created
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-store
Pragma: no-cache
Set-Cookie: AMBARISESSIONID=j2au8meo5w73182sf1wnjn9z8;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
User: admin
Content-Type: text/plain
Content-Length: 0&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;3). Restarted Ambari Server.&lt;/P&gt;&lt;PRE&gt;# ambari-server  restart&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;4). Checked the Ambari UI.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="39450-flume-custom-alert.png" style="width: 2984px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17791i00CE79FFC1721ECE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="39450-flume-custom-alert.png" alt="39450-flume-custom-alert.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;My Cluster Details:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;[root@amb25101 ambari-server]# ambari-server --version
2.5.1.0-159
[root@amb25101 ambari-server]# python --version
Python 2.7.5&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 06:11:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198221#M160272</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2019-08-18T06:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to test custom ambari alert</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198222#M160273</link>
      <description>&lt;P&gt;What I don't clear is why on one server show me&lt;/P&gt;&lt;PRE&gt;'NoneType' object has no attribute 'modules'&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;,but the other is ok&lt;/P&gt;&lt;P&gt;I try to restart the ambari-agent,It show me ok&lt;/P&gt;&lt;P&gt;So terrible.&lt;/P&gt;&lt;P&gt;resloved.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 12:37:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198222#M160273</guid>
      <dc:creator>darkz1984</dc:creator>
      <dc:date>2017-09-21T12:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to test custom ambari alert</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198223#M160274</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3418/jsensharma.html" nodeid="3418"&gt;@Jay Kumar SenSharma&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Referring to the PUT command used for triggering the alert manually, Is it possible to pass some parameters/custom information to the script which gets trigged by the alert ? If yes, is it via headers OR body of the PUT request ?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 20:15:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-test-custom-ambari-alert/m-p/198223#M160274</guid>
      <dc:creator>sam_kalmesh</dc:creator>
      <dc:date>2019-04-16T20:15:46Z</dc:date>
    </item>
  </channel>
</rss>

