Giter Club home page Giter Club logo

go-monitor's Introduction

go-monitor Build Status GoDoc GitHub release

The main goal of go-monitor is provide a simple and extensible way to build monitorizable long term execution processes or daemons via HTTP.

Thanks to the defaults aspects you can monitorize parameters as runtime, memory, etc. for any Go processes and daemons. As well you can create your custom aspects for monitorize custom parameters from your applications.

Installation

The recommended way to install go-monitor

go get gopkg.in/mcuadros/go-monitor.v1

Examples

Default Monitor

Import the package:

import "gopkg.in/mcuadros/go-monitor.v1"

Start the monitor just before of the bootstrap of your code:

m := monitor.NewMonitor(":9000")
m.Start()

Now just try curl http://localhost:9000/

{
  "MemStats": {
    "Alloc": 7716521256,
    "TotalAlloc": 1935822232552,
    "Sys": 46882078488,
    ...
  },
  "Runtime": {
    "GoVersion": "go1.3.3",
    "GoOs": "linux",
    "GoArch": "amd64",
    "CpuNum": 24,
    "GoroutineNum": 21196,
    "Gomaxprocs": 24,
    "CgoCallNum": 111584
  }
}

At the / you can find all the aspects that are loaded by default, you can request other aspects through the URL /<aspect-name>,<aspect-name>

Custom Monitor

Define your custom aspect, in this case just a simple one that count the number of hits on it.

type CustomAspect struct {
  Count int
}

func (a *CustomAspect) GetStats() interface{} {
  a.Count++
  return a.Count
}

func (a *CustomAspect) Name() string {
  return "Custom"
}

func (a *CustomAspect) InRoot() bool {
  return false
}

Now just add the CustomAspect to the monitor and run it.

m := monitor.NewMonitor(":9000")
m.AddAspect(&CustomAspect{})
m.Start()

Hit http://localhost:9000/Custom and obtain:

{
  "Custom": 5
}

License

MIT, see LICENSE

go-monitor's People

Contributors

mcuadros avatar

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.