zabbix-快速入门

1 Login and configuring user

 
Overview

In this section you will learn how to log in and set up a system user in Zabbix.

Login

This is the Zabbix “Welcome” screen. Enter the user name Admin with password zabbix to log in as a Zabbix superuser.

When logged in, you will see 'Connected as Admin' in the lower right corner of the page. Access to Configuration and Administration menus will be granted.

Protection against brute force attacks

In case of five consecutive failed login attempts, Zabbix interface will pause for 30 seconds in order to prevent brute force and dictionary attacks.

The IP address of a failed login attempt will be displayed after a successful login.

Adding user

To view information about users, go to Administration → Users.

Initially there are only two users defined in Zabbix.

  • 'Admin' user is a Zabbix superuser, which has full permissions.
  • 'Guest' user is a special default user. If you are not logged in, you are accessing Zabbix with “guest” permissions. By default, “guest” has no permissions on Zabbix objects.

To add a new user, click on Create user.

In the new user form, make sure to add your user to one of the existing user groups, for example 'Zabbix administrators'.

By default, new users have no media (notification delivery methods) defined for them. To create one, go to the 'Media' tab and click on Add.

In this pop-up, enter an e-mail address for the user.

You can specify a time period when the medium will be active (see Time period specification page for description of the format), by default a medium is always active. You can also customise trigger severity levels for which the medium will be active, but leave all of them enabled for now.

Click on Add, then click Add in the user properties form. The new user appears in the userlist.

Adding permissions

By default, a new user has no permissions to access hosts. To grant the user rights, click on the group of the user in the Groups column (in this case - 'Zabbix administrators'). In the group properties form, go to thePermissions tab.

This user is to have read-only access to Linux servers group, so click on Select next to the user group selection field.

In this pop-up, mark the checkbox next to 'Linux servers', then click SelectLinux servers should be displayed in the selection field. Click the 'Read' button to set permission level and then Add to add the group to the list of permissions. In the user group properties form, click Update.

 

 

In Zabbix, access rights to hosts are assigned to  user groups, not individual users.

Done! You may try to log in using the credentials of the new user.

 

2 New host         #新的主机

 
Overview

In this section you will learn how to set up a new host.

A host in Zabbix is a networked entity (physical, virtual) that you wish to monitor. The definition of what can be a “host” in Zabbix is quite flexible. It can be a physical server, a network switch, a virtual machine or some application.

Adding host

Information about configured hosts in Zabbix is available in Configuration → Hosts. There is already one pre-defined host, called 'Zabbix server', but we want to learn adding another.

To add a new host, click on Create host. This will present us with a host configuration form.

The bare minimum to enter here is:

Host name

  • Enter a host name. Alphanumerics, spaces, dots, dashes and underscores are allowed.

Groups

  • Select one or several groups from the right hand side selectbox and click on  « to move them to the 'In groups' selectbox.

 

 

All access permissions are assigned to host groups, not individual hosts. That is why a host must belong to at least one group.

 

 

IP address

  • Enter the IP address of the host. Note that if this is the Zabbix server IP address, it must be specified in the Zabbix agent configuration file 'Server' directive.

Other options will suit us with their defaults for now.

When done, click Add. Your new host should be visible in the hostlist.

 

3 New item            #新项目

 
Overview

In this section you will learn how to set up an item.

Items are the basis of gathering data in Zabbix. Without items, there is no data - because only an item defines a single metric or what data to get off of a host.

Adding item

All items are grouped around hosts. That is why to configure a sample item we go to Configuration → Hosts and find the 'New host' we have created.

The Items link in the row of 'New host' should display a count of '0'. Click on the link, and then click on Create item. This will present us with an item definition form.

For our sample item, the essential information to enter is:

Name

  • Enter  CPU Load as the value. This will be the item name displayed in lists and elsewhere.

