Zabbix-16 automatic discovery of linux and windows clients

1. Goal

Use zabbix's automatic discovery to monitor various clients in batches (linux, windows)

2. Preparations and ideas

1. Create a linux host group and windows host group to accommodate hosts on the zabbix console web (of course you can customize various groups and add clients to different groups according to certain rules)

2. Create an automatic discovery rule on the zabbix console web. There is a parameter in the rule to collect the parameters from the client, and the ones that meet the rules will be collected.

Three, create automatic discovery rules on the zabbix console web

1. Create a Linux host group to accommodate automatic collection

 Group name: xDiscoverGroup Linux, click update.

2. Same as above, create another host group [xDiscoverGroup Windows] to accommodate windows clients that are automatically discovered.

3. Create [Auto-discovery] rules for discovering linux clients
and click [Configuration---Auto-discovery----Create Discovery Rules]

Name: x automatic discovery rule (because this is a good test screenshot, the description here does not feel very reasonable now)
IP range: 10.100.100.10-100 (the ip address range of the linux client to be scanned)
update interval: 1m (due to We are a test environment, in order to find the client faster, we adjusted the time down to 1 minute)
Check-check type: Zabbix client (must choose this, because we have custom parameters passed through zabbix-agent)
check
-Port range: 10050 (the default port of the zabbix client is this) Check-key value: x.autodiscover (here is used to check the client's agent custom parameters, this is written in the previous experiment, it can be written for easy identification For example, x.autodiscoverLinux, no matter what you write, you must make the zabbix server-side and client-side parameters consistent, and the client custom parameters will be introduced later)
Equipment uniqueness criteria: ip address
Host name: DNS name
visible Name: Host name
Enabled: Checked

4. Create a [auto-discovery] rule for discovering windows client
name: x rule for auto-discovering windows client
ip range: 10.100.100.10-110
update interval: 1m
check-check type: zabbix client
check-port range: 10050
key Value: x.autodiscoverWindwos (this custom parameter must also be added to the zabbix-agent parameter of the windows client, the two correspond to each other)

5. (Omitted) Take a look at the two automatic discovery rules just created

Fourth, create an action on the zabbix console web

1. Create an action for operating the automatically discovered linux client
Click [Configuration-Action-Create Action] on the zabbix page in turn

Name: xDiscoveryAction (it can also be written here to be more easily identifiable, such as: xActionDciscoveryLinux)
Calculation method: and/or (default) 
add a few rules according to your own ideas, for example, if I add three conditions, it will be triggered This "action"
A service type---equal to---Zabbix client
B host IP address---equal to---10.100.100.10-100
C auto-discovery check---equal---auto-discovery rule: Zabbix client End "x.autodiscover",
and then click [Operation]

Default title: Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS} The default is OK
Message content: The default is OK (not posted here)
Operation: Add according to your own situation, I wrote 4 items this time . The
operation is as follows ---send a message to the user Admin (Zabbix Administrator) 
operation---send a message to the user group Zabbix administrators to
add to the host group:  xDiscoverGroup Linux (this is the linux client that we created at the beginning to accommodate automatic discovery The group of the end host)
connect to the template: Template OS Linux by Zabbix agent (a linux template is automatically added to the automatically discovered host, and there is a graphic by default after adding here)

2. Create an action for operating the automatic discovery of the Linux client.
Name: xActionDiscoveryWindowsClient.
Condition A: Host IP address is equal to  10.100.100.10-100
Condition B: Service type is equal to  Zabbix client    (this requirement must also be used in conjunction with the following one)
Condition C: The auto-discovery rule is equal to x's auto-discovery windows client's rule (this is the auto-discovery windows client's rule just added)
and then click operation

Default title: The default is OK.
Message content: The default is OK.
Operation: There are two suggestions that must be selected, otherwise this action is meaningless. The following
operation-add to the host group: xDiscoverGroup Windows (this is the group we created before to accommodate the automatically discovered windows client)
Operation-associated with the template: Template OS Windows by Zabbix agent (automatically discovered winsow host Put on a default template for easy drawing)

3. (Omitted) Demonstrate the actions created to handle the automatic discovery of windows and linux hosts

5. Modify the zabbix-agent configuration file of the Linux client to allow it to participate in automatic discovery

1. For how to install the zabbix-agent program on the Linux host, please refer to " Zabbix-02: Adding the zabbix-agent client to the server "

2. Modify the corresponding parameters and add custom parameters in the zabbix main configuration file of the linux type client. (Complete configuration display)

[root@mycat32 zabbix]# egrep -v '^#|^[[:space:]]|^$' /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=10.100.100.31
ServerActive=10.100.100.31
Hostname=mycat32
Include=/etc/zabbix/zabbix_agentd.d/*.conf
UserParameter=x.autodiscover,echo kahn123

3. Annotation

Sixth, modify the zabbix-agent configuration file of the windows client to allow it to participate in automatic discovery

1. Regarding how to install zabbix agent on windows, please refer to " Zabbix-04 to install zabbix-agent on windows side agent ", or find the corresponding version of the agent program to download and install https://www.zabbix .com/download_agents

The default windows7 zabbix-agent is installed to C:\Program Files\Zabbix Agent, then the absolute path of the configuration file is C:\Program Files\Zabbix Agent\zabbix_agentd.conf

2. Modify the configuration file C:\Program Files\Zabbix Agent\zabbix_agentd.conf
and add a line in the configuration file [UserParameter=x.autodiscoverWindwos, echo suibianxie]

Long-winded:
Although the necessary parameters have been filled in when installing the windows client zabbix agent, it is recommended to check the necessary parameters in the configuration file, as follows:
Server=10.100.100.31 ---->Set the ip of the
zabbix server ServerActive=10.100. 100.31 ---->Set the ip
Hostname=XIAOEMO actively discovered by the zabbix server ----->Set the host name of the client to be displayed on the zabbix console web

3. After modifying the configuration file, remember to restart the service
control panel of the zabbix-agent program on the window ---service---zabbix agent. Double click it, click restart

4. (Extension) If your zabbix has the [zabbix_agentd] program, you can execute commands under the command line of the zabbix server to manually obtain the data of the monitored terminal, so that you can also judge whether zabbix can monitor the monitored terminal. as follows

cd /usr/local/zabbix/bin
./zabbix_get -s 10.100.100.107 -p 10050 -k "x.autodiscoverWindwos"

Note:
-s 10.100.100.107 represents the ip of the monitored terminal
-p 10050 represents the
zabbix agent port of the monitored terminal -k "x.autodiscoverWindwos" represents the key of the custom parameter

6. Test results

1. Go to the zabbix console web to see if the host has been discovered, and see if there are graphics in the monitoring.

Note that there is a small pit. The interval of the automatic discovery rule cannot be set too small and the network segment scanned cannot be too large. For example, as set in the screenshot above, from 10.100.100.10-110, we set the scan time to 1m, so that I can automatically discover the windows client after trying for a long time. But when the scan time is changed to 2m, and then the scanned network segment is changed from 10.100.100.105-110, it will be automatically discovered within a few minutes.

In the actual production environment, the scan in the automatic discovery rule set to 1h feels more reasonable.

---------------END----------2020/4/19 00:49:50------------- ----------------------------

------Send a bowl of chicken soup as usual: try to fill the days, don't let loneliness surround you, please be kind and cherish yourself, give yourself a strong reason, there is no obstacle in life. -------

Guess you like

Origin blog.csdn.net/xoofly/article/details/105606594