{"id":23721073,"url":"https://github.com/nhas/statscollector","last_synced_at":"2025-06-25T05:03:40.410Z","repository":{"id":119332948,"uuid":"276866697","full_name":"NHAS/StatsCollector","owner":"NHAS","description":"Simple golang application to monitor groups of computers (metrics, alive status). ","archived":false,"fork":false,"pushed_at":"2020-07-21T21:02:32.000Z","size":94,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-25T05:02:45.296Z","etag":null,"topics":["golang","metrics","monitoring","servers","ssh"],"latest_commit_sha":null,"homepage":"","language":"Go","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/NHAS.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-07-03T09:55:28.000Z","updated_at":"2020-07-21T21:02:34.000Z","dependencies_parsed_at":"2023-07-17T09:30:09.404Z","dependency_job_id":null,"html_url":"https://github.com/NHAS/StatsCollector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NHAS/StatsCollector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHAS%2FStatsCollector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHAS%2FStatsCollector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHAS%2FStatsCollector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHAS%2FStatsCollector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NHAS","download_url":"https://codeload.github.com/NHAS/StatsCollector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHAS%2FStatsCollector/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261807929,"owners_count":23212683,"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":["golang","metrics","monitoring","servers","ssh"],"created_at":"2024-12-30T22:16:53.350Z","updated_at":"2025-06-25T05:03:40.392Z","avatar_url":"https://github.com/NHAS.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StatsCollector\n\nAn extremely basic group server monitoring solution. Use at your own risk.  \nDecided that I wanted to try my hand at creating something to send me emails and let me view basic stats about the computers I monitor.  \n\nAn agent based approach is utilised here, `Iris` as the client and `Theia` as the server/collector.  \n\nThis project also heavily heavily uses the golang SSH library to manage authentication of clients and servers. \n\n\n\n\n## Local Machine Install\n\nInstall `postgres`, through whatever you distro allows (e.g pacman, yum, apt so on).  \n\nCurrent the DB connection can only be localhost, without SSL with the user `gorm` and the database of `stats`. These are not hard limitations and could be easily changed by editing `cmd/theia/main.go`.  \n\nAs such create a user `gorm`\n\n\n```\nsudo -u postgres psql\npostgres=# create database stats;\npostgres=# create user gorm with encrypted password '\u003cENTER A GOOD PASSWORD HERE\u003e';\npostgres=# grant all privileges on database gorm to stats;\n\n```\nAdapted from \u003ca href=\"https://medium.com/coding-blocks/creating-user-database-and-adding-access-on-postgresql-8bfcd2f4a91e\"\u003ehere\u003c/a\u003e\n\nGet the project and build it.\n```\ngo get github.com/NHAS/StatsCollector\ncd ~/go/src/github.com/NHAS/StatsCollector/\nmkdir bin/\ncd bin/\ngo build -o ../...\n```\n\n\nCreate the file structure to seperate the client/server config and key information.\n\n```\nmkdir {client,server}\n```\n\nGenerate keypairs for both the client and server with ssh-keygen.\n\n```\nssh-keygen -t ed25519 -f server/id_ed25519\nssh-keygen -t ed25519 -f client/id_ed25519\n```\n\n\nSample server config into `server/`:\n\n```\n{\n\t\"ssh_listen_addr\": \":2222\",\n\t\"web_interface_addr\": \":8080\",\n\t\"private_key_path\": \"./server/id_ed25519\",\n\t\"web_path\": \"/home/\u003cYOUR USERNAME\u003e/go/src/github.com/NHAS/StatsCollector/resources\"\n}\n```\n\nSample client config into `client/`:\n\n```\n{\n\t\"server_address\": \"127.0.0.1:2222\",\n\t\"authorised_key\": \"\u003cSERVER AUTHORISED KEY\u003e\",\n\t\"monitor_urls\": [\n\t\t{\n\t\t\t\"url\": \"https://endpointyouwanttocheck.com\",\n\t\t\t\"ok_code\": 200,\n\t\t\t\"timeout\": 5\n\t\t}\n\t],\n\t\"private_key_path\": \"./client/id_ed25519\"\n}\n```\n\n\nAdd a user with `theia` (this will prompt for username \u0026 pwd):\n```\n./theia -adduser\n```\n\nThen start server with (this assumes postgres is running):\n\n```\nPASSWORD=\"\u003cENTER A GOOD PASSWORD HERE\u003e\" ./theia -config server/config.json -log server/log.txt \n```\n\nAnd then client: \n\n```\n./iris -config client/config.json -log client/log.   \n```\n\nOpen `localhost:8080` in a browser and login with previously created creds. \nFinally add the clients public key under `Add Agent` section in the top right. \n\n\n## Deployment\n\nUnfortunately I havent gotten around to making anything more automated. But below you'll find the `systemd` service files to run these as services.  \nFrom them you should be able to infer what paths you could put things. \n\nBut its up to you. \n\n```\n[Unit]\nDescription=Theia Stats Collector Server\nAfter=network.target postgresql.service\nRequires=postgresql.service\n\n[Service]\nType=simple\nRestart=always\nRestartSec=1\nUser=theia\nExecStart=/usr/local/bin/theia -config /usr/local/etc/theia/config.json -log /var/log/theia/log.txt\nEnvironment=PASSWORD=\u003cYOUR MASSIVELY GOOD PASSWORD\u003e\n\n[Install]\nWantedBy=multi-user.target\n```\n\n```\n[Unit]\nDescription=Iris Stats Collector Client\nAfter=network.target\n\n[Service]\nType=simple\nRestart=always\nRestartSec=1\nUser=iris\nExecStart=/usr/local/bin/iris -config /usr/local/etc/iris/config.json -log /var/log/iris/log.txt\n\n[Install]\nWantedBy=multi-user.target\n```\n\n## Current Features\n\n- Email alerts on selected hosts about disk usage, endpoint failure or host failure\n- SSH pub key based auth\n- Web ready authentication\n- Basic metric collection of memory, disk and network services\n- Basic user management \n\n## Limitations\n\n- Features no history for metrics (memory/disk)\n- All users are administrators\n- Email host configuration (the thing that sends the email) is a bit jank at the moment\n- Events arent displayed with very useful information as of yet\n- Dashboard is quite information sparse\n- Renaming of agents isnt possible through the web interface as of yet\n- If monitor of an endpoint is removed client side, it is not updated server side\n\n## Todo\n\n- Rename agents in web interface\n- Rework email notifications to be user specific\n- Rework disk utilisation alerts to be disk specific, so you can disable alerts on loopback devices\n- Add more useful information to the dashboard when all hosts are up\n- Create automated deployement script, or look into packaging ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhas%2Fstatscollector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhas%2Fstatscollector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhas%2Fstatscollector/lists"}