Key

  • Manually enter  system.cpu.load as the value. This is a technical name of an item that identifies the type of information that will be gathered. The particular key is just one of  pre-defined keys that come with Zabbix agent.

Type of information

  • Select  Numeric (float) here. This attribute defines the format of expected data.

 

 

You may also want to reduce the amount of days  item history will be kept, to 7 or 14. This is good practice to relieve the database from keeping lots of historical values.

 

 

Other options will suit us with their defaults for now.

When done, click Add. The new item should appear in the itemlist. Click on Details above the list to view what exactly was done.

Seeing data

With an item defined, you might be curious if it is actually gathering data. For that, go to Monitoring → Latest data, click on the + before - other - and expect your item to be there and displaying data.

With that said, first data may take up to 60 seconds to arrive. That, by default, is how often the server reads configuration changes and picks up new items to execute.

If you see no value in the 'Change' column, maybe only one value has been received so far. Wait 30 seconds for another value to arrive.

If you do not see information about the item as in the screenshot, make sure that:

  • you entered item 'Key' and 'Type of information' fields exactly as in the screenshot
  • both agent and server are running
  • host status is 'Monitored' and its availability icon is green
  • host is selected in the host dropdown, item is active
Graphs

With the item working for a while, it might be time to see something visual. Simple graphs are available for any monitored numeric item without any additional configuration. These graphs are generated on runtime.

To view the graph, go to Monitoring → Latest data and click on the 'Graph' link next to the item.

 

 

4 New trigger                   #新触发器

 
Overview

In this section you will learn how to set up a trigger.

Items only collect data. To automatically evaluate incoming data we need to define triggers. A trigger contains an expression that defines a threshold of what is an acceptable level for the data.

If that level is surpassed by the incoming data, a trigger will “fire” or go into a 'Problem' state - letting us know that something has happened that may require attention. If the level is acceptable again, trigger returns to an 'Ok' state.

Adding trigger

To configure a trigger for our item, go to Configuration → Hosts, find 'New host' and click on Triggers next to it and then on Create trigger. This presents us with a trigger definition form.

For our trigger, the essential information to enter here is:

Name

  • Enter  CPU load too high on 'New host' for 3 minutes as the value. This will be the trigger name displayed in lists and elsewhere.

Expression

  • Enter: {New host:system.cpu.load.avg(180)}>2

This is the trigger expression. Make sure that the expression is entered right, down to the last symbol. The item key here (system.cpu.load) is used to refer to the item. This particular expression basically says that the problem threshold is exceeded when the CPU load average value for 3 minutes is over 2. You can learn more about the syntax of trigger expressions.

When done, click Add. The new trigger should appear in the trigger list.

Displaying trigger status

With a trigger defined, you might be interested to see its status.

For that, go to Monitoring → Triggers. After 3 minutes or so (we asked to evaluate a 3-minute average after all) your trigger should appear there, presumably with a green 'OK' flashing in the 'Status' column.

The flashing indicates a recent change of trigger status, one that has taken place in the last 30 minutes.

If a red 'PROBLEM' is flashing there, then obviously the CPU load has exceeded the threshold level you defined in the trigger.

 

5 Receiving problem notification                 #接收问题的通知

 
Overview

In this section you will learn how to set up alerting in the form of notifications in Zabbix.

With items collecting data and triggers designed to “fire” upon problem situations, it would also be useful to have some alerting mechanism in place that would notify us about important events even when we are not directly looking at Zabbix frontend.

This is what notifications do. E-mail being the most popular delivery method for problem notifications, we will learn how to set up an e-mail notification.

E-mail settings

Initially there are several predefined notification delivery methods in Zabbix. E-mail is one of those.

To configure e-mail settings, go to Administration → Media types and click on Email in the list of pre-defined media types.

This will present us with the e-mail settings definition form.

Set the values of SMTP server, SMTP helo and SMTP e-mail to the appropriate for your environment.

 

 

