{"id":15001521,"url":"https://github.com/moetelo/xray-stats","last_synced_at":"2026-03-14T22:14:58.151Z","repository":{"id":255382637,"uuid":"849433172","full_name":"moetelo/xray-stats","owner":"moetelo","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-29T17:53:58.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-27T08:23:31.479Z","etag":null,"topics":["shadowsocks","vless","vmess","xray","xray-core"],"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/moetelo.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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-08-29T15:28:57.000Z","updated_at":"2024-11-29T17:54:02.000Z","dependencies_parsed_at":"2024-11-13T20:22:41.739Z","dependency_job_id":"c438d93a-af13-42d5-a5d8-202e6ce5c8af","html_url":"https://github.com/moetelo/xray-stats","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"cb4a1c18fac5d6eaccde2676d62c36fd432b426b"},"previous_names":["moetelo/xray-stats-collector"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/moetelo/xray-stats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moetelo%2Fxray-stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moetelo%2Fxray-stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moetelo%2Fxray-stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moetelo%2Fxray-stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moetelo","download_url":"https://codeload.github.com/moetelo/xray-stats/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moetelo%2Fxray-stats/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30519471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-14T19:51:21.629Z","status":"ssl_error","status_checked_at":"2026-03-14T19:51:12.959Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["shadowsocks","vless","vmess","xray","xray-core"],"created_at":"2024-09-24T18:02:51.140Z","updated_at":"2026-03-14T22:14:58.134Z","avatar_url":"https://github.com/moetelo.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xray-stats\n\n## Usage\n\n`./install.sh`: Installs the scripts and sets up the environment.\n\n`./install.sh \u003ctraffic-data-dir\u003e`: Installs the scripts and sets up the environment with the specified traffic data directory.\n\n## Scripts\n\n`install.sh`: Sets up the environment and installs the necessary scripts.\n\n`stats-collect`: Collects traffic statistics using the xray API and processes them.\n\n`stats-query`: Summarizes the traffic data for each user on a specified date. If no date is provided, it defaults to the current date. It displays the downlink and uplink data in megabytes (MB) for each user.\n\n## Configuration\n\nThe traffic data directory is stored in `/usr/local/etc/xray-stats/directory`. You can change this by re-running the `install.sh` script with a different directory.\n\n## How it works\n\nThe `stats-collect` script collects and stores traffic data for each user:\n\n1. Runs `xray api statsquery -reset` to get traffic stats.\n1. Processes the output with `jq` using `stats-to-user-down-up.jq`.\n1. Reads the traffic data directory path from `/usr/local/etc/xray-stats/directory`.\n1. Appends downlink and uplink values to files named with the current date in the respective directories.\n\nThis organizes traffic data by user and date, with separate files for downlink and uplink data.\n\nThe file consists of multiple lines, each containing a traffic value in bytes. The script appends the traffic value to the file, creating a new file if it does not exist.\n\n### Cron Job\n\nThe `install.sh` script installs a cron job from `xray-stats.cron`.\n\nIt runs the `stats-collect` script every 5 minutes, and sums the traffic data for each user on the current date every hour.\n\n## Example directory structure\n\n```\n/var/local/xray-traffic/\n├── user1/\n│   ├── down/\n│   │   └── 2024-01-01\n│   └── up/\n│       └── 2024-01-01\n└── user2/\n    ├── down/\n    │   └── 2024-01-01\n    └── up/\n        └── 2024-01-01\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoetelo%2Fxray-stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoetelo%2Fxray-stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoetelo%2Fxray-stats/lists"}