util

package
v0.0.0-...-a19e79c Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2015 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package util defines utilities for bosun.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPath is returned by Command if the program is not in the PATH.
	ErrPath = errors.New("program not in PATH")
	// ErrTimeout is returned by Command if the program timed out.
	ErrTimeout = errors.New("program killed after timeout")

	// Debug enables debug logging.
	Debug = false
)
View Source
var (
	// Hostname is the machine's hostname.
	Hostname string
	// FullHostname will, if false, uses the hostname upto the first ".". Run Set()
	// manually after changing.
	FullHostname bool
)

Functions

func Clean

func Clean(s string) string

Clean cleans a hostname based on the current FullHostname setting.

func Command

func Command(timeout time.Duration, stdin io.Reader, name string, arg ...string) (io.Reader, error)

Command executes the named program with the given arguments. If it does not exit within timeout, it is sent SIGINT (if supported by Go). After another timeout, it is killed.

func NewSingleHostProxy

func NewSingleHostProxy(target *url.URL) *httputil.ReverseProxy

Creates a new http Proxy that forwards requests to the specified url. Differs from httputil.NewSingleHostReverseProxy only in that it properly sets the host header.

func ReadCommand

func ReadCommand(line func(string) error, name string, arg ...string) error

ReadCommand runs command name with args and calls line for each line from its stdout. Command is interrupted (if supported by Go) after 10 seconds and killed after 20 seconds.

func ReadCommandTimeout

func ReadCommandTimeout(timeout time.Duration, line func(string) error, stdin io.Reader, name string, arg ...string) error

ReadCommandTimeout is the same as ReadCommand with a specifiable timeout. It can also take a []byte as input (useful for chaining commands).

func Set

func Set()

Set sets Hostntame based on the current preferences.

Types

This section is empty.

Jump to

Keyboard shortcuts

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