README.md in zabbix-ruby-client-0.0.13 vs README.md in zabbix-ruby-client-0.0.14
- old
+ new
@@ -48,11 +48,11 @@
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 0/6 * * * /bin/zsh -c ". $HOME/.rvm/scripts/rvm && cd $HOME/zrc && bundle exec zrc upload -t hourly.yml"
+ 0 * * * * /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.
@@ -68,31 +68,128 @@
* 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](master/zabbix-templates/apt_tpl.xml)
* sysinfo (uses uname -a) is populating the host info in the inventory, and should be ran at setup and/or monthly [sysinfo_tpl](master/zabbix-templates/sysinfo_tpl.xml)
* apache (depends on mod_status with status_extended on) [apache_tpl](master/zabbix-templates/apache_tpl.xml)
* mysql (uses mysqladmin extended-status) [mysql_tpl](master/zabbix-templates/mysql_tpl.xml)
* nginx (requires httpStubStatus nginx module) [nginx_tpl](master/zabbix-templates/nginx_tpl.xml)
+* redis (uses redis-cli info) [redis_tpl](master/zabbix-templates/redis_tpl.xml) (unfinished)
+ * args [ "/path/to/redis-cli", "options to connect" ]
You can add extra plugins in a plugins/ dir in the working dir, just by copying one of the existing plugins in the repo and change to your need. All plugins present in plugins/ will be loaded if present in the config file you use. That can be convenient to test by using the -t flag, for example `bundle exec zrc -t testplugin.yml` where testplugin.yml only contains the name and args for yoiur plugin.
+## Custom plugins how-to
+
+With the default config there is a plugins/ dir specified where you can put your own custom plugins. Those plugins need at least one `collect(*args)` method and optionaly a `discover(*args)` if this plugins plays the discover role.
+
+Here is a basic plugin skeleton you can reproduce:
+
+```ruby
+class ZabbixRubyClient
+ module Plugins
+ module Myplugin
+ extend self
+
+ def collect(*args)
+ host = args[0]
+ # the rest of args are the params you pass in the args: in your yml config file
+ string = args[1]
+ int = args[2]
+
+ time = Time.now.to_i
+ back = []
+ back << "#{host} myplugin[item] #{time} #{string} #{int}"
+ return back
+ end
+
+ end
+ end
+end
+
+ZabbixRubyClient::Plugins.register('myplugin', ZabbixRubyClient::Plugins::Myplugin)
+```
+
+You can test custom plugins by creating a new `myplugin.yml` file with:
+
+```yaml
+---
+- name: myplugin
+ args: [ "something", 42 ]
+```
+
+and then use the `show` command to try it out and see what will be sent to the server, and use `upload` for testing the template you made for it on the zabbix configuration panel:
+
+```
+$ bundle exec zrc show -t myplugin.yml
+myhost myplugin[item] 1381669455 something 42
+```
+
+## Note about security
+
+As you may already know, Zabbix is not very concerned about securing exchanges between agent and server, or sender and server. A cautious sysadmin will then properly manage his setup using ssh tunneling.
+
+After launching manual tunnels and ensuring their survival with monit I tried `autossh` which is much more reliable. It requires to have keys exchanged from server and client, in my case I prefer doing reverse tunnels from server, because I have some plan about doing a resend from client in case server didn't open the tunnel (in case of server reboot or network failure). That resend trick is not implemented yet though.
+
+I first created on both sides an autossh user with no console and no password:
+
+```
+sudo useradd -m -r -s /bin/false -d /usr/local/zabtunnel zabtunnel
+```
+
+On the zabbix server I created a key that I transfered to the clients in `/usr/local/zabtunnel/,ssh/authorized_keys`
+
+```
+sudo su -s /bin/bash - zabtunnel
+ssh-keygen
+```
+
+Then I copy `id_rsa.pub` over to `/usr/local/zabtunnel/.ssh/authorized_keys` on each client.
+
+Check [autossh doc](http://www.harding.motd.ca/autossh/README), note that ubuntu has a package for it. Here is what my `/usr/local/bin/autossh.sh` looks like:
+
+```bash
+#!/bin/sh
+
+HOSTLIST="host1 host2 host3 etc"
+
+for i in $HOSTLIST; do
+ sudo -u zabtunnel \
+ AUTOSSH_LOGLEVEL=6 \
+ AUTOSSH_LOGFILE=/usr/local/zabtunnel/$i.log \
+ AUTOSSH_PIDFILE=/usr/local/zabtunnel/$i.pid \
+ /usr/bin/autossh -2 -M 0 -f -qN \
+ -o 'ServerAliveInterval 60' \
+ -o 'ServerAliveCountMax 3' \
+ -R 10051:localhost:10051 $i
+done
+
+exit 0
+```
+
+Then you can change zabbix-server config and add a localhost ListenIP (by default it listens to all interfaces)
+
+```
+ListenIP 127.0.0.1
+```
+
## Todo
-* read /proc rather than rely on installed tools
+* read /proc rather than rely on installed tools (done)
* write tests
* add more plugins
* memcache
* redis
* mysql master/slave
* monit
* passenger
- * nginx
+ * nginx (done)
* 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
+* verify compatibility with ruby 1.9 (done)
+* create a resend system that will store timed data on client if connection to server fails, and will send pending (missed) data on next batch.
## Contributing
1. Fork it