shh

package module
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2014 License: GPL-3.0 Imports: 26 Imported by: 0

README

System Heuristics Herald (aka Shh)

Gathers and relays system metrics

Install

go get github.com/heroku/shh

Configuration

Configuration of shh doesn't use a config file, instead it uses environment variables.

Environment Var Type Explanation Default
SHH_INTERVAL duration Polling Interval 10s
SHH_OUTPUTTER string Outputter stdoutl2metder
SHH_POLLERS list of string Pollers to poll conntrack,cpu,df,disk,listen,load,mem,nif,ntpdate,processes,self
SHH_SOURCE string Source to emit
SHH_PREFIX string Metric prefix to use
SHH_PROFILE_PORT string Profile Port 0 (off)
SHH_PERCENTAGES list of string Default pollers which should report percentages when applicable
SHH_DF_TYPES list of string Default DF types btrfs,ext3,ext4,tmpfs,xfs
SHH_LISTEN string Default network socket info for listen unix,#shh
SHH_LISTEN_TIMEOUT string Socket timeout duration SHH_INTERVAL
SHH_NIF_DEVICES list of string Devices to poll eth0,lo
SHH_NTPDATE_SERVERS list of string NTP Servers 0.pool.ntp.org,1.pool.ntp.org
SHH_CPU_AGGR bool Whether to only report aggregate CPU usage true
SHH_LIBRATO_USER string The Librato API User
SHH_LIBRATO_TOKEN string The Librato API Token
SHH_LIBRATO_URL string The Librato API User https://metrics-api.librato.com/v1/metrics
SHH_LIBRATO_BATCH_SIZE int The max number of metrics to submit in a single request 500
SHH_LIBRATO_BATCH_TIMEOUT duration The max time metrics will sit un-delivered SHH_INTERVAL
SHH_LIBRATO_ROUND bool Should shh round times to the nearest interval? true
SHH_NETWORK_TIMEOUT duration Timeout til connect (will retry). And timeout to first header (will assume successful). Used for HTTP(S) endpoints and other network communication 5s
SHH_CARBON_HOST string Where the Carbon Outputter sends it's data
SHH_SOCKSTAT_PROTOS list of string Protocols to report sockstats about TCP,UDP,TCP6,UDP6
SHH_STATSD_HOST string Where the Statsd Outputter sends it's data
SHH_STATSD_PROTO string Whether the Stats Outputter uses TCP or UDP udp
SHH_SYSLOGNG_SOCKET string The location of the syslog-ng socket /var/lib/syslog-ng/syslog-ng.ctl
`SHH_FULL list of strings Pollers that should report full metrics. shh defaults to minimal ""
SHH_DISK_FILTER regexp Scan devices that match this regex (xv
SHH_PROCESSES_REGEX regexp Scan / extract metrics for processes that match this regex \A\z
SHH_TICKS int cpu ticks per second: see getconf CLK_TCK. Default is probably correct. (temporary until we use cgo) 100
SHH_PAGE_SIZE int system page size in bytes: see getconf PAGESIZE. Default is probably correct. (temporary until we use cgo) 4096
SHH_NAGIOS3_METRIC_NAMES list of strings list of nagios 3 metric names to report stats on, see nagios3stats -h NUMSERVICES,NUMHOSTS,AVGACTSVCLAT,AVGACTHSTLAT,NUMHSTACTCHK5M,NUMSVCACTCHK5M,NUMHSTACTCHK1M,NUMSVCACTCHK1M
SHH_SPLUNK_PEERS_SKIP_VERIFY bool whether or not to skip verification of HTTPS cert on splunk peers endpoint false
SHH_SPLUNK_PEERS_URL string URL of splunk distributed peers status (e.g. https://user:pass@localhost:8089/services/search/distributed/peers?count=-1
SHH_FOLSOM_BASE_URL string URL of exported folsom metrics via folsome_cowboy or folsom_webmachine (e.g. https://localhost:5564/)

For more information on the duration type, see time.ParseDuration

The regexp type supports valid regexps documented here.

A note about SHH_OUTPUTTER

The SHH_OUTPUTTER variable may not be enough on it's own to get the desired result. For instance, the Librato outputter, requires that SHH_LIBRATO_USER and SHH_LIBRATO_TOKEN be set.

A note about SHH_PERCENTAGES

This variable works on "virtual" pollers and computes "percentage used", reporting as ".perc"

  • mem (from the mem poller)
  • swap (from the mem poller)
  • df (from the df_poller)

Building Debs on Heroku

heroku apps:create freeformz-build-shh --buildpack git://github.com/kr/heroku-buildpack-go.git
git push heroku
heroku open

Wait for the deb to be available, download and do what you want with it.

'Local' Development

  1. Obtain a Linux system (only really tested on Ubuntu ATM)
  2. Install Go (version 1.3 works fine)
  3. Set GOPATH appropriately
  4. go get github.com/tool/godep
  5. go get github.com/heroku/shh
  6. cd $GOPATH/src/github.com/heroku/shh
  7. godep go install ./...
  8. $GOPATH/bin/shh

hack away

Contributing

The goal for shh is to be a stable, low footprint system metrics poller, and we welcome contributions, feedback and bug reports to make that happen.

We're currently focused on supporting GNU/Linux systems, since that's where we're using shh, but are open to supporting other platforms provided the low footprint nature is preserved.

Please file bug reports through Github Issues. If you'd like to contribute changes, please fork and submit a pull request.

License

Copyright 2013 - 2014, Edward Muller, and contributors

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Documentation

Index

Examples

Constants

View Source
const (
	VERSION                          = "0.9.2"
	DEFAULT_EMPTY_STRING             = ""
	DEFAULT_INTERVAL                 = "60s"                                                              // Default tick interval for pollers
	DEFAULT_OUTPUTTER                = "stdoutl2metder"                                                   // Default outputter
	DEFAULT_POLLERS                  = "conntrack,cpu,df,disk,listen,load,mem,nif,ntpdate,processes,self" // Default pollers
	DEFAULT_PROFILE_PORT             = "0"                                                                // Default profile port, 0 disables
	DEFAULT_DF_TYPES                 = "btrfs,ext3,ext4,xfs"                                              // Default fs types to report df for
	DEFAULT_DF_LOOP                  = false                                                              // Default to not reporting df metrics for loop back filesystems
	DEFAULT_NIF_DEVICES              = "eth0,lo"                                                          // Default interfaces to report stats for
	DEFAULT_NTPDATE_SERVERS          = "0.pool.ntp.org,1.pool.ntp.org"                                    // Default to the pool.ntp.org servers
	DEFAULT_CPU_AGGR                 = true                                                               // Default whether to only report aggregate CPU
	DEFAULT_SYSLOGNG_SOCKET          = "/var/lib/syslog-ng/syslog-ng.ctl"                                 // Default location of the syslog-ng socket
	DEFAULT_SELF_POLLER_MODE         = "minimal"                                                          // Default to only minimal set of self metrics
	DEFAULT_SOCKSTAT_PROTOS          = "TCP,UDP,TCP6,UDP6"                                                // Default protocols to report sockstats on
	DEFAULT_PERCENTAGES              = ""                                                                 // Default pollers where publishing perc metrics is allowed
	DEFAULT_FULL                     = ""                                                                 // Default list of pollers who should report full metrycs
	DEFAULT_LIBRATO_URL              = "https://metrics-api.librato.com/v1/metrics"                       // Default librato url to submit metrics to
	DEFAULT_LIBRATO_BATCH_SIZE       = 500                                                                // Default submission count
	DEFAULT_LIBRATO_BATCH_TIMEOUT    = "10s"                                                              // Default submission after
	DEFAULT_LIBRATO_ROUND            = true                                                               // Round measure_time to interval
	DEFAULT_LISTEN_ADDR              = "unix,#shh"                                                        // listen on UDS #shh
	DEFAULT_DISK_FILTER              = "(xv|s)d"                                                          // xvd* and sd* by default
	DEFAULT_PROCESSES_REGEX          = `\A\z`                                                             // Regex of processes to pull additional stats about
	DEFAULT_TICKS                    = 100                                                                // Default number of clock ticks per second (see _SC_CLK_TCK)
	DEFAULT_PAGE_SIZE                = 4096                                                               // Default system page size (see getconf PAGESIZE)
	DEFAULT_NAGIOS3_METRIC_NAMES     = "NUMSERVICES,NUMHOSTS,AVGACTSVCLAT,AVGACTHSTLAT,NUMHSTACTCHK5M,NUMSVCACTCHK5M,NUMHSTACTCHK1M,NUMSVCACTCHK1M"
	DEFAULT_SPLUNK_PEERS_SKIP_VERIFY = false
	DEFAULT_NETWORK_TIMEOUT          = "5s"
)
View Source
const (
	SYS         = "/sys/block/"
	SECTOR_SIZE = 512
)
View Source
const (
	LibratoBacklog         = 8 // No more than N pending batches in-flight
	LibratoMaxAttempts     = 4 // Max attempts before dropping batch
	LibratoStartingBackoff = 500 * time.Millisecond
)
View Source
const (
	SOCKSTAT4 = "/proc/net/sockstat"
	SOCKSTAT6 = "/proc/net/sockstat6"
)
View Source
const (
	STATS_COMMAND = "STATS\n"
	HEADER        = "SourceName;SourceId;SourceInstance;State;Type;Number"
	FOOTER        = "."
)
View Source
const (
	CONNTRACK_DATA = "/proc/sys/net/netfilter/nf_conntrack_count"
)
View Source
const (
	CPU_DATA = "/proc/stat"
)
View Source
const (
	DEVICE_FILE = "/proc/net/dev"
)
View Source
const (
	FILE_NR_DATA = "/proc/sys/fs/file-nr"
)
View Source
const (
	LOAD_DATA = "/proc/loadavg"
)
View Source
const (
	MEMORY_FILE = "/proc/meminfo"
)
View Source
const (
	PROC = "/proc"
)

Variables

View Source
var (
	MetricNameRegexp = regexp.MustCompile("^[a-zA-Z0-9]([a-zA-Z0-9.-]+)?$")
	UnitRegexp       = regexp.MustCompile("^([a-zA-Z$%#]+)(,([a-zA-Z$%#]+))?$") // <unit 1>,<abbr 3>
)
View Source
var (
	Logger    = log.New(os.Stdout, "shh: ", log.LstdFlags)
	ErrLogger = log.New(os.Stderr, "shh: ", log.LstdFlags)
)
View Source
var (
	Empty           = Unit{"", ""}
	Percent         = Unit{"Percent", "%"}
	Bytes           = Unit{"Bytes", "b"}
	Seconds         = Unit{"Seconds", "s"}
	MilliSeconds    = Unit{"MilliSeconds", "ms"}
	NanoSeconds     = Unit{"NanoSeconds", "ns"}
	Requests        = Unit{"Requests", "reqs"}
	Errors          = Unit{"Errors", "errs"}
	Packets         = Unit{"Packets", "pkts"}
	INodes          = Unit{"INodes", "inodes"}
	Files           = Unit{"Files", "files"}
	Processes       = Unit{"Processes", "procs"}
	Threads         = Unit{"Threads", "threads"}
	Connections     = Unit{"Connections", "conns"}
	Sockets         = Unit{"Sockets", "socks"}
	Avg             = Unit{"Avg", "avg"}
	Objects         = Unit{"Objects", "objs"}
	Routines        = Unit{"Routines", "routines"}
	Metrics         = Unit{"Metrics", "metrics"}
	Faults          = Unit{"Faults", "faults"}
	Ops             = Unit{"Operations", "ops"}
	Peers           = Unit{"Peers", "peers"}
	ContextSwitches = Unit{"ContextSwitches", "cswit"}
	Words           = Unit{"Words", "words"}
	Reductions      = Unit{"Reductions", "rdux"}
)
View Source
var (
	MEM_MINIMAL_LIST = []string{"memfree", "memtotal", "swapfree", "swaptotal", "buffers", "cached", "swapcached"}
)
View Source
var (
	MetricNameNormalizer = strings.NewReplacer("#", ".", "_", "-")
)
View Source
var (
	NonWord = regexp.MustCompile("\\W")
)

Functions

func Atofloat64

func Atofloat64(s string) float64
Example (Big)
fmt.Println(Atofloat64("10226292680.3"))
Output:

1.02262926803e+10
Example (Small)
fmt.Println(Atofloat64("0.0"))
Output:

0

func Atouint64

func Atouint64(s string) uint64
Example (Big)
fmt.Println(Atouint64("10226292680"))
Output:

10226292680
Example (Small)
fmt.Println(Atouint64("0"))
Output:

0

func Exists

func Exists(path string) bool

Checks to see if a path exists or not

Example
fmt.Println(Exists("./foozle_not_found"))
fmt.Println(Exists("./file_test.go"))
Output:

false
true

func FatalError added in v0.6.0

func FatalError(ctx slog.Context, err error, msg interface{})

func Fields

func Fields(line string) []string
Example (Basic)
fmt.Println(Fields("  eth0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"))
Output:

[eth0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
Example (Parens)
fmt.Println(Fields("372 (kworker/2:1) S 2 0 0 0 -1 69238880 0 0 0 0 0 17293 0 0 20 0 1 0 40 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744073709551615 0 0 17 2 0 0 0 0 0 0 0 0 0 0 0 0 0\n"))
Output:

[372 (kworker/2:1) S 2 0 0 0 -1 69238880 0 0 0 0 0 17293 0 0 20 0 1 0 40 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744073709551615 0 0 17 2 0 0 0 0 0 0 0 0 0 0 0 0 0]
Example (Parens2)
f := Fields("Active(anon):      42384 kB")
fmt.Println(f)
fmt.Println(len(f))
Output:

[Active(anon) 42384 kB]
3
Example (Squashed)
fmt.Println(Fields("  eth0:10226292680 39079204    0    0    0     0          0         0 10250230999 51012120    0    0    0     0       0          0\n"))
Output:

[eth0 10226292680 39079204 0 0 0 0 0 0 10250230999 51012120 0 0 0 0 0 0]

func FileLineChannel

func FileLineChannel(fpath string) <-chan string

Small wrapper to handle errors on open

Example (NoError)

FileLineChannel

c := FileLineChannel("./misc_test.go")
var i int
for d := range c {
	d = d
	i++
}
fmt.Println(i > 0)
Output:

true

func FixUpName

func FixUpName(name string) []string
Example

FixUpName

fmt.Println(FixUpName("foo(bar)"))
fmt.Println(FixUpName("Foo(Bar)"))
fmt.Println(FixUpName("foo_bar"))
fmt.Println(FixUpName("Foo_Bar)"))
fmt.Println(FixUpName("Foo"))
fmt.Println(FixUpName("(Foo)"))
Output:

[foo bar]
[foo bar]
[foo bar]
[foo bar]
[foo]
[foo]

func GetEnvWithDefault

func GetEnvWithDefault(env string, def string) string

Returns the value of $env from the OS and if it's empty, returns def

Example (Default)
os.Setenv("SHH_TEST_ENV", "bar")
fmt.Println(GetEnvWithDefault("SHH_TEST_ENV", "bar"))
Output:

bar
Example (Empty)
os.Setenv("SHH_TEST_ENV", "")
fmt.Println(GetEnvWithDefault("SHH_TEST_ENV", "bar"))
Output:

bar
Example (NotDefault)
os.Setenv("SHH_TEST_ENV", "foo")
fmt.Println(GetEnvWithDefault("SHH_TEST_ENV", "bar"))
Output:

foo
Example (NotSet)
os.Clearenv()
fmt.Println(GetEnvWithDefault("SHH_TEST_ENV", "bar"))
Output:

bar

func GetEnvWithDefaultBool

func GetEnvWithDefaultBool(env string, def bool) bool

Returns the value of $env from the OS and if it's empty, returns def

func GetEnvWithDefaultDuration

func GetEnvWithDefaultDuration(env string, def string) time.Duration
Example (Default)
os.Setenv("SHH_TEST_ENV", "42s")
fmt.Println(GetEnvWithDefaultDuration("SHH_TEST_ENV", "42s"))
Output:

42s
Example (Empty)
os.Setenv("SHH_TEST_ENV", "")
fmt.Println(GetEnvWithDefaultDuration("SHH_TEST_ENV", "42s"))
Output:

42s
Example (NotDefault)
os.Setenv("SHH_TEST_ENV", "7s")
fmt.Println(GetEnvWithDefaultDuration("SHH_TEST_ENV", "42s"))
Output:

7s
Example (NotSet)
os.Clearenv()
fmt.Println(GetEnvWithDefaultDuration("SHH_TEST_ENV", "42s"))
Output:

42s

func GetEnvWithDefaultInt

func GetEnvWithDefaultInt(env string, def int) int

Returns the value of $env from the OS and if it's empty, returns def

Example (Default)
os.Setenv("SHH_TEST_ENV", "42")
fmt.Println(GetEnvWithDefaultInt("SHH_TEST_ENV", 42))
Output:

42
Example (Empty)
os.Setenv("SHH_TEST_ENV", "")
fmt.Println(GetEnvWithDefaultInt("SHH_TEST_ENV", 42))
Output:

42
Example (NotDefault)
os.Setenv("SHH_TEST_ENV", "7")
fmt.Println(GetEnvWithDefaultInt("SHH_TEST_ENV", 42))
Output:

7
Example (NotSet)
os.Clearenv()
fmt.Println(GetEnvWithDefaultInt("SHH_TEST_ENV", 42))
Output:

42

func GetEnvWithDefaultRegexp added in v0.8.3

func GetEnvWithDefaultRegexp(env string, def string) *regexp.Regexp

Returns a *regexp.Regexp compiled from the env or default

func GetEnvWithDefaultStrings

func GetEnvWithDefaultStrings(env string, def string) []string

Returns a slice of sorted strings from the environment or default split on , So "foo,bar" returns ["bar","foo"]

Example (Empty)
os.Setenv("SHH_TEST_ENV", "")
fmt.Println(len(GetEnvWithDefaultStrings("SHH_TEST_ENV", "")))
Output:

0
Example (Multiple)
os.Setenv("SHH_TEST_ENV", "foo,bar")
v := GetEnvWithDefaultStrings("SHH_TEST_ENV", "")
fmt.Println(len(v))
fmt.Println(v[0])
fmt.Println(v[1])
Output:

2
bar
foo
Example (Single)
os.Setenv("SHH_TEST_ENV", "foo")
v := GetEnvWithDefaultStrings("SHH_TEST_ENV", "")
fmt.Println(len(v))
fmt.Println(v[0])
Output:

1
foo

func GetEnvWithDefaultURL added in v0.8.8

func GetEnvWithDefaultURL(env string, def string) *url.URL

Returns a *url.URL representing the given env, or nil if empty

func LinearSliceContainsString

func LinearSliceContainsString(ss []string, s string) bool
Example
fmt.Println(SliceContainsString([]string{"a", "b", "c"}, "a"))
fmt.Println(SliceContainsString([]string{"a", "b", "c"}, "b"))
fmt.Println(SliceContainsString([]string{"a", "b", "c"}, "c"))
fmt.Println(SliceContainsString([]string{"a", "b", "c"}, "z"))
fmt.Println(SliceContainsString([]string{"a", "b", "c"}, "aa"))
Output:

true
true
true
false
false

func LogError added in v0.6.0

func LogError(ctx slog.Context, err error, msg interface{})

func PercentFormat

func PercentFormat(val float64) string
Example
fmt.Println(PercentFormat(100.0))
fmt.Println(PercentFormat(42.314))
Output:

100.00
42.31

func SliceContainsString

func SliceContainsString(ss []string, s string) bool
Example
fmt.Println(SliceContainsString([]string{"a", "b", "c"}, "a"))
fmt.Println(SliceContainsString([]string{"a", "b", "c"}, "b"))
fmt.Println(SliceContainsString([]string{"a", "b", "c"}, "c"))
fmt.Println(SliceContainsString([]string{"a", "b", "c"}, "z"))
fmt.Println(SliceContainsString([]string{"a", "b", "c"}, "aa"))
Output:

true
true
true
false
false

func Ui64toa

func Ui64toa(val uint64) string
Example
fmt.Println(Ui64toa(10226292680))
Output:

10226292680

Types

type Carbon

type Carbon struct {
	Host string
	// contains filtered or unexported fields
}

func NewCarbonOutputter

func NewCarbonOutputter(measurements <-chan Measurement, config Config) *Carbon

func (*Carbon) Connect

func (out *Carbon) Connect(host string) net.Conn

func (*Carbon) Output

func (out *Carbon) Output()

func (*Carbon) Start

func (out *Carbon) Start()

type Config

type Config struct {
	Interval              time.Duration
	Outputter             string
	Pollers               []string
	Source                string
	Prefix                string
	ProfilePort           string
	Percentages           []string
	Full                  []string
	DfTypes               []string
	DfLoop                bool
	Listen                string
	ListenTimeout         time.Duration
	NifDevices            []string
	NtpdateServers        []string
	CpuOnlyAggregate      bool
	LibratoUrl            *url.URL
	LibratoUser           string
	LibratoToken          string
	LibratoBatchSize      int
	LibratoBatchTimeout   time.Duration
	LibratoRound          bool
	NetworkTimeout        time.Duration
	CarbonHost            string
	SockStatProtos        []string
	StatsdHost            string
	StatsdProto           string
	SyslogngSocket        string
	Start                 time.Time
	DiskFilter            *regexp.Regexp
	UserAgent             string
	ProcessesRegex        *regexp.Regexp
	Ticks                 int
	PageSize              int
	Nagios3MetricNames    []string
	SplunkPeersSkipVerify bool
	SplunkPeersUrl        *url.URL
	FolsomBaseUrl         *url.URL
}

func GetConfig

func GetConfig() (config Config)

type Conntrack

type Conntrack struct {
	// contains filtered or unexported fields
}

func NewConntrackPoller

func NewConntrackPoller(measurements chan<- Measurement) Conntrack

func (Conntrack) Exit

func (poller Conntrack) Exit()

func (Conntrack) Name

func (poller Conntrack) Name() string

func (Conntrack) Poll

func (poller Conntrack) Poll(tick time.Time)

type CounterMeasurement added in v0.5.0

type CounterMeasurement struct {
	// contains filtered or unexported fields
}

func (CounterMeasurement) Difference added in v0.5.0

func (CounterMeasurement) Name added in v0.5.0

func (c CounterMeasurement) Name(prefix string) string

func (CounterMeasurement) StrValue added in v0.5.0

func (c CounterMeasurement) StrValue() string

func (CounterMeasurement) Time added in v0.5.0

func (c CounterMeasurement) Time() time.Time

func (CounterMeasurement) Type added in v0.5.0

func (CounterMeasurement) Unit added in v0.5.0

func (c CounterMeasurement) Unit() Unit

func (CounterMeasurement) Value added in v0.5.0

func (c CounterMeasurement) Value() interface{}

type Cpu

type Cpu struct {
	AggregateOnly bool
	// contains filtered or unexported fields
}

func NewCpuPoller

func NewCpuPoller(measurements chan<- Measurement, config Config) Cpu

func (Cpu) Exit

func (poller Cpu) Exit()

func (Cpu) Name

func (poller Cpu) Name() string

func (Cpu) Poll

func (poller Cpu) Poll(tick time.Time)

type CpuValues

type CpuValues struct {
	User    float64
	Nice    float64
	System  float64
	Idle    float64
	Iowait  float64
	Irq     float64
	Softirq float64
	Steal   float64
	Guest   float64
}

func (CpuValues) DiffPercent

func (cv CpuValues) DiffPercent(last CpuValues) CpuValues

func (CpuValues) Total

func (cv CpuValues) Total() float64

type Df

type Df struct {
	Types []string
	Loop  bool
	// contains filtered or unexported fields
}

func NewDfPoller

func NewDfPoller(measurements chan<- Measurement, config Config) Df

func (Df) Exit

func (poller Df) Exit()

func (Df) Name

func (poller Df) Name() string

func (Df) Poll

func (poller Df) Poll(tick time.Time)

type Disk

type Disk struct {
	// contains filtered or unexported fields
}

func NewDiskPoller

func NewDiskPoller(measurements chan<- Measurement, config Config) Disk

func (Disk) Exit

func (poller Disk) Exit()

func (Disk) Name

func (poller Disk) Name() string

type FileNr added in v0.5.0

type FileNr struct {
	// contains filtered or unexported fields
}

func NewFileNrPoller added in v0.5.0

func NewFileNrPoller(measurements chan<- Measurement) FileNr

func (FileNr) Exit added in v0.5.0

func (poller FileNr) Exit()

func (FileNr) Name added in v0.5.0

func (poller FileNr) Name() string

func (FileNr) Poll added in v0.5.0

func (poller FileNr) Poll(tick time.Time)

type FloatGaugeMeasurement added in v0.5.0

type FloatGaugeMeasurement struct {
	// contains filtered or unexported fields
}

func (FloatGaugeMeasurement) Name added in v0.5.0

func (g FloatGaugeMeasurement) Name(prefix string) string

func (FloatGaugeMeasurement) StrValue added in v0.5.0

func (g FloatGaugeMeasurement) StrValue() string

func (FloatGaugeMeasurement) Time added in v0.5.0

func (g FloatGaugeMeasurement) Time() time.Time

func (FloatGaugeMeasurement) Type added in v0.5.0

func (FloatGaugeMeasurement) Unit added in v0.5.0

func (c FloatGaugeMeasurement) Unit() Unit

func (FloatGaugeMeasurement) Value added in v0.5.0

func (g FloatGaugeMeasurement) Value() interface{}

type FolsomGarbageCollection added in v0.9.2

type FolsomGarbageCollection struct {
	NumOfGcs       uint64 `json:"number_of_gcs"`
	WordsReclaimed uint64 `json:"words_reclaimed"`
}

type FolsomIo added in v0.9.2

type FolsomIo struct {
	Input  uint64 `json:"input"`
	Output uint64 `json:"output"`
}

type FolsomMemory added in v0.9.2

type FolsomMemory struct {
	Total         uint64 `json:"total"`
	Processes     uint64 `json:"processes"`
	ProcessesUsed uint64 `json:"processes_used"`
	System        uint64 `json:"system"`
	Atom          uint64 `json:"atom"`
	AtomUsed      uint64 `json:"atom_used"`
	Binary        uint64 `json:"binary"`
	Code          uint64 `json:"code"`
	Ets           uint64 `json:"ets"`
}

type FolsomMetrics added in v0.9.2

type FolsomMetrics struct {
	Metrics []string `json:""`
}

type FolsomPoller added in v0.9.2

type FolsomPoller struct {
	// contains filtered or unexported fields
}

func NewFolsomPoller added in v0.9.2

func NewFolsomPoller(measurements chan<- Measurement, config Config) FolsomPoller

func (FolsomPoller) Exit added in v0.9.2

func (poller FolsomPoller) Exit()

func (FolsomPoller) Name added in v0.9.2

func (poller FolsomPoller) Name() string

func (FolsomPoller) Poll added in v0.9.2

func (poller FolsomPoller) Poll(tick time.Time)

type FolsomReductions added in v0.9.2

type FolsomReductions struct {
	Total     uint64 `json:"total_reductions"`
	SinceLast uint64 `json:"reductions_since_last_call"`
}

type FolsomRuntime added in v0.9.2

type FolsomRuntime struct {
	Total     uint64 `json:"total_run_time"`
	SinceLast uint64 `json:"time_since_last_call"`
}

type FolsomStatistics added in v0.9.2

type FolsomStatistics struct {
	ContextSwitches   uint64                  `json:"context_switches"`
	GarbageCollection FolsomGarbageCollection `json:"garbage_collection"`
	Io                FolsomIo                `json:"io"`
	Reductions        FolsomReductions        `json:"reductions"`
	RunQueue          uint64                  `json:"run_queue"`
	Runtime           FolsomRuntime           `json:"runtime"`
	WallClock         FolsomWallClock         `json:"wall_clock"`
}

type FolsomValue added in v0.9.2

type FolsomValue struct {
	Name  string
	Type  string      `json:"type"`
	Value json.Number `json:"value"`
}

type FolsomWallClock added in v0.9.2

type FolsomWallClock struct {
	Total     uint64 `json:"total_wall_clock_time"`
	SinceLast uint64 `json:"wall_clock_time_since_last_call"`
}

type GaugeMeasurement added in v0.5.0

type GaugeMeasurement struct {
	// contains filtered or unexported fields
}

func (GaugeMeasurement) Name added in v0.5.0

func (g GaugeMeasurement) Name(prefix string) string

func (GaugeMeasurement) StrValue added in v0.5.0

func (g GaugeMeasurement) StrValue() string

func (GaugeMeasurement) Time added in v0.5.0

func (g GaugeMeasurement) Time() time.Time

func (GaugeMeasurement) Type added in v0.5.0

func (GaugeMeasurement) Unit added in v0.5.0

func (c GaugeMeasurement) Unit() Unit

func (GaugeMeasurement) Value added in v0.5.0

func (g GaugeMeasurement) Value() interface{}

type Librato

type Librato struct {
	Timeout   time.Duration
	BatchSize int
	User      string
	Token     string
	Url       string
	// contains filtered or unexported fields
}

func NewLibratoOutputter

func NewLibratoOutputter(measurements <-chan Measurement, config Config) *Librato

func (*Librato) Start

func (out *Librato) Start()

type LibratoMetric

type LibratoMetric struct {
	Name       string             `json:"name"`
	Value      interface{}        `json:"value"`
	When       int64              `json:"measure_time"`
	Source     string             `json:"source,omitempty"`
	Attributes LibratoMetricAttrs `json:"attributes,omitempty"`
}

type LibratoMetricAttrs added in v0.5.0

type LibratoMetricAttrs struct {
	UnitName string `json:"display_units_long,omitempty"`
	UnitAbbr string `json:"display_units_short,omitempty"`
}

type LibratoPostBody added in v0.5.0

type LibratoPostBody struct {
	Gauges   []LibratoMetric `json:"gauges,omitempty"`
	Counters []LibratoMetric `json:"counters,omitempty"`
}

type Listen

type Listen struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewListenPoller

func NewListenPoller(measurements chan<- Measurement, config Config) Listen

func (*Listen) Accept added in v0.9.2

func (poller *Listen) Accept()

func (Listen) Exit

func (poller Listen) Exit()

func (*Listen) HandleListenConnection added in v0.8.8

func (poller *Listen) HandleListenConnection(conn net.Conn)

func (Listen) Name

func (poller Listen) Name() string

func (Listen) Poll

func (poller Listen) Poll(tick time.Time)

type Load

type Load struct {
	// contains filtered or unexported fields
}

func NewLoadPoller

func NewLoadPoller(measurements chan<- Measurement) Load

func (Load) Exit

func (poller Load) Exit()

func (Load) Name

func (poller Load) Name() string

func (Load) Poll

func (poller Load) Poll(tick time.Time)

type Measurement

type Measurement interface {
	Name(prefix string) string // Metric name
	Value() interface{}
	StrValue() string // String representation of the value
	Time() time.Time  // the underlying time object.
	Type() MeasurementType
	Unit() Unit
}

type MeasurementType added in v0.5.0

type MeasurementType int
const (
	CounterType MeasurementType = iota
	GaugeType
	FloatGaugeType
)

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

func NewMemoryPoller

func NewMemoryPoller(measurements chan<- Measurement, config Config) Memory

func (Memory) Exit

func (poller Memory) Exit()

func (Memory) Name

func (poller Memory) Name() string

type Multi

type Multi struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

func NewMultiPoller

func NewMultiPoller(measurements chan<- Measurement, config Config) Multi

func (Multi) Exit

func (mp Multi) Exit()

func (Multi) Name

func (mp Multi) Name() string

func (Multi) Poll

func (mp Multi) Poll(tick time.Time)

func (Multi) RegisterPoller

func (mp Multi) RegisterPoller(poller Poller)

type Nagios3StatsPoller added in v0.8.6

type Nagios3StatsPoller struct {
	// contains filtered or unexported fields
}

func NewNagios3StatsPoller added in v0.8.6

func NewNagios3StatsPoller(measurements chan<- Measurement, config Config) Nagios3StatsPoller

func (Nagios3StatsPoller) Exit added in v0.8.6

func (poller Nagios3StatsPoller) Exit()

func (Nagios3StatsPoller) Name added in v0.8.6

func (poller Nagios3StatsPoller) Name() string

func (Nagios3StatsPoller) Poll added in v0.8.6

func (poller Nagios3StatsPoller) Poll(tick time.Time)

type NetworkInterface

type NetworkInterface struct {
	Devices []string
	// contains filtered or unexported fields
}

func NewNetworkInterfacePoller

func NewNetworkInterfacePoller(measurements chan<- Measurement, config Config) NetworkInterface

func (NetworkInterface) Exit

func (poller NetworkInterface) Exit()

func (NetworkInterface) Name

func (poller NetworkInterface) Name() string

func (NetworkInterface) Poll

func (poller NetworkInterface) Poll(tick time.Time)

http://www.kernel.org/doc/Documentation/filesystems/proc.txt (section 1.4)

type Ntpdate

type Ntpdate struct {
	Servers []string
	// contains filtered or unexported fields
}

func NewNtpdatePoller

func NewNtpdatePoller(measurements chan<- Measurement, config Config) Ntpdate

func (Ntpdate) Exit

func (poller Ntpdate) Exit()

func (Ntpdate) Name

func (poller Ntpdate) Name() string

func (Ntpdate) Poll

func (poller Ntpdate) Poll(tick time.Time)

FIXME: Timeout

type Outputter

type Outputter interface {
	Start()
}

func NewOutputter

func NewOutputter(name string, measurements <-chan Measurement, config Config) (Outputter, error)

FIXME: Any way to do this with reflect and a map?

type Poller

type Poller interface {
	Name() string
	Exit()
	Poll(tick time.Time)
}

type ProcInfo added in v0.8.3

type ProcInfo struct {
	// contains filtered or unexported fields
}

type Procs added in v0.5.0

type Procs struct {
	// contains filtered or unexported fields
}

func NewProcessesPoller

func NewProcessesPoller(measurements chan<- Measurement, config Config) Procs

func (Procs) Exit added in v0.5.0

func (poller Procs) Exit()

func (Procs) GetProcInfo added in v0.8.3

func (poller Procs) GetProcInfo(pid int) (pInfo ProcInfo)

func (Procs) Name added in v0.5.0

func (poller Procs) Name() string

func (Procs) Poll added in v0.5.0

func (poller Procs) Poll(tick time.Time)

func (Procs) ScanProcIo added in v0.8.3

func (poller Procs) ScanProcIo(pInfo *ProcInfo)

func (Procs) ScanProcStat added in v0.8.3

func (poller Procs) ScanProcStat(pInfo *ProcInfo)

func (Procs) ScanProcStatus added in v0.8.3

func (poller Procs) ScanProcStatus(pInfo *ProcInfo)

type Self

type Self struct {
	// contains filtered or unexported fields
}

func NewSelfPoller

func NewSelfPoller(measurements chan<- Measurement, config Config) Self

func (Self) Exit

func (poller Self) Exit()

func (Self) Name

func (poller Self) Name() string

func (Self) Poll

func (poller Self) Poll(tick time.Time)

See http://golang.org/pkg/runtime/#MemStats

type SockStat added in v0.5.0

type SockStat struct {
	Protocols []string
	// contains filtered or unexported fields
}

func NewSockStatPoller added in v0.5.0

func NewSockStatPoller(measurements chan<- Measurement, config Config) SockStat

func (SockStat) Exit added in v0.5.0

func (poller SockStat) Exit()

func (SockStat) Name added in v0.5.0

func (poller SockStat) Name() string

func (SockStat) Poll added in v0.5.0

func (poller SockStat) Poll(tick time.Time)

http://www.kernel.org/doc/Documentation/filesystems/proc.txt (section 1.4)

type SplunkPeerEntry added in v0.8.8

type SplunkPeerEntry struct {
	Title string          `xml:"title"`
	Keys  []SplunkPeerKey `xml:"content>dict>key"`
}

type SplunkPeerKey added in v0.8.8

type SplunkPeerKey struct {
	Name  string `xml:"name,attr"`
	Value string `xml:",chardata"`
}

type SplunkPeers added in v0.8.8

type SplunkPeers struct {
	Entries []SplunkPeerEntry `xml:"entry"`
}

type SplunkSearchPeersPoller added in v0.8.8

type SplunkSearchPeersPoller struct {
	// contains filtered or unexported fields
}

func NewSplunkSearchPeersPoller added in v0.8.8

func NewSplunkSearchPeersPoller(measurements chan<- Measurement, config Config) SplunkSearchPeersPoller

func (SplunkSearchPeersPoller) Exit added in v0.8.8

func (poller SplunkSearchPeersPoller) Exit()

func (SplunkSearchPeersPoller) Name added in v0.8.8

func (poller SplunkSearchPeersPoller) Name() string

func (SplunkSearchPeersPoller) Poll added in v0.8.8

func (poller SplunkSearchPeersPoller) Poll(tick time.Time)

type Statsd

type Statsd struct {
	Proto string
	Host  string
	// contains filtered or unexported fields
}

func NewStatsdOutputter

func NewStatsdOutputter(measurements <-chan Measurement, config Config) *Statsd

func (*Statsd) Connect

func (out *Statsd) Connect(host string) net.Conn

func (*Statsd) Encode

func (s *Statsd) Encode(mm Measurement) string

func (*Statsd) Output

func (out *Statsd) Output()

func (*Statsd) Start

func (out *Statsd) Start()

type StdOutL2MetDer

type StdOutL2MetDer struct {
	// contains filtered or unexported fields
}

func NewStdOutL2MetDer

func NewStdOutL2MetDer(measurements <-chan Measurement, config Config) *StdOutL2MetDer

func (*StdOutL2MetDer) Output

func (out *StdOutL2MetDer) Output()

func (*StdOutL2MetDer) Start

func (out *StdOutL2MetDer) Start()

type StdOutL2MetRaw

type StdOutL2MetRaw struct {
	// contains filtered or unexported fields
}

func NewStdOutL2MetRaw

func NewStdOutL2MetRaw(measurements <-chan Measurement, config Config) *StdOutL2MetRaw

func (*StdOutL2MetRaw) Output

func (out *StdOutL2MetRaw) Output()

func (*StdOutL2MetRaw) Start

func (out *StdOutL2MetRaw) Start()

type SyslogngStats

type SyslogngStats struct {
	Socket string
	// contains filtered or unexported fields
}

func NewSyslogngStatsPoller

func NewSyslogngStatsPoller(measurements chan<- Measurement, config Config) SyslogngStats

func (SyslogngStats) Exit

func (poller SyslogngStats) Exit()

func (SyslogngStats) Name

func (poller SyslogngStats) Name() string

func (SyslogngStats) Poll

func (poller SyslogngStats) Poll(tick time.Time)

type Unit added in v0.5.0

type Unit struct {
	// contains filtered or unexported fields
}

func (Unit) Abbr added in v0.5.0

func (u Unit) Abbr() string

func (Unit) Name added in v0.5.0

func (u Unit) Name() string

Directories

Path Synopsis
Godeps
_workspace/src/github.com/heroku/slog
Package slog provides some Strcutred Logging helpers ATM: Mostly used to hold some context for a http handler and log at the end of a request Generally should provide the oposite of logfmt: https://github.com/kr/logfmt Sample use in a http.HandleFunc http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { start := time.Now() ctx := slog.Context{} defer func() { fmt.Println(ctx) } defer func() { ctx.Measure("health.check.duration", time.Since(start)) } ctx.Count("health.check",1) ...stuff }) Produces a line like so for every request: count#health.check=1 measure#health.check.duration=0.004s
Package slog provides some Strcutred Logging helpers ATM: Mostly used to hold some context for a http handler and log at the end of a request Generally should provide the oposite of logfmt: https://github.com/kr/logfmt Sample use in a http.HandleFunc http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { start := time.Now() ctx := slog.Context{} defer func() { fmt.Println(ctx) } defer func() { ctx.Measure("health.check.duration", time.Since(start)) } ctx.Count("health.check",1) ...stuff }) Produces a line like so for every request: count#health.check=1 measure#health.check.duration=0.004s
cmd
shh

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL