{"id":16642952,"url":"https://github.com/nir0s/shtatsd","last_synced_at":"2026-05-28T08:31:08.363Z","repository":{"id":67212900,"uuid":"174677157","full_name":"nir0s/shtatsd","owner":"nir0s","description":"A bash client for emitting statsd-formatted metrics","archived":false,"fork":false,"pushed_at":"2019-03-09T21:10:40.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-19T17:26:37.305Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/nir0s.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-03-09T10:03:18.000Z","updated_at":"2023-09-07T12:10:48.000Z","dependencies_parsed_at":"2023-02-21T11:15:29.100Z","dependency_job_id":null,"html_url":"https://github.com/nir0s/shtatsd","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"86f757f1606db5ce203c4db681a037289eba2ba6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nir0s/shtatsd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nir0s%2Fshtatsd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nir0s%2Fshtatsd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nir0s%2Fshtatsd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nir0s%2Fshtatsd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nir0s","download_url":"https://codeload.github.com/nir0s/shtatsd/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nir0s%2Fshtatsd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33601380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-12T08:07:03.918Z","updated_at":"2026-05-28T08:31:08.345Z","avatar_url":"https://github.com/nir0s.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"shtatsd\n=======\n\n[![Circle CI](https://circleci.com/gh/strigo/shtatsd.svg?style=shield)](https://circleci.com/gh/strigo/shtatsd)\n\n\nshtatsd is a statsd client for bash. It is the reasonable alternative to: `echo -n \"my_metric:60|g\" \u003e/dev/udp/localhost/8125`\n\nNote that the following documentation relates to the code currently in the master branch. If you want to view docs for previous versions, please choose the relevant release in the \"releases\" tab.\n\nAll basic metric types are supported. You can also emit labels (for Prometheus, dogstatsd, etc..) by adding them to the metric.\n\n## Installation\n\n```bash\nInstall locally:\n\n[[ ! -f \"statsd\" ]] \u0026\u0026 \\\n\tcurl -LO https://github.com/strigo/shtatsd/raw/master/statsd \u0026\u0026 \\\n\tchmod +x statsd\n\nor directly to your path (Yes, we sudo):\n\n[[ ! -f \"/usr/bin/statsd\" ]] \u0026\u0026 \\\n\tsudo curl -L https://github.com/strigo/shtatsd/raw/master/statsd -o /usr/bin/statsd \u0026\u0026 \\\n\tsudo chmod +x /usr/bin/statsd\n```\n\n## Usage\n\n```shell\n. statsd\n\nstatsd.increment \"my_counter\"\nstatsd.increment \"my_counter\" 2\nstatsd.increment \"my_counter\" 5 0.1\n\nstatsd.decrement \"my_counter\"\nstatsd.decrement \"my_counter\" 2\nstatsd.decrement \"my_counter\" 5 0.1\n\nstatsd.gauge \"my_gauge\" 113\nstatsd.gauge \"my_gauge\" 113 0.3\n\nstatsd.timing \"my_timer\" 314\nstatsd.timing \"my_timer\" 314 0.5\n\nstatsd.histogram \"my_histogram\" 5\nstatsd.set \"my_set\" 1092\n```\n\nDon't, forget, bash, expansion, everywhere. Spaces are evil.\n\n### Calculating time in milliseconds\n\nThe `statsd.timing` function expects time in milliseconds. `shtatsd` provides a helper for this, and you can use it like so:\n\n```\n. ./statsd\n\nfunction example_function() {\n  statsd.increment 'function_call_count,key=value'\n  local -r start_time=$(statsd.helper.now)\n\n  sleep 3\n\n  local -r end_time=$(statsd.helper.now)\n  statsd.timing 'function_duration_ms,key=value' $(($end_time-$start_time))\n}\n\nexample_function \"$@\"\n```\n\n\n## Env var based config\n\nYou can use environment variables to set the STATSD_HOST and STATSD_PORT to emit to (defaulting to 127.0.0.1 and 8125 respectively).\n\n\n## Tests\n\nTo run tests locally:\n\n```shell\n$ npm install bats\n...\n$ git submodule init\n$ git submodule update --remote\n$ node_modules/bats/bin/bats test/*.bats\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnir0s%2Fshtatsd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnir0s%2Fshtatsd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnir0s%2Fshtatsd/lists"}