Coder Social home page Coder Social logo

The Giraffi Ruby Gem

A Ruby wrapper for the Giraffi API

Installation

gem install giraffi

Requirements

  • Ruby 1.9.2 or later
  • An apikey for the Giraffi API

Usage

How to start monitoring your web site status via HTTP

  1. Create a new Giraffi::Client object
  2. Create a medium
  3. Create an axion
  4. Add the medium you created to the axion
  5. Create an item
  6. Add a service to the item
  7. Add a trigger to the service
  8. Update the axion of the trigger
  9. Update the region of the service
  10. Reload the settings
require 'json'
require 'pp'

# An `APIKEY` that allows you to access the Giraffi API
APIKEY = 'hanamoguella'

# Sample attributes to create a `medium`
medium_attrs = {
  name: "Alert Email",
  mediumtype: "email",
  options: { address: "[email protected]" }
}

# Sample attributes to create an `axion`
axion_attrs = {
  name: "aborted alert",
  axiontype: "messaging",
  options: {}
}

# Sample attributes to create an `item`
item_attrs = {
  name: "web01",
  host: "localhost",
  ip: "127.0.0.1",
  normalinterval: 120,
  warninginterval: 60,
  warningretry: 2,
  status: 1
}

# Sample attributes to create a `service`
service_attrs = {
  servicetype: "web_response_time",
  normalinterval: 120,
  warninginterval: 60,
  warningretry: 2,
  status: 1,
  options: {}
}

# Sample attributes to create a `trigger`
trigger_attrs = {
  triggertype: "timeout",
  axioninterval: 180,
  options:{
    time: "3"
  }
}

# Create a Giraffi client object
g = Giraffi.new({apikey: APIKEY})

# Create a medium
response = g.create_medium(medium_attrs)
medium_id = JSON.parse(response.body)['medium']['id']

# Create an axion
response = g.create_axion(axion_attrs)
axion_id = JSON.parse(response.body)['axion']['id']

# Add the medium you created to the axion
pp g.add_medium_to_axion(axion_id, medium_id)

# Create an item
response = g.create_item(item_attrs)
item_id = JSON.parse(response.body)['item']['id']

# Add a service to the item
response = g.add_service_to_item(item_id, service_attrs)
service_id = JSON.parse(response.body)['service']['id']

# Add a trigger to the service
response = g.add_trigger_to_service(service_id, trigger_attrs)
trigger_id = JSON.parse(response.body)['trigger']['id']

# Update the axion of the trigger
pp g.update_axion_of_trigger(trigger_id, axion_id, "problem")

# Update the region of the service
pp g.update_region_of_service(service_id, "JP")

# Reload the settings
pp g.reload_items

giraffi's Projects

giraffi doesnโ€™t have any public repositories yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.