Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertProcessList(p *sigar.ProcList) *[]ProcessList
- func DogConnect() *statsd.Client
- func DogStatsdSetup() *statsd.Client
- func GetCurrentUsername() string
- func GetHostname() string
- func GetPIDs() *sigar.ProcList
- func GetProcessList() *[]ProcessList
- func LoadConfig()
- func LoadFilesStats(content string) (string, float64)
- func Log(message, priority string)
- func OpenLogfile(logfile string) *tail.Tail
- func ReturnCurrentUTC() string
- func SendApacheServerStats(apache []ApacheProcess, procs map[int]uint64)
- func SendLineStats(dog *statsd.Client, line string, metric string)
- func SendMetrics(p []ProcessList) bool
- func SendSignalStats(current DNSStats, previous DNSStats)
- func SetDirection() string
- func TailLog(t *tail.Tail, dog *statsd.Client, r *regexp.Regexp)
- func TailOutput(dog *statsd.Client, r *regexp.Regexp)
- type ApacheProcess
- type DNSServer
- type DNSStats
- type ProcessList
Constants ¶
const (
// DogStatsdAddr is the default address for Dogstatsd.
DogStatsdAddr = "127.0.0.1:8125"
)
Variables ¶
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 )
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 )
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 )
var ( // Endpoint holds the address we're going to ping. Endpoint string )
var ( // MinimumMemory is the minimum size of an Apache process that we log stats for. MinimumMemory uint64 )
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 ¶
DogConnect sets up a connection and sets standard tags.
func DogStatsdSetup ¶
DogStatsdSetup sets up a connection to DogStatsd.
func GetCurrentUsername ¶
func GetCurrentUsername() string
GetCurrentUsername grabs the current user running the binary.
func GetProcessList ¶
func GetProcessList() *[]ProcessList
GetProcessList returns all the processes.
func LoadFilesStats ¶
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 ¶
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 ¶
SendLineStats sends the stats to Datadog.
func SendMetrics ¶
func SendMetrics(p []ProcessList) bool
SendMetrics sends memory metrics to Dogstatsd.
func SendSignalStats ¶
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.
Types ¶
type ApacheProcess ¶
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 ¶
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.