Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
derekwbrown committed Jan 16, 2018
1 parent 1a65cc2 commit daa1e66
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 42 deletions.
10 changes: 2 additions & 8 deletions agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ package main
import (
"flag"
_ "net/http/pprof"



)

func main() {
Expand All @@ -24,13 +21,10 @@ func main() {
if err := config.NewLoggerLevel("info", ""); err != nil {
panic(err)
}

exit := make(chan struct{})

// Invoke the Agent
runAgent(exit)



}

10 changes: 4 additions & 6 deletions agent/main_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/DataDog/datadog-process-agent/statsd"
"github.com/DataDog/datadog-process-agent/util"
)

var opts struct {
configPath string
ddConfigPath string
Expand Down Expand Up @@ -59,16 +60,14 @@ func versionString() string {

return buf.String()
}

const agentDisabledMessage = `process-agent not enabled.
Set env var DD_PROCESS_AGENT_ENABLED=true or add
process_agent_enabled: true
to your datadog.conf file.
Exiting.`



func runAgent(exit chan bool){

func runAgent(exit chan bool) {

if opts.version {
fmt.Println(versionString())
Expand Down Expand Up @@ -187,7 +186,6 @@ func runAgent(exit chan bool){
}
}


func debugCheckResults(cfg *config.AgentConfig, check string) error {
sysInfo, err := checks.CollectSystemInfo(cfg)
if err != nil {
Expand Down Expand Up @@ -230,4 +228,4 @@ func printResults(cfg *config.AgentConfig, ch checks.Check) error {
fmt.Println(string(b))
}
return nil
}
}
4 changes: 2 additions & 2 deletions agent/main_nodocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
package main

import (
log "github.com/cihub/seelog"
"os"
"os/signal"
"syscall"
log "github.com/cihub/seelog"

)

func initMetadataProviders() {
}

// Handles signals - tells us whether we should exit.
func handleSignals(exit chan bool) {
sigIn := make(chan os.Signal, 100)
Expand Down
11 changes: 6 additions & 5 deletions agent/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ package main
import (
"flag"
"fmt"
// "log"
// "log"
_ "net/http/pprof"
"os"
"path/filepath"
"time"

log "github.com/cihub/seelog"
"golang.org/x/sys/windows/svc"
"golang.org/x/sys/windows/svc/debug"
"golang.org/x/sys/windows/svc/eventlog"
"golang.org/x/sys/windows/svc/mgr"
log "github.com/cihub/seelog"
)

var elog debug.Log
Expand All @@ -38,7 +38,7 @@ var winopts struct {

func init() {
fmt.Printf("main_windows.init()")

}

type myservice struct{}
Expand Down Expand Up @@ -75,7 +75,7 @@ func (m *myservice) Execute(args []string, r <-chan svc.ChangeRequest, changes c
}()
elog.Info(0x40000003, ServiceName)
runAgent(exit)

changes <- svc.Status{State: svc.Stopped}
return
}
Expand Down Expand Up @@ -114,6 +114,7 @@ func EnableLoggingToFile() {
logger, _ := log.LoggerFromConfigAsBytes([]byte(seeConfig))
log.ReplaceLogger(logger)
}

// main is the main application entry point
func main() {
flag.StringVar(&opts.configPath, "config", defaultConfigPath, "Path to datadog.yaml config")
Expand All @@ -127,7 +128,7 @@ func main() {
flag.BoolVar(&winopts.uninstallService, "uninstall-service", false, "Remove the trace agent from the Service Control Manager")
flag.BoolVar(&winopts.startService, "start-service", false, "Starts the trace agent service")
flag.BoolVar(&winopts.stopService, "stop-service", false, "Stops the trace agent service")

flag.Parse()
EnableLoggingToFile()
isIntSess, err := svc.IsAnInteractiveSession()
Expand Down
10 changes: 4 additions & 6 deletions checks/container_nodocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package checks
import (
"time"

"github.com/DataDog/datadog-process-agent/config"
"github.com/DataDog/datadog-agent/pkg/util/docker"
"github.com/DataDog/datadog-process-agent/config"
"github.com/DataDog/datadog-process-agent/model"
)

Expand Down Expand Up @@ -37,7 +37,7 @@ func (c *ContainerCheck) RealTime() bool { return false }
// Run runs the ContainerCheck to collect a list of running containers and the
// stats for each container.
func (c *ContainerCheck) Run(cfg *config.AgentConfig, groupID int32) ([]model.MessageBody, error) {

return nil, nil
}

Expand All @@ -59,9 +59,7 @@ func fmtContainers(
i := 0
for _, _ = range containers {

chunk = append(chunk, &model.Container{

})
chunk = append(chunk, &model.Container{})

if len(chunk) == perChunk {
chunked[i] = chunk
Expand All @@ -73,4 +71,4 @@ func fmtContainers(
chunked[i] = chunk
}
return chunked
}
}
3 changes: 1 addition & 2 deletions checks/container_rt_nodocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ func fmtContainerStats(
chunk := make([]*model.ContainerStat, 0, perChunk)
i := 0
for _, _ = range containers {
chunk = append(chunk, &model.ContainerStat{
})
chunk = append(chunk, &model.ContainerStat{})
if len(chunk) == perChunk {
chunked[i] = chunk
chunk = make([]*model.ContainerStat, 0, perChunk)
Expand Down
2 changes: 0 additions & 2 deletions checks/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ func formatIO(fp *process.FilledProcess, lastIO *process.IOCountersStat, before
}
}


func formatMemory(fp *process.FilledProcess) *model.MemoryStat {
ms := &model.MemoryStat{
Rss: fp.MemInfo.RSS,
Expand All @@ -225,7 +224,6 @@ func formatMemory(fp *process.FilledProcess) *model.MemoryStat {
return ms
}


// skipProcess will skip a given process if it's blacklisted or hasn't existed
// for multiple collections.
func skipProcess(
Expand Down
2 changes: 0 additions & 2 deletions checks/process_nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"github.com/DataDog/datadog-process-agent/config"
"github.com/DataDog/datadog-process-agent/model"

)

func formatUser(fp *process.FilledProcess) *model.ProcessUser {
Expand Down Expand Up @@ -71,4 +70,3 @@ func calculatePct(deltaProc, deltaTime, numCPU float64) float32 {
// In order to emulate top we multiply utilization by # of CPUs so a busy loop would be 100%.
return float32(overalPct * numCPU)
}

12 changes: 5 additions & 7 deletions checks/process_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ package checks
import (
"runtime"

"github.com/DataDog/datadog-process-agent/model"
"github.com/DataDog/gopsutil/cpu"
"github.com/DataDog/gopsutil/process"
"github.com/DataDog/datadog-process-agent/model"

)

func formatUser(fp *process.FilledProcess) *model.ProcessUser {
Expand All @@ -25,9 +24,9 @@ func formatCPU(fp *process.FilledProcess, t2, t1, syst2, syst1 cpu.TimesStat) *m
// is in nanoseconds.
return &model.CPUStat{
LastCpu: t2.CPU,
TotalPct: calculatePct(((t2.User-t1.User)+(t2.System-t1.System)) * 100, deltaSys, numCPU),
UserPct: calculatePct((t2.User-t1.User) * 100, deltaSys, numCPU),
SystemPct: calculatePct((t2.System-t1.System) * 100, deltaSys, numCPU),
TotalPct: calculatePct(((t2.User-t1.User)+(t2.System-t1.System))*100, deltaSys, numCPU),
UserPct: calculatePct((t2.User-t1.User)*100, deltaSys, numCPU),
SystemPct: calculatePct((t2.System-t1.System)*100, deltaSys, numCPU),
NumThreads: fp.NumThreads,
Cpus: []*model.SingleCPUStat{},
Nice: fp.Nice,
Expand All @@ -49,9 +48,8 @@ func calculatePct(deltaProc, deltaTime, numCPU float64) float32 {
overalPct = 100
}

// In order to emulate task mgr, we divide by number of CPUs.
// In order to emulate task mgr, we divide by number of CPUs.
// Task mgr displays percentage of available CPU (so a busy loop process
// on a 2 core CPU is 50%)
return float32(overalPct / numCPU)
}

4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ func NewAgentConfig(agentIni *File, agentYaml *YamlAgentConfig) (*AgentConfig, e

// (Re)configure the logging from our configuration
//if err := NewLoggerLevel(cfg.LogLevel, cfg.LogFile); err != nil {
// return nil, err
// }
// return nil, err
// }

cfg.HostName = ""
if ecsutil.IsFargateInstance() {
Expand Down

0 comments on commit daa1e66

Please sign in to comment.