Zabbix Monitor

Gem Version Build Status Code Climate Coverage

Zabbix monitoring for Ruby apps. Works with pushing and polling: push data to the agent server with zabbix_sender or collect data with the Zabbix agent.

Here you can find Documentation


Requires the Zabbix agent to be installed.

Add this line to your application's Gemfile:

gem 'zabbix-monitor'

And then execute:

$ bundle

Or install it yourself as:

$ gem install zabbix-monitor

To include the rake tasks in your application, add the following line to your Rakefile (before App::Application.load_tasks):

require 'tasks/zabbix'


For Rails applications:

Place your Zabbix Monitoring configuration in an initializer:

require 'zabbix'

Zabbix.configure do |config|
  config.config_file_path = '/etc/zabbix/zabbix_agentd.conf'
  # optional, defaults to ./log/#{RACK_ENV}.log
  # config.log_file_path = '/var/log/monitor.log'
  config.host_name = 'servername'
  config.mode = :push
  config.rules = [
      :command => '',
      :zabbix_key => 'zabbix.test'

Put the host name as configured in your Zabbix server config in config.host_name.

Set the config.mode to one of the following options:

  • :push uses the Zabbix agent to push the data to the Zabbix server
  • :file writes the data to tmp/zabbix-stats.yml
  • :stdout writes the data to the stdout

Put your monitoring rules in config.rules. Each rule contains a Ruby command to be executed by the Zabbix Monitor and the key as configured on the Zabbix Server.

Start running your monitoring jobs with:

$ rake zabbix:start

File mode

In :file mode, monitoring var can be read from the monitoring file using zabbix_reader command. Create a script that's been executed by the Zabbix daemon:

#! /bin/bash
cd /path/to/app/
echo $( RAILS_ENV=production bundle exec zabbix_reader $1 )

To speed up the reading of variables, you can also use awk to look for variables. Create the following script instead:

#! /bin/bash
cd /path/to/app/

if [ -f tmp/zabbix-stats.yml ]
  echo $( awk -F: -v var=$1 '$0 ~ var {$1=""; print $0; exit}' tmp/zabbix-stats.yml )
  echo Zabbix monitor file not found


Capistrano tasks are added in lib/tasks/zabbix.rb. Currently, only Capistrano 2 is supported. Add the following lines of code to your deploy.rb:

require 'zabbix/capistrano'

namespace :deploy do

  # if you're running God.rb, it will be restarted automatically
  after 'deploy:update_code', 'zabbix:stop'
  # else
  after 'deploy:update_code', 'zabbix:restart'



A detailed overview can be found in the CHANGELOG.


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request