Go to file
Ivan Danyliuk 149c8f048f
Add Go modules support
2019-02-04 13:03:43 +01:00
demo Updated screenshots 2015-05-03 21:09:27 +03:00
.gitignore gitignore change 2015-05-03 19:58:36 +03:00
.travis.yml Update .travis.yml 2017-09-04 22:56:15 +02:00
LICENSE Create LICENSE 2017-07-10 12:41:15 +02:00
README.md Update CI badge 2017-05-22 15:46:28 +02:00
average.go Added support for arrays (print average) 2015-08-20 21:38:04 -04:00
average_test.go Added support for arrays (print average) 2015-08-20 21:38:04 -04:00
data.go Code cleanups 2015-05-01 20:12:23 +03:00
expvars.go Add customizable endpoints ('/debug/vars') 2015-10-15 23:11:48 -04:00
expvars.json Initial commit 2015-04-21 12:51:01 +03:00
expvars_advanced.json Refactoring 2015-04-25 15:54:17 +03:00
expvars_test.go Added support for arrays (print average) 2015-08-20 21:38:04 -04:00
go.mod Add Go modules support 2019-02-04 13:03:43 +01:00
go.sum Add Go modules support 2019-02-04 13:03:43 +01:00
main.go Switch to master termui version 2019-01-19 11:40:36 +02:00
self.go Make gometalinter a bit happier 2015-10-15 23:36:29 -04:00
service.go Added support for arrays (print average) 2015-08-20 21:38:04 -04:00
stack.go Small improvements to PR 2015-09-25 12:39:31 -04:00
stack_test.go Small improvements to PR 2015-09-25 12:39:31 -04:00
ui.go UI separated to multiple files 2015-05-03 16:52:50 +03:00
ui_dummy.go Refactored URLs handling 2015-07-10 19:29:22 +03:00
ui_multi.go Switch to master termui version 2019-01-19 11:40:36 +02:00
ui_single.go Switch to master termui version 2019-01-19 11:40:36 +02:00
utils.go Make gometalinter a bit happier 2015-10-15 23:36:29 -04:00
utils_test.go Make gometalinter a bit happier 2015-10-15 23:36:29 -04:00
var.go allow escaping the dot character in paths using a backslash 2015-12-01 16:53:13 -05:00
var_test.go allow escaping the dot character in paths using a backslash 2015-12-01 16:53:13 -05:00

README.md

ExpvarMon

Build Status

TermUI based Go apps monitor using expvars variables (/debug/vars). Quickest way to monitor your Go app.

Introduction

Go apps console monitoring tool. Minimal configuration efforts. Quick and easy monitoring solution for one or multiple services.

Features

  • Single- and multi-apps mode
  • Local and remote apps support
  • HTTP and HTTPS endpoints, including Basic Auth support
  • Arbitrary number of apps and vars to monitor (from 1 to 30+, depends on size of your terminal)
  • Track restarted/failed apps
  • Show maximum value
  • Supports: Integer, float, duration, memory, string, bool, array variables
  • Sparkline charts for integer, duration and memory data
  • Auto-resize on font-size change or window resize
  • Uses amazing TermUI library by gizak

Demo

Multiple apps mode

Multi mode

Single app mode

Single mode

You can monitor arbitrary number of services and variables:

1 var 25 apps

Purpose

This app targets debug/develop sessions when you need an instant way to monitor you app(s). It's not intended to monitor apps in production. Also it doesn't use any storage engines and doesn't send notifications.

Install

Just run go get:

go get github.com/divan/expvarmon

Usage

Prepare your app

First, you have to add expvars support into your Go program. It's as simple as:

import _ "expvar"

and note the port your app is listening on. If it's not, just add two lines:

import "net/http"
...
http.ListenAndServe(":1234", nil)

and expvar will add handler for "localhost:1234/debug/vars" to your app.

By default, expvars adds two variables: memstats and cmdline. It's enough to monitor memory and garbage collector status in your app.

Run expvarmon

Just run expvarmon with -ports="1234" flag:

expvarmon -ports="1234"

That's it.

More examples:

./expvarmon -ports="80"
./expvarmon -ports="23000-23010,http://example.com:80-81" -i=1m
./expvarmon -ports="80,remoteapp:80" -vars="mem:memstats.Alloc,duration:Response.Mean,Counter"
./expvarmon -ports="1234-1236" -vars="Goroutines" -self
./expvarmon -ports="https://user:pass@my.remote.app.com:443" -vars="Goroutines" -self

Advanced usage

If you need to monitor more (or less) vars, you can specify them with -vars command line flag.

$ no ports specified. Use -ports arg to specify ports of Go apps to monitor
Usage of ./expvarmon:
  -dummy
    	Use dummy (console) output
  -endpoint string
    	URL endpoint for expvars (default "/debug/vars")
  -i duration
    	Polling interval (default 5s)
  -ports string
    	Ports/URLs for accessing services expvars (start-end,port2,port3,https://host:port)
  -self
    	Monitor itself
  -vars string
    	Vars to monitor (comma-separated) (default "mem:memstats.Alloc,mem:memstats.Sys,mem:memstats.HeapAlloc,mem:memstats.HeapInuse,duration:memstats.PauseNs,duration:memstats.PauseTotalNs")

Examples:
	./expvarmon -ports="80"
	./expvarmon -ports="23000-23010,http://example.com:80-81" -i=1m
	./expvarmon -ports="80,remoteapp:80" -vars="mem:memstats.Alloc,duration:Response.Mean,Counter"
	./expvarmon -ports="1234-1236" -vars="Goroutines" -self

For more details and docs, see README: http://github.com/divan/expvarmon

So, yes, you can specify multiple ports, using '-' for ranges, and specify fully-qualified URLs for remote apps. To override default URL endpoint ("/debug/vars"), use -endpoint flag.

You can also monitor expvarmon itself, using -self flag.

Basic Auth

If your expvar endpoint is protected by Basic Auth, you have two options:

  • Set environmental variables HTTP_USER and HTTP_PASSWORD accordingly. These values will be applied to each endpoint.
  • Embed your credentials to URL via command line flag: -ports="http://user:pass@myapp:1234"

Vars

Expvarmon doesn't restrict you to monitor only memstats. You can publish your own counters and variables using expvar.Publish() method or using expvar wrappers libraries. Just pass your variables names as they appear in JSON to -var command line flag.

Notation is dot-separated, for example: memstats.Alloc for .MemStats.Alloc field. Quick link to runtime.MemStats documentation: http://golang.org/pkg/runtime/#MemStats

Expvar allows to export only basic types - structs, ints, floats, arrays (int or float), bools and strings. For arrays, average will be calculated. Ints are used for sparklines, and displayed as is. But you can specify modifier to make sure it will be rendered properly.

Vars are specified as a comma-separated list of var identifiers with (optional) modifiers.

Modifier Description
mem: renders int64 as memory string (KB, MB, etc)
duration: renders int64 as time.Duration (1s, 2ms, 12h23h)
str: doesn't display sparklines chart for this value, just display as string