Skip to content

Repository files navigation

Updown

A Ruby wrapper and CLI for the updown.io API

Installation

Add this line to your application's Gemfile:

gem'updown'

Or install it yourself as:

$ gem install updown

Configuration

Set your API key

# config/initializers/updown.rbUpdown.configuredo |config|
config.api_key='your_api_key'end# orUpdown.configuration.api_key='your_api_key'

Or set the UPDOWN_API_KEY environment variable

Find your API key in your settings page.

Usage

List all your checks:

Updown::Check.all# => [<Updown::Check>, <Updown::Check>, … ]

Retrieve a specific check:

Updown::Check.getcheck_token# => <Updown::Check># include performance metrics for the last hourcheck=Updown::Check.getcheck_token,metrics: truecheck.metrics# => {"apdex": 0.98, "requests": { … }, "timings": { … }}

List downtimes for a specific check (paginated, 100 per call):

check.downtimes# => [<Updown::Downtime>, <Updown::Downtime>, … ]check.downtimespage: 2# => [<Updown::Downtime>]

Get detailed performance metrics for a specific check:

# Default is for last monthcheck.get_metrics# => {"apdex": 0.98, "requests": { … }, "timings": { … }}# Specify time spancheck.get_metricsfrom: 4.hours.ago,to: 2.hours.ago# => {"apdex": 1, "requests": { … }, "timings": { … }}# Specify grouping per location (:host) or hour (:time)check.get_metricsgroup: :host# => {# "sgp" => {"apdex": 0.82, "host": { city: "Singapore", … }, … },# "sfo" => {"apdex": 0.98, "host": { city: "San Francisco", … }, … },# "alpha" => {"apdex": 0.98, "host": { city: "Montreal", … }, … },# "gra" => {"apdex": 0.92, "host": { city: "Gravelines", … }, … }# }

Create a new check:

Updown::Check.create'https://google.com'# => <Updown::Check>

You can also set any parameters allowed by the API, like enabled, published, period or apdex_t:

Updown::Check.create'https://google.com',period: 30,published: true# => <Updown::Check>

In case of validation errors, an Updown::Error will be raised:

Updown::Check.create'https://google.com',period: 45# => Updown::Error: URL is already registered (given: "https://google.com"), Period is not included in the list (given: 45)

Update a specific check:

check.updateperiod: 30# => <Updown::Check>

Delete a specific check:

check.destroy# => true

Learn more about the API here: https://updown.io/api

Command Line

This gem also comes with an updown shell command. First, configure your API key:

$ updown configure YOUR_API_KEY

See the status of your checks:

$ updown status
[up] rjis — https://google.com
[DOWN] bn94 — https://bing.com
[up] qwer — http://stackoverflow.com

Open the status page of a check:

$ updown open rjis

Add a new check:

$ updown add https://google.com

Todo

  • Write tests!

Contributing

  1. Fork it ( https://github.com/askehansen/updown-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

MIT

About

A ruby wrapper for the Updown.io API

Resources

Stars

23 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages