cmd

package
v0.0.0-...-5227827 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2016 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DogStatsdAddr is the default address for Dogstatsd.
	DogStatsdAddr = "127.0.0.1:8125"
)

Variables

View Source
var (
	// DnsmasqLog is the logfile that dnsmasq logs to.
	DnsmasqLog string

	// FullLogs determines whether we're looking at '--log-queries'
	// levels of logs for dnsmasq.
	// It's disabled by default as it's pretty inefficient.
	FullLogs bool

	// CurrentTimestamp is the current timestamp from the dnsmasq logs.
	CurrentTimestamp int64

	// StatsCurrent is the current timestamp's stats.
	StatsCurrent *DNSStats

	// StatsPrevious is the last timestamp's stats.
	StatsPrevious *DNSStats

	// MemoryFlag sends dnsmasq memory stats to Datadog if true.
	MemoryFlag bool
)
View Source
var (
	// Direction adds information about which command is running to the logs.
	Direction string

	// Verbose logs all output to stdout.
	Verbose bool

	// ProcessName is the process to match.
	ProcessName string

	// MetricPrefix prefixes all metrics emitted.
	MetricPrefix string

	// Interval is the amount of seconds to loop.
	Interval int
)
View Source
var (
	// LogFile is the file to tail.
	LogFile string

	// ProgramStdout is a program to run to capture stdout.
	ProgramStdout string

	// Match is the regex to match in the file.
	Match string

	// MetricName is the name of the metric to send to Datadog.
	MetricName string

	// MetricTag is the name of the tag to add to the metric we're sending to Datadog.
	MetricTag string
)
View Source
var (
	// Endpoint holds the address we're going to ping.
	Endpoint string
)
View Source
var (
	// MinimumMemory is the minimum size of an Apache process that we log stats for.
	MinimumMemory uint64
)
View Source
var RootCmd = &cobra.Command{
	Use:   "goshe",
	Short: "Additional stats to datadog.",
	Long:  `Additional stats to datadog.`,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("`goshe -h` for help information.")
		fmt.Println("`goshe -v` for version information.")
	},
}

RootCmd is the default Cobra struct that starts it all off. https://github.com/spf13/cobra

Functions

func ConvertProcessList

func ConvertProcessList(p *sigar.ProcList) *[]ProcessList

ConvertProcessList converts the *sigar.ProcList into our []ProcessList struct.

func DogConnect

func DogConnect() *statsd.Client

DogConnect sets up a connection and sets standard tags.

func DogStatsdSetup

func DogStatsdSetup() *statsd.Client

DogStatsdSetup sets up a connection to DogStatsd.

func GetCurrentUsername

func GetCurrentUsername() string

GetCurrentUsername grabs the current user running the binary.

func GetHostname

func GetHostname() string

GetHostname returns the hostname.

func GetPIDs

func GetPIDs() *sigar.ProcList

GetPIDs returns a pointer to all pids on machine.

func GetProcessList

func GetProcessList() *[]ProcessList

GetProcessList returns all the processes.

func LoadConfig

func LoadConfig()

LoadConfig loads the configuration from a config file.

func LoadFilesStats

func LoadFilesStats(content string) (string, float64)

LoadFilesStats - a testable function to get the loaded file stats.

func Log

func Log(message, priority string)

Log adds the global Direction to a message and sends to syslog. Syslog is setup in main.go

func OpenLogfile

func OpenLogfile(logfile string) *tail.Tail

OpenLogfile opens a logfile and passes back a *tail.Tail pointer.

func ReturnCurrentUTC

func ReturnCurrentUTC() string

ReturnCurrentUTC returns the current UTC time in RFC3339 format.

func SendApacheServerStats

func SendApacheServerStats(apache []ApacheProcess, procs map[int]uint64)

SendApacheServerStats sends tagged Apache stats to Datadog

func SendLineStats

func SendLineStats(dog *statsd.Client, line string, metric string)

SendLineStats sends the stats to Datadog.

func SendMetrics

func SendMetrics(p []ProcessList) bool

SendMetrics sends memory metrics to Dogstatsd.

func SendSignalStats

func SendSignalStats(current DNSStats, previous DNSStats)

SendSignalStats sends stats to Datadog using copies of the current data. TODO: Right now we're ignoring all sorts of stats - will see if we need them.

func SetDirection

func SetDirection() string

SetDirection returns the direction.

func TailLog

func TailLog(t *tail.Tail, dog *statsd.Client, r *regexp.Regexp)

TailLog tails a file and sends stats to Datadog.

func TailOutput

func TailOutput(dog *statsd.Client, r *regexp.Regexp)

TailOutput watches the output of ProgramStdout and matches on those lines.

Types

type ApacheProcess

type ApacheProcess struct {
	Pid   int64
	Vhost string
}

ApacheProcess holds the interesting pieces of Apache stats.

func GetApacheServerStats

func GetApacheServerStats() []ApacheProcess

GetApacheServerStats grabs info from mod_status and parses it.

type DNSServer

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

DNSServer is data gathered from a dnsmasq server log line.

type DNSStats

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

DNSStats is data gathered from dnsmasq time, queries and server lines.

type ProcessList

type ProcessList struct {
	Pname string
	Pid   int
	Pmem  uint64 // in bytes
}

ProcessList is a simplified list of processes on a system.

func GetMatches

func GetMatches(match string, wantGoshe bool) []ProcessList

GetMatches returns only the matches we want from running processes.

func MatchProcessList

func MatchProcessList(procs []ProcessList, match string, goshe bool) []ProcessList

MatchProcessList looks through the struct processes that match.

func (*ProcessList) USR1

func (p *ProcessList) USR1() bool

USR1 sends a USR1 signal to the process.

Jump to

Keyboard shortcuts

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