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

Zabbix uses ifstat tools to customize how to obtain Nic traffic.

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

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!

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

Network Security

Wechat

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

12
Report