'SMTP email' will be used as the 'From' address for the notifications sent from Zabbix.

 

 

Press Update when ready.

Now you have configured 'Email' as a working media type. A media type must be linked to users by defining specific delivery addresses (like we did when configuring a new user), otherwise it will not be used.

New action

Delivering notifications is one of the things actions do in Zabbix. Therefore, to set up a notification, go to Configuration → Actions and click on Create action.

In this form, enter a name for the action.

In the most simple case, if we do not add any more specific conditions, the action will be taken upon any trigger change from 'Ok' to 'Problem'.

We still should define what the action should do - and that is done in the Operations tab. Click on New in the Operations block, which opens a new operation form.

Here, click on Add in the Send to Users block and select the user ('user') we have defined. Select 'Email' as the value of Send only to. When done with this, click on Add in the operation detail block.

{TRIGGER.STATUS} and {TRIGGER.NAME} macros (or variables), visible in the Default subject and Default message fields, will be replaced with the actual trigger status and trigger name values.

That is all for a simple action configuration, so click Add in the action form.

Receiving notification

Now, with delivering notifications configured it would be fun to actually receive one. To help with that, we might on purpose increase the load on our host - so that our trigger “fires” and we receive a problem notification.

Open the console on your host and run:

cat /dev/urandom | md5sum

You may run one or several of these processes.

Now go to Monitoring → Latest data and see how the values of 'CPU Load' have increased. Remember, for our trigger to fire, the 'CPU Load' value has to go over '2' for 3 minutes running. Once it does:

  • in  Monitoring → Triggers you should see the trigger with a flashing 'Problem' status
  • you should receive a problem notification in your e-mail

 

 

If notifications do not work:

 

  • verify once again that both the e-mail settings and the action have been configured properly
  • make sure the user you created has at least read permissions on the host which generated the event, as noted in the  Adding user step. The user, being part of the 'Zabbix administrators' user group must have at least read access to 'Linux servers' host group that our host belongs to.
  • Additionally, you can check out the action log by going to  Reports → Action log.

 

6 New template                                       #新的模板

 
Overview

In this section you will learn how to set up a template.

Previously we learned how to set up an item, a trigger and how to get a problem notification for the host.

While all of these steps offer a great deal of flexibility in themselves, it may appear like a lot of steps to take if needed for, say, a thousand hosts. Some automation would be handy.

This is where templates come to help. Templates allow to group useful items, triggers and other entities so that those can be reused again and again by applying to hosts in a single step.

When a template is linked to a host, the host inherits all entities of the template. So, basically a pre-prepared bunch of checks can be applied very quickly.

Adding template

To start working with templates, we must first create one. To do that, in Configuration → Templates click on Create template. This will present us with a template configuration form.

The required parameters to enter here are:

Template name

  • Enter a template name. Alpha-numericals, spaces and underscores are allowed.

Groups

  • Select one or several groups from the right hand side selectbox and click on  « to move them to the 'In groups' selectbox. The template must belong to a group.

When done, click Add. Your new template should be visible in the list of templates.

As you may see, the template is there, but it holds nothing in it - no items, triggers or other entities.

Adding item to template

To add an item to the template, go to the item list for 'New host'. In Configuration → Hosts click on Items next to 'New host'.

Then:

  • mark the checkbox of the 'CPU Load' item in the list
  • click on  Copy below the list
  • select the template to copy item to

  • click on  Copy

If you now go to Configuration → Templates, 'New template' should have one new item in it.

We will stop at one item only for now, but similarly you can add any other items, triggers or other entities to the template until it's a fairly complete set of entities for given purpose (monitoring OS, monitoring single application).

Linking template to host

With a template ready, it only remains to add it to a host. For that, go to Configuration → Hosts, click on 'New host' to open its property form and go to the Templates tab.

There, click on Select next to Link new templates. In the pop-up window click on the name of template we have created ('New template'). As it appears in the Link new templates field, click on Add. The template should appear in the Linked templates list.

