{"id":16735678,"url":"https://github.com/tecnickcom/rpistat","last_synced_at":"2025-07-06T14:03:39.800Z","repository":{"id":66250117,"uuid":"583979753","full_name":"tecnickcom/rpistat","owner":"tecnickcom","description":"Web-Service to collect system usage statistics","archived":false,"fork":false,"pushed_at":"2025-06-26T19:02:56.000Z","size":727,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-06T14:03:14.154Z","etag":null,"topics":["raspberry-pi","statistics","system","usage"],"latest_commit_sha":null,"homepage":"","language":"Go","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/tecnickcom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":["https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ"]}},"created_at":"2022-12-31T18:36:51.000Z","updated_at":"2025-06-26T18:58:47.000Z","dependencies_parsed_at":"2023-03-13T20:30:20.270Z","dependency_job_id":"6b160534-7f9f-4560-bbb7-8812002e1f13","html_url":"https://github.com/tecnickcom/rpistat","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":"0.024390243902439046","last_synced_commit":"282b4f35dad69f5d917826b1b9a87632f8f07145"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/tecnickcom/rpistat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecnickcom%2Frpistat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecnickcom%2Frpistat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecnickcom%2Frpistat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecnickcom%2Frpistat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tecnickcom","download_url":"https://codeload.github.com/tecnickcom/rpistat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecnickcom%2Frpistat/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263914030,"owners_count":23529074,"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":["raspberry-pi","statistics","system","usage"],"created_at":"2024-10-13T00:06:54.301Z","updated_at":"2025-07-06T14:03:39.783Z","avatar_url":"https://github.com/tecnickcom.png","language":"Go","readme":"\u003c!-- Space: \u003cno value\u003e --\u003e\n\u003c!-- Parent: Projects --\u003e\n\u003c!-- Title: rpistat --\u003e\n\u003c!-- Attachment: doc/images/logo.png --\u003e\n\n# rpistat\n\n*Web-Service to collect system usage statistics.*\n\n[![Donate via PayPal](https://img.shields.io/badge/donate-paypal-87ceeb.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026currency_code=GBP\u0026business=paypal@tecnick.com\u0026item_name=donation%20for%20rpistat%20project)\n*Please consider supporting this project by making a donation via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026currency_code=GBP\u0026business=paypal@tecnick.com\u0026item_name=donation%20for%20rpistat%20project)*\n\n![rpistat logo](doc/images/logo.png)\n\n* **category:**    Application\n* **copyright:**   2022-2025 Nicola Asuni - Tecnick.com LTD\n* **license:**     [LICENSE](https://github.com/tecnickcom/rpistat/blob/main/LICENSE)\n* **cvs:**         https://github.com/tecnickcom/rpistat\n\n[![check](https://github.com/tecnickcom/rpistat/actions/workflows/check.yaml/badge.svg)](https://github.com/tecnickcom/rpistat/actions/workflows/check.yaml)\n\n----------\n\n## TOC\n* [Description](#description)\n* [Documentation](#documentation)\n\t* [public](#documentation_public)\n\t\t* [General](#documentation_public_general)\n* [Development](#development)\n* [Deployment](#deployment)\n\n----------\n\n\u003ca name=\"description\"\u003e\u003c/a\u003e\n## Description\nWeb-Service to collect system usage statistics.\n\nThis project was started to collect system usage statistics from a remote [Raspberry PI 4](https://www.raspberrypi.com/products/raspberry-pi-4-model-b/) but it can be compiled and used with other systems too.\n\nThe statistics are exposed both via the ```/stats``` Web API endpoint and [Prometheus](https://prometheus.io/) metrics at ```/metrics```.\n\nAn [HomeAssistant](https://www.home-assistant.io/) sensor and template to collect those metrics can be found in the ```resources/HomeAssistant/``` directory.\n\n\n### REST API Example:\n\n```\ncurl 192.168.1.2:65501/stats\n\n{\n\n      \"datetime\": \"2023-06-27T07:03:54Z\",\n      \"timestamp\": 1687849434569669934,\n      \"hostname\": \"rpi4\",\n      \"uptime\": 680189000000000,\n      \"memory_total\": 1005973504,\n      \"memory_free\": 587198464,\n      \"memory_used\": 418775040,\n      \"memory_usage\": 0.41628833993623754,\n      \"load_1m\": 0,\n      \"load_5m\": 0,\n      \"load_15m\": 0,\n      \"temperature_cpu\": 44.303,\n      \"disk_total\": 31109140480,\n      \"disk_free\": 27586793472,\n      \"disk_used\": 3522347008,\n      \"disk_usage\": 0.11322546858099501,\n      \"network\": [\n            {\n                  \"nic\": \"eth0\",\n                  \"rx\": 163621268,\n                  \"tx\": 113155073\n            },\n            {\n                  \"nic\": \"wlan0\",\n                  \"rx\": 8225055,\n                  \"tx\": 1327982\n            },\n            {\n                  \"nic\": \"eth1\",\n                  \"rx\": 24906794,\n                  \"tx\": 18615044\n            }\n      ]\n\n}\n```\n\n### HomeAssistant Screenshot\n\n![HomeAssistant screenshot](doc/images/homeassistant.png)\n\n\n----------\n\n\n\n\u003ca name=\"documentation\"\u003e\u003c/a\u003e\n## Documentation\n\u003ca name=\"documentation_public\"\u003e\u003c/a\u003e\n* public\n\t\u003ca name=\"documentation_public_general\"\u003e\u003c/a\u003e\n\t* General  \n\t_General project documentation_\n\t\t* [GitHup project page](https://github.com/tecnickcom/rpistat)\n\n\n----------\n\n\n\n\u003ca name=\"development\"\u003e\u003c/a\u003e\n## Development\n### TOC\n\n* [Style and Conventions](#style)\n* [Requirements](#requirements)\n* [Quick Start](#quickstart)\n* [Running all tests](#runtest)\n* [Documentation](#gendoc)\n* [Usage](#usage)\n* [Configuration](CONFIG.md)\n* [Examples](#examples)\n* [Logs](#logs)\n* [Metrics](#metrics)\n* [Profiling](#profiling)\n* [OpenAPI](#openapi)\n* [Docker](#docker)\n\n\n\u003ca name=\"style\"\u003e\u003c/a\u003e\n## Style and Conventions\n\nFor the general style and conventions, please refer to external documents:\nhttps://github.com/uber-go/guide/blob/master/style.md\n\n\n\u003ca name=\"quickstart\"\u003e\u003c/a\u003e\n## Developers' Quick Start\n\nTo quickly get started with this project, follow these steps:\n\n1. Ensure you ahev installed the latest Go version and Python3 for some extra tests.\n1. Clone the repository: `git clone https://github.com/tecnickcom/rpistat.git`.\n2. Change into the project directory: `cd rpistat`.\n3. Install the required dependencies and test everything: `DEVMODE=LOCAL make x`.\n\nNow you are ready to start developing with rpistat!\n\n\nThis project includes a *Makefile* that allows you to test and build the project in a Linux-compatible system with simple commands.  \nAll the artifacts and reports produced using this *Makefile* are stored in the *target* folder.  \n\nAlternatively, everything can be built inside a [Docker](https://www.docker.com) container using the command `make dbuild` that uses the environment defined at `resources/docker/Dockerfile.dev`.\n\nTo see all available options:\n```bash\nmake help\n```\n\n\n\u003ca name=\"runtest\"\u003e\u003c/a\u003e\n## Running all tests\n\nBefore committing the code, please check if it passes all tests using\n```bash\nmake x\n```\n\nthat is an alias for:\n```bash\nDEVMODE=LOCAL make format clean mod deps generate qa build docker dockertest\n```\n\n\n\u003ca name=\"gendoc\"\u003e\u003c/a\u003e\n## Documentation\n\nThe `README.md` documentation file is generated using the source templates in `doc/src` via `make gendoc` command.\n\nTo update links and common information edit the file `doc/src/config.yaml` in YAML format.\nThe schema of the configuration file is defined by the JSON schema: `doc/src/config.schema.json`.\nThe document templates are defined by the `*.tmpl` files in [gomplate](https://docs.gomplate.ca)-compatible format.\n\nTo regenerate the static documentation file:\n```bash\nmake gendoc\n```\n\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n## Usage\n\n```bash\nrpistat [flags]\n\nFlags:\n\n-c, --configDir  string  Configuration directory to be added on top of the search list\n-f, --logFormat  string  Logging format: CONSOLE, JSON\n-o, --loglevel   string  Log level: EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG\n```\n\n\u003ca name=\"examples\"\u003e\u003c/a\u003e\n## Examples\n\nOnce the application has being compiled with `make build`, it can be quickly tested:\n\n```bash\ntarget/usr/bin/rpistat -c resources/test/etc/rpistat\n```\n\n\n\u003ca name=\"logs\"\u003e\u003c/a\u003e\n## Logs\n\nThis program logs the log messages in JSON format:\n\n```\n{\n\t\"level\": \"info\",\n\t\"timestamp\": 1595942715776382171,\n\t\"msg\": \"Request\",\n\t\"program\": \"rpistat\",\n\t\"version\": \"0.0.0\",\n\t\"release\": \"0\",\n    \"hostname\":\"myserver\",\n\t\"request_id\": \"c4iah65ldoyw3hqec1rluoj93\",\n\t\"request_method\": \"GET\",\n\t\"request_path\": \"/uid\",\n\t\"request_query\": \"\",\n\t\"request_uri\": \"/uid\",\n\t\"request_useragent\": \"curl/7.69.1\",\n\t\"remote_ip\": \"[::1]:36790\",\n\t\"response_code\": 200,\n\t\"response_message\": \"OK\",\n\t\"response_status\": \"success\",\n\t\"response_data\": \"avxkjeyk43av\"\n}\n```\n\nLogs are sent to stderr by default.\n\nThe log level can be set either in the configuration or as command argument (`logLevel`).\n\n\n\u003ca name=\"metrics\"\u003e\u003c/a\u003e\n## Metrics\n\nThis service provides [Prometheus](https://prometheus.io/) metrics at the `/metrics` endpoint.\n\n\n\u003ca name=\"profiling\"\u003e\u003c/a\u003e\n## Profiling\n\nThis service provides [PPROF](https://github.com/google/pprof) profiling data at the `/pprof` endpoint.\n\nThe pprof data can be analyzed and displayed using the pprof tool:\n\n```\ngo get github.com/google/pprof\n```\n\nExample:\n\n```\npprof -seconds 10 -http=localhost:8182 http://INSTANCE_URL:PORT/pprof/profile\n```\n\n\n\u003ca name=\"openapi\"\u003e\u003c/a\u003e\n## OpenAPI\n\nThe rpistat API is specified via the [OpenAPI 3](https://www.openapis.org/) file: `openapi.yaml`.\n\nThe openapi file can be edited using the Swagger Editor:\n\n```\ndocker pull swaggerapi/swagger-editor\ndocker run -p 8056:8080 swaggerapi/swagger-editor\n```\n\nand pointing the Web browser to http://localhost:8056\n\n\n\u003ca name=\"docker\"\u003e\u003c/a\u003e\n## Docker\n\nTo build a Docker scratch container for the rpistat executable binary execute the following command:\n```\nmake docker\n```\n\n### Useful Docker commands\n\nTo manually create the container you can execute:\n```\ndocker build --tag=\"tecnickcom/rpistatdev\" .\n```\n\nTo log into the newly created container:\n```\ndocker run -t -i tecnickcom/rpistatdev /bin/bash\n```\n\nTo get the container ID:\n```\nCONTAINER_ID=`docker ps -a | grep tecnickcom/rpistatdev | cut -c1-12`\n```\n\nTo delete the newly created docker container:\n```\ndocker rm -f $CONTAINER_ID\n```\n\nTo delete the docker image:\n```\ndocker rmi -f tecnickcom/rpistatdev\n```\n\nTo delete all containers\n```\ndocker rm $(docker ps -a -q)\n```\n\nTo delete all images\n```\ndocker rmi $(docker images -q)\n```\n\n\n----------\n\n\u003ca name=\"deployment\"\u003e\u003c/a\u003e\n## Deployment\nAfter building the executable binary with `make build`:\n\n* Copy the `target/usr/bin/rpistat` file into `/usr/bin/rpistat` in the target system.\n* Set the file is executable with: `sudo chmod +x /usr/bin/rpistat`.\n* Copy and edit the configuration file `resources/etc/rpistat/config.json` into `/etc/rpistat/config.json` in the target system.\n* Copy the service file `resources/etc/systemd/system/rpistat.service` into `/etc/systemd/system/rpistat.service` in the target system and enable it:\n```\nsudo systemctl daemon-reload\nsudo systemctl enable rpistat.service\nsudo systemctl start rpistat.service\n```\n\n\n----------\n\n\n","funding_links":["https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ","https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026currency_code=GBP\u0026business=paypal@tecnick.com\u0026item_name=donation%20for%20rpistat%20project"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftecnickcom%2Frpistat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftecnickcom%2Frpistat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftecnickcom%2Frpistat/lists"}