Use Zabbix and grafana to monitor switch traffic

1. Install Zabbix

# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.noarch.rpm  
# yum -y install zabbix-server-mysql zabbix-web-mysql
# yum -y install mariadb-server mariadb
# systemctl start mariadb
# systemctl status mariadb
# systemctl enable mariadb
# cd /usr/share/doc/zabbix-server-mysql-3.4.4
# zcat create.sql.gz | mysql -uzabbix -p zabbix
# egrep -v "^#|^$" /etc/zabbix/zabbix_server.conf 
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=wangzhijian
StartPollers=15
StartPollersUnreachable=25
StartPingers=10
StartDiscoverers = 10
SNMPTrapperFile = / var / log / snmptrap / snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
# systemctl start zabbix-server
# systemctl status zabbix-server
# systemctl enable zabbix-server
# vim /etc/httpd/conf.d/zabbix.conf
    php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value always_populate_raw_post_data -1
        # php_value date.timezone Europe/Riga
        php_value date.timezone Asia/Shanghai
# systemctl start httpd
# systemctl status httpd
# systemctl enable httpd

Enter http://localhost/zabbix in the browser to log in to zabbix, the default user name is Admin, and the default password is zabbix.


2. Install Grafana and its Zabbix plugin

# yum install https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.0.3-1.x86_64.rpm
# systemctl start grafana-server
# grafana-cli plugins list-remote
# grafana-cli plugins list-remote | grep zabbix
id: alexanderzobnin-zabbix-app version: 3.9.0
# grafana-cli plugins install alexanderzobnin-zabbix-app
# systemctl restart grafana-server

Enter http://localhost:3000 in the browser to log in to grafana, the default user name is admin, and the default password is admin.


3. Configure Zabbix access switch

a. Create a host group

zabbix01.PNG


b. Configure and add the group name

zabbix02.PNG


c. Click the host to enter the host interface to create a host

zabbix03.PNG


d. Click Create host to create

zabbix04.PNG


e. Configure hostname, group and SNMP interface

zabbix05.PNG


f. SNMPv2 is used here to monitor the switch. Officially, there are ready-made templates for use. Remember to click Add after selecting the template to successfully add the template.

zabbix06.PNG


g. Configure the host macro, where the configuration macro is {$SNMP_COMMUNITY}, the value is the username public of the switch snmp

zabbix07.PNG


h. The configuration is completed as shown below, but since some of the auto-discovery rules of the template are not applicable, the unnecessary rules are now disabled

zabbix08.PNG


i. Disable MIB rules

zabbix09.PNG


j. Deactivate unneeded monitoring item prototypes

zabbix10.PNG


k. After that, the collected monitoring items, triggers and graphs will be displayed, and the time of the collected items will be different.

zabbix11.PNG


l. Now view the monitoring graph

QQ screenshot 20180503145625.png


4. Configure Zabbix to connect to Grafana

a. Log in to Grafana and click Enable now to enter the Zabbix plugin page

QQ screenshot 20180327172426.png


b. Click Enable to enable Zabbix plugin

QQ screenshot 20180327172455.png


c. Then click Data Sources under the settings icon to configure zabbix

QQ picture 20180410101216.png


d. Configure zabbix, the main configuration items:

HTTP URL项:

           http://127.0.0.1/zabbix/api_jsonrpc.php

Zabbix API details项:

Here is still the default username Admin and the default password zabbix

After the configuration is complete, click save&test to save and test. If it is normal, there will be a green prompt box. If the configuration is wrong, a red prompt box will be displayed.

QQ screenshot 20180410102241.png

QQ screenshot 20180410102633.png

QQ screenshot 20180410102813.png


e. Then you can view the dashboard of the zabbix server

QQ screenshot 20180503150025.png


f. Click New dashboard to create a dashboard

QQ screenshot 20180503150208.png


g. Here we first click on the settings to set the variables first

QQ screenshot 20180503150246.png


h. Configure the dashboard name

QQ screenshot 20180503150717.png


i. Configuration variables, pay special attention to the configuration of Query values

QQ screenshot 20180503150949.png


①Configure the first variable

QQ screenshot 20180503151016.png


②Configure the second variable

QQ screenshot 20180503151036.png


③ Configure the third variable

In the last variable configuration, the regular expression needs to be configured here. My regular expression configuration is as follows:

/(GigabitEthernet\d{1,}/\d{1,}/\d{1,}/\d{1,}|GigabitEthernet\d{1,}/\d{1,}/\d{1,}|GigabitEthernet \d{1,}/\d{1,})/

QQ screenshot 20180503151057.png


j. Now start to configure the graph, click the Panel button to create a new graph

QQ截图20180503164403.png


① Click Singlestat under New Panel to configure the name of the acquisition switch

QQ截图20180503151744.png

QQ截图20180503151800.png


②Create a new graph and click Singlestat under New Panel to configure the online time of the acquisition switch

QQ截图20180503151854.png

QQ截图20180503151910.png

QQ截图20180503151935.png


③Create a new graph and click Singlestat under New Panel to configure and collect the ping value of the switch to confirm whether the switch is running normally [Note: The thresholds on the options page here are set to 0, 1; the configuration inverts the color of the color tab, that is, 0 corresponds to red (WARNING), 1 corresponds to green (HEALTHY). ]

QQ截图20180503152001.png

QQ截图20180503152014.png

QQ截图20180503152027.png


Click Graph under New Panel to configure the collection traffic

QQ截图20180503152112.png

QQ截图20180503152126.png


k. After the configuration is completed, the flow chart will be displayed as follows:

QQ截图20180503152250.png

Display the traffic of a port

QQ截图20180503164218.png

Configure refresh time

QQ截图20180503152319.png


Special Note: The template here can only display the traffic of a certain port of a switch, or display the traffic of all interfaces of a switch. If you want to have one graphic per port, you can only configure it one by one and build it separately. This is the only way I have learned for the time being. If you have a better solution, I hope to discuss it together. The existence of grafana can make your monitoring graphics more beautiful, but if you don't need it, zabbix can do it.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325337139&siteId=291194637