sysfact

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2020 License: LGPL-2.1 Imports: 20 Imported by: 2

README

sysfact

A utility for collecting and formatting system information.

Overview

The sysfact utility provides a simple, structured mechanism for collecting and formatting pieces of information about Linux, BSD, macOS, and other operating systems. It achieves this using collection scripts, which run in parallel when sysfact is invoked to gather details. Collection scripts can be written in any language, as they are called via a shell process-- they only need to be executable to run. Scripts emit details, one per line, to standard output with a simple format: metricname:type:value\n

Installation

Binaries

Soon. Soon...

From Source
go get -u github.com/ghetzel/sysfact/cmd/sysfact

Formatting

For example, here is a some output that would be usable by sysfact:

demo.things.enabled:bool:true
demo.items.0.name:str:Item 1: Things
demo.items.0.count:int:42
demo.items.0.factor:float:3.14
demo.items.1.name:str:Item 2: Stuff
demo.items.1.count:int:99
demo.items.1.factor:float:2.178
demo.items.1.active:bool:true

This is what the above would look like using the "json" format option:

{
  "demo": {
    "items": [
      {
        "count": 42,
        "factor": 3.14,
        "name": "Item 1: Things"
      },
      {
        "active": true,
        "count": 99,
        "factor": 2.178,
        "name": "Item 2: Stuff"
      }
    ],
    "things": {
      "enabled": true
    }
  }
}

Output can be formatted into JSON, YAML, as a flat list of "key=value" items, or in several popular timeseries string formats; like InfluxDB's Line Protocol, OpenTSDB/KairosDB, and Graphite.

Output

Finally, the results of formatting the collected data can be output, either via standard output (the default), or using the built-in HTTP client. You can specify a URL, HTTP method, request headers, query string parameters (as command line flags), and timeouts. This provides a flexible and powerful mechanism for using sysfact as a component in monitoring, inventory collection, and other data collection systems.

Documentation

Index

Constants

View Source
const Version = `0.7.0`

Variables

View Source
var InfluxdbTagValueCharCompress = regexp.MustCompile(`[\s,]+`)
View Source
var InfluxdbTagValueCharFilter = regexp.MustCompile(`\s{2,}`)
View Source
var RenderAsTemplatePrefix = `@`
View Source
var RenderPatterns = []string{
	`any/any`,
	`any/${arch}`,
	`${os.platform}/any`,
	`${os.platform}/${arch}`,
	`${os.family}/any`,
	`${os.family}/${arch}`,
	`${os.distribution}/any`,
	`${os.distribution}/${arch}`,
	`${os.distribution}-${os.version}/any`,
	`${os.distribution}-${os.version}/${arch}`,
}

Functions

func Render added in v0.7.0

func Render(basedir string, options *RenderOptions) error

func Report added in v0.6.6

func Report(paths ...string) (map[string]interface{}, error)

Generate a system report using the default settings.

Types

type InfluxdbPayload

type InfluxdbPayload []string

func (InfluxdbPayload) Generate

func (self InfluxdbPayload) Generate(series TupleSet, tags map[string]interface{}, now *time.Time) (string, error)

type RenderOptions added in v0.7.0

type RenderOptions struct {
	DestDir         string `default:"~"`
	DefaultDirMode  int    `default:"493"`
	DefaultFileMode int    `default:"420"`
	Owner           string
	Group           string
	DryRun          bool
	// contains filtered or unexported fields
}

func (*RenderOptions) Enforce added in v0.7.0

func (self *RenderOptions) Enforce(path string) error

func (*RenderOptions) ModeFor added in v0.7.0

func (self *RenderOptions) ModeFor(info os.FileInfo) os.FileMode

type Reporter

type Reporter struct {
	Plugins     []plugins.Plugin
	FieldPrefix string
	KeyFormat   ReporterKeyFormat
}

func NewReporter

func NewReporter(paths ...string) *Reporter

Create a new Reporter instance that can be configured.

func (*Reporter) GetReportValues

func (self *Reporter) GetReportValues(fields []string, skipFields []string) (map[string]interface{}, error)

Generates a report and retrieves the values of the given fields.

func (*Reporter) Report

func (self *Reporter) Report() (map[string]interface{}, error)

Generate and return the full report from all discovered plugins.

type ReporterKeyFormat added in v0.6.2

type ReporterKeyFormat int
const (
	FormatUnderscore ReporterKeyFormat = iota
	FormatPascalize
	FormatCamelize
)

type Tuple

type Tuple struct {
	Key           string
	Value         interface{}
	NormalizedKey string
	Tags          map[string]interface{}
}

type TupleSet

type TupleSet []Tuple

func (TupleSet) Len

func (self TupleSet) Len() int

func (TupleSet) Less

func (self TupleSet) Less(i, j int) bool

func (TupleSet) Remove

func (self TupleSet) Remove(i int)

func (TupleSet) Swap

func (self TupleSet) Swap(i, j int)

func (TupleSet) ToMap

func (self TupleSet) ToMap(flat bool) map[string]interface{}

Directories

Path Synopsis
cmd
sysfact command

Jump to

Keyboard shortcuts

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