Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation and debugging of Zabbix-Network-Weathermap

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Zabbix-Network-Weathermap installation

It can be installed on a new host, as long as you can call Zabbix API. To take advantage of the existing host, you can install it with Web, so to get the data is to find the local Web and call Zabbix API.

Installation steps

It is a little different from the steps in the project and has been adjusted. Install the python environment first, and then install all other dependencies through pip:

# install python3 environment $yum install python3 # update pip$ easy_install-3.6-I https://mirrors.aliyun.com/pypi/simple-U pip$ pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ # install other dependent components via pip $pip install Pillow $pip install py-zabbix $pip install ruamel.yaml==0.14.12# download the project locally You can also use git to clone the project to local $wget-- output-document=Zabbix-Network-Weathermap.zip https://github.com/Prototype-X/Zabbix-Network-Weathermap/archive/master.zip # to extract If you use git, you don't have to unzip the $yum install unnzip$ unzip Zabbix-Network-Weathermap.zip-d / opt # folder to rename and authorize $mv / opt/Zabbix-Network-Weathermap {- master,} $chown-R zabbix:zabbix / opt/Zabbix-Network-Weathermap $chmod astatx / opt/Zabbix-Network-Weathermap/starter.py $chmod astatx / opt/Zabbix-Network-Weathermap/weathermap.py

When the installation comes to an end, the later part of agent may not need to be installed at first, and may not need to be installed in the end, and there are other ways of deployment other than agent.

Installation of the agent side

The steps here continue with the steps above. However, agent is not necessary, and the next steps here can be avoided.

Crontab can be used instead of agent, and it may be better. The purpose is to periodically call the project's python script to request data from zabbix, draw pictures, and then update the background map used by the topology diagram.

Crontab can execute scripts on a regular basis. The monitoring item of agent can also set the polling time to execute the script.

If you want to execute the script regularly with agent, go ahead:

# copy the agent configuration file in the project to the agent configuration directory $cp / opt/Zabbix-Network-Weathermap/template/userparameter_weathermap.conf / etc/zabbix/zabbix_agentd.d/ # you need to restart agent to load the new configuration effective $systemctl restart zabbix-agent # download the template configuration file to your computer Then upload the settings on the template $yum install lrzsz$ sz / opt/Zabbix-Network-Weathermap/template/weathermap.xml browser via web

This step is also done for agent, which is not needed if you do not poll the execution script for agent's monitoring items.

Import template

Upload the downloaded template file to zabbix: configuration-> templates-> Import. Then select the file to import and upload it with the default rules.

Agent host binding template

Configure-> host, select agent host, go to template paging, select the newly uploaded template "Template Weathermap" update, and complete the binding.

Create a Zabbix user

Execute the script, request data through API, update the background image, and need to use a user to authenticate.

Create new user with permissions Zabbix Admin

User must have read-only or read-write access to hosts and hosts groups present in map

The administrator account is directly used in the experiment, and the specific permissions have not been carefully verified.

Set the macros of the template

Configure-> template-> Template Weathermap-> Macro:

There are 4 macros preset here, and the value of the macro needs to be modified. The value of the macro is the command-line argument that executes the script.

For example, the actual script to be executed is:

$. / opt/Zabbix-Network-Weathermap/starter.py-s mapname1 mapname2-z http://localhost/zabbix/-l Admin-p zabbix

Then fill in the value of the macro with the following parameters.

Specific how to fill in, what is the use of each macro, later manual debugging will talk about.

Here, disable the four monitoring items of Template Weathermap, wait for manual debugging, and then complete the setting, and then enable it.

Complete the installation

At this point, the installation is initially completed.

The next step is usage and debugging. The debugging process can execute the script manually on the server through the command line. So there is no need for agent.

Debug

There are two executable python scripts under the project:

Weathermap.pystarter.py

The main function is weathermap.py, and starter.py also calls weathermap.py. The difference is that it is executed through starter.py, and finally the execution time of the script is printed.

Parameters are required to execute the script, and the meaning of the parameters can be seen through the-h option. There are only the following four commands to perform different functions:

$weathermap.py-s mapname1 mapnameN-z http://localhost/zabbix-l Admin-p zabbix$ weathermap.py-s mapname1 mapnameN-f $weathermap.py-m mapname1.yaml mapnameN.yaml-I / var/www/weather$ weathermap.py-m mapname1.yaml-u

The options-s and-m are followed by more parameters, which corresponds to how many topology diagrams you need to use weathermap.

Create a topology diagram

First create a topology diagram on Web, which requires nodes and connections.

Original topology diagram:

Beautification of connection

The effect can not be seen until the full effect comes out. You can wait until the effect comes out, and then adjust it according to the suggestion.

There are 4 types of connections. It is recommended to choose dashed lines:

Thick line, dotted line.

The color of the connection can also be set, try a lighter color, or a color similar to the background.

Weathermap debugging

First take a look at the project directory / opt/Zabbix-Network-Weathermap/mapcfgs. It is empty at first, or there are several sample files.

Generate yaml configuration files used by the corresponding weather according to the topology diagram

In the weathermap project, generate the yaml configuration file for the topology diagram.

Execute the following command:

$weathermap.py-s mapname1-z http://localhost/zabbix-l Admin-p zabbix

-s mapname1, is the command of the topology diagram in the corresponding zabbix.

-z fill in the url on the home page of zabbix.

-l,-p, is the user name and password of the account.

If the execution is successful, a yaml configuration file with the corresponding name is generated.

Edit configuration file

Find those configuration items for link- in the configuration

Link-10: node1: node-12 node2: node-15 name1: web name2: Router_symbol_ (96) hostname: web itemin: net.if.in ["eth0"] itemout: net.if.out ["eth0"]

