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
b. Configure and add the group name
c. Click the host to enter the host interface to create a host
d. Click Create host to create
e. Configure hostname, group and SNMP interface
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.
g. Configure the host macro, where the configuration macro is {$SNMP_COMMUNITY}, the value is the username public of the switch snmp
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
i. Disable MIB rules
j. Deactivate unneeded monitoring item prototypes
k. After that, the collected monitoring items, triggers and graphs will be displayed, and the time of the collected items will be different.
l. Now view the monitoring graph
4. Configure Zabbix to connect to Grafana
a. Log in to Grafana and click Enable now to enter the Zabbix plugin page
b. Click Enable to enable Zabbix plugin
c. Then click Data Sources under the settings icon to configure zabbix
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.
e. Then you can view the dashboard of the zabbix server
f. Click New dashboard to create a dashboard
g. Here we first click on the settings to set the variables first
h. Configure the dashboard name
i. Configuration variables, pay special attention to the configuration of Query values
①Configure the first variable
②Configure the second variable
③ 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,})/
j. Now start to configure the graph, click the Panel button to create a new graph
① Click Singlestat under New Panel to configure the name of the acquisition switch
②Create a new graph and click Singlestat under New Panel to configure the online time of the acquisition switch
③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). ]
④ Click Graph under New Panel to configure the collection traffic
k. After the configuration is completed, the flow chart will be displayed as follows:
Display the traffic of a port
Configure refresh time
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.