Bandwidth monitor via Zabbix server

3,837 total views, 5 views today

Zabbix server gives you bandwidth calculation via “[eth0,bytes]” and “net.if.out[eth0,bytes]” functions. But sometime you might face some issue with this functions, e.g. sometime might be your actual bandwidth data mismatch with the Zabbix server shown data. So, for the mitigate this problem you can use this solution. If you face any issue regarding this please comment on these post.

Please find the related video for this.

Here I am using vnstat tool for the collecting of all bandwidth data from agent servers.

Dependency Package (Ubuntu, CentOS):

  • vnstat
  • bc
  • zip, unzip
  • dos2unix

This Tutorial gives you 

  • Total Outbound for today
  • Total OutBound For Current Hour
  • Total Inbound for today
  • Total Inbound For Current Hour
  • Total Bandwidth For Previous Hour
  • Total Bandwidth For Current Hour
  • Total Bandwidth for Today
  • Total Bandwidth for last 7 days
  • Total Bandwidth for the current Month
  • Last 2 month bandwidth (current+previous)

In Agent server (Login to the agent server SSH)

First Install all package along with the dependencies.

# apt-get install vnstat bc unzip zip dos2unix -y

Setup the vnstat interface and create interface database for vnstat. Edit below code () with your server network interface.

# vnstat -u -i $interface

Now create a directory for Bandwidth calculation script and go to the directory.

# mkdir /etc/zabbix/script
# cd /etc/zabbix/script

Download the below link and unzip the file.

# wget
# unzip

Give the executive permission to the all script files

# chmod +x *

Add below cron for automatic Bandwidth Update.

echo "*/5 * * * * sh /etc/zabbix/script/"

to removing all hidden windows characters from script files

# dos2unix *.sh

Add UserParameter to the zabbix agent conf file

# echo "UserParameter=system.monthlybandwidth,/etc/zabbix/script/
UserParameter=system.currenthourout,/etc/zabbix/script/" >> /etc/zabbix/zabbix_agentd.conf

Restart the zabbix agent 

For Ubuntu
# /etc/init.d/zabbix-agent restart
For CentOS
# systemctl restart zabbix-agent

Check once the zabbix agent server is running or not.

# netstat -tlnp | grep zabbix

You have done in the Zabbix agent Part, Now login to the zabbix server Dashboard.

In Zabbix Server (Login to the Zabbix server Dashboard)

Download the below Template and unzip

After unzip, Login to the zabbix Dashboard –> Configuration –> Templates –> Click on Import –> Select the xml template file –> Click on Import

After the template successfully add to the zabbix server, select the host server and attach the newly added template.
dashboard –> Configuration –> Hosts –> Select Host –> Template Tab –> Link New template –> Add –> Update.

After Update the host, Wait some time we will get all Bandwidth Calculation report.

You are all Done!


Extra Data from This tutorials

By Default Below two items are disabled and you will not get below two data.

  • Total Outbound for today
  • Total Inbound for today

But If you want to see this data, you can enable it anytime from your zabbix dashboard.
Dashboard –> Configuration –> Templates –> Network for Linux –> Items –> Check 2 Item that are disabled –> Click on Enable.

If You face any issue regarding this please comment below:
Thank You

5 Comments to “Bandwidth monitor via Zabbix server”

  1. Den says:

    Last 2 month bandwidth (current+previous) 2019-09-09 12:11:37 (standard_in) 1: syntax error

    1. try2answer says:

      Hello Den,

      Sorry for the late response!
      Actually all the script is completely depend on the vnstat output format. Output format of vnstat will be differed on the each Linux distribution (Ubuntu, Centos). So in that case can you please provide the output of below commands. so that I can check from my end and update the script respectively.

      # vnstat –oneline
      # vnstat –m

      Also, as all the script are written in windows system, so it is recommended that please run dos2unix command before using all the script.


  2. Parthiban says:

    I do above configuration in centos server( zabbix client) and in zabiix server showing wrong data, wt to do

    1. try2answer says:

      Hello Parthiban,

      Sorry for late reply, is your vnstat is showing correct data by command line? are all data (Monthly, daily, Hourly) showing the same thing. If yes please send me the screen shot in my email address. I will like to resolve the issue.


Leave a Reply

Your email address will not be published. Required fields are marked *