InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Mac tutorials

  • Brew
  • Chrome enable webgl on old macbooks
  • How to change computer display name on Mac
  • How to change default system voice for text-to-speech on Mac
  • How to install drupal on Mac usin MAMP
  • How to remove hard drive icon from mac desktop
  • How to use rrdtool plot traffic from network interface
  • How to view your WiFi password on Mac
  • Mac - change desktop icons size
  • Mac - how to take timed screenshot
  • Mac - how to always show scroll bar
  • Mac - how to change default location for screenshots
  • Mac - how to open apps not from App Store
  • Mac - how to take screenshots
  • Mac - how to use kubernetes with Lima-VM
  • Mac - kubernetes minikube - create deployment
  • Mac - make spotlight search faster
  • Mac - show volume icon on menu bar
  • Mac Command Line
  • Mac Finder
  • Mac Preview
  • Mac m1 - How to Install Kubernetes with kind
  • Mac m1 - How to Install Kubernetes with minikube
  • Mac m1 - minikube - create multi node kubernetes cluster
  • Mac podman quick start guide
  • NestJS Quick start tutorial on Mac
  • NextJS Quick start tutorial on Mac
  • Vagarant quick start guide on Mac
  • Windows on Mac
  • minikube kubernetes - create deployment with multiple replica and load balancer
  • minikube kubernetes - how to access service IP endpoint using curl
  • minikube kubernetes - how to access specific pod IP endpoint using curl
 
  • Home
  • > Tutorials
  • > Mac

How to use rrdtool plot traffic from network interface

By admin | Last updated on Mar 20, 2016

rrdtool open source tool is used to log time series data and create nice graphs form that data. Official information can be obtained from rrdtool‘s official site. For the purpose of this article I am taking network usage monitoring use case. Netstat can be used to print the outgoing and incoming traffic for an interface. Here are the steps:

Installing rrdtool

rrdtool can be installed on Mac using brew.

$ brew install rrdtool
$ brew list rrdtool

To install it on Ubuntu Linux you can use sudo apt-get install rrdtool.

Create an rrd db file

Next step is to create an rrd file specifying data source. Run the following command:

$ rrdtool create traffic.rrd --step 120 DS:incoming:COUNTER:240:U:U RRA:AVERAGE:0.5:1:60

This will create a Data source traffic of type COUNTER and heartbeat 240 seconds which will expect data at interval of 120 seconds.
RRA (Round robin archives) has a step of 1 and 60 rows stored.

Command to print total network packets

Use netstat to print incoming and outgoing traffic on an interface. Assuming your network interface is en1 on your local computer, run this:

$ netstat -i -I en1

To print incoming traffic:

$ netstat -i -I en1 | awk '{print $5}' | tail -1

Update rrd db

Run the following command to update the db file:

$ netstat -i -I en1 | awk '{print $5}' | tail -1 | xargs -n1 -I % rrdtool update traffic.rrd N:%

Generate graph using rrdtool

Use the following command to generate the graph based on the collected data

$ rrdtool  graph rrdtool_incoming_traffic.png -w 245 -h 80 -a PNG --start -3600 --end now --title "incoming traffic" DEF:incoming=traffic.rrd:incoming:AVERAGE  LINE2:incoming#FF0000

Now this should be scheduled as a cron running every 2 min. Here is the image which got generated after few hours.
rrdtool_incoming_traffic

Suggested posts:

  1. How to transfer android apk using adb
  2. bower – installation and quick start guide
  3. Use x2go to access remote Ubuntu Linux
  4. NFS client and server handy commands
  5. How to customize wordpress rss feed
  6. How to prevent ssh session freezing due to timeout
  7. CSS max-width – limit maximum wodth of an element
  8. How to use ssh port forwarding to surf a site from different location
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Mac, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress