{"id":16161423,"url":"https://github.com/gamemann/stat","last_synced_at":"2025-03-18T22:30:45.328Z","repository":{"id":92735821,"uuid":"315100841","full_name":"gamemann/Stat","owner":"gamemann","description":"A small project to gather counter statistics from the file system or output from commands. Useful for retrieving packets per second and bytes per second on a network interface.","archived":false,"fork":false,"pushed_at":"2024-06-11T02:24:56.000Z","size":37,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T12:30:12.421Z","etag":null,"topics":["bps","bytes","c","conversions","linux","network","packets","per","pps","rx","second","statistics","stats"],"latest_commit_sha":null,"homepage":"https://moddingcommunity.com/forums/topic/75-stat","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gamemann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-22T18:05:51.000Z","updated_at":"2025-02-16T12:55:32.000Z","dependencies_parsed_at":"2024-10-27T19:16:23.850Z","dependency_job_id":"a64f4a2a-6c5f-4515-bb4d-def9d4487b5c","html_url":"https://github.com/gamemann/Stat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FStat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FStat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FStat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FStat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gamemann","download_url":"https://codeload.github.com/gamemann/Stat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243950813,"owners_count":20373664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bps","bytes","c","conversions","linux","network","packets","per","pps","rx","second","statistics","stats"],"created_at":"2024-10-10T02:25:13.311Z","updated_at":"2025-03-18T22:30:45.082Z","avatar_url":"https://github.com/gamemann.png","language":"C","readme":"[![Stat Build Workflow](https://github.com/gamemann/Stat/actions/workflows/build.yml/badge.svg)](https://github.com/gamemann/Stat/actions/workflows/build.yml)\n\nA small project that allows you to gather statistics (counters) from files on the file system or command outputs. This was designed for Linux.\n\nThis is useful for retrieving the incoming/outgoing packets or bytes per second on a network interface from the file system or from the output of a command such as `ethtool`.\n\n## Building Program\nYou can simply use `make` to build this program. The `Makefile` uses `clang` to compile the program.\n\n```\napt-get install clang # (Debian/Ubuntu-based systems)\nyum install devtoolset-7 llvm-toolset-7 llvm-toolset-7-clang-analyzer llvm-toolset-7-clang-tools-extra # (CentOS/Others)\nmake\n```\n\nYou may use `make install` to copy the `gstat` executable to your `$PATH` via `/usr/bin`.\n\n**Note** - We use `gstat` instead of `stat` due to other common packages.\n\n## Command Line Usage\nGeneral command line usage can be found below.\n\n```\ngstat [-i \u003cinterface\u003e --pps --bps --path \u003cpath\u003e -c \u003c\"kbps\" or \"mbps\" or \"gbps\"\u003e --custom \u003cinteger\u003e]\n--pps =\u003e Set path to RX packet path.\n--bps =\u003e Set path to RX byte path.\n-p --path =\u003e Use count (integer) from a given path on file system.\n-i --dev =\u003e The name of the interface to use when setting --pps or --bps.\n-c --convert =\u003e Convert to either \"kbps\", \"mbps\", or \"gbps\".\n--custom =\u003e Divides the count value by this much before outputting to stdout.\n--interval =\u003e Use this interval (in microseconds) instead of one second.\n--count -n =\u003e Maximum amount of times to request the counter before stopping program (0 = no limit).\n--time -t =\u003e Time limit (in seconds) before stopping program (0 = no limit).\n--cmd =\u003e The command to execute and retrieve output from.\n--sep =\u003e The separator to apply to the command's output.\n--key =\u003e The key to search for when separating the command output.\n```\n\n**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:\n\n```\ngstat --path /sys/class/net/ens18/statistics/tx_packets\n```\n\n### Command Argument\nYou may use a combination of the `--cmd`, `--sep`, and `--key` arguments to retrieve a counter from a command's output such as `ethtool`.\n\nFor example, take a look at the following output from `ethtool`.\n\n```bash\n$ sudo ethtool -S enp1s0\n\nNIC statistics:\n     rx_queue_0_packets: 901268\n     rx_queue_0_bytes: 211930005\n     rx_queue_0_drops: 0\n     rx_queue_0_xdp_packets: 0\n     rx_queue_0_xdp_tx: 0\n     rx_queue_0_xdp_redirects: 0\n     rx_queue_0_xdp_drops: 0\n     rx_queue_0_kicks: 14\n     rx_queue_1_packets: 1237084\n     rx_queue_1_bytes: 469671713\n     rx_queue_1_drops: 0\n     rx_queue_1_xdp_packets: 0\n     rx_queue_1_xdp_tx: 0\n     rx_queue_1_xdp_redirects: 0\n     rx_queue_1_xdp_drops: 0\n     rx_queue_1_kicks: 19\n     tx_queue_0_packets: 16508781\n     tx_queue_0_bytes: 1528281628\n     tx_queue_0_xdp_tx: 0\n     tx_queue_0_xdp_tx_drops: 0\n     tx_queue_0_kicks: 6598201\n     tx_queue_0_tx_timeouts: 0\n     tx_queue_1_packets: 16154602\n     tx_queue_1_bytes: 1348764220\n     tx_queue_1_xdp_tx: 0\n     tx_queue_1_xdp_tx_drops: 0\n     tx_queue_1_kicks: 6051221\n     tx_queue_1_tx_timeouts: 0\n```\n\nIf you want the `rx_queue_0_packets` value used as the counter (starting at `901268`), you would execute the following command.\n\n```bash\nsudo gstat --cmd \"ethtool -S enp1s0\" --sep \":\" --key \"rx_queue_0_packets\"\n```\n\nEach line from the command's output is trimmed of white-spaces.\n\n## Credits\n* [Christian Deacon](https://github.com/gamemann)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemann%2Fstat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgamemann%2Fstat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemann%2Fstat/lists"}