in Others

Step-by-step tutorial on integrating Zabbix with CloudBacko

This post expands on a previous post How to integrate Zabbix with CloudBacko for MSPs and provides step-by-step tutorial on how to integrate Zabbix with CloudBacko. This post also delves deeper into recommended monitoring setup in Zabbix.

Follow this guide to set up monitoring in a Windows PC with CloudBacko installed.

Use case

Company A has 20 PCs and 2 servers installed with CloudBacko. We need to monitor the backup job status of each backup sets in the PCs and servers. We want to receive notifications immediately when backup jobs do not complete successfully.

0. Installation of Zabbix server and agent

Zabbix follows a client-server model. A Zabbix monitoring server should be set up inside the company network. The monitoring server acts as a central repository of data. Zabbix server software can be installed in a physical or virtual machine. It is a central process that performs monitoring, interacts with Zabbix proxies and agents, calculates triggers and sends notifications.

Zabbix server can be installed by one of the three methods:

  • Install it from the distribution packages
  • Download the latest source archive and compile it yourself
  • Download the virtual appliance

Zabbix agent is a process deployed on monitoring targets to actively monitor local resources and applications. It is installed in devices that need to be monitored.

In our use case, we need to install the agent in the 20 PCs and 2 servers.

Zabbix provides pre-complied agents for a wide range of platforms. Refer to the download page in Zabbix website.

After the server and agent are installed properly, we can start configuring the monitored items.

1. Adding host group

The first step for configuration is to create a new host group. A host group is logical group of hosts. Host groups are used when assigning assess rights for different user groups. In our setup, we treat host group as the whole network in Company A.

Click on Configuration -> Host groups, enter a new group name.

You can choose from the list of templates or existing hosts to add into the newly created host group.
Adding host group

2. Adding host and template

Host is a network device you want to monitor. It can be a client computer, router or physical or virtual server.

In Configuration -> Hosts, click Create Host on the right.

Create hostA screen of adding a new host appears.

Enter the host name and add group “Company A Network”. Enter the IP address for this host and leave the port as default 10050.

Adding hostClick on the second left tab button “Template”, we are going to add items to monitor by using template in Zabbix.

Template is a set of entities (items, triggers, graphs, screens, applications, low-level discovery rules) to be applied on one or several hosts. Templates help us speed up the deployment of monitoring tasks on a host; also it makes it easier to apply mass changes to monitoring tasks. Templates are linked directly to individual hosts.

Since the computer we want to monitor is Windows 7, we select from the list “Template OS Windows”. Click “add” and then “Update”. The template is then linked to the host.

Add template in hostReturn to the host list, we now have 9 applications, 18 items, 9 triggers, 2 graphs and 2 discovery automatically set up for the host. (Items and triggers will be explained in later sections.)

Host listWe now need to add our own items to monitor CloudBacko.

3. Adding items

Item in Zabbix is a particular piece of data that you want to receive from a host. In the current context, we are going to monitor the CloudBacko log files.

Click on Configuration->Host. The host list appears. Click on the “Items” link on the host “benjamin-yip.companya.local”. It shows all items applied on the host.

Host list Click on the “Create item” button on top right. The form to create host appears.

Create itemFill in the form to add item.

Set itemOnly four fields, Name, Type, Key and Type of information are required. The other fields are optional. The following explains each fields.

Name

Enter a suitable name to identify the item. We suggest using the name of application CloudBacko and the CloudBacko backup set id as part of the name. Backup set id is a unique randomly generated 13-digit string.

In this example, we use “CloudBacko Log file-1409103670275″.

Type

Choose “Zabbix agent (active)” for Type. It requests the agent to retrieve a list of items from Zabbix server for checking, and actively send new data values to Zabbix server.

Type of information

Select “Log” for “Type of information”.

Key

The key field determines which log files to be monitored and which data to return by the Zabbix agent. The key field allows regular expression in the filename. The path to the files should be absolute path.

Format of  the key field is as follows:

logrt[/path/to/file/filename_regexp_pattern,<content_regexp>,<encoding>,<maxlines>,<mode>,<output>]

In our example, we are monitoring the cloud backup set 1409103670275. This CloudBacko instance is created by benjamin.yip. So the log files reside at “C:\Documents and Settings\benjamin.yip\.cbp\log\1409103670275\Backup” folder.

Key field in our example is configured as:
logrt["C:\Documents and Settings\benjamin.yip\.cbp\log\1409103670275\Backup\^.*log$","Backup",,,,]

We have used regular expression ^.*log$ to include all files with extension .log.

Note: For each CloudBacko backup set, a 13-digit backup set id is generated. Refer to the post How to integrate Zabbix with CloudBacko for MSPs for the locations of these log files.

As the key field requires absolute file path, each CloudBacko backup set for each user in the host should have a corresponding item configured in Zabbix.

The second argument <content_regexp> is optional. If <content_regexp> is present, the Zabbix agent will filter entries of the log file by the content regexp and only return matched data to Zabbix server. In this example, all log file entries with the keyword “Backup” are returned to Zabbix server for further analysis.

