cis

package
v0.0.0-...-fe13f99 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

The cis package handles sending data to CIS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffered

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

Buffered buffers CIS data for bulk writing.

func NewBuffered

func NewBuffered(size int, writer BulkWriter) *Buffered

NewBuffered creates a new Buffered instance. size is the size of the buffer; writer is the instrument that writes the data to CIS. Buffered instances are safe to use with multiple goroutines.

func (*Buffered) Flush

func (b *Buffered) Flush() ([]Stats, error)

Flush writes out the contents of the buffer, clears the buffer, and returns the pieces written or the pieces that would have been written if there was any error.

func (*Buffered) Write

func (b *Buffered) Write(stats Stats) ([]Stats, error)

Write buffers data. When size pieces of data are buffered, Write bulk clears the buffer, and returns the pieces written or the pieces that would have been written if there was any error. When simply adding to the buffer instead of bulk writing, Write always returns nil, nil.

type BulkWriter

type BulkWriter interface {
	WriteAll(stats []Stats) error
}

BulkWriter is the interface for batch writing data to CIS.

type Client

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

Client represents a client connection to CIS. Client instances are safe to use with multiple goroutines.

func NewClient

func NewClient(config Config) (*Client, error)

NewClient returns a new CIS client instance.

func (*Client) Write

func (c *Client) Write(stats *Stats) error

Write writes data to CIS

func (*Client) WriteAll

func (c *Client) WriteAll(stats []Stats) error

WriteAll batch writes data to CIS.

type Config

type Config struct {
	// CIS endpoint. Example. "http://a.cis.endpoint.net:8080"
	Endpoint string
	// Required: data center e.g us-east-1.
	DataCenter string
	// Optional: Name for writing tricorder metrics for async http.
	// If ommitted, writing is synchronous.
	Name string
}

Config represents the configuration for connecting to CIS

type PackageEntry

type PackageEntry struct {
	// Package name e.g python3.4
	Name string
	// Package version e.g 3.4
	Version string
	// Package size
	Size uint64
}

PackageEntry represents a single package on a machine This type should support ==

type PackageInfo

type PackageInfo struct {
	// The packaging type e.g debian.
	ManagementType string
	// The individual packages
	Packages []PackageEntry
}

PackageInfo represents all the packages on a machine

func (*PackageInfo) Equals

func (p *PackageInfo) Equals(rhs *PackageInfo) bool

Equals returns true if p is equivalent to rhs.

type Stats

type Stats struct {
	// Time the data were fetched
	TimeStamp time.Time
	// The AWS instance ID of the machine
	InstanceId string
	// The packags on the machine
	Packages PackageInfo
}

Stats represents fetching package data for a machine

func GetStats

func GetStats(list metrics.List, optInstanceId string) *Stats

GetStats extracts the CIS data from the metrics pulled for a machine GetStats uses the optInstanceId if supplied. Otherwise, it tries to extract instanceId from the health agent. GetStats returns nil if it cannot find any CIS data.

func (*Stats) Key

func (s *Stats) Key() interface{}

Key keys by the instance ID

Jump to

Keyboard shortcuts

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