<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/monitoring-r-applications-with-rzabbix/"></div></div><div><a data-url="https://www.r-bloggers.com/monitoring-r-applications-with-rzabbix/" data-counturl="https://www.r-bloggers.com/monitoring-r-applications-with-rzabbix/" data-count="horizontal" data-text="Monitoring R Applications with RZabbix" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://r-addict.com/2016/09/15/RZabbix-Announcement.html"> http://r-addict.com</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img src="https://i2.wp.com/r-addict.com/images/fulls/RZabbix.png?w=456" data-recalc-dims="1"> As R users we mostly perform analysis, produce reports and create interactive shiny applications. Those are rather one-time performances. Sometimes, however, the R developer enters the world of the real software development, where R applications should be distributed and maintained on many machines. Then one really appreciates the value of a proper applications monitoring. In this post I present my last package called <a target="_blank" href="https://cran.r-project.org/web/packages/RZabbix/index.html">RZabbix</a> – the R interface to the <a target="_blank" href="https://www.zabbix.com/documentation/3.0/manual/api/reference">Zabbix API</a> data.</p>
<ul>
<li><a target="_blank" href="http://r-addict.com/2016/09/15/RZabbix-Announcement.html#what-is-zabbix">What is Zabbix?</a></li>
<li><a target="_blank" href="http://r-addict.com/2016/09/15/RZabbix-Announcement.html#example-of-usage">Example of usage</a></li>
<li><a target="_blank" href="http://r-addict.com/2016/09/15/RZabbix-Announcement.html#you-can-contribute">You can contribute!</a></li>
</ul>
<h1>What is Zabbix?</h1>
<p>According to <a target="_blank" href="http://www.zabbix.com/product.php">procudct overview</a></p>
<blockquote>
<p>With Zabbix it is possible to gather virtually limitless types of data from the network. High performance real-time monitoring means that tens of thousands of servers, virtual machines and network devices can be monitored simultaneously. Along with storing the data, visualization features are available (overviews, maps, graphs, screens, etc), as well as very flexible ways of analyzing the data for the purpose of alerting.</p>
</blockquote>
<p>This <strong>Ultimate Enterprise-class Monitoring Platform</strong> was nominated for the 2nd time among world’s best monitoring solutions according to Gartner</p>
<p>Zabbix can be used to <a target="_blank" href="http://www.zabbix.com/monitor_everything.php">Monitor everything</a> – servers, network devices and applications, gathering accurate statistics and performance data.</p>
<p><br>
</p>
<p></p>
<h1> Connect from R with RZabbix <a data-count-href="/MarcinKosinski/RZabbix/stargazers" data-style="mega" data-count-aria-label="# stargazers on GitHub" target="_blank" data-count-api="/repos/MarcinKosinski/RZabbix#stargazers_count" data-icon="octicon-star" href="https://github.com/MarcinKosinski/RZabbix">Star</a></h1>
<p>I have created a simple R connector to <a target="_blank" href="https://www.zabbix.com/documentation/3.2/manual/api/reference">Zabbix API</a>, packed in the library and released it on <a target="_blank" href="https://share.zabbix.com/dir-libraries/rzabbix">Share Zabbix</a> and also on <a target="_blank" href="https://cran.r-project.org/web/packages/RZabbix/index.html">CRAN</a>.</p>
<p>You can install the package with</p>
<figure>
<pre><code data-lang="r"><span>install.packages</span><span>(</span><span>'RZabbix'</span><span>)</span><span> </span><span>library</span><span>(</span><span>RZabbix</span><span>)</span><span>
</span><span>?</span><span>ZabbixAPI</span><span> </span><span>#</span><span> </span><span>help</span><span> </span><span>manual</span><span> </span><span>page</span></code></pre>
</figure>
<p>and then connect to Zabbix API with</p>
<figure>
<pre><code data-lang="r"><span>ZabbixAPI</span><span>(</span><span>
</span><span>'http://localhost/zabbix/'</span><span>,</span><span>
</span><span>body</span><span> </span><span>=</span><span> </span><span>list</span><span>(</span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;user.login&quot;</span><span>,</span><span>
</span><span>params</span><span> </span><span>=</span><span> </span><span>jsonlite</span><span>::</span><span>unbox</span><span>(</span><span>
</span><span>data.frame</span><span>(</span><span>user</span><span> </span><span>=</span><span> </span><span>&quot;Admin&quot;</span><span>,</span><span>
</span><span>password</span><span> </span><span>=</span><span> </span><span>&quot;zabbix&quot;</span><span>)))</span><span>
</span><span>)</span><span> </span><span>-></span><span> </span><span>auth</span></code></pre>
</figure>
<p>The authentication is required, because every other call need to use <code>auth</code> parameter in its body.</p>
<p>Base information of the API version can be checked with</p>
<figure>
<pre><code data-lang="r"><span>ZabbixAPI</span><span>(</span><span>
</span><span>'http://localhost/zabbix'</span><span>,</span><span>
</span><span>body</span><span> </span><span>=</span><span> </span><span>list</span><span>(</span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;apiinfo.version&quot;</span><span>))</span></code></pre>
</figure>
<p>and the regular request to get history of an item of <code>item_id</code> number can be done as below</p>
<figure>
<pre><code data-lang="r"><span>ZabbixAPI</span><span>(</span><span>
</span><span>'http://localhost/zabbix'</span><span>,</span><span>
</span><span>body</span><span> </span><span>=</span><span> </span><span>list</span><span>(</span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;history.get&quot;</span><span>,</span><span>
</span><span>params</span><span> </span><span>=</span><span> </span><span>jsonlite</span><span>::</span><span>unbox</span><span>(</span><span>
</span><span>data.frame</span><span>(</span><span>output</span><span> </span><span>=</span><span> </span><span>&quot;extend&quot;</span><span>,</span><span>
</span><span>itemids</span><span> </span><span>=</span><span> </span><span>&quot;item_id&quot;</span><span>,</span><span>
</span><span>history</span><span> </span><span>=</span><span> </span><span>0</span><span>,</span><span>
</span><span>sortfield</span><span> </span><span>=</span><span> </span><span>&quot;clock&quot;</span><span>,</span><span>
</span><span>sortorder</span><span> </span><span>=</span><span> </span><span>&quot;DESC&quot;</span><span>,</span><span>
</span><span>limit</span><span> </span><span>=</span><span> </span><span>10</span><span>)</span><span>
</span><span>),</span><span>
</span><span>auth</span><span> </span><span>=</span><span> </span><span>auth</span><span>))</span></code></pre>
</figure>
<p>The body parameter can be also passed as a JSON string – see example for getting event data for object with <code>object_id</code> number</p>
<figure>
<pre><code data-lang="r"><span>library</span><span>(</span><span>jsonlite</span><span>)</span><span>
</span><span>paste0</span><span>(</span><span>'{
&quot;method&quot;: &quot;event.get&quot;,
&quot;params&quot;: {
&quot;output&quot;: &quot;extend&quot;,
&quot;select_acknowledges&quot;: &quot;extend&quot;,
&quot;objectids&quot;: &quot;object_id&quot;,
&quot;sortfield&quot;: [&quot;clock&quot;, &quot;eventid&quot;],
&quot;sortorder&quot;: &quot;DESC&quot;
},
&quot;auth&quot;: &quot;'</span><span>,</span><span> </span><span>auth</span><span>,</span><span> </span><span>'&quot;
}'</span><span>)</span><span> </span><span>-></span><span> </span><span>json_rpc</span><span>
</span><span>ZabbixAPI</span><span>(</span><span>'http://localhost/zabbix'</span><span>,</span><span>
</span><span>body</span><span> </span><span>=</span><span> </span><span>fromJSON</span><span>(</span><span>json_rpc</span><span>))</span><span> </span><span>-></span><span> </span><span>event.info</span></code></pre>
</figure>
<p>Methods and params to Zabbix API can be found in <a target="_blank" href="https://www.zabbix.com/documentation/3.2/manual/api/reference">Method reference</a>. It is a great date, because <a target="_blank" href="https://www.facebook.com/zabbix/photos/a.457911347570950.119798.144923832203038/1420122278016514/?type=3&theater">few days ago new version of Zabbix (3.2) was released</a>.</p>
<p><img src="https://i1.wp.com/r-addict.com/images/fulls/zab_32.jpg?w=456" data-recalc-dims="1"></p>
<p>You can try to set your own <a target="_blank" href="https://www.zabbix.org/wiki/Dockerized_Zabbix">Zabbix Server from Docker container</a> or you can use <a target="_blank" href="http://zabbix.org/zabbix/">public test Zabbix on zabbix.org</a>. If you are not yet motivated for using Docker then read my post from May <a target="_blank" href="http://r-addict.com/2016/05/13/Docker-Motivation.html"><br>
R 3.3.0 is another motivation for Docker</a> or join <a target="_blank" href="http://www.meetup.com/Cracow-R-User-Group/events/233624341/">10th Cracow R User Group meetup</a> at the end of September where I will present <a target="_blank" href="http://erkakrakow.pl/index.php/spotkania/24-10-spotkanie-entuzjastow-r-w-krakowie">Rocker: explanation and motivation for Docker containers usage in applications development (by R user, for R users)</a></p>
<h1>Example of usage</h1>
<p><a target="_blank" href="https://github.com/jangaraj">Jan Garaj</a> from <a target="_blank" href="http://www.monitoringartist.com/">Monitoring Artist</a> has used RZabbix to provide <a target="_blank" href="https://github.com/monitoringartist/monitoring-analytics">Monitoring Analytics</a> – R statistical computing and graphic tool for monitoring metrics from data scientists.</p>
<p><img alt="Monitoring Analytics" src="https://i1.wp.com/raw.githubusercontent.com/monitoringartist/monitoring-analytics/master/doc/monitoring-analytics.gif?w=456&ssl=1" data-recalc-dims="1"></p>
<h1>You can contribute!</h1>
<p>RZabbix is still a young package and many can be done. If you would like to contribute then fill free to <a data-count-href="/MarcinKosinski/RZabbix/network" data-count-aria-label="# forks on GitHub" target="_blank" data-count-api="/repos/MarcinKosinski/RZabbix#forks_count" data-icon="octicon-repo-forked" href="https://github.com/MarcinKosinski/RZabbix/fork">Fork</a> the RZabbix repository. I am currently looking for examples on how to <a target="_blank" href="https://github.com/MarcinKosinski/RZabbix/issues/6#issue-152191501">create a SLA overview for a specific host, calculate the amount of diskspace used by all active hosts and filesystems and create a overview of the most active triggers</a> and I am thinking about <a target="_blank" href="https://github.com/MarcinKosinski/RZabbix/issues/1">adding tests</a>.</p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/monitoring-r-applications-with-rzabbix/"></div></div><div><a data-url="https://www.r-bloggers.com/monitoring-r-applications-with-rzabbix/" data-counturl="https://www.r-bloggers.com/monitoring-r-applications-with-rzabbix/" data-count="vertical" data-text="Monitoring R Applications with RZabbix" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://r-addict.com/2016/09/15/RZabbix-Announcement.html"> http://r-addict.com</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/YBi6EkItjNc"></a></div>