The remaining four arguments: <encoding>,<maxlines>,<mode>,<output> are optional. The following table extracted from Zabbix documentation explains these options.

encoding character encoding of the log file, e.g. UTF-8
maxlines maximum number of new lines per second the agent will send to Zabbix server or proxy. This parameter overrides the value of ‘MaxLinesPerSecond’ in zabbix_agentd.conf
mode possible values: all (default), skip (skip processing of older data).
The mode parameter is supported from version 2.0.
output an optional output formatting template.The escape sequence is replaced with the matched text while an \N (where N=1…9) escape sequence is replaced with Nth matched group (or an empty string if the N exceeds the number of captured groups).
If <output> is left empty – the whole line containing the matched text is returned.
Note that all global regular expression types except ‘Result is TRUE’ always return the whole matched line and the <output> parameter is ignored.
The output parameter is supported from version 2.2

Zabbix agent will search through the path for files that match the filename_regexp_pattern, search for the line that matches <content_regexp> and return the lines in the format as stated in <output>.

Other fields

The remaining fields “Update interval (in sec)”, “History storage period (in days)”, “Log time format”, “New application” and “Description” are optional.

Refer to Zabbix documentation for detailed description.

Click “Add” button to add the item.

4. Adding triggers

Trigger is a logical expression that defines the threshold. If received data reaches the threshold defined, the trigger state will go from ‘Ok’ to ‘Problem’. Action will be triggered.

Go back to Configuration -> Hosts and click on Triggers.

Create triggerThe page shows a list of all triggers on the host. Before adding any new triggers, we have 9 triggers installed from template.

Click on the “Create trigger” button on top right.

Create triggerThe form to create trigger shows up.

Create trigger

Enter the name for this trigger. If email prompt is activated for this trigger, this name field is used as the title of the notification email. We suggest using the application name, job status, company name and username in this field to give sufficient information in the email title.

In our example, we use “CloudBacko Backup Job completed with ERROR – ABC company_BenjaminIP-FTP”.

Expression is the logical expression.

Zabbix provides a Trigger expression condition interface to easily format an expression. In the Expression field, click “Add” to format the expression.

Add expression

Click “Select” button to choose the “benjamin-yip.companya.local: CloudBacko Log file-1409103670275″ item.

In the “Function” drop-down list, choose “Find string V in last (most recent) value. N = 1 – if found, 0 – otherwise”. In the V field, enter “Backup completed with error”.

Construct expression

Click “Insert” button. The expression is constructed in the Expression text box. Change the final numerical value to 1. We want the expression to evaluate to 1 when “Backup completed with error” is found in the log file.

Create trigger

Add in more description as needed.

Choose the severity. We set this trigger as “Warning”. Click “Add” button to finish creating this trigger.

Trigger design

For every CloudBacko backup jobs, the log files uses one of the seven backup job status. (Refer to the previous post How to integrate Zabbix with CloudBacko.)We recommend adding at least 6 triggers for each backup set. In our example, they are:

Trigger name Backup job status in log file (keywords)
CloudBacko Backup Job completed with ERROR – ABC company_BenjaminIP-FTP Backup completed with error
CloudBacko Backup Job completed with WARNING – ABC company_BenjaminIP-FTP Backup completed with warning
CloudBacko Backup Job interrupted by ERROR – ABC company_BenjaminIP-FTP Backup Interrupted by Error
CloudBacko Backup Job interrupted by SYSTEM ERROR – ABC company_BenjaminIP-FTP Backup Interrupted by System Error
CloudBacko Backup Job interrupted by SCHEDULER – ABC company_BenjaminIP-FTP Backup Interrupted by Scheduler
CloudBacko Backup Job interrupted by USER – ABC company_BenjaminIP-FTP Backup Interrupted by User

It’s possible to add multiple triggers for one item.

The corresponding expression for each trigger should follow the same format as follows. Replace the content in str() with keywords in the above table.

Trigger in our example is:

{erica-cheong.ahsayhqt.local:logrt["C:\Documents and Settings\benjamin.yip\.cbp\log\1409103670275\Backup\^.*log$","Backup",,,,].str(Backup completed with error)}=1

In this way, the system admin will receive notifications for any backup job that did not complete successfully.

5. Add Action

Action is a predefined operations to react an event. An action consists of operations (e.g. sending a notification) and conditions to determine when the operation is carried out.

Click on Configuration -> Action. Click on the “Create action” button on the top right to add new action.

Create actionThe “Create action” form shows up.

Form to fill in action

Enter the name field. We recommend using the company name in the field.

A default email template is set in Default subject and Default message field. You can customize the message as needed. Refer to this page for all marcos can be used in the subject and message field.

Click on the Conditions tab and edit the conditions for this action to fire. We add the condition that “Trigger severity >= Warning” and host name is “Company A Network”.

Add condition in actionClick “Add” to create the action.

Conclusion

CloudBacko is flexible and easy to be monitored using log files.

Stay tuned for other remote monitoring software integration with CloudBacko.

Write a Comment

Comment