Click Update in the form to save the changes. The template is now added to the host, with all entities that it holds.

As you may have guessed, this way it can be applied to any other host as well. Any changes to the items, triggers and other entities at the template level will propagate to the hosts the template is linked to.

Linking pre-defined templates to hosts

As you may have noticed, Zabbix comes with a set of predefined templates for various OS, devices and applications. To get started with monitoring very quickly, you may link the appropriate one of them to a host, but beware that these templates need to be fine-tuned for your environment. Some checks may not be needed, and polling intervals may be way too frequent.

More information about templates is available.

 

1 Configuring a host

 
Overview

To configure a host in Zabbix frontend, do the following:

  • Go to:  Configuration → Hosts
  • Click on  Create host to the right (or on the host name to edit an existing host)
  • Enter parameters of the host in the form

You can also use the Clone and Full clone buttons in the form of an existing host to create a new host. Clicking on Clone will retain all host parameters and template linkage (keeping all entities from those templates). Full clone will additionally retain directly attached entities (applications, items, triggers, graphs, low-level discovery rules and web scenarios).

Note: When a host is cloned, it will retain all template entities as they are originally on the template. Any changes to those entities made on the existing host level (such as changed item interval, modified regular expression or added prototypes to the low-level discovery rule) will not be cloned to the new host; instead they will be as on the template.

Configuration

The Host tab contains general host attributes:

ParameterDescription
Host nameEnter a unique host name. Alphanumerics, spaces, dots, dashes and underscores are allowed.
Note: With Zabbix agent running on the host you are configuring, the agent configuration file parameter Hostname must have the same value as the host name entered here. The name in the parameter is needed in the processing of active checks.
Visible nameIf you set this name, it will be the one visible in lists, maps, etc. This attribute has UTF-8 support.
GroupsSelect host groups the host belongs to. A host must belong to at least one host group.
New host groupA new group can be created and linked to the host. Ignored, if empty.
InterfacesSeveral host interface types are supported for a host: AgentSNMPJMX and IPMI.
To add a new interface, click on Add in the Interfaces block and enter IP/DNSConnect to and Port info.
Note: Interfaces that are used in any items cannot be removed and link Remove is greyed out for them.
Use bulk requests option for SNMP interfaces allows to enable/disable bulk processing of SNMP requests per interface.
IP addressHost IP address (optional).
DNS nameHost DNS name (optional).
Connect toClicking the respective button will tell Zabbix server what to use to retrieve data from agents:
IP - Connect to the host IP address (recommended)
DNS - Connect to the host DNS name
PortTCP/UDP port number. Default values are: 10050 for Zabbix agent, 161 for SNMP agent, 12345 for JMX and 623 for IPMI.
DefaultCheck the radio button to set the default interface.
DescriptionEnter the host description.
Monitored by proxyThe host can be monitored either by Zabbix server or one of Zabbix proxies:
(no proxy) - host is monitored by Zabbix server
Proxy name - host is monitored by Zabbix proxy “Proxy name”
EnabledMark the checkbox to make the host active, ready to be monitored. If unchecked, the host is not active, thus not monitored.

The Templates tab allows you to link templates to the host. All entities (items, triggers, graphs and applications) will be inherited from the template.

To link a new template, start typing in the Link new templates field until a list of matching templates appear. Scroll down to select. When all templates to be linked are selected, click on Add.

To unlink a template, use one of the two options in the Linked templates block:

  • Unlink - unlink the template, but preserve its items, triggers and graphs
  • Unlink and clear - unlink the template and remove all its items, triggers and graphs

Listed template names are clickable links leading to the template configuration form.

See also known issues about template linkage.

The IPMI tab contains IPMI management attributes.

ParameterDescription
Authentication algorithmSelect the authentication algorithm.
Privilege levelSelect the privilege level.
UsernameUser name for authentication.
PasswordPassword for authentication.