Some of the options are empty by default and need to be filled in manually. The most basic is to fill in 3 items:

Hostname: the "host name" that needs to collect data. If a "visible name" is defined, fill in the latter. Itemin: enter the key of the monitoring item, which means to request to obtain data. Itemout: ditto.

There are other configurations that can be added or modified and can be changed later.

Generate background map

After modifying the configuration file, execute the following script to get the data and generate the background image:

$weathermap.py-m mapname1.yaml-I ~ /

After the command is executed, a background image of png is generated in the home directory:

Upload background image

The above may be the practice of the old version, now you can send the background image directly to zabbix for direct use. Execute the following command:

$weathermap.py-m mapname1.yaml-u

Add the-u option and upload it directly to zabbix.

At this point, you can go to the web, and apply the generated background image to the "background image" in the attributes of the topology diagram:

Update picture elements

According to the effect of the picture, it can be found that the generated lines are generated according to the location of the node. If the topology diagram has been edited, such as the location of the nodes has changed, or new nodes have been added, then the configuration of the yaml file needs to be adjusted. You can update the settings on the topology diagram by executing the following command:

$weathermap.py-s mapname1-f

Summary

At this point, all four scripts have been used and the effect has been cleared.

To generate a configuration file, you only need to create a new topology diagram and manually execute it once before you modify the yaml configuration file, which needs to be executed automatically and refresh the data. The execution frequency will be relatively high, such as uploading the background image once a minute, which is not needed. There is no need to update the picture element at all, this needs to be performed once after the picture is updated. It also needs to be set to automatic, but the frequency should not be very high, such as checking the status of agent monitoring items once an hour.

If you use agent to execute scripts on a regular basis, check the status of the monitoring items after deployment.

Configure-> Host-> Select the monitoring items of the host-> View the monitoring items of the "Weathermap" application set, and mainly view the status and information below.

If there is a problem with the value setting of the macro, the exception thrown by python is usually recorded in the message. At this point, you should log in to the server to manually execute the script to check and troubleshoot.

If there is nothing wrong with the script running parameters, there is likely to be an execution timeout problem:

Agent execution timeout problem

The instructions in the project are as follows:

Zabbix API performance is low. Zabbix agent run weathermap.py. Weathermap.py can be terminated by timeout, set in zabbix_agentd.conf.

Decision:

Increase the timeout for example: zabbix_agentd.conf set Timeout=10One item to one map in Template WeathermapUse cron to run the scripts

There is a timeout limit for zabbix's agent, which defaults to 3 seconds. A normal execution of the script, if a topology diagram, may be just enough. If you ask for several topology diagrams at a time, it is likely to time out. You can use starter.py on the command line to run a script to see the run time. However, execution triggered by agent may be less efficient and a little more time-consuming.

The solution is as follows:

Increase the timeout of agent. For example, if you operate only one topology diagram and multiple topology diagrams at a time in 10 seconds, you need to set up multiple monitoring items and use crontab to execute scripts regularly.

With agent, starter.py is actually called when polling.

The font is too small

Not only the font size (fontsize), but also the background color (bgcolor). These are the parameters under map.

After executing the command with the-s option, the settings in the yaml configuration file are overwritten by the default values. The font size defaults to 10 and the background color defaults to empty.

So even if these two items are set, the background map of the composite requirement is generated. But the next time you execute the command with the-s option, such as updating the image element, the settings in the configuration file will be changed back to the default values. The image generated after that will return to the default effect.

Source code modification

This problem can be solved by modifying the source code by adding the following paragraph:

The most recent modification of the project was 12 Oct 2018. If there is a problem, you may have to solve it by yourself.

Yaml configuration parameters

Global Settin

The beginning of the configuration file:

% YAML 1.2---map: name: mapname1 bgcolor:''# set background color, default is empty fontsize: 10 # set font size, default 10 is too small width: 1200 height: 800zabbix: url: http://zabbix.example.com login: admin password: admintable: # generate a legend, display time and arrow color meaning show: true # default is false You can change to true to enable x: 1100 y: 100palette: # each color represents a segment of utilization, and the default color is very good -'# 908C8Ccolors -'# FFFFFF'-'# 8000FFsets -'# 00FFFsets -'# 00EAEAFS -'# 00FF00colors -'# FFFF00'-'# FF9933'-'# FF0000'link: # default line settings Each link can also be individually configured with bandwidth: 100 # line bandwidth, affecting the color of the display, unit Mbits/s width: 10 # line thickness, the default value can also be. Maybe you can set different thickness according to the bandwidth.

Settings of nodes and Lin

Node-11: name: Router # label: R1 # is used in the old version. If set, you can draw the label # icon: Router64.png # use the old version. If set, you can draw the node icon x: 125y: 75 # copy: true # if set, even if this element is not in the topology Also draw the visible name on node-15: name: Router_symbol_ (96) x: 375y: 324link-9: node1: node-11 node2: node-15 name1: Router # zabix name2: Router_symbol_ (96) # bandwidth: 10 # can override the default link setting # width: 5 # copy: true # if set, even if this element is not in the topology Also draw hostname: Router # set the node collected by the monitoring item itemin: net.if.in ["eth0"] # set the key itemout of the monitoring item: net.if.out ["eth0"] # set the key of the monitoring item

There are two parameters used in the old version, label and icon. When drawing, you can also draw the nodes.

The previously generated background image has no node information, and the node information is directly displayed as elements of the topology diagram and does not need to be drawn on the background.

When using the-I parameter to generate a picture, add these settings to draw the node as well. This is the implementation of the version, and it may not be possible to apply the background map of the topology at that time.

Dashboard effect

To refresh the data on the topology in real time, it is necessary to automatically refresh the topology diagram. Configured on the dashboard on the home page

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report