Distributed System Monitoring zabbix explanation 2 Mail alarm notification-Technical flow Ken

Source: Internet
Author: User
Overview

In the previous blog "Distributed System Monitoring zabbix explains a technology stream Ken", we have explained in detail how to install zabbix. This blog will explain in detail how to use zabbix to monitor another host, and implements the email alarm and notification mechanism.

First, we need to create a host to be monitored and set corresponding monitoring items. When the metric item collects data, the trigger triggers an alarm based on the exception status. Based on some alarm mechanisms, it will also notify us of some important events, instead of directly viewing them at the zabbix front-end.

This is the notification function. E-mail is the most common method for sending abnormal notifications. We will learn how to configure email notifications.

 

Host creation Overview

The host in zabbix is a network entity (physical or virtual) You want to monitor ). In zabbix, the host definition is very flexible. It can be a physical server, a network switch, a virtual machine or some applications.

Add hosts

In zabbix, you can useConfiguration → host (hosts)Menu to view the configured host information. By default, there is a pre-defined host named 'zabbix Server. But we need to learn how to add another one.

ClickCreate host)To add a new host. This displays a host configuration table.

Enter at least the following fields:

Host Name)

  • Enter a host name, which can contain letters, numbers, spaces, dots, hyphens (.), hyphens (-), and underscores (_).

Group

  • Select one or more groups from the select box on the right, and then click?Move them to the in group selection box.
All access permissions are assigned to the Host group instead of individual hosts. This is why the host must belong to at least one group.

IP address

  • Enter the IP address of the host. Note that if this is the IP address of zabbix server, it must be the value of the 'server' parameter in the zabbix agent configuration file.

Temporarily retain the default values of other options.

ClickAdd). You can see the newly added host in the host list.

 

Create metric Summary

Metrics are the basis for data acquisition in zabbix. There is no metric item, so there is no data-because only the metric item in a host defines a single metric or the data to be obtained.

Add Metric

The host contains all the metrics. If you want to configure a metric example, goConfiguration → host (hosts)And find the created 'new host )'.

In the row 'new host (new host,Monitoring item (items)The number of links is displayed as '0 '. Click this link, and then clickCreate item)A metric definition table is displayed.

Configure the host I just created, click items, and then click Create item in the upper left corner.

For a metric example, enter the following information:

Name)

  • InputCPU loadAs the value. This value is displayed in the list and elsewhere as the metric name.

Value (key)

  • Click Select to select the content you want to monitor. This is a technical name of a metric and is used to identify the type of information to be obtained. This specific value must be one of the predefined values of zabbix agent. I chose to monitor port 80 of my 10.220.5.20.

Type of information)

  • SelectNumeric (float). This attribute defines the format of the data to be obtained.

 

You also need to reduce the number of days the metric item has been retained for, 7 or 14 days. For databases, the best practice is to prevent the database from retaining too much historical data.

 

We keep the default values for other options temporarily.

ClickAdd). The new metric item appears in the metric item list. ClickDetail)To view details.

View data

After a metric is defined, you may be curious about the specific value it obtains. GoMonitoring (Monitoring) → latest data (latest data), Click-Other-Previous+And then view the monitoring metrics you have defined and the obtained values. For example, we can see that the current last value is 1, indicating that port 80 of my 10.220.5.20.is online.

At the same time, it takes up to 60 seconds to obtain the metric value for the first time. By default, this is the frequency at which the server reads the changed configuration file and obtains and executes new monitoring metrics.

If you do not see the value in the 'Change 'column, you may have only obtained the value once so far. Wait 30 seconds to obtain the new metric value.

If you do not see the metric information on the current interface, confirm:

  • The value (key) of the metric item you entered is the same as that of type of information.
  • Both agent and server are running
  • The host status is 'monitored (monitored) 'and Its Availability icon is green.
  • The monitoring item is enabled.
Chart

After the monitoring item has been running for a period of time, you can view the visual chart. A simple chart is applicable to any monitored numeric metric item without additional configuration. These charts are generated at runtime.

