Jump to content

Stat


Christian
 Share

Recommended Posts

  • Superuser

A small project that allows you to gather statistics (integers/counts) from files on the file system. This was designed for Linux.

 

This is useful for retrieving the incoming/outgoing packets per second or incoming/outgoing bytes per second on a network interface.

 

Building Program
You can simply use make to build this program. The Makefile uses clang to compile the program.

 

# (Debian/Ubuntu-based systems)
apt-get install clang

# (CentOS/Others)
yum install devtoolset-7 llvm-toolset-7 llvm-toolset-7-clang-analyzer llvm-toolset-7-clang-tools-extra

# Build the project.
make


You may use make install to copy the gstat executable to your $PATH via /usr/bin.

 

Note - We use gstat instead of stat due to other common packages.

 

Command Line Usage
General command line usage can be found below.

 

gstat [-i <interface> --pps --bps --path <path> -c <"kbps" or "mbps" or "gbps"> --custom <integer>]
--pps => Set path to RX packet path.
--bps => Set path to RX byte path.
-p --path => Use count (integer) from a given path on file system.
-i --dev => The name of the interface to use when setting --pps or --bps.
-c --convert => Convert to either "kbps", "mbps", or "gbps".
--custom => Divides the count value by this much before outputting to stdout.
--interval => Use this interval (in microseconds) instead of one second.
--count -n => Maximum amount of times to request the counter before stopping program (0 = no limit).
--time -t => Time limit (in seconds) before stopping program (0 = no limit).


Note - If you want to receive another counter such as outgoing (TX) packets, you can set the file to pull the count from with the -p (or --path) flag.

 

For example.

 

gstat --path /sys/class/net/ens18/statistics/tx_packets


Credits

 

GitHub Repository & Source Code

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

By using this site you agree to the Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.