The Macros tab allows you to define host-level user macros. You may also view here template-level and global macros if you select the Inherited and host macros option. That is where all defined user macros for the host are displayed with the value they resolve to as well as their origin.

For convenience, links to respective templates and global macro configuration are provided. It is also possible to edit a template/global macro on the host level, effectively creating a copy of the macro on the host.

The Host inventory tab allows you to manually enter inventory information for the host. You can also select to enable Automatic inventory population, or disable inventory population for this host.

The Encryption tab allows you to require encrypted connections with the host.

ParameterDescription
Connections to hostHow Zabbix server or proxy connects to Zabbix agent on a host: no encryption (default), using PSK (pre-shared key) or certificate.
Connections from hostSelect what type of connections are allowed from the host (i.e. from Zabbix agent and Zabbix sender). Several connection types can be selected at the same time (useful for testing and switching to other connection type). Default is “No encryption”.
IssuerAllowed issuer of certificate. Certificate is first validated with CA (certificate authority). If it is valid, signed by the CA, then the Issuer field can be used to further restrict allowed CA. This field is intended to be used if your Zabbix installation uses certificates from multiple CAs. If this field is empty then any CA is accepted.
SubjectAllowed subject of certificate. Certificate is first validated with CA. If it is valid, signed by the CA, then the Subject field can be used to allow only one value of Subject string. If this field is empty then any valid certificate signed by the configured CA is accepted.
PSK identityPre-shared key identity string.
PSKPre-shared key (hex-string). Maximum length: 512 hex-digits (256-byte PSK) if Zabbix uses GnuTLS or OpenSSL library, 64 hex-digits (32-byte PSK) if Zabbix uses mbed TLS (PolarSSL) library. Example: 1f87b595725ac58dd977beef14b97461a7c1045b9a1c963065002c5473194952
Configuring a host group

To configure a host group in Zabbix frontend, do the following:

  • Go to:  Configuration → Host groups
  • Click on  Create Group in the upper right corner of the screen
  • Enter parameters of the group in the form

ParameterDescription
Group nameEnter a unique host group name.
To create a nested host group, use the '/' forward slash separator, for example Europe/Latvia/Riga/Zabbix servers. You can create this group even if none of the three parent host groups (Europe/Latvia/Riga) exist. In this case creating these parent host groups is up to the user; they will not be created automatically.
Leading and trailing slashes, several slashes in a row are not allowed. Asterisks are not allowed in Zabbix 3.2.0, 3.2.1. Escaping of '/' is not supported.
Nested representation of host groups is supported since Zabbix 3.2.0.
HostsSelect hosts, members of the group. A host group may have zero, one or more hosts.

Permissions to nested host groups

  • When creating a child host group to an existing parent host group,  user group permissions to the child are inherited from the parent (for example, when creating  Riga/Zabbix servers if  Riga already exists)
  • When creating a parent host group to an existing child host group, no permissions to the parent are set (for example, when creating  Riga if  Riga/Zabbix servers already exists)

 

2 Inventory

 
Overview

You can keep the inventory of networked devices in Zabbix.

There is a special Inventory menu in the Zabbix frontend. However, you will not see any data there initially and it is not where you enter data. Building inventory data is done manually when configuring a host or automatically by using some automatic population options.

Building inventory
 
Manual mode

When configuring a host, in the Host inventory tab you can enter such details as the type of device, serial number, location, responsible person, etc - data that will populate inventory information.

If a URL is included in host inventory information and it starts with 'http' or 'https', it will result in a clickable link in the Inventory section.

Automatic mode

Host inventory can also be populated automatically. For that to work, when configuring a host the inventory mode in the Host inventory tab must be set to Automatic.

Then you can configure host items to populate any host inventory field with their value, indicating the destination field with the respective attribute (called Item will populate host inventory field) in item configuration.

Items that are especially useful for automated inventory data collection:

  • system.hw.chassis[full|type|vendor|model|serial] - default is [full], root permissions needed
  • system.hw.cpu[all|cpunum,full|maxfreq|vendor|model|curfreq] - default is [all,full]
  • system.hw.devices[pci|usb] - default is [pci]
  • system.hw.macaddr[interface,short|full] - default is [all,full], interface is regexp
  • system.sw.arch
  • system.sw.os[name|short|full] - default is [name]
  • system.sw.packages[package,manager,short|full] - default is [all,all,full], package is regexp
Inventory mode selection

Inventory mode can be selected in the host configuration form.

Inventory mode by default for new hosts is selected based on the Default host inventory mode setting in Administration → General → Other.

For hosts added by network discovery or auto registration actions, it is possible to define a Set host inventory mode operation selecting manual or automatic mode. This operation overrides the Default host inventory mode setting.

Inventory overview

The details of all existing inventory data are available in the Inventory menu.

In Inventory → Overview you can get a host count by various fields of the inventory.

In Inventory → Hosts you can see all hosts that have inventory information. Clicking on the host name will reveal the inventory details in a form.

The Overview tab shows:

ParameterDescription
Host nameName of the host.
Clicking on the name opens a menu with the scripts defined for the host.
Host name is displayed with an orange icon, if the host is in maintenance.
Visible nameVisible name of the host (if defined).
Host (Agent, SNMP, JMX, IPMI)
interfaces
This block provides details of the interfaces configured for the host.
OSOperating system inventory field of the host (if defined).
HardwareHost hardware inventory field (if defined).
SoftwareHost software inventory field (if defined).
DescriptionHost description.
MonitoringLinks to monitoring sections with data for this host: WebLatest dataTriggersProblemsGraphsScreens.
ConfigurationLinks to configuration sections for this host: HostApplicationsItemsTriggersGraphsDiscoveryWeb.
The amount of configured entities is listed in parenthesis after each link.

The Details tab shows all inventory fields that are populated (are not empty).

Inventory macros

There are host inventory macros {INVENTORY.*} available for use in notifications, for example:

“Server in {INVENTORY.LOCATION1} has a problem, responsible person is {INVENTORY.CONTACT1}, phone number {INVENTORY.POC.PRIMARY.PHONE.A1}.”

For more details, see the Macros supported by location page.

 

3 Mass update

 
Overview

Sometimes you may want to change some attribute for a number of hosts at once. Instead of opening each individual host for editing, you may use the mass update function for that.

Using mass update

To mass-update some hosts, do the following:

  • Mark the checkboxes before the hosts you want to update in the  host list
  • Click on  Mass update below the list
  • Navigate to the desired tab of attributes ( HostTemplatesIPMI or  Inventory)
  • Mark the checkboxes of any attribute to update and enter a new value for them

Replace host groups will remove the host from any existing host groups and replace those with the one(s) specified in this field.

Add new or existing host groups allows to specify additional host groups from the existing ones or enter completely new host groups for the hosts.

Both these fields are auto-complete - starting to type in them offers a dropdown of matching host groups. If the host group is new, it also appears in the dropdown and it is indicated by (new) after the string. Just scroll down to select.

To update template linkage in the Templates tab, select Link templates and start typing the template name in the auto-complete field until a dropdown appears offering the matching templates. Just scroll down to select the template to link.

The Replace option will allow to link a new template while unlinking any template that was linked to the hosts before. The Clear when unlinking option will allow to not only unlink any previously linked templates, but also remove all elements inherited from them (items, triggers, etc.).

To be able to mass update inventory fields, the Inventory mode should be set to 'Manual' or 'Automatic'.

When done with all required changes, click on Update. The attributes will be updated accordingly for all the selected hosts.

 

 

未完待续·············

 

 

 

 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/it-hack/p/7492691.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值