{"id":19866153,"url":"https://github.com/tlux/vnstat-ruby","last_synced_at":"2025-05-02T05:32:21.747Z","repository":{"id":56897587,"uuid":"46375552","full_name":"tlux/vnstat-ruby","owner":"tlux","description":"A Ruby solution to retrieve network traffic information using the vnstat command line utility.","archived":false,"fork":false,"pushed_at":"2024-03-01T16:51:17.000Z","size":151,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-15T14:11:20.537Z","etag":null,"topics":["gem","network-monitoring","networking","ruby","ruby-gem","traffic-information","vnstat"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tlux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2015-11-17T21:08:13.000Z","updated_at":"2020-07-28T09:20:21.000Z","dependencies_parsed_at":"2024-11-12T15:32:19.495Z","dependency_job_id":"fc916dd1-61ad-4286-a40f-2f278395c957","html_url":"https://github.com/tlux/vnstat-ruby","commit_stats":{"total_commits":135,"total_committers":2,"mean_commits":67.5,"dds":"0.014814814814814836","last_synced_commit":"16093157f8d29b0ad5c1af48ed62f1c18960f154"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tlux%2Fvnstat-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tlux%2Fvnstat-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tlux%2Fvnstat-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tlux%2Fvnstat-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tlux","download_url":"https://codeload.github.com/tlux/vnstat-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251993002,"owners_count":21677022,"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":["gem","network-monitoring","networking","ruby","ruby-gem","traffic-information","vnstat"],"created_at":"2024-11-12T15:25:06.907Z","updated_at":"2025-05-02T05:32:16.738Z","avatar_url":"https://github.com/tlux.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vnstat-ruby\n\n[![Build Status](https://travis-ci.org/tlux/vnstat-ruby.svg?branch=master)](https://travis-ci.org/tlux/vnstat-ruby)\n[![Coverage Status](https://coveralls.io/repos/github/tlux/vnstat-ruby/badge.svg?branch=master)](https://coveralls.io/github/tlux/vnstat-ruby?branch=master)\n[![Gem Version](https://badge.fury.io/rb/vnstat-ruby.svg)](https://badge.fury.io/rb/vnstat-ruby)\n\nVnstat is a tool that tracks the traffic on your network interfaces.\nThis tiny library is intended to provide network traffic information\nthrough an easy-to-use API.\n\nIt depends on the\n[vnstat command line utility](http://humdi.net/vnstat/) which is\nmaintained by Teemu Toivola.\n\n### Prerequisites\n\n* Ruby 2.3.0 or greater\n* Make sure you have `vnstat` CLI installed by running `which vnstat`.\n\nOn Ubuntu you can get the vnstat package via `apt-get install vnstat`.\n\n### Getting Started\n\n#### Setup\n\nOnce the dependent package is installed, you are ready to install the\nvnstat-ruby gem.\n\n```bash\ngem install vnstat-ruby\n```\n\nOr, add the following line to the Gemfile of your project and run the\n`bundle install` command:\n\n```ruby\ngem 'vnstat-ruby'\n```\n\n#### Configuration\n\nBy default, vnstat-ruby tries to automatically determine the location of your\nvnstat executable. If you need to change this path for some reason, you can\noverride the default:\n\n```ruby\nVnstat.config.executable_path = '/usr/bin/vnstat'\n```\n\n### Usage\n\n#### Network Interfaces\n\nTo retrieve a list of all known network interfaces:\n\n```ruby\nVnstat.interfaces # =\u003e #\u003cVnstat::InterfaceCollection ...\u003e\nVnstat.interfaces.ids # =\u003e ['eth01', 'eth02']\n```\n\nTo only retrieve traffic stats for a single interface:\n\n```ruby\nVnstat.interfaces.first # =\u003e #\u003cVnstat::Interface id: \"eth01\"\u003e\n```\n\nIf you know the name of a network interface, you can also retrieve the\nstats of that particular one:\n\n```ruby\nVnstat['eth01'] # =\u003e #\u003cVnstat::Interface id: \"eth01\"\u003e\n```\n\n#### Traffic Information\n\n##### Total\n\n```ruby\ninterface = Vnstat['eth01']\n```\n\n```ruby\ninterface.total # =\u003e #\u003cVnstat::Result ...\u003e\ninterface.total.bytes_received # =\u003e 1024000\ninterface.total.bytes_sent # =\u003e 2048000\ninterface.total.bytes_transmitted # =\u003e 3072000\n```\n\n##### By Month\n\n```ruby\ninterface.months # =\u003e #\u003cVnstat::Traffic::Monthly ...\u003e\n```\n\n```ruby\ninterface.months.first\ninterface.months[2015, 9]\n# =\u003e #\u003cVnstat::Result::Month year: 2015, month: 9, ...\u003e\n```\n\n```ruby\ninterface.months[2015, 10].bytes_received # =\u003e 3072000\n```\n\n##### By Day\n\n```ruby\ninterface.days # =\u003e #\u003cVnstat::Traffic::Daily ...\u003e\n```\n\n```ruby\ninterface.days.first\ninterface.days[Date.new(2015, 11, 23)]\ninterface.days[2015, 11, 23]\n# =\u003e #\u003cVnstat::Result::Day date: #\u003cDate: 2015-11-23\u003e, ...\u003e\n```\n\n```ruby\ninterface.days[2015, 11, 23].bytes_received # =\u003e 2048000\n```\n\n##### By Hour\n\n```ruby\ninterface.hours # =\u003e #\u003cVnstat::Traffic::Hourly ...\u003e\n```\n\n```ruby\ninterface.hours.first\ninterface.hours[Date.new(2015, 9, 22), 10]\ninterface.hours[2015, 9, 22, 10]\n# =\u003e #\u003cVnstat::Result::Hour date: #\u003cDate: 2015-11-23\u003e, hour: 10\u003e\n```\n\n```ruby\ninterface.hours[2015, 9, 22, 10].bytes_received # =\u003e 2048000\n```\n\n##### Tops\n\n```ruby\ninterface.tops #=\u003e #\u003cVnstat::Traffic::Tops ...\u003e\ninterface.tops.count #=\u003e 10\ninterface.tops.each do |top|\n  # ...\nend\n```\n\n```ruby\ninterface.tops.first\ninterface.tops[2]\n# =\u003e #\u003cVnstat::Result::Minute time: 2015-11-05 09:03:42 +0000\u003e\n```\n\n```ruby\ninterface.tops[1].bytes_received # =\u003e 1024000\n```\n\n### Contributing to vnstat-ruby\n\n* Check out the latest master to make sure the feature hasn't been implemented\n  or the bug hasn't been fixed yet.\n* Check out the issue tracker to make sure someone already hasn't requested it\n  and/or contributed it.\n* Fork the project.\n* Start a feature/bugfix branch.\n* Commit and push until you are happy with your contribution.\n* Make sure to add tests for it. This is important so I don't break it in a\n  future version unintentionally.\n* Please try not to mess with the Rakefile, version, or history. If you want to\n  have your own version, or is otherwise necessary, that is fine, but please\n  isolate to its own commit so I can cherry-pick around it.\n\n### Copyright\n\nCopyright (c) 2015-2020 Tobias Casper. See LICENSE.txt for further details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftlux%2Fvnstat-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftlux%2Fvnstat-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftlux%2Fvnstat-ruby/lists"}