sweet

package module
v0.0.0-...-33b9329 Latest Latest
Warning

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

Go to latest
Published: May 22, 2015 License: BSD-3-Clause Imports: 18 Imported by: 0

README

Network device configuration backups and change alerts for the 21st century - inspired by RANCID!

See: http://gosweet.org

##Features:

  • Stores device configs in Git
  • Simple configuration file
  • Single binary - only runtime dependency is Git
  • Email notifications
  • Built-in web status dashboard
  • Embedded Cisco IOS/ASA and Juniper JunOS support
  • Supports external collection scripts (such as clogin, jlogin, etc.)
  • Currently supports Linux and OSX

##Quickstart:

[router1.example.com]
method = cisco
user = sweetuser
pass = SecretPW4sweet

##Usage:

  sweet [options] <config>
  sweet -h --help
  sweet --version

Options:
  -w, --workspace <dir>     Specify workspace directory [default: ./workspace].
  -i, --interval <secs>     Collection interval in secs [default: 300].
  -c, --concurrency <num>   Concurrent device collections [default: 30].
  -t, --to <email@addr>     Send change notifications to this email.
  -f, --from <email@addr>   Send change notifications from this email.
  -s, --smtp <host:port>    SMTP server connection info [default: localhost:25].
  --insecure                Accept untrusted SSH device keys.
  --push                    Do a "git push" after committing changed configs.
  --syslog                  Send log messages to syslog rather than stdout.
  --timeout <secs>          Device collection timeout in secs [default: 60].
  --web                     Run an HTTP status server.
  --weblisten <host:port>   Host and port to use for HTTP status server [default: localhost:5000].
  --version                 Show version.
  -h, --help                Show this screen.

##Authors:

##Contributors:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func RunCollectors

func RunCollectors(Opts *SweetOptions)

// Kickoff collector runs

Types

type Cisco

type Cisco struct {
}

func (Cisco) Collect

func (collector Cisco) Collect(device DeviceConfig) (map[string]string, error)

type Collector

type Collector interface {
	Collect(device DeviceConfig) (map[string]string, error)
}

type ConfigDiff

type ConfigDiff struct {
	Diff    string
	Added   int
	Removed int
	NewFile bool
}

type DeviceConfig

type DeviceConfig struct {
	Hostname       string
	Method         string
	Target         string
	Timeout        time.Duration
	CommandTimeout time.Duration
	Config         map[string]string
}

DeviceAccess stores host access info

type DeviceStatus

type DeviceStatus struct {
	Device       DeviceConfig
	State        DeviceStatusState
	When         time.Time
	Configs      map[string]string
	Diffs        map[string]ConfigDiff
	ErrorMessage string
}

type DeviceStatusState

type DeviceStatusState int
const (
	StatePending DeviceStatusState = iota
	StateError
	StateTimeout
	StateSuccess
)

type External

type External struct {
}

func (External) Collect

func (collector External) Collect(device DeviceConfig) (map[string]string, error)

type JunOS

type JunOS struct {
}

func (JunOS) Collect

func (collector JunOS) Collect(device DeviceConfig) (map[string]string, error)

type SSHCollector

type SSHCollector struct {
	Receive chan string
	Send    chan string
}

type Status

type Status struct {
	Status map[string]DeviceStatus
	Lock   sync.Mutex
}

func (*Status) Get

func (s *Status) Get(device string) DeviceStatus

func (*Status) GetAll

func (s *Status) GetAll() map[string]DeviceStatus

func (*Status) Set

func (s *Status) Set(stat DeviceStatus)

type SweetOptions

type SweetOptions struct {
	Interval      time.Duration
	Timeout       time.Duration
	GitPush       bool
	Insecure      bool
	Concurrency   int
	HttpListen    string
	HttpEnabled   bool
	SmtpString    string
	Workspace     string
	ExecutableDir string
	ToEmail       string
	FromEmail     string
	UseSyslog     bool
	DefaultUser   string
	DefaultPass   string
	DefaultMethod string
	Syslog        *syslog.Writer
	Devices       []DeviceConfig
	Status        *Status
}

func (*SweetOptions) LogChanges

func (Opts *SweetOptions) LogChanges(message string)

func (*SweetOptions) LogErr

func (Opts *SweetOptions) LogErr(message string)

func (*SweetOptions) LogFatal

func (Opts *SweetOptions) LogFatal(message string)

// logging convenience methods

func (*SweetOptions) LogInfo

func (Opts *SweetOptions) LogInfo(message string)

type WebReport

type WebReport struct {
	DeviceStatus
	Class          string
	CSSID          string
	EnableDiffLink bool
	EnableConfLink bool
}

ReportWebData options for formatting web status page.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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