Zabbix Ruby Client
This tool is designed to make easy to install zabbix reporter on monitored servers using zabbix-sender rather than zabbix-agent. It targets on monitoring mainly linux servers and is built on a plugin system so that you can decide what is going to be reported.
The development is still in progress but it produces results and works in my case. Use at your own risk and read the code first. It is developed under ruby 2 but should work on 1.9.3 as well.
Check the Changelog for recent changes, code is still under huge development and is likely to move a lot until version 0.1.
Installation
Install it yourself as:
gem install zabbix-ruby-client
Usage
zrc init [name]
# will create a directory [name] (default: zabbix-ruby-client) for
# storing configuration and temporary files
cd [name]
bundle
# makes the zabbix-ruby-client [name] ready to run
# then edit config.yml according to your needs
bundle exec zrc
# to list available commands
bundle exec zrc show
# to test the data collection
Setting up cronjobs
When ready just install a cron task according to your environment
echo '* * * * * /bin/bash -lc "cd /path/to/zrc && bundle exec zrc upload"' | crontab
# or
echo '* * * * * /bin/zsh -c ". $HOME/.rvm/scripts/rvm && cd /path/to/zrc && bundle exec zrc upload"' | crontab
# or
echo '* * * * * /bin/zsh -c "export RBENV_ROOT=/usr/local/var/rbenv && eval \"$(rbenv init - zsh)\" && cd /path/to/zrc && bundle exec zrc upload"' | crontab
By default zrc show
and zrc upload
will read config.yml (for the general config) and minutely.yml (for the list of plugins to run).
You can use -c to specify another config file, and -t to use another list of plugins. The zrc init
command will create sample minutely.yml, hourly.yml and monthly.yml but you can create any arbitrary list of plugins, that can be used in your cronjobs.
Here is an example setup using the files generated by the init:
* * * * * /bin/zsh -c ". $HOME/.rvm/scripts/rvm && cd $HOME/zrc && bundle exec zrc upload"
0 */6 * * * /bin/zsh -c ". $HOME/.rvm/scripts/rvm && cd $HOME/zrc && bundle exec zrc upload -t hourly.yml"
0 0 1 * * /bin/zsh -c ". $HOME/.rvm/scripts/rvm && cd $HOME/zrc && bundle exec zrc upload -t monthly.yml"
plugins
There are a set of standart plugins included in the package, aimed at linux systems.
- ubuntu system stats (system_tpl includes the following)
- load (uses /proc/loadavg) load_tpl
- cpu (uses /proc/stat) cpu_tpl
- memory (requires iostat, apt-get install sysstat) memory_tpl
- disk (uses /proc/diskstats) disk_tpl
- network (uses /proc/net/dev) network_tpl
- apt (uses ubuntu /usr/lib/update-notifier/apt-check) this one will populate the 'tag' field in host info, and is supposed to run every few hours or at least not every minute apt_tpl
- sysinfo (uses uname -a) is populating the host info in the inventory, and should be ran at setup and/or monthly sysinfo_tpl
- apache (depends on mod_status with status_extended on) apache_tpl
You can add extra plugin directories in the configuration file.
Todo
- read /proc rather than rely on installed tools
- write tests
- add more plugins
- memcache
- redis
- mysql master/slave
- monit
- passenger
- nginx
- logged users
- denyhosts
- postfix
- sendgrid
- airbrake
- disk occupation (done)
- try to work out a way to create host/graphs/alerts from the client using Zabbix API
- verify compatibility with ruby 1.9
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Contributors
- @mose - author
License
Copyright 2013 Faria Systems - MIT license - created by mose at mose.com