Zabbix agent framework - first steps

First steps wit zaf

Zabbix Agent Framework is used to maintain external zabbix checks in one place. More info can be found on github. Who needs it? Anybody who want to easily deploy/manage/develop external checks for Zabbix agent. Please note, zaf plugin is not Zabbix plugin. While Zabbix plugin is pure "C" code, zaf plugin can be writen in almost any language and does not heavily depends on Zabbix agent.

Did you try to make some external check working before?

If so, you know what I am talking about. You have to read plugin documentation, do plugin install manualy and shell scipts on one-line agent config are not so nice. Zaf tries to automatize maximum number of steps and give framework for another developers how to create plugins easily.

Try zaf!

First of all, we need to install zaf. Suppose we are trying to play. So we do not want to create zaf debian package but we will use standalone installer. More info how to create deb packages with zaf can be found on github. Standalone installer should work on debian, ubuntu, openwrt and freebsd.

Install

Easiest way how to install zaf is to become root and run:

curl -sk https://raw.githubusercontent.com/limosek/zaf/1.3/install.sh | \
 sh -s auto \
 ZAF_GIT=0 \
 Z_Server=your.zabbix.server \
 Z_ServerActive=your.zabbix.server \
 Hostname='' \
 HostnameItem=system.hostname

ZAF_GIT=0 means that we will not use git repository

Z_ optiopns are options which will be automaticaly set into zabbix agent config by installer. So you can configue your zabbix agent automaticaly by one command. Options which are empty (like Hostname) will be automaticaly unset.

Result should look like this:

Installing from url ...
curl -f -k -s -L -o - https://github.com/limosek/zaf//archive/1.3.tar.gz
zaf: Removing plugin zaf

Plugin 'zaf' version 0.3:
 Basic items for Zabbix Agent Framework

Maintainer: Lukas Macura <lukas@macura.cz>
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/zaf

Items: framework_version plugins discovery.plugins plugin_version 

zaf: Restarting agent (/etc/init.d/zabbix_agentd restart)
zaf: You are not zabbix user. Test will be run with your privileges and sudo access!
zaf.framework_version                         [t|1.3]
zaf: Install done. Use 'zaf' to get started.

We can see that zaf is installed directly from github and it automaticaly enabled default plugin 'zaf'.

Zaf plugins

By default, zaf will install itself and basic plugin, named 'zaf'. Let us see information about installation.

zaf show
Plugin 'zaf' version 0.3:
 Basic items for Zabbix Agent Framework

Maintainer: Lukas Macura <lukas@macura.cz>
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/zaf

Items: framework_version plugins discovery.plugins plugin_version 

So we can see some information about zaf plugin and its installed items. We can even test items:

zaf test zaf.framework_version
zaf: You are not zabbix user. Test will be run with your privileges and sudo access!
zaf.framework_version: zaf.framework_version [t|1.0]

So zaf tested item zaf.framework_version. It uses zabbix_agentd -t to do so. Please note that item keys above are plugin specific. Name of item for Zabbix is plugin.item. In our case zaf.framework_version.

Importing into Zabbix

Now we need to import Zabbix template for zaf plugin. Template is crucial part of each zaf plugin. You can download it from each plugin home. In our case, please use https://github.com/limosek/zaf-plugins/blob/master/zaf/template.xml and import it to your Zabbix. After importing, please apply this plugin to host where zaf was installed. After some short time you should see informations in latest data. In my case you can see more zaf plugins installed. More info about them available here. Please note that zaf plugin is for monitoring zaf itself. So you can discover zaf plugins on specific host and get plugins version.

Latest data


Try another plugin

Zaf is installed and configured. Now it is easy to install next plugins. Let us try psx plugin. This plugin will autodiscover processess and collects statistics about them. Again, we need to import template for this plugin into Zabbix:

zaf install psx

And here are some nice results

Process statistics from psx template

Runing installer or zaf command without parameters will show you some info about possibilities.

# zaf
/usr/bin/zaf Version 1.0. Please use some of this commands:
/usr/bin/zaf Cmd [ZAF_OPTION=value] ...
Commands:
/usr/bin/zaf update			To update repo
/usr/bin/zaf plugins		To list installed plugins
/usr/bin/zaf show [plugin]		To show installed plugins or plugin info
/usr/bin/zaf items [plugin]		To list all suported items [for plugin]
/usr/bin/zaf test [plugin[.item]]	To test [all] suported items by zabbix_agentd [for plugin]
/usr/bin/zaf get [plugin[.item]]	To test [all] suported items by zabbix_get [for plugin]
/usr/bin/zaf install plugin		To install plugin
/usr/bin/zaf remove plugin		To remove plugin
/usr/bin/zaf self-upgrade		To self-upgrade zaf
/usr/bin/zaf self-remove		To self-remove zaf and its config
# install.sh
Please specify how to install.
install.sh {auto|interactive|debug-auto|debug-interactive|reconf} [Agent-Options] [Zaf-Options]
scratch means that config file will be created from scratch
 Agent-Options: Z_Option=value [...]
 Zaf-Options: ZAF_OPT=value [...]
 To unset Agent-Option use Z_Option=''

Example 1 (default install): install.sh auto
Example 2 (preconfigure agent options): install.sh auto A_Server=zabbix.server A_ServerActive=zabbix.server A_Hostname=$(hostname)
Example 3 (preconfigure zaf packaging system to use): install.sh auto ZAF_PKG=opkg
Example 4 (interactive): install.sh interactive

If you have any questions, ask me :) Next article will be about zaf plugin structure and creation. It is easy :)

Lukas

 

Poslední komentáře

Bez komentářů.

Kdo je nový

  • radimk
  • limo