Sha256: 5c54110982734b0a76ad042b2489e7a7d707bf1b6c6ef3816fe6c61e569a250d
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
# StatsLite Simple way to get server information as json. Easy to extend with a `config.rb` file. Embeddable in Rails ### Standalone usage Requirements ruby, min version 2 ```shell script gem install stats_lite stats-lite curl http://localhost:9111 ```  create a `config.rb` then `stats-lite` ```ruby # example config.rb # basic usage StatsLite.configure do |s| s.password "1234" # password protection s.port 9111 # listening port end ``` ```shell script # now it's protected by passowrd curl http://localhost:9111?password=1234 ``` ### Rails usage `gem "stats_lite"` ```ruby # routes.rb mount StatsLite::App => "/server-stats" ``` ### Advanced configuration ```ruby StatsLite.configure do |s, h| s.password ENV["STATS_LITE_PASS"] # defaults to nil, unprotected s.port ENV["STATS_LITE_PORT"], defaults to 9111 s.data -> (data) do # add more data data[:ruby_current_time] = Time.now #simple value data[:linux_time] = h.command("date") # bash command, supports {cache: true, expires_in: 60} data[:slow_command] = h.fetch :slow_command, -> { sleep 1 "slow command" }, expires_in: 5 # cached ruby value end s.app do |sinatra| # extend the app, add multiple routes, which are protected by the password sinatra.get("/another_route") do content_type :json { cpus: h.command("nproc", { cache: true }) }.to_json end end end ```
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stats_lite-0.5.0 | README.md |
stats_lite-0.1.0 | README.md |