Bacula:一个开源备份方案,针对bacula的zabbix监控实现
This project is mainly composed by a bash script and a Zabbix template. The bash script reads values from Bacula Catalog and sends it to Zabbix Server. While the Zabbix template has items and other configurations that receive this values, start alerts and generate graphs and screens. This material was created using Bacula at 7.0.5 version and Zabbix at 2.4.5 version in a GNU/Linux CentOS 7 operational system.
Link this Zabbix template to each host that has a Bacula’s backup job implemented. Each host configured in Zabbix with this template linked needs to have its name equals to the name configured in Bacula’s Client resource. Otherwise the data collected by the bash script will not be received by Zabbix server.
Items
This Zabbix template has two types of items, the items to receive data of backup jobs, and the itens to receive data of Bacula’s processes. The items that receive data of Bacula’s processes are described below:
The items that receive data of backup jobs are divided into the three backup’s levels: Full, Differential and Incremental. For each level there are six items as described below:
Triggers
The triggers are configured to identify the host that started the trigger through the variable {HOST.NAME}. In the same way as the items, the triggers has two types too. The triggers that are related to Bacula’s processes:
And the triggers that are related to backup jobs:
Graphs
Again, in the same way as the items related to backup jobs, the graphs are divided into the three backup’s levels: Full, Differential and Incremental. For each level there are five graphs as described below:
Screens
There are three screens, one for each backup level, that displays the five graphs previously configured for that level.
Create the configuration file /etc/bacula/bacula-zabbix.conf
as the sample in this repository, customize it for your infrastructure environment, and set the permissions as below:
chown root:bacula /etc/bacula/bacula-zabbix.conf
chmod 640 /etc/bacula/bacula-zabbix.conf
Create the bash script file /var/spool/bacula/bacula-zabbix.bash
by copying it from this repository and set the permissions as below:
chown bacula:bacula /var/spool/bacula/bacula-zabbix.bash
chmod 700 /var/spool/bacula/bacula-zabbix.bash
Edit the Bacula Director configuration file /etc/bacula/bacula-dir.conf
to start the script at the finish of each job. To do this you need to change the lines described below in the Messages resource that is used by all the configured jobs:
Messages {
...
mailcommand = "/var/spool/bacula/bacula-zabbix.bash %i"
mail = 127.0.0.1 = all, !skipped
...
}
Now restart the Bacula Director service. In my case I used this command:
systemctl restart bacula-dir
Make a copy of the Zabbix template from this repository and import it to your Zabbix server.
Edit your hosts that have configured backup jobs to use this template. Don’t forget to edit the variables with the Bacula’s processes names, and to disable in hosts that are only Bacula’s clients the items that check the Bacula Director and Storage processes.
Bacula:
Zabbix:
Integration:
Feel free to send bug reports and feature requests here:
If you are using this solution in production, please write me about it. It’s very important for me to know that my work is not meaningless.