Zabbix uses ifstat tools to customize how to obtain Nic traffic.
1. Obtain ifstat
Wget http://distfiles.macports.org/ifstat/ifstat-1.1.tar.gztar xf ifstat-1.1.tar.gzcd ifstat-1.1./configuremake & & make installln-s / usr/local/bin/ifstat / sbin/
2. Custom monitoring script
Vim networkflow.sh
#! / bin/bashcase $1 in inflow) ifstat-I eth0 1 1 | sed-n '3p' | awk' {print $(NF-1)}';; outflow) ifstat-I eth0 11 | sed-n '3p' | awk' {print $(NF)}';; esac
I specify the network card eth0 in the script. If you do, you can improve the script a little bit, and then get the name of the network card that needs to be monitored automatically. Inflow represents the ingress rate of the network card, and outflow represents the egress rate.
Chmod axix networkflow.shcp networkflow.sh / usr/local/zabbix_agentd/defineScripts/
By the way, the / usr/local/zabbix_agentd/defineScripts directory is the directory on my server where the custom scripts are placed.
3. Customize the key of zabbix
Vim / usr/local/zabbix_agentd/etc/zabbix_agentd.userparams.conf
Add a paragraph at the bottom:
# check network flowUserParameter=network_flow [*], / usr/local/zabbix_agentd/defineScripts/networkflow.sh $1
/ usr/local/zabbix_agentd/etc/zabbix_agentd.userparams.conf is the file I Include in / usr/local/zabbix_agentd/etc/zabbix_agentd.conf as a separate place to store the custom key.
Then restart zabbix_agentd, and the custom key takes effect.
4. Zabbix server UI uses this key
This can be added to an existing template or create a new template.
Establish item
Establish trigger
Establish graphs
My side is just incoming traffic as an example.
5. Apply it to hosts
The above is the effect picture.
Got it!