{"id":21713818,"url":"https://github.com/snh/collectd-wireguard","last_synced_at":"2025-04-12T19:04:14.747Z","repository":{"id":227819330,"uuid":"177403730","full_name":"snh/collectd-wireguard","owner":"snh","description":"A simple shell script which when used with the exec plugin for collectd, will retrieve per-peer WireGuard transfer metrics for consumption by collectd.","archived":false,"fork":false,"pushed_at":"2019-08-26T11:52:16.000Z","size":18,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-12T19:03:34.778Z","etag":null,"topics":["collectd","collectd-exec-plugin","collectd-plugin","wireguard"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/snh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2019-03-24T11:12:07.000Z","updated_at":"2025-03-09T08:02:42.000Z","dependencies_parsed_at":"2024-03-15T09:58:16.474Z","dependency_job_id":"6d3ae57a-5a3e-43a4-a571-10cc99bed468","html_url":"https://github.com/snh/collectd-wireguard","commit_stats":null,"previous_names":["snh/collectd-wireguard"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snh%2Fcollectd-wireguard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snh%2Fcollectd-wireguard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snh%2Fcollectd-wireguard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snh%2Fcollectd-wireguard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snh","download_url":"https://codeload.github.com/snh/collectd-wireguard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618275,"owners_count":21134200,"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":["collectd","collectd-exec-plugin","collectd-plugin","wireguard"],"created_at":"2024-11-26T00:27:36.578Z","updated_at":"2025-04-12T19:04:14.720Z","avatar_url":"https://github.com/snh.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# collectd-wireguard\n\nA simple shell script which when used with the [_exec_](https://collectd.org/wiki/index.php/Plugin:Exec)\nplugin for [_collectd_](https://collectd.org/), will retrieve per-peer [_WireGuard_](https://www.wireguard.com/)\ntransfer metrics for consumption by _collectd_.\n\n## Example\n\n### WireGuard configuration\n\n```\n$ wg\ninterface: wg0\n  public key: 8x0BeYAO6R2v/hKm6kNfohxf9QfQdKd3tfCPsARuemU=\n  private key: (hidden)\n  listening port: 51820\n\npeer: eynPhbDg/Ca9Z4Nmk37C6TAMwtdsiYIEh1OEzP5z0Es=\n  endpoint: 172.28.128.4:51820\n  allowed ips: 10.0.0.2/32\n  latest handshake: 20 minutes, 45 seconds ago\n  transfer: 11.35 GiB received, 57.93 MiB sent\n\ninterface: wg1\n  public key: 65bI/yi7hwLuuU494nfVSNASkwyIXlYGP7woVzHAq2c=\n  private key: (hidden)\n  listening port: 51821\n\npeer: z6xFfD7J7oVHWGRO4p3YDyOW2FYuTIZPFjDs4CshaVI=\n  allowed ips: 10.0.1.2/32\n```\n\n### `collectd-wireguard.sh` output\n\n```\n$ COLLECTD_HOSTNAME=\"example-host\" COLLECTD_INTERVAL=5 ./collectd-wireguard.sh\nPUTVAL \"example-host/wireguard-wg0/if_octets-eynPhbDg/Ca9Z4Nmk37C6TAMwtdsiYIEh1OEzP5z0Es=\" interval=5 N:12182053116:60742952\nPUTVAL \"example-host/wireguard-wg1/if_octets-z6xFfD7J7oVHWGRO4p3YDyOW2FYuTIZPFjDs4CshaVI=\" interval=5 N:0:0\n```\n\n## Requirements\n\n- [_WireGuard_](https://www.wireguard.com/)\n- [_collectd_](https://collectd.org/)\n  - [_exec_ plugin](https://collectd.org/wiki/index.php/Plugin:Exec)\n- [_Bash_](https://www.gnu.org/software/bash/)\n- [_Sudo_](https://www.sudo.ws/)\n\n## Configuration\n\nThis example assumes that the script will be run as the `collectd` user, using\n`sudo` to run `wg show all transfer` as `root`.\n\nFor security reasons, it is not recommended that you run this script directly as\n`root`.\n\nTo run this script as a different user, replace `collectd` in the _collectd_ and\n_sudoers_ with the appropriate username.\n\nThese instructions may require some tweaking depending on your specific\nenvironment and/or operating system/distribution.\n\n### _collectd-wireguard_\n\nPlace `collectd-wireguard.sh` in a suitable location, accessible by the user\nrunning this script. For this example `/usr/share/collectd/` is used.\n\n### _collectd_\n\nAdd the following to your `collectd.conf`, which is often located at\n`/etc/collectd/collectd.conf`:\n\n```\nLoadPlugin exec\n\n\u003cPlugin exec\u003e\n  Exec \"collectd\" \"/usr/share/collectd/collectd-wireguard.sh\"\n\u003c/Plugin\u003e\n```\n\nThis example executes the script as the `collectd` user.\n\n### _sudoers_\n\nTo allow the user running the script to execute `wg show all transfer`, add the\nfollowing to your `sudoers` file using `visudo`:\n\n```\ncollectd ALL=(root) NOPASSWD: /usr/bin/wg show all transfer\n```\n\n## Development\n\nA _Vagrant_ `Vagrantfile` is included which will provision two Debian Buster\nbased nodes with _WireGuard_, _collectd_, and _collectd-wireguard_.\n\n_collectd_ is configured to write to `/var/lib/collectd/csv/` in CSV format.\n\n## License\n\n```\nMIT License\n\nCopyright (c) 2019 Steven Honson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnh%2Fcollectd-wireguard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnh%2Fcollectd-wireguard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnh%2Fcollectd-wireguard/lists"}