Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sebyx07/stats-lite
Get system stats of your linux servers. CPU, RAM, HDD, extendable
https://github.com/sebyx07/stats-lite
devops linux monitoring rails rails5 ruby
Last synced: 16 days ago
JSON representation
Get system stats of your linux servers. CPU, RAM, HDD, extendable
- Host: GitHub
- URL: https://github.com/sebyx07/stats-lite
- Owner: sebyx07
- License: mit
- Created: 2019-10-04T10:03:43.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-20T07:25:29.000Z (about 2 years ago)
- Last Synced: 2024-10-29T14:15:19.707Z (3 months ago)
- Topics: devops, linux, monitoring, rails, rails5, ruby
- Language: Ruby
- Homepage: https://github.com/sebyx07/stats-lite
- Size: 98.6 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# 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
sudo apt-get install -y ruby build-essential ruby-dev
```Usage standalone, you might need to run some commands as __sudo__.
```shell_script
gem install stats_lite --no-ri --no-rdoc
stats-lite
curl http://localhost:9111
```Add to startup, crontab
```shell_script
crontab -e
# then add
@reboot /usr/local/bin/stats-lite /home/deploy/.stats-lite/config.rb
```![demo](https://raw.githubusercontent.com/sebyx07/stats-lite/master/docs/example.png)
create a `config.rb` then `stats-lite`
```ruby
# example config.rb
# basic usageStatsLite.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 9111s.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
ends.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
ends.rack do # use rack builder, it's also password protected from above^
map "/rack" do
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['OK']] }
end
ends.cron do |rufus| # uses the Rufus scheduler, more details here https://github.com/jmettraux/rufus-scheduler
rufus.every "5s" do
print "\n cron job"
end
rufus.every "1h" do
print "\n hourly cron job"
end
end
end
```