GoMonitoring (Monitoring) → latest data (latest data)Click the 'graph (graph) 'link next to the metric item to view the chart.

 

 

New trigger Overview

Metric items are only used to collect data. To automatically evaluate the received data, we need to define the trigger. A trigger contains an expression that defines an acceptable threshold level for data.

If the received data exceeds the defined level, the trigger will be "triggered" or enter the "problem" status-to attract our attention, let us know that a problem has occurred. If the data is restored to a reasonable range, the trigger will be in the "OK" status.

Add trigger

Configure a trigger for the monitoring metrics, goConfiguration → host (hosts), Find 'add host (new host) ', and click NextTriggers)And then clickCreate trigger). This will show us a trigger definition form.

The following are required for triggers:

Name)

  • Enter check_80_triger as the value. This value will be used as the trigger name in the list and other places.

Expression)

  • Input: {ken1: net. tcp. Listen [80]. Last ()} = 0

Value. Make sure that the expression is entered correctly, including all symbols. This specific expression roughly indicates that if the return value of port 80 is 0, the problematic threshold is triggered.

ClickAdd). The new trigger is displayed in the trigger list.

Show trigger status

After a trigger is defined, you may want to view its status.

GoMonitoring (Monitoring) → triggers)To view. After 3 minutes (we need to wait 3 minutes to evaluate the trigger's 3-minute average), the trigger will be displayed here. A green 'OK' should flash in the 'status 'column.

Flashing means that the trigger status has changed in the last 30 minutes.

If there is a blinking red 'problem' here, obviously, this indicates that port 80 is already at the threshold level defined in the trigger.

 

Email Alert Overview

When the metric item collects data, the trigger triggers an alarm based on the exception status. Based on some alarm mechanisms, it will also notify us of some important events, instead of directly viewing them at the zabbix front-end.

This is the notification function. E-mail is the most common method for sending abnormal notifications. We will learn how to configure email notifications.

Email settings

Zabbix initially has built-in predefined notification sending methods, which are email notification.

GoAdministration → media types)And clickEmailTo configure email.

This will show us the e-mail setting definition form.

Set the values of SMTP server, smtp helo, and SMTP e-mail based on your environment.

 

'Smtp email 'serves as the 'sender (from)' address of the zabbix notification.

 

After everything is ready, clickUpdate).

Now you have configured 'email 'as an available media type. A media type must be associated with users through the Sending address. To create a notification, goConfiguration → action)And then clickCreate action).

In this form, enter the name of the action.

{Trigger. Status} and {trigger. name} are macro (macros) or variables.Default subjectAndDefault MessageView regions. It is replaced by the actual trigger status and trigger name value.

In most simple examples, if we do not add more specified conditions, this action will occur when the trigger changes from 'OK' to 'problem.

We also need to define what this action has done-that is, inOperations)Tab. ClickNew)To open an operation form.

HereSend to users)Block clickAdd)And select the user we defined earlier ('user '). Select 'email'Send only. Then, in the Operation Details area, clickAdd).

This is a simple action configuration step, that is, clickAdd).

Get notification

Now, the notification configuration is complete. Let's see how it sends the notification to the actual recipient. To achieve this goal, we need to turn off port 80 so that our trigger will be triggered and we will receive an exception notification.

Open the console of the host and run:

[[email protected] local]# pkill httpd[[email protected] local]# ss -tnl | grep 80

Make sure port 80 has been disabled.

 

Now goMonitoring (Monitoring) → latest data (latest data)To check whether the last value has been changed to 0.

  • InMonitoring (Monitoring) → triggers), You will see that the trigger status shows a green blinking 'problem'
  • You will receive an exception notification in your email.

If the notification function does not work properly:
  • Verify that the email settings and Action Settings are correctly configured.
  • Make sure that the user you created has at least the read permission on the host that generates the event. AsAdd UserAs mentioned in the step, users in the 'zabbix administrators 'user group must have at least read permission on the 'linux servers' Host group (the group to which the host belongs.
  • In addition, you canReport> Action Log)Check the Action Log.

Distributed System Monitoring zabbix explanation 2 Mail alarm notification-Technical flow Ken

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.