{"id":21297508,"url":"https://github.com/fvdm/nodejs-vnstat-dumpdb","last_synced_at":"2026-01-06T08:14:16.388Z","repository":{"id":5735473,"uuid":"6947572","full_name":"fvdm/nodejs-vnstat-dumpdb","owner":"fvdm","description":"Node.js wrapper for vnStat --dumpdb, with error handling and the same output structure on each system","archived":false,"fork":false,"pushed_at":"2022-04-21T09:34:06.000Z","size":73,"stargazers_count":6,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-06-24T11:58:42.508Z","etag":null,"topics":["networking","nodejs","statistics","unlicense","vnstat"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vnstat-dumpdb","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fvdm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-30T23:21:45.000Z","updated_at":"2023-01-23T12:44:49.000Z","dependencies_parsed_at":"2022-08-18T17:42:29.600Z","dependency_job_id":null,"html_url":"https://github.com/fvdm/nodejs-vnstat-dumpdb","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/fvdm/nodejs-vnstat-dumpdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-vnstat-dumpdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-vnstat-dumpdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-vnstat-dumpdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-vnstat-dumpdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fvdm","download_url":"https://codeload.github.com/fvdm/nodejs-vnstat-dumpdb/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-vnstat-dumpdb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264870621,"owners_count":23676277,"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":["networking","nodejs","statistics","unlicense","vnstat"],"created_at":"2024-11-21T14:37:57.181Z","updated_at":"2026-01-06T08:14:16.364Z","avatar_url":"https://github.com/fvdm.png","language":"JavaScript","funding_links":["https://ko-fi.com/franklin"],"categories":[],"sub_categories":[],"readme":"# vnstat-dumpdb\n\nGet network traffic statistics from [vnStat](https://github.com/vergoh/vnstat).\n\n[![npm](https://img.shields.io/npm/v/vnstat-dumpdb.svg?maxAge=3600)](https://www.npmjs.com/package/vnstat-dumpdb?activeTab=versions)\n[![Build Status](https://github.com/fvdm/nodejs-vnstat-dumpdb/actions/workflows/node.js.yml/badge.svg?branch=master)](https://github.com/fvdm/nodejs-vnstat-dumpdb/actions/workflows/node.js.yml)\n[![Coverage Status](https://coveralls.io/repos/github/fvdm/nodejs-vnstat-dumpdb/badge.svg?branch=master)](https://coveralls.io/github/fvdm/nodejs-vnstat-dumpdb?branch=master)\n\n* [Changelog](https://github.com/fvdm/nodejs-vnstat-dumpdb/releases)\n* [Node.js](https://nodejs.org)\n\n\n## Example\n\n### Callback style\n\n```js\nconst vnstat = require( 'vnstat-dumpdb' )();\n\n// Get traffic per day\nvnstat.getStats( 'eth0', ( err, data ) =\u003e {\n  if ( err ) {\n    console.log( err );\n    return;\n  }\n\n  console.log( data.traffic.days );\n} );\n\n// Read config setting\nvnstat.getConfig( ( err, config ) =\u003e {\n  if ( err ) {\n    console.log( err );\n    return;\n  }\n\n  console.log( `Interfaces updating every ${config.UpdateInterval} minutes` );\n} );\n```\n\n### Promise style\n\n```js\nconst vnstat = require( 'vnstat-dumpdb' )();\n\n// Get traffic per day with async/await\nasync function getTraffic () {\n  try {\n    const data = await vnstat.getStats( 'eth0' );\n    console.log( data.traffic.days );\n\n    const config = await vnstat.getConfig();\n    console.log( `Interfaces updating every ${config.UpdateInterval} minutes` );\n  }\n  catch ( err ) {\n    console.log( err );\n  }\n}\n\ngetTraffic();\n```\n\n\n## Installation\n\nMake sure you have **vnStat v1.13** or later.\n\n`npm install vnstat-dumpdb`\n\n\n## Configuration\n\nThe module loads as a function to override the defaults:\n\nsetting | type   | default | description\n--------|--------|---------|----------------------\n[bin]   | string | vnstat  | Path to vnstat binary\n[iface] | string | `false` | i.e. `eth0` or `false` to list all\n\n\n## Callback \u0026 errors\n\nEach method supports both **callback** and **Promise** patterns:\n\n### Callback style\n\nEach method takes an optional callback _function_ which gets two arguments:\n\n* `err` - Instance of `Error` or `null`\n* `data` - Result `object` or not set when error\n\n```js\nconst myCallback = ( err, data ) =\u003e {\n  if ( err ) {\n    console.log( err );\n    console.log( err.stack );\n    return;\n  }\n\n  console.log( data );\n};\n```\n\n### Promise style\n\nIf no callback is provided, the method returns a `Promise`:\n\n```js\n// Using async/await\ntry {\n  const data = await vnstat.getConfig();\n  console.log( data );\n}\ncatch ( err ) {\n  console.log( err );\n}\n\n// Using .then() / .catch()\nvnstat.getConfig()\n  .then( ( data ) =\u003e console.log( data ) )\n  .catch( ( err ) =\u003e console.log( err ) );\n```\n\n\n#### Errors\n\nmessage           | description                       | additional\n------------------|-----------------------------------|---------------------------\nno config         | Can't load config for `getConfig` | `err.details`, `err.error`\ninvalid data      | Can't read stats for `getStats`   | `err.details`\ninvalid interface | `iface` is invalid or not set up  |\n\n\n\n## getStats ( [iface], [callback] )\n\nGet statistics for one, multiple or all interfaces.\n\n* One: `vnstat.getStats( 'eth0', callback )` or `await vnstat.getStats( 'eth0' )`\n* All: `vnstat.getStats( false, callback )` or `await vnstat.getStats()`\n\n\n```js\n// Get traffic for interface en1 (callback)\nvnstat.getStats( 'en1', console.log );\n\n// Get traffic for interface en1 (promise)\nconst data = await vnstat.getStats( 'en1' );\n\n// Output\n{ id: 'en1',\n  nick: 'en1',\n  created: { date: { year: 2012, month: 11, day: 21 } },\n  updated:\n   { date: { year: 2013, month: 10, day: 28 },\n     time: { hour: 3, minute: 25 } },\n  traffic:\n   { total: { rx: 593576855, tx: 63746811 },\n     days:\n      [ { id: 0,\n          date: { year: 2013, month: 10, day: 28 },\n          rx: 4083261,\n          tx: 119674 },\n        { id: 1,\n          date: { year: 2013, month: 10, day: 27 },\n          rx: 2206367,\n          tx: 52314 },\n        ...\n      ],\n     months:\n      [ { id: 0,\n          date: { year: 2013, month: 10 },\n          rx: 158176326,\n          tx: 7740561 },\n        { id: 1,\n          date: { year: 2013, month: 9 },\n          rx: 119230002,\n          tx: 3394278 },\n        ...\n      ],\n     tops:\n      [ { id: 0,\n          date: { year: 2013, month: 10, day: 5 },\n          time: { hour: 0, minute: 10 },\n          rx: 22445455,\n          tx: 601967 },\n        { id: 1,\n          date: { year: 2013, month: 9, day: 23 },\n          time: { hour: 0, minute: 0 },\n          rx: 20201102,\n          tx: 461492 },\n        ...\n      ],\n      hours: []\n  }\n}\n```\n\n\n## getConfig ( [callback] )\n\nGet vnStat configuration.\n\n```js\n// Callback style\nvnstat.getConfig( ( err, config ) =\u003e {\n  if ( err ) {\n    console.log( err );\n    return;\n  }\n\n  console.log( `Interfaces updating every ${config.UpdateInterval} seconds` );\n} );\n\n// Promise style\nconst config = await vnstat.getConfig();\nconsole.log( `Interfaces updating every ${config.UpdateInterval} seconds` );\n```\n\n\n## Unlicense\n\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to \u003chttps://unlicense.org\u003e\n\n\nAuthor\n------\n\n[Franklin](https://frankl.in)\n| [Buy me a coffee](https://ko-fi.com/franklin)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvdm%2Fnodejs-vnstat-dumpdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffvdm%2Fnodejs-vnstat-dumpdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvdm%2Fnodejs-vnstat-dumpdb/lists"}