<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>logIt &#187; JSON</title>
	<atom:link href="https://lakm.us/logit/tag/json/feed/" rel="self" type="application/rss+xml" />
	<link>https://lakm.us/logit</link>
	<description>Log Around The Clock</description>
	<lastBuildDate>Sat, 06 Jun 2015 14:17:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Acknowledging Event: Zabbix Python API</title>
		<link>https://lakm.us/logit/2012/05/acknowledging-event-zabbix-python-api/</link>
		<comments>https://lakm.us/logit/2012/05/acknowledging-event-zabbix-python-api/#comments</comments>
		<pubDate>Mon, 14 May 2012 02:40:43 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Zabbix]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=388</guid>
		<description><![CDATA[Acknowledgement is one of the things that is provided by Zabbix API in its event section. We can make use of the methods get() and acknowledge() to automatically acknowledge an event. Digging through the attributes of those methods, the official doc doesn&#8217;t provide complete example to follow. Added with some luck, my search get me [...]]]></description>
				<content:encoded><![CDATA[<p>Acknowledgement is one of the things that is provided by <a href="http://www.zabbix.com/" title="Zabbix" target="_blank">Zabbix</a> API in its <a href="http://www.zabbix.com/documentation/1.8/api/event" title="Zabbix API 1.8: Event" target="_blank">event section</a>. We can make use of the methods <code>get()</code> and <code>acknowledge()</code> to automatically acknowledge an event. Digging through the attributes of those methods, the official doc doesn&#8217;t provide complete example to follow. Added with some luck, my search get me to have the following JSON RPC that works in <a href="http://www.zabbix.com/rn1.8.7.php" title="Zabbix 1.8.7 Release Announcement" target="_blank">Zabbix 1.8.7</a> using <a href="https://github.com/gescheit/scripts" title="Gescheit github" target="_blank">Gescheit API implementation</a> written in Python. </p>
<p>When the goal is to acknowledge a specific event, the JSON call is however limited to some basic responses. It means that you can&#8217;t query a single RPC request for i.e. the following combination: <em>list of acknowledged events <strong>with</strong> &#8220;problem&#8221; status <strong>and</strong> trigger ID 500</em> (500 is merely an example).</p>
<p>However, combination in a single request do exist i.e. I&#8217;ve tried: <em>list of acknowledged events <strong>with</strong> &#8220;problem&#8221; status</em> as the following GET request:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
<span style="color: #3366CC;">&quot;params&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;acknowledged&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;value&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;jsonrpc&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;2.0&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;method&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;event.get&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;auth&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;some-hash-authentication&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">:</span> some<span style="color: #339933;">-</span>RPC<span style="color: #339933;">-</span>sequence<span style="color: #339933;">-</span>integer
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><em>(Note: <code>value=1</code> means status is &#8220;problem&#8221;)</em></p>
<p>For the basic example above, find the script in <a href="https://github.com/bandono/scripts" title="forked Gescheit API github" target="_blank">my fork</a> of Gescheit API.</p>
<p>Back to our goal of acknowledging events, our API can make the following RPCs:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">ack_list=zapi.<span style="color: black;">event</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;acknowledged&quot;</span>:<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
problem_list=zapi.<span style="color: black;">event</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;value&quot;</span>:<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
event_trigger_list=zapi.<span style="color: black;">event</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;triggerids&quot;</span>:<span style="color: black;">&#91;</span>trigger_id<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Yes, they are three requests. We can then filter out a single event to be acknowledged by intersecting the three results. The first intersection is between <code>event_trigger_list</code>, <code>problem_list</code>, and <code>ack_list</code> as illustrated below:</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="problem-list-acknowledgement-intersection.jpg" src="../../../../images/problem-list-acknowledgement-intersection.jpg" title="Intersection of problem list, event list with specific trigger ID, and acknowledged event list" width="309" height="211" /><p class="wp-caption-text">Intersection of problem list, event list with specific trigger ID, and acknowledged event list</p></div>
<p>After we opt-out those intersections, we can then get the event with problem status and choose the latest event only to be acknowledged. Check the code on <a href="https://github.com/bandono/zabbix-custom-integration/blob/master/bin/api/zabbix_event_ack.py" title="zabbix_event_ack.py" target="_blank">my github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/05/acknowledging-event-zabbix-python-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
